azure-storage-blob 12.20.0b1__py3-none-any.whl → 12.21.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- azure/storage/blob/__init__.py +12 -2
- azure/storage/blob/_blob_client.py +64 -51
- azure/storage/blob/_blob_service_client.py +17 -12
- azure/storage/blob/_container_client.py +33 -23
- azure/storage/blob/_download.py +277 -167
- azure/storage/blob/_generated/_azure_blob_storage.py +1 -1
- azure/storage/blob/_generated/_configuration.py +2 -2
- azure/storage/blob/_generated/_patch.py +2 -0
- azure/storage/blob/_generated/_serialization.py +1 -1
- azure/storage/blob/_generated/aio/_azure_blob_storage.py +1 -1
- azure/storage/blob/_generated/aio/_configuration.py +2 -2
- azure/storage/blob/_generated/aio/_patch.py +2 -0
- azure/storage/blob/_generated/aio/operations/_append_blob_operations.py +10 -5
- azure/storage/blob/_generated/aio/operations/_blob_operations.py +45 -26
- azure/storage/blob/_generated/aio/operations/_block_blob_operations.py +12 -7
- azure/storage/blob/_generated/aio/operations/_container_operations.py +39 -20
- azure/storage/blob/_generated/aio/operations/_page_blob_operations.py +15 -10
- azure/storage/blob/_generated/aio/operations/_patch.py +3 -0
- azure/storage/blob/_generated/aio/operations/_service_operations.py +28 -10
- azure/storage/blob/_generated/models/_patch.py +3 -0
- azure/storage/blob/_generated/operations/_append_blob_operations.py +14 -9
- azure/storage/blob/_generated/operations/_blob_operations.py +76 -51
- azure/storage/blob/_generated/operations/_block_blob_operations.py +18 -13
- azure/storage/blob/_generated/operations/_container_operations.py +64 -39
- azure/storage/blob/_generated/operations/_page_blob_operations.py +24 -19
- azure/storage/blob/_generated/operations/_patch.py +3 -0
- azure/storage/blob/_generated/operations/_service_operations.py +43 -19
- azure/storage/blob/_generated/py.typed +1 -0
- azure/storage/blob/_lease.py +6 -5
- azure/storage/blob/_models.py +1 -1
- azure/storage/blob/_serialize.py +1 -0
- azure/storage/blob/_shared/authentication.py +62 -4
- azure/storage/blob/_shared/base_client.py +1 -1
- azure/storage/blob/_shared/base_client_async.py +3 -2
- azure/storage/blob/_shared/models.py +13 -12
- azure/storage/blob/_shared/shared_access_signature.py +1 -0
- azure/storage/blob/_shared_access_signature.py +1 -0
- azure/storage/blob/_version.py +1 -1
- azure/storage/blob/aio/__init__.py +13 -4
- azure/storage/blob/aio/_blob_client_async.py +50 -47
- azure/storage/blob/aio/_blob_service_client_async.py +11 -11
- azure/storage/blob/aio/_container_client_async.py +23 -20
- azure/storage/blob/aio/_download_async.py +317 -209
- azure/storage/blob/aio/_lease_async.py +6 -6
- {azure_storage_blob-12.20.0b1.dist-info → azure_storage_blob-12.21.0.dist-info}/METADATA +2 -2
- azure_storage_blob-12.21.0.dist-info/RECORD +82 -0
- azure_storage_blob-12.20.0b1.dist-info/RECORD +0 -81
- {azure_storage_blob-12.20.0b1.dist-info → azure_storage_blob-12.21.0.dist-info}/LICENSE +0 -0
- {azure_storage_blob-12.20.0b1.dist-info → azure_storage_blob-12.21.0.dist-info}/WHEEL +0 -0
- {azure_storage_blob-12.20.0b1.dist-info → azure_storage_blob-12.21.0.dist-info}/top_level.txt +0 -0
@@ -6,7 +6,8 @@
|
|
6
6
|
# Code generated by Microsoft (R) AutoRest Code Generator.
|
7
7
|
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
8
8
|
# --------------------------------------------------------------------------
|
9
|
-
|
9
|
+
import sys
|
10
|
+
from typing import Any, Callable, Dict, IO, Iterator, List, Literal, Optional, Type, TypeVar, Union
|
10
11
|
|
11
12
|
from azure.core.exceptions import (
|
12
13
|
ClientAuthenticationError,
|
@@ -26,6 +27,10 @@ from .. import models as _models
|
|
26
27
|
from .._serialization import Serializer
|
27
28
|
from .._vendor import _convert_request
|
28
29
|
|
30
|
+
if sys.version_info >= (3, 9):
|
31
|
+
from collections.abc import MutableMapping
|
32
|
+
else:
|
33
|
+
from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports
|
29
34
|
T = TypeVar("T")
|
30
35
|
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
|
31
36
|
|
@@ -42,7 +47,7 @@ def build_set_properties_request(
|
|
42
47
|
restype: Literal["service"] = kwargs.pop("restype", _params.pop("restype", "service"))
|
43
48
|
comp: Literal["properties"] = kwargs.pop("comp", _params.pop("comp", "properties"))
|
44
49
|
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
|
45
|
-
version: Literal["
|
50
|
+
version: Literal["2024-08-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-08-04"))
|
46
51
|
accept = _headers.pop("Accept", "application/xml")
|
47
52
|
|
48
53
|
# Construct URL
|
@@ -78,7 +83,7 @@ def build_get_properties_request(
|
|
78
83
|
|
79
84
|
restype: Literal["service"] = kwargs.pop("restype", _params.pop("restype", "service"))
|
80
85
|
comp: Literal["properties"] = kwargs.pop("comp", _params.pop("comp", "properties"))
|
81
|
-
version: Literal["
|
86
|
+
version: Literal["2024-08-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-08-04"))
|
82
87
|
accept = _headers.pop("Accept", "application/xml")
|
83
88
|
|
84
89
|
# Construct URL
|
@@ -112,7 +117,7 @@ def build_get_statistics_request(
|
|
112
117
|
|
113
118
|
restype: Literal["service"] = kwargs.pop("restype", _params.pop("restype", "service"))
|
114
119
|
comp: Literal["stats"] = kwargs.pop("comp", _params.pop("comp", "stats"))
|
115
|
-
version: Literal["
|
120
|
+
version: Literal["2024-08-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-08-04"))
|
116
121
|
accept = _headers.pop("Accept", "application/xml")
|
117
122
|
|
118
123
|
# Construct URL
|
@@ -153,7 +158,7 @@ def build_list_containers_segment_request(
|
|
153
158
|
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
|
154
159
|
|
155
160
|
comp: Literal["list"] = kwargs.pop("comp", _params.pop("comp", "list"))
|
156
|
-
version: Literal["
|
161
|
+
version: Literal["2024-08-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-08-04"))
|
157
162
|
accept = _headers.pop("Accept", "application/xml")
|
158
163
|
|
159
164
|
# Construct URL
|
@@ -195,7 +200,7 @@ def build_get_user_delegation_key_request(
|
|
195
200
|
restype: Literal["service"] = kwargs.pop("restype", _params.pop("restype", "service"))
|
196
201
|
comp: Literal["userdelegationkey"] = kwargs.pop("comp", _params.pop("comp", "userdelegationkey"))
|
197
202
|
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
|
198
|
-
version: Literal["
|
203
|
+
version: Literal["2024-08-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-08-04"))
|
199
204
|
accept = _headers.pop("Accept", "application/xml")
|
200
205
|
|
201
206
|
# Construct URL
|
@@ -223,13 +228,15 @@ def build_get_user_delegation_key_request(
|
|
223
228
|
return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, content=content, **kwargs)
|
224
229
|
|
225
230
|
|
226
|
-
def build_get_account_info_request(
|
231
|
+
def build_get_account_info_request(
|
232
|
+
url: str, *, timeout: Optional[int] = None, request_id_parameter: Optional[str] = None, **kwargs: Any
|
233
|
+
) -> HttpRequest:
|
227
234
|
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
|
228
235
|
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
|
229
236
|
|
230
237
|
restype: Literal["account"] = kwargs.pop("restype", _params.pop("restype", "account"))
|
231
238
|
comp: Literal["properties"] = kwargs.pop("comp", _params.pop("comp", "properties"))
|
232
|
-
version: Literal["
|
239
|
+
version: Literal["2024-08-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-08-04"))
|
233
240
|
accept = _headers.pop("Accept", "application/xml")
|
234
241
|
|
235
242
|
# Construct URL
|
@@ -243,9 +250,13 @@ def build_get_account_info_request(url: str, **kwargs: Any) -> HttpRequest:
|
|
243
250
|
# Construct parameters
|
244
251
|
_params["restype"] = _SERIALIZER.query("restype", restype, "str")
|
245
252
|
_params["comp"] = _SERIALIZER.query("comp", comp, "str")
|
253
|
+
if timeout is not None:
|
254
|
+
_params["timeout"] = _SERIALIZER.query("timeout", timeout, "int", minimum=0)
|
246
255
|
|
247
256
|
# Construct headers
|
248
257
|
_headers["x-ms-version"] = _SERIALIZER.header("version", version, "str")
|
258
|
+
if request_id_parameter is not None:
|
259
|
+
_headers["x-ms-client-request-id"] = _SERIALIZER.header("request_id_parameter", request_id_parameter, "str")
|
249
260
|
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
|
250
261
|
|
251
262
|
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
|
@@ -265,7 +276,7 @@ def build_submit_batch_request(
|
|
265
276
|
|
266
277
|
comp: Literal["batch"] = kwargs.pop("comp", _params.pop("comp", "batch"))
|
267
278
|
multipart_content_type: Optional[str] = kwargs.pop("multipart_content_type", _headers.pop("Content-Type", None))
|
268
|
-
version: Literal["
|
279
|
+
version: Literal["2024-08-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-08-04"))
|
269
280
|
accept = _headers.pop("Accept", "application/xml")
|
270
281
|
|
271
282
|
# Construct URL
|
@@ -308,7 +319,7 @@ def build_filter_blobs_request(
|
|
308
319
|
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
|
309
320
|
|
310
321
|
comp: Literal["blobs"] = kwargs.pop("comp", _params.pop("comp", "blobs"))
|
311
|
-
version: Literal["
|
322
|
+
version: Literal["2024-08-04"] = kwargs.pop("version", _headers.pop("x-ms-version", "2024-08-04"))
|
312
323
|
accept = _headers.pop("Accept", "application/xml")
|
313
324
|
|
314
325
|
# Construct URL
|
@@ -386,7 +397,7 @@ class ServiceOperations:
|
|
386
397
|
:rtype: None
|
387
398
|
:raises ~azure.core.exceptions.HttpResponseError:
|
388
399
|
"""
|
389
|
-
error_map = {
|
400
|
+
error_map: MutableMapping[int, Type[HttpResponseError]] = {
|
390
401
|
401: ClientAuthenticationError,
|
391
402
|
404: ResourceNotFoundError,
|
392
403
|
409: ResourceExistsError,
|
@@ -461,7 +472,7 @@ class ServiceOperations:
|
|
461
472
|
:rtype: ~azure.storage.blob.models.StorageServiceProperties
|
462
473
|
:raises ~azure.core.exceptions.HttpResponseError:
|
463
474
|
"""
|
464
|
-
error_map = {
|
475
|
+
error_map: MutableMapping[int, Type[HttpResponseError]] = {
|
465
476
|
401: ClientAuthenticationError,
|
466
477
|
404: ResourceNotFoundError,
|
467
478
|
409: ResourceExistsError,
|
@@ -536,7 +547,7 @@ class ServiceOperations:
|
|
536
547
|
:rtype: ~azure.storage.blob.models.StorageServiceStats
|
537
548
|
:raises ~azure.core.exceptions.HttpResponseError:
|
538
549
|
"""
|
539
|
-
error_map = {
|
550
|
+
error_map: MutableMapping[int, Type[HttpResponseError]] = {
|
540
551
|
401: ClientAuthenticationError,
|
541
552
|
404: ResourceNotFoundError,
|
542
553
|
409: ResourceExistsError,
|
@@ -638,7 +649,7 @@ class ServiceOperations:
|
|
638
649
|
:rtype: ~azure.storage.blob.models.ListContainersSegmentResponse
|
639
650
|
:raises ~azure.core.exceptions.HttpResponseError:
|
640
651
|
"""
|
641
|
-
error_map = {
|
652
|
+
error_map: MutableMapping[int, Type[HttpResponseError]] = {
|
642
653
|
401: ClientAuthenticationError,
|
643
654
|
404: ResourceNotFoundError,
|
644
655
|
409: ResourceExistsError,
|
@@ -720,7 +731,7 @@ class ServiceOperations:
|
|
720
731
|
:rtype: ~azure.storage.blob.models.UserDelegationKey
|
721
732
|
:raises ~azure.core.exceptions.HttpResponseError:
|
722
733
|
"""
|
723
|
-
error_map = {
|
734
|
+
error_map: MutableMapping[int, Type[HttpResponseError]] = {
|
724
735
|
401: ClientAuthenticationError,
|
725
736
|
404: ResourceNotFoundError,
|
726
737
|
409: ResourceExistsError,
|
@@ -781,14 +792,25 @@ class ServiceOperations:
|
|
781
792
|
return deserialized # type: ignore
|
782
793
|
|
783
794
|
@distributed_trace
|
784
|
-
def get_account_info(
|
795
|
+
def get_account_info( # pylint: disable=inconsistent-return-statements
|
796
|
+
self, timeout: Optional[int] = None, request_id_parameter: Optional[str] = None, **kwargs: Any
|
797
|
+
) -> None:
|
785
798
|
"""Returns the sku name and account kind.
|
786
799
|
|
800
|
+
:param timeout: The timeout parameter is expressed in seconds. For more information, see
|
801
|
+
:code:`<a
|
802
|
+
href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting
|
803
|
+
Timeouts for Blob Service Operations.</a>`. Default value is None.
|
804
|
+
:type timeout: int
|
805
|
+
:param request_id_parameter: Provides a client-generated, opaque value with a 1 KB character
|
806
|
+
limit that is recorded in the analytics logs when storage analytics logging is enabled. Default
|
807
|
+
value is None.
|
808
|
+
:type request_id_parameter: str
|
787
809
|
:return: None or the result of cls(response)
|
788
810
|
:rtype: None
|
789
811
|
:raises ~azure.core.exceptions.HttpResponseError:
|
790
812
|
"""
|
791
|
-
error_map = {
|
813
|
+
error_map: MutableMapping[int, Type[HttpResponseError]] = {
|
792
814
|
401: ClientAuthenticationError,
|
793
815
|
404: ResourceNotFoundError,
|
794
816
|
409: ResourceExistsError,
|
@@ -805,6 +827,8 @@ class ServiceOperations:
|
|
805
827
|
|
806
828
|
_request = build_get_account_info_request(
|
807
829
|
url=self._config.url,
|
830
|
+
timeout=timeout,
|
831
|
+
request_id_parameter=request_id_parameter,
|
808
832
|
restype=restype,
|
809
833
|
comp=comp,
|
810
834
|
version=self._config.version,
|
@@ -868,7 +892,7 @@ class ServiceOperations:
|
|
868
892
|
:rtype: Iterator[bytes]
|
869
893
|
:raises ~azure.core.exceptions.HttpResponseError:
|
870
894
|
"""
|
871
|
-
error_map = {
|
895
|
+
error_map: MutableMapping[int, Type[HttpResponseError]] = {
|
872
896
|
401: ClientAuthenticationError,
|
873
897
|
404: ResourceNotFoundError,
|
874
898
|
409: ResourceExistsError,
|
@@ -974,7 +998,7 @@ class ServiceOperations:
|
|
974
998
|
:rtype: ~azure.storage.blob.models.FilterBlobSegment
|
975
999
|
:raises ~azure.core.exceptions.HttpResponseError:
|
976
1000
|
"""
|
977
|
-
error_map = {
|
1001
|
+
error_map: MutableMapping[int, Type[HttpResponseError]] = {
|
978
1002
|
401: ClientAuthenticationError,
|
979
1003
|
404: ResourceNotFoundError,
|
980
1004
|
409: ResourceExistsError,
|
@@ -0,0 +1 @@
|
|
1
|
+
# Marker file for PEP 561.
|
azure/storage/blob/_lease.py
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
# Licensed under the MIT License. See License.txt in the project root for
|
4
4
|
# license information.
|
5
5
|
# --------------------------------------------------------------------------
|
6
|
+
# pylint: disable=docstring-keyword-should-match-keyword-only
|
6
7
|
|
7
8
|
import uuid
|
8
9
|
|
@@ -107,7 +108,7 @@ class BlobLeaseClient(object): # pylint: disable=client-accepts-api-version-key
|
|
107
108
|
https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-blob-service-operations.
|
108
109
|
This value is not tracked or validated on the client. To configure client-side network timesouts
|
109
110
|
see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
|
110
|
-
#other-client--per-operation-configuration>`
|
111
|
+
#other-client--per-operation-configuration>`__.
|
111
112
|
:rtype: None
|
112
113
|
"""
|
113
114
|
mod_conditions = get_modify_conditions(kwargs)
|
@@ -164,7 +165,7 @@ class BlobLeaseClient(object): # pylint: disable=client-accepts-api-version-key
|
|
164
165
|
https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-blob-service-operations.
|
165
166
|
This value is not tracked or validated on the client. To configure client-side network timesouts
|
166
167
|
see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
|
167
|
-
#other-client--per-operation-configuration>`
|
168
|
+
#other-client--per-operation-configuration>`__.
|
168
169
|
:return: None
|
169
170
|
"""
|
170
171
|
mod_conditions = get_modify_conditions(kwargs)
|
@@ -218,7 +219,7 @@ class BlobLeaseClient(object): # pylint: disable=client-accepts-api-version-key
|
|
218
219
|
https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-blob-service-operations.
|
219
220
|
This value is not tracked or validated on the client. To configure client-side network timesouts
|
220
221
|
see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
|
221
|
-
#other-client--per-operation-configuration>`
|
222
|
+
#other-client--per-operation-configuration>`__.
|
222
223
|
:return: None
|
223
224
|
"""
|
224
225
|
mod_conditions = get_modify_conditions(kwargs)
|
@@ -271,7 +272,7 @@ class BlobLeaseClient(object): # pylint: disable=client-accepts-api-version-key
|
|
271
272
|
https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-blob-service-operations.
|
272
273
|
This value is not tracked or validated on the client. To configure client-side network timesouts
|
273
274
|
see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
|
274
|
-
#other-client--per-operation-configuration>`
|
275
|
+
#other-client--per-operation-configuration>`__.
|
275
276
|
:return: None
|
276
277
|
"""
|
277
278
|
mod_conditions = get_modify_conditions(kwargs)
|
@@ -334,7 +335,7 @@ class BlobLeaseClient(object): # pylint: disable=client-accepts-api-version-key
|
|
334
335
|
https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-blob-service-operations.
|
335
336
|
This value is not tracked or validated on the client. To configure client-side network timesouts
|
336
337
|
see `here <https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob
|
337
|
-
#other-client--per-operation-configuration>`
|
338
|
+
#other-client--per-operation-configuration>`__.
|
338
339
|
:return: Approximate time remaining in the lease period, in seconds.
|
339
340
|
:rtype: int
|
340
341
|
"""
|
azure/storage/blob/_models.py
CHANGED
@@ -1064,7 +1064,7 @@ class ContainerEncryptionScope(object):
|
|
1064
1064
|
class DelimitedJsonDialect(DictMixin):
|
1065
1065
|
"""Defines the input or output JSON serialization for a blob data query.
|
1066
1066
|
|
1067
|
-
:keyword str delimiter: The line separator character, default value is '
|
1067
|
+
:keyword str delimiter: The line separator character, default value is '\\\\n'.
|
1068
1068
|
"""
|
1069
1069
|
|
1070
1070
|
def __init__(self, **kwargs):
|
azure/storage/blob/_serialize.py
CHANGED
@@ -8,6 +8,7 @@ import logging
|
|
8
8
|
import re
|
9
9
|
from typing import List, Tuple
|
10
10
|
from urllib.parse import unquote, urlparse
|
11
|
+
from functools import cmp_to_key
|
11
12
|
|
12
13
|
try:
|
13
14
|
from yarl import URL
|
@@ -27,6 +28,66 @@ from . import sign_string
|
|
27
28
|
logger = logging.getLogger(__name__)
|
28
29
|
|
29
30
|
|
31
|
+
table_lv0 = [
|
32
|
+
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
33
|
+
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
34
|
+
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x71c, 0x0, 0x71f, 0x721, 0x723, 0x725,
|
35
|
+
0x0, 0x0, 0x0, 0x72d, 0x803, 0x0, 0x0, 0x733, 0x0, 0xd03, 0xd1a, 0xd1c, 0xd1e,
|
36
|
+
0xd20, 0xd22, 0xd24, 0xd26, 0xd28, 0xd2a, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
37
|
+
0xe02, 0xe09, 0xe0a, 0xe1a, 0xe21, 0xe23, 0xe25, 0xe2c, 0xe32, 0xe35, 0xe36, 0xe48, 0xe51,
|
38
|
+
0xe70, 0xe7c, 0xe7e, 0xe89, 0xe8a, 0xe91, 0xe99, 0xe9f, 0xea2, 0xea4, 0xea6, 0xea7, 0xea9,
|
39
|
+
0x0, 0x0, 0x0, 0x743, 0x744, 0x748, 0xe02, 0xe09, 0xe0a, 0xe1a, 0xe21, 0xe23, 0xe25,
|
40
|
+
0xe2c, 0xe32, 0xe35, 0xe36, 0xe48, 0xe51, 0xe70, 0xe7c, 0xe7e, 0xe89, 0xe8a, 0xe91, 0xe99,
|
41
|
+
0xe9f, 0xea2, 0xea4, 0xea6, 0xea7, 0xea9, 0x0, 0x74c, 0x0, 0x750, 0x0,
|
42
|
+
]
|
43
|
+
|
44
|
+
table_lv4 = [
|
45
|
+
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
46
|
+
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
47
|
+
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8012, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8212, 0x0, 0x0,
|
48
|
+
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
49
|
+
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
50
|
+
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
51
|
+
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
52
|
+
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
53
|
+
]
|
54
|
+
|
55
|
+
def compare(lhs: str, rhs: str) -> int: # pylint:disable=too-many-return-statements
|
56
|
+
tables = [table_lv0, table_lv4]
|
57
|
+
curr_level, i, j, n = 0, 0, 0, len(tables)
|
58
|
+
lhs_len = len(lhs)
|
59
|
+
rhs_len = len(rhs)
|
60
|
+
while curr_level < n:
|
61
|
+
if curr_level == (n - 1) and i != j:
|
62
|
+
if i > j:
|
63
|
+
return -1
|
64
|
+
if i < j:
|
65
|
+
return 1
|
66
|
+
return 0
|
67
|
+
|
68
|
+
w1 = tables[curr_level][ord(lhs[i])] if i < lhs_len else 0x1
|
69
|
+
w2 = tables[curr_level][ord(rhs[j])] if j < rhs_len else 0x1
|
70
|
+
|
71
|
+
if w1 == 0x1 and w2 == 0x1:
|
72
|
+
i = 0
|
73
|
+
j = 0
|
74
|
+
curr_level += 1
|
75
|
+
elif w1 == w2:
|
76
|
+
i += 1
|
77
|
+
j += 1
|
78
|
+
elif w1 == 0:
|
79
|
+
i += 1
|
80
|
+
elif w2 == 0:
|
81
|
+
j += 1
|
82
|
+
else:
|
83
|
+
if w1 < w2:
|
84
|
+
return -1
|
85
|
+
if w1 > w2:
|
86
|
+
return 1
|
87
|
+
return 0
|
88
|
+
return 0
|
89
|
+
|
90
|
+
|
30
91
|
# wraps a given exception with the desired exception type
|
31
92
|
def _wrap_exception(ex, desired_type):
|
32
93
|
msg = ""
|
@@ -36,8 +97,6 @@ def _wrap_exception(ex, desired_type):
|
|
36
97
|
|
37
98
|
# This method attempts to emulate the sorting done by the service
|
38
99
|
def _storage_header_sort(input_headers: List[Tuple[str, str]]) -> List[Tuple[str, str]]:
|
39
|
-
# Define the custom alphabet for weights
|
40
|
-
custom_weights = "-!#$%&*.^_|~+\"\'(),/`~0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]abcdefghijklmnopqrstuvwxyz{}"
|
41
100
|
|
42
101
|
# Build dict of tuples and list of keys
|
43
102
|
header_dict = {}
|
@@ -46,9 +105,8 @@ def _storage_header_sort(input_headers: List[Tuple[str, str]]) -> List[Tuple[str
|
|
46
105
|
header_dict[k] = v
|
47
106
|
header_keys.append(k)
|
48
107
|
|
49
|
-
# Sort according to custom defined weights
|
50
108
|
try:
|
51
|
-
header_keys = sorted(header_keys, key=
|
109
|
+
header_keys = sorted(header_keys, key=cmp_to_key(compare))
|
52
110
|
except ValueError as exc:
|
53
111
|
raise ValueError("Illegal character encountered when sorting headers.") from exc
|
54
112
|
|
@@ -231,7 +231,7 @@ class StorageAccountHostsMixin(object): # pylint: disable=too-many-instance-att
|
|
231
231
|
audience = str(kwargs.pop('audience')).rstrip('/') + DEFAULT_OAUTH_SCOPE
|
232
232
|
else:
|
233
233
|
audience = STORAGE_OAUTH_SCOPE
|
234
|
-
self._credential_policy = StorageBearerTokenCredentialPolicy(credential, audience)
|
234
|
+
self._credential_policy = StorageBearerTokenCredentialPolicy(cast(TokenCredential, credential), audience)
|
235
235
|
elif isinstance(credential, SharedKeyCredentialPolicy):
|
236
236
|
self._credential_policy = credential
|
237
237
|
elif isinstance(credential, AzureSasCredential):
|
@@ -6,7 +6,7 @@
|
|
6
6
|
# mypy: disable-error-code="attr-defined"
|
7
7
|
|
8
8
|
import logging
|
9
|
-
from typing import Any, Dict, Optional, Tuple, TYPE_CHECKING, Union
|
9
|
+
from typing import Any, cast, Dict, Optional, Tuple, TYPE_CHECKING, Union
|
10
10
|
|
11
11
|
from azure.core.async_paging import AsyncList
|
12
12
|
from azure.core.credentials import AzureNamedKeyCredential, AzureSasCredential
|
@@ -104,7 +104,8 @@ class AsyncStorageAccountHostsMixin(object):
|
|
104
104
|
audience = str(kwargs.pop('audience')).rstrip('/') + DEFAULT_OAUTH_SCOPE
|
105
105
|
else:
|
106
106
|
audience = STORAGE_OAUTH_SCOPE
|
107
|
-
self._credential_policy = AsyncStorageBearerTokenCredentialPolicy(
|
107
|
+
self._credential_policy = AsyncStorageBearerTokenCredentialPolicy(
|
108
|
+
cast(AsyncTokenCredential, credential), audience)
|
108
109
|
elif isinstance(credential, SharedKeyCredentialPolicy):
|
109
110
|
self._credential_policy = credential
|
110
111
|
elif isinstance(credential, AzureSasCredential):
|
@@ -453,19 +453,20 @@ class AccountSasPermissions(object):
|
|
453
453
|
class Services(object):
|
454
454
|
"""Specifies the services accessible with the account SAS.
|
455
455
|
|
456
|
-
:
|
457
|
-
Access for the `~azure.storage.blob.BlobServiceClient
|
458
|
-
:
|
459
|
-
Access for the `~azure.storage.queue.QueueServiceClient
|
460
|
-
:
|
461
|
-
Access for the `~azure.storage.fileshare.ShareServiceClient
|
456
|
+
:keyword bool blob:
|
457
|
+
Access for the `~azure.storage.blob.BlobServiceClient`. Default is False.
|
458
|
+
:keyword bool queue:
|
459
|
+
Access for the `~azure.storage.queue.QueueServiceClient`. Default is False.
|
460
|
+
:keyword bool fileshare:
|
461
|
+
Access for the `~azure.storage.fileshare.ShareServiceClient`. Default is False.
|
462
462
|
"""
|
463
463
|
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
464
|
+
def __init__(
|
465
|
+
self, *,
|
466
|
+
blob: bool = False,
|
467
|
+
queue: bool = False,
|
468
|
+
fileshare: bool = False
|
469
|
+
) -> None:
|
469
470
|
self.blob = blob
|
470
471
|
self.queue = queue
|
471
472
|
self.fileshare = fileshare
|
@@ -493,7 +494,7 @@ class Services(object):
|
|
493
494
|
res_queue = 'q' in string
|
494
495
|
res_file = 'f' in string
|
495
496
|
|
496
|
-
parsed = cls(res_blob, res_queue, res_file)
|
497
|
+
parsed = cls(blob=res_blob, queue=res_queue, fileshare=res_file)
|
497
498
|
parsed._str = string # pylint: disable = protected-access
|
498
499
|
return parsed
|
499
500
|
|
@@ -3,6 +3,7 @@
|
|
3
3
|
# Licensed under the MIT License. See License.txt in the project root for
|
4
4
|
# license information.
|
5
5
|
# --------------------------------------------------------------------------
|
6
|
+
# pylint: disable=docstring-keyword-should-match-keyword-only
|
6
7
|
|
7
8
|
from datetime import date
|
8
9
|
|
@@ -3,6 +3,7 @@
|
|
3
3
|
# Licensed under the MIT License. See License.txt in the project root for
|
4
4
|
# license information.
|
5
5
|
# --------------------------------------------------------------------------
|
6
|
+
# pylint: disable=docstring-keyword-should-match-keyword-only
|
6
7
|
|
7
8
|
from typing import ( # pylint: disable=unused-import
|
8
9
|
Union, Optional, Any, TYPE_CHECKING
|
azure/storage/blob/_version.py
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
# Licensed under the MIT License. See License.txt in the project root for
|
4
4
|
# license information.
|
5
5
|
# --------------------------------------------------------------------------
|
6
|
+
# pylint: disable=docstring-keyword-should-match-keyword-only
|
6
7
|
|
7
8
|
import os
|
8
9
|
|
@@ -31,7 +32,7 @@ async def upload_blob_to_url(
|
|
31
32
|
:param data:
|
32
33
|
The data to upload. This can be bytes, text, an iterable or a file-like object.
|
33
34
|
:type data: bytes or str or Iterable
|
34
|
-
|
35
|
+
:param credential:
|
35
36
|
The credentials with which to authenticate. This is optional if the
|
36
37
|
blob URL already has a SAS token. The value can be a SAS token string,
|
37
38
|
an instance of a AzureSasCredential or AzureNamedKeyCredential from azure.core.credentials,
|
@@ -40,7 +41,11 @@ async def upload_blob_to_url(
|
|
40
41
|
- except in the case of AzureSasCredential, where the conflicting SAS tokens will raise a ValueError.
|
41
42
|
If using an instance of AzureNamedKeyCredential, "name" should be the storage account name, and "key"
|
42
43
|
should be the storage account key.
|
43
|
-
:type credential:
|
44
|
+
:type credential:
|
45
|
+
~azure.core.credentials.AzureNamedKeyCredential or
|
46
|
+
~azure.core.credentials.AzureSasCredential or
|
47
|
+
~azure.core.credentials.TokenCredential or
|
48
|
+
str or dict[str, str] or None
|
44
49
|
:keyword bool overwrite:
|
45
50
|
Whether the blob to be uploaded should overwrite the current data.
|
46
51
|
If True, upload_blob_to_url will overwrite any existing data. If set to False, the
|
@@ -64,7 +69,7 @@ async def upload_blob_to_url(
|
|
64
69
|
:keyword str encoding:
|
65
70
|
Encoding to use if text is supplied as input. Defaults to UTF-8.
|
66
71
|
:returns: Blob-updated property dict (Etag and last modified)
|
67
|
-
:rtype: dict
|
72
|
+
:rtype: dict[str, Any]
|
68
73
|
"""
|
69
74
|
async with BlobClient.from_blob_url(blob_url, credential=credential) as client:
|
70
75
|
return await client.upload_blob(data=data, blob_type=BlobType.BlockBlob, **kwargs)
|
@@ -99,7 +104,11 @@ async def download_blob_from_url(
|
|
99
104
|
- except in the case of AzureSasCredential, where the conflicting SAS tokens will raise a ValueError.
|
100
105
|
If using an instance of AzureNamedKeyCredential, "name" should be the storage account name, and "key"
|
101
106
|
should be the storage account key.
|
102
|
-
:type credential:
|
107
|
+
:type credential:
|
108
|
+
~azure.core.credentials.AzureNamedKeyCredential or
|
109
|
+
~azure.core.credentials.AzureSasCredential or
|
110
|
+
~azure.core.credentials.TokenCredential or
|
111
|
+
str or dict[str, str] or None
|
103
112
|
:keyword bool overwrite:
|
104
113
|
Whether the local file should be overwritten if it already exists. The default value is
|
105
114
|
`False` - in which case a ValueError will be raised if the file already exists. If set to
|