azure-storage-blob 12.26.0b1__py3-none-any.whl → 12.27.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.
Files changed (72) hide show
  1. azure/storage/blob/__init__.py +6 -5
  2. azure/storage/blob/_blob_client.py +59 -38
  3. azure/storage/blob/_blob_client.pyi +780 -0
  4. azure/storage/blob/_blob_client_helpers.py +4 -3
  5. azure/storage/blob/_blob_service_client.py +57 -17
  6. azure/storage/blob/_blob_service_client.pyi +182 -0
  7. azure/storage/blob/_container_client.py +47 -22
  8. azure/storage/blob/_container_client.pyi +380 -0
  9. azure/storage/blob/_deserialize.py +1 -1
  10. azure/storage/blob/_download.py +7 -7
  11. azure/storage/blob/_encryption.py +177 -184
  12. azure/storage/blob/_generated/_azure_blob_storage.py +3 -2
  13. azure/storage/blob/_generated/_configuration.py +2 -2
  14. azure/storage/blob/_generated/_utils/__init__.py +6 -0
  15. azure/storage/blob/_generated/{_serialization.py → _utils/serialization.py} +4 -22
  16. azure/storage/blob/_generated/aio/_azure_blob_storage.py +3 -2
  17. azure/storage/blob/_generated/aio/_configuration.py +2 -2
  18. azure/storage/blob/_generated/aio/operations/_append_blob_operations.py +6 -10
  19. azure/storage/blob/_generated/aio/operations/_blob_operations.py +35 -39
  20. azure/storage/blob/_generated/aio/operations/_block_blob_operations.py +9 -13
  21. azure/storage/blob/_generated/aio/operations/_container_operations.py +20 -24
  22. azure/storage/blob/_generated/aio/operations/_page_blob_operations.py +13 -17
  23. azure/storage/blob/_generated/aio/operations/_service_operations.py +10 -14
  24. azure/storage/blob/_generated/models/_models_py3.py +30 -9
  25. azure/storage/blob/_generated/operations/_append_blob_operations.py +11 -15
  26. azure/storage/blob/_generated/operations/_blob_operations.py +60 -64
  27. azure/storage/blob/_generated/operations/_block_blob_operations.py +16 -20
  28. azure/storage/blob/_generated/operations/_container_operations.py +39 -43
  29. azure/storage/blob/_generated/operations/_page_blob_operations.py +23 -27
  30. azure/storage/blob/_generated/operations/_service_operations.py +19 -23
  31. azure/storage/blob/_lease.py +3 -2
  32. azure/storage/blob/_lease.pyi +81 -0
  33. azure/storage/blob/_list_blobs_helper.py +1 -1
  34. azure/storage/blob/_quick_query_helper.py +3 -3
  35. azure/storage/blob/_serialize.py +1 -0
  36. azure/storage/blob/_shared/__init__.py +7 -7
  37. azure/storage/blob/_shared/authentication.py +49 -32
  38. azure/storage/blob/_shared/avro/avro_io.py +44 -42
  39. azure/storage/blob/_shared/avro/avro_io_async.py +42 -41
  40. azure/storage/blob/_shared/avro/datafile.py +24 -21
  41. azure/storage/blob/_shared/avro/datafile_async.py +15 -15
  42. azure/storage/blob/_shared/avro/schema.py +196 -217
  43. azure/storage/blob/_shared/base_client.py +79 -70
  44. azure/storage/blob/_shared/base_client_async.py +53 -68
  45. azure/storage/blob/_shared/constants.py +1 -1
  46. azure/storage/blob/_shared/models.py +94 -92
  47. azure/storage/blob/_shared/parser.py +3 -3
  48. azure/storage/blob/_shared/policies.py +186 -147
  49. azure/storage/blob/_shared/policies_async.py +58 -69
  50. azure/storage/blob/_shared/request_handlers.py +50 -45
  51. azure/storage/blob/_shared/response_handlers.py +54 -45
  52. azure/storage/blob/_shared/shared_access_signature.py +65 -73
  53. azure/storage/blob/_shared/uploads.py +56 -49
  54. azure/storage/blob/_shared/uploads_async.py +70 -58
  55. azure/storage/blob/_version.py +1 -1
  56. azure/storage/blob/aio/__init__.py +8 -10
  57. azure/storage/blob/aio/_blob_client_async.py +81 -48
  58. azure/storage/blob/aio/_blob_client_async.pyi +763 -0
  59. azure/storage/blob/aio/_blob_service_client_async.py +54 -15
  60. azure/storage/blob/aio/_blob_service_client_async.pyi +187 -0
  61. azure/storage/blob/aio/_container_client_async.py +55 -26
  62. azure/storage/blob/aio/_container_client_async.pyi +384 -0
  63. azure/storage/blob/aio/_download_async.py +15 -11
  64. azure/storage/blob/aio/_lease_async.py +3 -2
  65. azure/storage/blob/aio/_lease_async.pyi +81 -0
  66. azure/storage/blob/aio/_quick_query_helper_async.py +3 -3
  67. {azure_storage_blob-12.26.0b1.dist-info → azure_storage_blob-12.27.0.dist-info}/METADATA +18 -6
  68. azure_storage_blob-12.27.0.dist-info/RECORD +94 -0
  69. {azure_storage_blob-12.26.0b1.dist-info → azure_storage_blob-12.27.0.dist-info}/WHEEL +1 -1
  70. azure_storage_blob-12.26.0b1.dist-info/RECORD +0 -85
  71. {azure_storage_blob-12.26.0b1.dist-info → azure_storage_blob-12.27.0.dist-info/licenses}/LICENSE +0 -0
  72. {azure_storage_blob-12.26.0b1.dist-info → azure_storage_blob-12.27.0.dist-info}/top_level.txt +0 -0
@@ -26,17 +26,18 @@ logger = logging.getLogger(__name__)
26
26
  VERSION = 1
27
27
 
28
28
  if PY3:
29
- MAGIC = b'Obj' + bytes([VERSION])
29
+ MAGIC = b"Obj" + bytes([VERSION])
30
30
  MAGIC_SIZE = len(MAGIC)
31
31
  else:
32
- MAGIC = 'Obj' + chr(VERSION)
32
+ MAGIC = "Obj" + chr(VERSION)
33
33
  MAGIC_SIZE = len(MAGIC)
34
34
 
35
35
  # Size of the synchronization marker, in number of bytes:
36
36
  SYNC_SIZE = 16
37
37
 
38
38
  # Schema of the container header:
39
- META_SCHEMA = schema.parse("""
39
+ META_SCHEMA = schema.parse(
40
+ """
40
41
  {
41
42
  "type": "record", "name": "org.apache.avro.file.Header",
42
43
  "fields": [{
@@ -50,13 +51,15 @@ META_SCHEMA = schema.parse("""
50
51
  "type": {"type": "fixed", "name": "sync", "size": %(sync_size)d}
51
52
  }]
52
53
  }
53
- """ % {
54
- 'magic_size': MAGIC_SIZE,
55
- 'sync_size': SYNC_SIZE,
56
- })
54
+ """
55
+ % {
56
+ "magic_size": MAGIC_SIZE,
57
+ "sync_size": SYNC_SIZE,
58
+ }
59
+ )
57
60
 
58
61
  # Codecs supported by container files:
59
- VALID_CODECS = frozenset(['null', 'deflate'])
62
+ VALID_CODECS = frozenset(["null", "deflate"])
60
63
 
61
64
  # Metadata key associated to the schema:
62
65
  SCHEMA_KEY = "avro.schema"
@@ -69,6 +72,7 @@ SCHEMA_KEY = "avro.schema"
69
72
  class DataFileException(schema.AvroException):
70
73
  """Problem reading or writing file object containers."""
71
74
 
75
+
72
76
  # ------------------------------------------------------------------------------
73
77
 
74
78
 
@@ -84,7 +88,7 @@ class DataFileReader(object): # pylint: disable=too-many-instance-attributes
84
88
  """
85
89
  self._reader = reader
86
90
  self._raw_decoder = avro_io.BinaryDecoder(reader)
87
- self._header_reader = kwargs.pop('header_reader', None)
91
+ self._header_reader = kwargs.pop("header_reader", None)
88
92
  self._header_decoder = None if self._header_reader is None else avro_io.BinaryDecoder(self._header_reader)
89
93
  self._datum_decoder = None # Maybe reset at every block.
90
94
  self._datum_reader = datum_reader
@@ -97,11 +101,11 @@ class DataFileReader(object): # pylint: disable=too-many-instance-attributes
97
101
  self._read_header()
98
102
 
99
103
  # ensure codec is valid
100
- avro_codec_raw = self.get_meta('avro.codec')
104
+ avro_codec_raw = self.get_meta("avro.codec")
101
105
  if avro_codec_raw is None:
102
106
  self.codec = "null"
103
107
  else:
104
- self.codec = avro_codec_raw.decode('utf-8')
108
+ self.codec = avro_codec_raw.decode("utf-8")
105
109
  if self.codec not in VALID_CODECS:
106
110
  raise DataFileException(f"Unknown codec: {self.codec}.")
107
111
 
@@ -110,7 +114,7 @@ class DataFileReader(object): # pylint: disable=too-many-instance-attributes
110
114
 
111
115
  # object_position is to support reading from current position in the future read,
112
116
  # no need to downloading from the beginning of avro.
113
- if hasattr(self._reader, 'object_position'):
117
+ if hasattr(self._reader, "object_position"):
114
118
  self.reader.track_object_position()
115
119
 
116
120
  self._cur_object_index = 0
@@ -120,8 +124,7 @@ class DataFileReader(object): # pylint: disable=too-many-instance-attributes
120
124
  if self._header_reader is not None:
121
125
  self._datum_decoder = self._raw_decoder
122
126
 
123
- self.datum_reader.writer_schema = (
124
- schema.parse(self.get_meta(SCHEMA_KEY).decode('utf-8')))
127
+ self.datum_reader.writer_schema = schema.parse(self.get_meta(SCHEMA_KEY).decode("utf-8"))
125
128
 
126
129
  def __enter__(self):
127
130
  return self
@@ -168,7 +171,7 @@ class DataFileReader(object): # pylint: disable=too-many-instance-attributes
168
171
  """Reports the value of a given metadata key.
169
172
 
170
173
  :param str key: Metadata key to report the value of.
171
- :returns: Value associated to the metadata key, as bytes.
174
+ :return: Value associated to the metadata key, as bytes.
172
175
  :rtype: bytes
173
176
  """
174
177
  return self._meta.get(key)
@@ -184,15 +187,15 @@ class DataFileReader(object): # pylint: disable=too-many-instance-attributes
184
187
  header = self.datum_reader.read_data(META_SCHEMA, header_decoder)
185
188
 
186
189
  # check magic number
187
- if header.get('magic') != MAGIC:
190
+ if header.get("magic") != MAGIC:
188
191
  fail_msg = f"Not an Avro data file: {header.get('magic')} doesn't match {MAGIC!r}."
189
192
  raise schema.AvroException(fail_msg)
190
193
 
191
194
  # set metadata
192
- self._meta = header['meta']
195
+ self._meta = header["meta"]
193
196
 
194
197
  # set sync marker
195
- self._sync_marker = header['sync']
198
+ self._sync_marker = header["sync"]
196
199
 
197
200
  def _read_block_header(self):
198
201
  self._block_count = self.raw_decoder.read_long()
@@ -200,7 +203,7 @@ class DataFileReader(object): # pylint: disable=too-many-instance-attributes
200
203
  # Skip a long; we don't need to use the length.
201
204
  self.raw_decoder.skip_long()
202
205
  self._datum_decoder = self._raw_decoder
203
- elif self.codec == 'deflate':
206
+ elif self.codec == "deflate":
204
207
  # Compressed data is stored as (length, data), which
205
208
  # corresponds to how the "bytes" type is encoded.
206
209
  data = self.raw_decoder.read_bytes()
@@ -229,7 +232,7 @@ class DataFileReader(object): # pylint: disable=too-many-instance-attributes
229
232
 
230
233
  # object_position is to support reading from current position in the future read,
231
234
  # no need to downloading from the beginning of avro file with this attr.
232
- if hasattr(self._reader, 'object_position'):
235
+ if hasattr(self._reader, "object_position"):
233
236
  self.reader.track_object_position()
234
237
  self._cur_object_index = 0
235
238
 
@@ -242,7 +245,7 @@ class DataFileReader(object): # pylint: disable=too-many-instance-attributes
242
245
  # object_position is to support reading from current position in the future read,
243
246
  # This will track the index of the next item to be read.
244
247
  # This will also track the offset before the next sync marker.
245
- if hasattr(self._reader, 'object_position'):
248
+ if hasattr(self._reader, "object_position"):
246
249
  if self.block_count == 0:
247
250
  # the next event to be read is at index 0 in the new chunk of blocks,
248
251
  self.reader.track_object_position()
@@ -24,7 +24,7 @@ logger = logging.getLogger(__name__)
24
24
  # Constants
25
25
 
26
26
  # Codecs supported by container files:
27
- VALID_CODECS = frozenset(['null'])
27
+ VALID_CODECS = frozenset(["null"])
28
28
 
29
29
 
30
30
  class AsyncDataFileReader(object): # pylint: disable=too-many-instance-attributes
@@ -39,9 +39,10 @@ class AsyncDataFileReader(object): # pylint: disable=too-many-instance-attribut
39
39
  """
40
40
  self._reader = reader
41
41
  self._raw_decoder = avro_io_async.AsyncBinaryDecoder(reader)
42
- self._header_reader = kwargs.pop('header_reader', None)
43
- self._header_decoder = None if self._header_reader is None else \
44
- avro_io_async.AsyncBinaryDecoder(self._header_reader)
42
+ self._header_reader = kwargs.pop("header_reader", None)
43
+ self._header_decoder = (
44
+ None if self._header_reader is None else avro_io_async.AsyncBinaryDecoder(self._header_reader)
45
+ )
45
46
  self._datum_decoder = None # Maybe reset at every block.
46
47
  self._datum_reader = datum_reader
47
48
  self.codec = "null"
@@ -59,11 +60,11 @@ class AsyncDataFileReader(object): # pylint: disable=too-many-instance-attribut
59
60
  await self._read_header()
60
61
 
61
62
  # ensure codec is valid
62
- avro_codec_raw = self.get_meta('avro.codec')
63
+ avro_codec_raw = self.get_meta("avro.codec")
63
64
  if avro_codec_raw is None:
64
65
  self.codec = "null"
65
66
  else:
66
- self.codec = avro_codec_raw.decode('utf-8')
67
+ self.codec = avro_codec_raw.decode("utf-8")
67
68
  if self.codec not in VALID_CODECS:
68
69
  raise DataFileException(f"Unknown codec: {self.codec}.")
69
70
 
@@ -72,7 +73,7 @@ class AsyncDataFileReader(object): # pylint: disable=too-many-instance-attribut
72
73
 
73
74
  # object_position is to support reading from current position in the future read,
74
75
  # no need to downloading from the beginning of avro.
75
- if hasattr(self._reader, 'object_position'):
76
+ if hasattr(self._reader, "object_position"):
76
77
  self.reader.track_object_position()
77
78
 
78
79
  # header_reader indicates reader only has partial content. The reader doesn't have block header,
@@ -80,8 +81,7 @@ class AsyncDataFileReader(object): # pylint: disable=too-many-instance-attribut
80
81
  # Also ChangeFeed only has codec==null, so use _raw_decoder is good.
81
82
  if self._header_reader is not None:
82
83
  self._datum_decoder = self._raw_decoder
83
- self.datum_reader.writer_schema = (
84
- schema.parse(self.get_meta(SCHEMA_KEY).decode('utf-8')))
84
+ self.datum_reader.writer_schema = schema.parse(self.get_meta(SCHEMA_KEY).decode("utf-8"))
85
85
  return self
86
86
 
87
87
  async def __aenter__(self):
@@ -129,7 +129,7 @@ class AsyncDataFileReader(object): # pylint: disable=too-many-instance-attribut
129
129
  """Reports the value of a given metadata key.
130
130
 
131
131
  :param str key: Metadata key to report the value of.
132
- :returns: Value associated to the metadata key, as bytes.
132
+ :return: Value associated to the metadata key, as bytes.
133
133
  :rtype: bytes
134
134
  """
135
135
  return self._meta.get(key)
@@ -145,15 +145,15 @@ class AsyncDataFileReader(object): # pylint: disable=too-many-instance-attribut
145
145
  header = await self.datum_reader.read_data(META_SCHEMA, header_decoder)
146
146
 
147
147
  # check magic number
148
- if header.get('magic') != MAGIC:
148
+ if header.get("magic") != MAGIC:
149
149
  fail_msg = f"Not an Avro data file: {header.get('magic')} doesn't match {MAGIC!r}."
150
150
  raise schema.AvroException(fail_msg)
151
151
 
152
152
  # set metadata
153
- self._meta = header['meta']
153
+ self._meta = header["meta"]
154
154
 
155
155
  # set sync marker
156
- self._sync_marker = header['sync']
156
+ self._sync_marker = header["sync"]
157
157
 
158
158
  async def _read_block_header(self):
159
159
  self._block_count = await self.raw_decoder.read_long()
@@ -182,7 +182,7 @@ class AsyncDataFileReader(object): # pylint: disable=too-many-instance-attribut
182
182
 
183
183
  # object_position is to support reading from current position in the future read,
184
184
  # no need to downloading from the beginning of avro file with this attr.
185
- if hasattr(self._reader, 'object_position'):
185
+ if hasattr(self._reader, "object_position"):
186
186
  await self.reader.track_object_position()
187
187
  self._cur_object_index = 0
188
188
 
@@ -195,7 +195,7 @@ class AsyncDataFileReader(object): # pylint: disable=too-many-instance-attribut
195
195
  # object_position is to support reading from current position in the future read,
196
196
  # This will track the index of the next item to be read.
197
197
  # This will also track the offset before the next sync marker.
198
- if hasattr(self._reader, 'object_position'):
198
+ if hasattr(self._reader, "object_position"):
199
199
  if self.block_count == 0:
200
200
  # the next event to be read is at index 0 in the new chunk of blocks,
201
201
  await self.reader.track_object_position()