1# coding=utf-8 2# -------------------------------------------------------------------------- 3# Copyright (c) Microsoft Corporation. All rights reserved. 4# Licensed under the MIT License. See License.txt in the project root for 5# license information. 6# 7# Code generated by Microsoft (R) AutoRest Code Generator. 8# Changes may cause incorrect behavior and will be lost if the code is 9# regenerated. 10# -------------------------------------------------------------------------- 11 12from azure.core.exceptions import map_error 13 14from .. import models 15 16 17class BlobOperations(object): 18 """BlobOperations operations. 19 20 You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. 21 22 :param client: Client for service requests. 23 :param config: Configuration of service client. 24 :param serializer: An object model serializer. 25 :param deserializer: An object model deserializer. 26 :ivar x_ms_requires_sync: . Constant value: "true". 27 :ivar x_ms_copy_action: . Constant value: "abort". 28 :ivar restype: . Constant value: "account". 29 """ 30 31 models = models 32 33 def __init__(self, client, config, serializer, deserializer): 34 35 self._client = client 36 self._serialize = serializer 37 self._deserialize = deserializer 38 39 self._config = config 40 self.x_ms_requires_sync = "true" 41 self.x_ms_copy_action = "abort" 42 self.restype = "account" 43 44 def download(self, snapshot=None, timeout=None, range=None, range_get_content_md5=None, range_get_content_crc64=None, request_id=None, lease_access_conditions=None, cpk_info=None, modified_access_conditions=None, cls=None, **kwargs): 45 """The Download operation reads or downloads a blob from the system, 46 including its metadata and properties. You can also call Download to 47 read a snapshot. 48 49 :param snapshot: The snapshot parameter is an opaque DateTime value 50 that, when present, specifies the blob snapshot to retrieve. For more 51 information on working with blob snapshots, see <a 52 href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating 53 a Snapshot of a Blob.</a> 54 :type snapshot: str 55 :param timeout: The timeout parameter is expressed in seconds. For 56 more information, see <a 57 href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting 58 Timeouts for Blob Service Operations.</a> 59 :type timeout: int 60 :param range: Return only the bytes of the blob in the specified 61 range. 62 :type range: str 63 :param range_get_content_md5: When set to true and specified together 64 with the Range, the service returns the MD5 hash for the range, as 65 long as the range is less than or equal to 4 MB in size. 66 :type range_get_content_md5: bool 67 :param range_get_content_crc64: When set to true and specified 68 together with the Range, the service returns the CRC64 hash for the 69 range, as long as the range is less than or equal to 4 MB in size. 70 :type range_get_content_crc64: bool 71 :param request_id: Provides a client-generated, opaque value with a 1 72 KB character limit that is recorded in the analytics logs when storage 73 analytics logging is enabled. 74 :type request_id: str 75 :param lease_access_conditions: Additional parameters for the 76 operation 77 :type lease_access_conditions: 78 ~azure.storage.blob.models.LeaseAccessConditions 79 :param cpk_info: Additional parameters for the operation 80 :type cpk_info: ~azure.storage.blob.models.CpkInfo 81 :param modified_access_conditions: Additional parameters for the 82 operation 83 :type modified_access_conditions: 84 ~azure.storage.blob.models.ModifiedAccessConditions 85 :param callable cls: A custom type or function that will be passed the 86 direct response 87 :return: object or the result of cls(response) 88 :rtype: Generator 89 :raises: 90 :class:`StorageErrorException<azure.storage.blob.models.StorageErrorException>` 91 """ 92 error_map = kwargs.pop('error_map', None) 93 lease_id = None 94 if lease_access_conditions is not None: 95 lease_id = lease_access_conditions.lease_id 96 encryption_key = None 97 if cpk_info is not None: 98 encryption_key = cpk_info.encryption_key 99 encryption_key_sha256 = None 100 if cpk_info is not None: 101 encryption_key_sha256 = cpk_info.encryption_key_sha256 102 encryption_algorithm = None 103 if cpk_info is not None: 104 encryption_algorithm = cpk_info.encryption_algorithm 105 if_modified_since = None 106 if modified_access_conditions is not None: 107 if_modified_since = modified_access_conditions.if_modified_since 108 if_unmodified_since = None 109 if modified_access_conditions is not None: 110 if_unmodified_since = modified_access_conditions.if_unmodified_since 111 if_match = None 112 if modified_access_conditions is not None: 113 if_match = modified_access_conditions.if_match 114 if_none_match = None 115 if modified_access_conditions is not None: 116 if_none_match = modified_access_conditions.if_none_match 117 118 # Construct URL 119 url = self.download.metadata['url'] 120 path_format_arguments = { 121 'url': self._serialize.url("self._config.url", self._config.url, 'str', skip_quote=True) 122 } 123 url = self._client.format_url(url, **path_format_arguments) 124 125 # Construct parameters 126 query_parameters = {} 127 if snapshot is not None: 128 query_parameters['snapshot'] = self._serialize.query("snapshot", snapshot, 'str') 129 if timeout is not None: 130 query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int', minimum=0) 131 132 # Construct headers 133 header_parameters = {} 134 header_parameters['Accept'] = 'application/xml' 135 if range is not None: 136 header_parameters['x-ms-range'] = self._serialize.header("range", range, 'str') 137 if range_get_content_md5 is not None: 138 header_parameters['x-ms-range-get-content-md5'] = self._serialize.header("range_get_content_md5", range_get_content_md5, 'bool') 139 if range_get_content_crc64 is not None: 140 header_parameters['x-ms-range-get-content-crc64'] = self._serialize.header("range_get_content_crc64", range_get_content_crc64, 'bool') 141 header_parameters['x-ms-version'] = self._serialize.header("self._config.version", self._config.version, 'str') 142 if request_id is not None: 143 header_parameters['x-ms-client-request-id'] = self._serialize.header("request_id", request_id, 'str') 144 if lease_id is not None: 145 header_parameters['x-ms-lease-id'] = self._serialize.header("lease_id", lease_id, 'str') 146 if encryption_key is not None: 147 header_parameters['x-ms-encryption-key'] = self._serialize.header("encryption_key", encryption_key, 'str') 148 if encryption_key_sha256 is not None: 149 header_parameters['x-ms-encryption-key-sha256'] = self._serialize.header("encryption_key_sha256", encryption_key_sha256, 'str') 150 if encryption_algorithm is not None: 151 header_parameters['x-ms-encryption-algorithm'] = self._serialize.header("encryption_algorithm", encryption_algorithm, 'EncryptionAlgorithmType') 152 if if_modified_since is not None: 153 header_parameters['If-Modified-Since'] = self._serialize.header("if_modified_since", if_modified_since, 'rfc-1123') 154 if if_unmodified_since is not None: 155 header_parameters['If-Unmodified-Since'] = self._serialize.header("if_unmodified_since", if_unmodified_since, 'rfc-1123') 156 if if_match is not None: 157 header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') 158 if if_none_match is not None: 159 header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str') 160 161 # Construct and send request 162 request = self._client.get(url, query_parameters, header_parameters) 163 pipeline_response = self._client._pipeline.run(request, stream=True, **kwargs) 164 response = pipeline_response.http_response 165 166 if response.status_code not in [200, 206]: 167 map_error(status_code=response.status_code, response=response, error_map=error_map) 168 raise models.StorageErrorException(response, self._deserialize) 169 170 header_dict = {} 171 deserialized = None 172 if response.status_code == 200: 173 deserialized = response.stream_download(self._client._pipeline) 174 header_dict = { 175 'Last-Modified': self._deserialize('rfc-1123', response.headers.get('Last-Modified')), 176 'x-ms-meta': self._deserialize('{str}', response.headers.get('x-ms-meta')), 177 'Content-Length': self._deserialize('long', response.headers.get('Content-Length')), 178 'Content-Type': self._deserialize('str', response.headers.get('Content-Type')), 179 'Content-Range': self._deserialize('str', response.headers.get('Content-Range')), 180 'ETag': self._deserialize('str', response.headers.get('ETag')), 181 'Content-MD5': self._deserialize('bytearray', response.headers.get('Content-MD5')), 182 'Content-Encoding': self._deserialize('str', response.headers.get('Content-Encoding')), 183 'Cache-Control': self._deserialize('str', response.headers.get('Cache-Control')), 184 'Content-Disposition': self._deserialize('str', response.headers.get('Content-Disposition')), 185 'Content-Language': self._deserialize('str', response.headers.get('Content-Language')), 186 'x-ms-blob-sequence-number': self._deserialize('long', response.headers.get('x-ms-blob-sequence-number')), 187 'x-ms-blob-type': self._deserialize(models.BlobType, response.headers.get('x-ms-blob-type')), 188 'x-ms-copy-completion-time': self._deserialize('rfc-1123', response.headers.get('x-ms-copy-completion-time')), 189 'x-ms-copy-status-description': self._deserialize('str', response.headers.get('x-ms-copy-status-description')), 190 'x-ms-copy-id': self._deserialize('str', response.headers.get('x-ms-copy-id')), 191 'x-ms-copy-progress': self._deserialize('str', response.headers.get('x-ms-copy-progress')), 192 'x-ms-copy-source': self._deserialize('str', response.headers.get('x-ms-copy-source')), 193 'x-ms-copy-status': self._deserialize(models.CopyStatusType, response.headers.get('x-ms-copy-status')), 194 'x-ms-lease-duration': self._deserialize(models.LeaseDurationType, response.headers.get('x-ms-lease-duration')), 195 'x-ms-lease-state': self._deserialize(models.LeaseStateType, response.headers.get('x-ms-lease-state')), 196 'x-ms-lease-status': self._deserialize(models.LeaseStatusType, response.headers.get('x-ms-lease-status')), 197 'x-ms-client-request-id': self._deserialize('str', response.headers.get('x-ms-client-request-id')), 198 'x-ms-request-id': self._deserialize('str', response.headers.get('x-ms-request-id')), 199 'x-ms-version': self._deserialize('str', response.headers.get('x-ms-version')), 200 'Accept-Ranges': self._deserialize('str', response.headers.get('Accept-Ranges')), 201 'Date': self._deserialize('rfc-1123', response.headers.get('Date')), 202 'x-ms-blob-committed-block-count': self._deserialize('int', response.headers.get('x-ms-blob-committed-block-count')), 203 'x-ms-server-encrypted': self._deserialize('bool', response.headers.get('x-ms-server-encrypted')), 204 'x-ms-encryption-key-sha256': self._deserialize('str', response.headers.get('x-ms-encryption-key-sha256')), 205 'x-ms-blob-content-md5': self._deserialize('bytearray', response.headers.get('x-ms-blob-content-md5')), 206 'x-ms-content-crc64': self._deserialize('bytearray', response.headers.get('x-ms-content-crc64')), 207 'x-ms-error-code': self._deserialize('str', response.headers.get('x-ms-error-code')), 208 } 209 if response.status_code == 206: 210 deserialized = response.stream_download(self._client._pipeline) 211 header_dict = { 212 'Last-Modified': self._deserialize('rfc-1123', response.headers.get('Last-Modified')), 213 'x-ms-meta': self._deserialize('{str}', response.headers.get('x-ms-meta')), 214 'Content-Length': self._deserialize('long', response.headers.get('Content-Length')), 215 'Content-Type': self._deserialize('str', response.headers.get('Content-Type')), 216 'Content-Range': self._deserialize('str', response.headers.get('Content-Range')), 217 'ETag': self._deserialize('str', response.headers.get('ETag')), 218 'Content-MD5': self._deserialize('bytearray', response.headers.get('Content-MD5')), 219 'Content-Encoding': self._deserialize('str', response.headers.get('Content-Encoding')), 220 'Cache-Control': self._deserialize('str', response.headers.get('Cache-Control')), 221 'Content-Disposition': self._deserialize('str', response.headers.get('Content-Disposition')), 222 'Content-Language': self._deserialize('str', response.headers.get('Content-Language')), 223 'x-ms-blob-sequence-number': self._deserialize('long', response.headers.get('x-ms-blob-sequence-number')), 224 'x-ms-blob-type': self._deserialize(models.BlobType, response.headers.get('x-ms-blob-type')), 225 'x-ms-copy-completion-time': self._deserialize('rfc-1123', response.headers.get('x-ms-copy-completion-time')), 226 'x-ms-copy-status-description': self._deserialize('str', response.headers.get('x-ms-copy-status-description')), 227 'x-ms-copy-id': self._deserialize('str', response.headers.get('x-ms-copy-id')), 228 'x-ms-copy-progress': self._deserialize('str', response.headers.get('x-ms-copy-progress')), 229 'x-ms-copy-source': self._deserialize('str', response.headers.get('x-ms-copy-source')), 230 'x-ms-copy-status': self._deserialize(models.CopyStatusType, response.headers.get('x-ms-copy-status')), 231 'x-ms-lease-duration': self._deserialize(models.LeaseDurationType, response.headers.get('x-ms-lease-duration')), 232 'x-ms-lease-state': self._deserialize(models.LeaseStateType, response.headers.get('x-ms-lease-state')), 233 'x-ms-lease-status': self._deserialize(models.LeaseStatusType, response.headers.get('x-ms-lease-status')), 234 'x-ms-client-request-id': self._deserialize('str', response.headers.get('x-ms-client-request-id')), 235 'x-ms-request-id': self._deserialize('str', response.headers.get('x-ms-request-id')), 236 'x-ms-version': self._deserialize('str', response.headers.get('x-ms-version')), 237 'Accept-Ranges': self._deserialize('str', response.headers.get('Accept-Ranges')), 238 'Date': self._deserialize('rfc-1123', response.headers.get('Date')), 239 'x-ms-blob-committed-block-count': self._deserialize('int', response.headers.get('x-ms-blob-committed-block-count')), 240 'x-ms-server-encrypted': self._deserialize('bool', response.headers.get('x-ms-server-encrypted')), 241 'x-ms-encryption-key-sha256': self._deserialize('str', response.headers.get('x-ms-encryption-key-sha256')), 242 'x-ms-blob-content-md5': self._deserialize('bytearray', response.headers.get('x-ms-blob-content-md5')), 243 'x-ms-content-crc64': self._deserialize('bytearray', response.headers.get('x-ms-content-crc64')), 244 'x-ms-error-code': self._deserialize('str', response.headers.get('x-ms-error-code')), 245 } 246 247 if cls: 248 return cls(response, deserialized, header_dict) 249 250 return deserialized 251 download.metadata = {'url': '/{containerName}/{blob}'} 252 253 def get_properties(self, snapshot=None, timeout=None, request_id=None, lease_access_conditions=None, cpk_info=None, modified_access_conditions=None, cls=None, **kwargs): 254 """The Get Properties operation returns all user-defined metadata, 255 standard HTTP properties, and system properties for the blob. It does 256 not return the content of the blob. 257 258 :param snapshot: The snapshot parameter is an opaque DateTime value 259 that, when present, specifies the blob snapshot to retrieve. For more 260 information on working with blob snapshots, see <a 261 href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating 262 a Snapshot of a Blob.</a> 263 :type snapshot: str 264 :param timeout: The timeout parameter is expressed in seconds. For 265 more information, see <a 266 href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting 267 Timeouts for Blob Service Operations.</a> 268 :type timeout: int 269 :param request_id: Provides a client-generated, opaque value with a 1 270 KB character limit that is recorded in the analytics logs when storage 271 analytics logging is enabled. 272 :type request_id: str 273 :param lease_access_conditions: Additional parameters for the 274 operation 275 :type lease_access_conditions: 276 ~azure.storage.blob.models.LeaseAccessConditions 277 :param cpk_info: Additional parameters for the operation 278 :type cpk_info: ~azure.storage.blob.models.CpkInfo 279 :param modified_access_conditions: Additional parameters for the 280 operation 281 :type modified_access_conditions: 282 ~azure.storage.blob.models.ModifiedAccessConditions 283 :param callable cls: A custom type or function that will be passed the 284 direct response 285 :return: None or the result of cls(response) 286 :rtype: None 287 :raises: 288 :class:`StorageErrorException<azure.storage.blob.models.StorageErrorException>` 289 """ 290 error_map = kwargs.pop('error_map', None) 291 lease_id = None 292 if lease_access_conditions is not None: 293 lease_id = lease_access_conditions.lease_id 294 encryption_key = None 295 if cpk_info is not None: 296 encryption_key = cpk_info.encryption_key 297 encryption_key_sha256 = None 298 if cpk_info is not None: 299 encryption_key_sha256 = cpk_info.encryption_key_sha256 300 encryption_algorithm = None 301 if cpk_info is not None: 302 encryption_algorithm = cpk_info.encryption_algorithm 303 if_modified_since = None 304 if modified_access_conditions is not None: 305 if_modified_since = modified_access_conditions.if_modified_since 306 if_unmodified_since = None 307 if modified_access_conditions is not None: 308 if_unmodified_since = modified_access_conditions.if_unmodified_since 309 if_match = None 310 if modified_access_conditions is not None: 311 if_match = modified_access_conditions.if_match 312 if_none_match = None 313 if modified_access_conditions is not None: 314 if_none_match = modified_access_conditions.if_none_match 315 316 # Construct URL 317 url = self.get_properties.metadata['url'] 318 path_format_arguments = { 319 'url': self._serialize.url("self._config.url", self._config.url, 'str', skip_quote=True) 320 } 321 url = self._client.format_url(url, **path_format_arguments) 322 323 # Construct parameters 324 query_parameters = {} 325 if snapshot is not None: 326 query_parameters['snapshot'] = self._serialize.query("snapshot", snapshot, 'str') 327 if timeout is not None: 328 query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int', minimum=0) 329 330 # Construct headers 331 header_parameters = {} 332 header_parameters['x-ms-version'] = self._serialize.header("self._config.version", self._config.version, 'str') 333 if request_id is not None: 334 header_parameters['x-ms-client-request-id'] = self._serialize.header("request_id", request_id, 'str') 335 if lease_id is not None: 336 header_parameters['x-ms-lease-id'] = self._serialize.header("lease_id", lease_id, 'str') 337 if encryption_key is not None: 338 header_parameters['x-ms-encryption-key'] = self._serialize.header("encryption_key", encryption_key, 'str') 339 if encryption_key_sha256 is not None: 340 header_parameters['x-ms-encryption-key-sha256'] = self._serialize.header("encryption_key_sha256", encryption_key_sha256, 'str') 341 if encryption_algorithm is not None: 342 header_parameters['x-ms-encryption-algorithm'] = self._serialize.header("encryption_algorithm", encryption_algorithm, 'EncryptionAlgorithmType') 343 if if_modified_since is not None: 344 header_parameters['If-Modified-Since'] = self._serialize.header("if_modified_since", if_modified_since, 'rfc-1123') 345 if if_unmodified_since is not None: 346 header_parameters['If-Unmodified-Since'] = self._serialize.header("if_unmodified_since", if_unmodified_since, 'rfc-1123') 347 if if_match is not None: 348 header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') 349 if if_none_match is not None: 350 header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str') 351 352 # Construct and send request 353 request = self._client.head(url, query_parameters, header_parameters) 354 pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) 355 response = pipeline_response.http_response 356 357 if response.status_code not in [200]: 358 map_error(status_code=response.status_code, response=response, error_map=error_map) 359 raise models.StorageErrorException(response, self._deserialize) 360 361 if cls: 362 response_headers = { 363 'Last-Modified': self._deserialize('rfc-1123', response.headers.get('Last-Modified')), 364 'x-ms-creation-time': self._deserialize('rfc-1123', response.headers.get('x-ms-creation-time')), 365 'x-ms-meta': self._deserialize('{str}', response.headers.get('x-ms-meta')), 366 'x-ms-blob-type': self._deserialize(models.BlobType, response.headers.get('x-ms-blob-type')), 367 'x-ms-copy-completion-time': self._deserialize('rfc-1123', response.headers.get('x-ms-copy-completion-time')), 368 'x-ms-copy-status-description': self._deserialize('str', response.headers.get('x-ms-copy-status-description')), 369 'x-ms-copy-id': self._deserialize('str', response.headers.get('x-ms-copy-id')), 370 'x-ms-copy-progress': self._deserialize('str', response.headers.get('x-ms-copy-progress')), 371 'x-ms-copy-source': self._deserialize('str', response.headers.get('x-ms-copy-source')), 372 'x-ms-copy-status': self._deserialize(models.CopyStatusType, response.headers.get('x-ms-copy-status')), 373 'x-ms-incremental-copy': self._deserialize('bool', response.headers.get('x-ms-incremental-copy')), 374 'x-ms-copy-destination-snapshot': self._deserialize('str', response.headers.get('x-ms-copy-destination-snapshot')), 375 'x-ms-lease-duration': self._deserialize(models.LeaseDurationType, response.headers.get('x-ms-lease-duration')), 376 'x-ms-lease-state': self._deserialize(models.LeaseStateType, response.headers.get('x-ms-lease-state')), 377 'x-ms-lease-status': self._deserialize(models.LeaseStatusType, response.headers.get('x-ms-lease-status')), 378 'Content-Length': self._deserialize('long', response.headers.get('Content-Length')), 379 'Content-Type': self._deserialize('str', response.headers.get('Content-Type')), 380 'ETag': self._deserialize('str', response.headers.get('ETag')), 381 'Content-MD5': self._deserialize('bytearray', response.headers.get('Content-MD5')), 382 'Content-Encoding': self._deserialize('str', response.headers.get('Content-Encoding')), 383 'Content-Disposition': self._deserialize('str', response.headers.get('Content-Disposition')), 384 'Content-Language': self._deserialize('str', response.headers.get('Content-Language')), 385 'Cache-Control': self._deserialize('str', response.headers.get('Cache-Control')), 386 'x-ms-blob-sequence-number': self._deserialize('long', response.headers.get('x-ms-blob-sequence-number')), 387 'x-ms-client-request-id': self._deserialize('str', response.headers.get('x-ms-client-request-id')), 388 'x-ms-request-id': self._deserialize('str', response.headers.get('x-ms-request-id')), 389 'x-ms-version': self._deserialize('str', response.headers.get('x-ms-version')), 390 'Date': self._deserialize('rfc-1123', response.headers.get('Date')), 391 'Accept-Ranges': self._deserialize('str', response.headers.get('Accept-Ranges')), 392 'x-ms-blob-committed-block-count': self._deserialize('int', response.headers.get('x-ms-blob-committed-block-count')), 393 'x-ms-server-encrypted': self._deserialize('bool', response.headers.get('x-ms-server-encrypted')), 394 'x-ms-encryption-key-sha256': self._deserialize('str', response.headers.get('x-ms-encryption-key-sha256')), 395 'x-ms-access-tier': self._deserialize('str', response.headers.get('x-ms-access-tier')), 396 'x-ms-access-tier-inferred': self._deserialize('bool', response.headers.get('x-ms-access-tier-inferred')), 397 'x-ms-archive-status': self._deserialize('str', response.headers.get('x-ms-archive-status')), 398 'x-ms-access-tier-change-time': self._deserialize('rfc-1123', response.headers.get('x-ms-access-tier-change-time')), 399 'x-ms-error-code': self._deserialize('str', response.headers.get('x-ms-error-code')), 400 } 401 return cls(response, None, response_headers) 402 get_properties.metadata = {'url': '/{containerName}/{blob}'} 403 404 def delete(self, snapshot=None, timeout=None, delete_snapshots=None, request_id=None, lease_access_conditions=None, modified_access_conditions=None, cls=None, **kwargs): 405 """If the storage account's soft delete feature is disabled then, when a 406 blob is deleted, it is permanently removed from the storage account. If 407 the storage account's soft delete feature is enabled, then, when a blob 408 is deleted, it is marked for deletion and becomes inaccessible 409 immediately. However, the blob service retains the blob or snapshot for 410 the number of days specified by the DeleteRetentionPolicy section of 411 [Storage service properties] (Set-Blob-Service-Properties.md). After 412 the specified number of days has passed, the blob's data is permanently 413 removed from the storage account. Note that you continue to be charged 414 for the soft-deleted blob's storage until it is permanently removed. 415 Use the List Blobs API and specify the "include=deleted" query 416 parameter to discover which blobs and snapshots have been soft deleted. 417 You can then use the Undelete Blob API to restore a soft-deleted blob. 418 All other operations on a soft-deleted blob or snapshot causes the 419 service to return an HTTP status code of 404 (ResourceNotFound). 420 421 :param snapshot: The snapshot parameter is an opaque DateTime value 422 that, when present, specifies the blob snapshot to retrieve. For more 423 information on working with blob snapshots, see <a 424 href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/creating-a-snapshot-of-a-blob">Creating 425 a Snapshot of a Blob.</a> 426 :type snapshot: str 427 :param timeout: The timeout parameter is expressed in seconds. For 428 more information, see <a 429 href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting 430 Timeouts for Blob Service Operations.</a> 431 :type timeout: int 432 :param delete_snapshots: Required if the blob has associated 433 snapshots. Specify one of the following two options: include: Delete 434 the base blob and all of its snapshots. only: Delete only the blob's 435 snapshots and not the blob itself. Possible values include: 'include', 436 'only' 437 :type delete_snapshots: str or 438 ~azure.storage.blob.models.DeleteSnapshotsOptionType 439 :param request_id: Provides a client-generated, opaque value with a 1 440 KB character limit that is recorded in the analytics logs when storage 441 analytics logging is enabled. 442 :type request_id: str 443 :param lease_access_conditions: Additional parameters for the 444 operation 445 :type lease_access_conditions: 446 ~azure.storage.blob.models.LeaseAccessConditions 447 :param modified_access_conditions: Additional parameters for the 448 operation 449 :type modified_access_conditions: 450 ~azure.storage.blob.models.ModifiedAccessConditions 451 :param callable cls: A custom type or function that will be passed the 452 direct response 453 :return: None or the result of cls(response) 454 :rtype: None 455 :raises: 456 :class:`StorageErrorException<azure.storage.blob.models.StorageErrorException>` 457 """ 458 error_map = kwargs.pop('error_map', None) 459 lease_id = None 460 if lease_access_conditions is not None: 461 lease_id = lease_access_conditions.lease_id 462 if_modified_since = None 463 if modified_access_conditions is not None: 464 if_modified_since = modified_access_conditions.if_modified_since 465 if_unmodified_since = None 466 if modified_access_conditions is not None: 467 if_unmodified_since = modified_access_conditions.if_unmodified_since 468 if_match = None 469 if modified_access_conditions is not None: 470 if_match = modified_access_conditions.if_match 471 if_none_match = None 472 if modified_access_conditions is not None: 473 if_none_match = modified_access_conditions.if_none_match 474 475 # Construct URL 476 url = self.delete.metadata['url'] 477 path_format_arguments = { 478 'url': self._serialize.url("self._config.url", self._config.url, 'str', skip_quote=True) 479 } 480 url = self._client.format_url(url, **path_format_arguments) 481 482 # Construct parameters 483 query_parameters = {} 484 if snapshot is not None: 485 query_parameters['snapshot'] = self._serialize.query("snapshot", snapshot, 'str') 486 if timeout is not None: 487 query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int', minimum=0) 488 489 # Construct headers 490 header_parameters = {} 491 if delete_snapshots is not None: 492 header_parameters['x-ms-delete-snapshots'] = self._serialize.header("delete_snapshots", delete_snapshots, 'DeleteSnapshotsOptionType') 493 header_parameters['x-ms-version'] = self._serialize.header("self._config.version", self._config.version, 'str') 494 if request_id is not None: 495 header_parameters['x-ms-client-request-id'] = self._serialize.header("request_id", request_id, 'str') 496 if lease_id is not None: 497 header_parameters['x-ms-lease-id'] = self._serialize.header("lease_id", lease_id, 'str') 498 if if_modified_since is not None: 499 header_parameters['If-Modified-Since'] = self._serialize.header("if_modified_since", if_modified_since, 'rfc-1123') 500 if if_unmodified_since is not None: 501 header_parameters['If-Unmodified-Since'] = self._serialize.header("if_unmodified_since", if_unmodified_since, 'rfc-1123') 502 if if_match is not None: 503 header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') 504 if if_none_match is not None: 505 header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str') 506 507 # Construct and send request 508 request = self._client.delete(url, query_parameters, header_parameters) 509 pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) 510 response = pipeline_response.http_response 511 512 if response.status_code not in [202]: 513 map_error(status_code=response.status_code, response=response, error_map=error_map) 514 raise models.StorageErrorException(response, self._deserialize) 515 516 if cls: 517 response_headers = { 518 'x-ms-client-request-id': self._deserialize('str', response.headers.get('x-ms-client-request-id')), 519 'x-ms-request-id': self._deserialize('str', response.headers.get('x-ms-request-id')), 520 'x-ms-version': self._deserialize('str', response.headers.get('x-ms-version')), 521 'Date': self._deserialize('rfc-1123', response.headers.get('Date')), 522 'x-ms-error-code': self._deserialize('str', response.headers.get('x-ms-error-code')), 523 } 524 return cls(response, None, response_headers) 525 delete.metadata = {'url': '/{containerName}/{blob}'} 526 527 def set_access_control(self, timeout=None, owner=None, group=None, posix_permissions=None, posix_acl=None, request_id=None, lease_access_conditions=None, modified_access_conditions=None, cls=None, **kwargs): 528 """Set the owner, group, permissions, or access control list for a blob. 529 530 :param timeout: The timeout parameter is expressed in seconds. For 531 more information, see <a 532 href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting 533 Timeouts for Blob Service Operations.</a> 534 :type timeout: int 535 :param owner: Optional. The owner of the blob or directory. 536 :type owner: str 537 :param group: Optional. The owning group of the blob or directory. 538 :type group: str 539 :param posix_permissions: Optional and only valid if Hierarchical 540 Namespace is enabled for the account. Sets POSIX access permissions 541 for the file owner, the file owning group, and others. Each class may 542 be granted read, write, or execute permission. The sticky bit is also 543 supported. Both symbolic (rwxrw-rw-) and 4-digit octal notation (e.g. 544 0766) are supported. 545 :type posix_permissions: str 546 :param posix_acl: Sets POSIX access control rights on files and 547 directories. The value is a comma-separated list of access control 548 entries. Each access control entry (ACE) consists of a scope, a type, 549 a user or group identifier, and permissions in the format 550 "[scope:][type]:[id]:[permissions]". 551 :type posix_acl: str 552 :param request_id: Provides a client-generated, opaque value with a 1 553 KB character limit that is recorded in the analytics logs when storage 554 analytics logging is enabled. 555 :type request_id: str 556 :param lease_access_conditions: Additional parameters for the 557 operation 558 :type lease_access_conditions: 559 ~azure.storage.blob.models.LeaseAccessConditions 560 :param modified_access_conditions: Additional parameters for the 561 operation 562 :type modified_access_conditions: 563 ~azure.storage.blob.models.ModifiedAccessConditions 564 :param callable cls: A custom type or function that will be passed the 565 direct response 566 :return: None or the result of cls(response) 567 :rtype: None 568 :raises: 569 :class:`DataLakeStorageErrorException<azure.storage.blob.models.DataLakeStorageErrorException>` 570 """ 571 error_map = kwargs.pop('error_map', None) 572 lease_id = None 573 if lease_access_conditions is not None: 574 lease_id = lease_access_conditions.lease_id 575 if_match = None 576 if modified_access_conditions is not None: 577 if_match = modified_access_conditions.if_match 578 if_none_match = None 579 if modified_access_conditions is not None: 580 if_none_match = modified_access_conditions.if_none_match 581 if_modified_since = None 582 if modified_access_conditions is not None: 583 if_modified_since = modified_access_conditions.if_modified_since 584 if_unmodified_since = None 585 if modified_access_conditions is not None: 586 if_unmodified_since = modified_access_conditions.if_unmodified_since 587 588 action = "setAccessControl" 589 590 # Construct URL 591 url = self.set_access_control.metadata['url'] 592 path_format_arguments = { 593 'url': self._serialize.url("self._config.url", self._config.url, 'str', skip_quote=True) 594 } 595 url = self._client.format_url(url, **path_format_arguments) 596 597 # Construct parameters 598 query_parameters = {} 599 if timeout is not None: 600 query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int', minimum=0) 601 query_parameters['action'] = self._serialize.query("action", action, 'str') 602 603 # Construct headers 604 header_parameters = {} 605 if owner is not None: 606 header_parameters['x-ms-owner'] = self._serialize.header("owner", owner, 'str') 607 if group is not None: 608 header_parameters['x-ms-group'] = self._serialize.header("group", group, 'str') 609 if posix_permissions is not None: 610 header_parameters['x-ms-permissions'] = self._serialize.header("posix_permissions", posix_permissions, 'str') 611 if posix_acl is not None: 612 header_parameters['x-ms-acl'] = self._serialize.header("posix_acl", posix_acl, 'str') 613 if request_id is not None: 614 header_parameters['x-ms-client-request-id'] = self._serialize.header("request_id", request_id, 'str') 615 header_parameters['x-ms-version'] = self._serialize.header("self._config.version", self._config.version, 'str') 616 if lease_id is not None: 617 header_parameters['x-ms-lease-id'] = self._serialize.header("lease_id", lease_id, 'str') 618 if if_match is not None: 619 header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') 620 if if_none_match is not None: 621 header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str') 622 if if_modified_since is not None: 623 header_parameters['If-Modified-Since'] = self._serialize.header("if_modified_since", if_modified_since, 'rfc-1123') 624 if if_unmodified_since is not None: 625 header_parameters['If-Unmodified-Since'] = self._serialize.header("if_unmodified_since", if_unmodified_since, 'rfc-1123') 626 627 # Construct and send request 628 request = self._client.patch(url, query_parameters, header_parameters) 629 pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) 630 response = pipeline_response.http_response 631 632 if response.status_code not in [200]: 633 map_error(status_code=response.status_code, response=response, error_map=error_map) 634 raise models.DataLakeStorageErrorException(response, self._deserialize) 635 636 if cls: 637 response_headers = { 638 'Date': self._deserialize('rfc-1123', response.headers.get('Date')), 639 'ETag': self._deserialize('str', response.headers.get('ETag')), 640 'Last-Modified': self._deserialize('rfc-1123', response.headers.get('Last-Modified')), 641 'x-ms-request-id': self._deserialize('str', response.headers.get('x-ms-request-id')), 642 'x-ms-version': self._deserialize('str', response.headers.get('x-ms-version')), 643 'x-ms-client-request-id': self._deserialize('str', response.headers.get('x-ms-client-request-id')), 644 } 645 return cls(response, None, response_headers) 646 set_access_control.metadata = {'url': '/{filesystem}/{path}'} 647 648 def get_access_control(self, timeout=None, upn=None, request_id=None, lease_access_conditions=None, modified_access_conditions=None, cls=None, **kwargs): 649 """Get the owner, group, permissions, or access control list for a blob. 650 651 :param timeout: The timeout parameter is expressed in seconds. For 652 more information, see <a 653 href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting 654 Timeouts for Blob Service Operations.</a> 655 :type timeout: int 656 :param upn: Optional. Valid only when Hierarchical Namespace is 657 enabled for the account. If "true", the identity values returned in 658 the x-ms-owner, x-ms-group, and x-ms-acl response headers will be 659 transformed from Azure Active Directory Object IDs to User Principal 660 Names. If "false", the values will be returned as Azure Active 661 Directory Object IDs. The default value is false. 662 :type upn: bool 663 :param request_id: Provides a client-generated, opaque value with a 1 664 KB character limit that is recorded in the analytics logs when storage 665 analytics logging is enabled. 666 :type request_id: str 667 :param lease_access_conditions: Additional parameters for the 668 operation 669 :type lease_access_conditions: 670 ~azure.storage.blob.models.LeaseAccessConditions 671 :param modified_access_conditions: Additional parameters for the 672 operation 673 :type modified_access_conditions: 674 ~azure.storage.blob.models.ModifiedAccessConditions 675 :param callable cls: A custom type or function that will be passed the 676 direct response 677 :return: None or the result of cls(response) 678 :rtype: None 679 :raises: 680 :class:`DataLakeStorageErrorException<azure.storage.blob.models.DataLakeStorageErrorException>` 681 """ 682 error_map = kwargs.pop('error_map', None) 683 lease_id = None 684 if lease_access_conditions is not None: 685 lease_id = lease_access_conditions.lease_id 686 if_match = None 687 if modified_access_conditions is not None: 688 if_match = modified_access_conditions.if_match 689 if_none_match = None 690 if modified_access_conditions is not None: 691 if_none_match = modified_access_conditions.if_none_match 692 if_modified_since = None 693 if modified_access_conditions is not None: 694 if_modified_since = modified_access_conditions.if_modified_since 695 if_unmodified_since = None 696 if modified_access_conditions is not None: 697 if_unmodified_since = modified_access_conditions.if_unmodified_since 698 699 action = "getAccessControl" 700 701 # Construct URL 702 url = self.get_access_control.metadata['url'] 703 path_format_arguments = { 704 'url': self._serialize.url("self._config.url", self._config.url, 'str', skip_quote=True) 705 } 706 url = self._client.format_url(url, **path_format_arguments) 707 708 # Construct parameters 709 query_parameters = {} 710 if timeout is not None: 711 query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int', minimum=0) 712 if upn is not None: 713 query_parameters['upn'] = self._serialize.query("upn", upn, 'bool') 714 query_parameters['action'] = self._serialize.query("action", action, 'str') 715 716 # Construct headers 717 header_parameters = {} 718 if request_id is not None: 719 header_parameters['x-ms-client-request-id'] = self._serialize.header("request_id", request_id, 'str') 720 header_parameters['x-ms-version'] = self._serialize.header("self._config.version", self._config.version, 'str') 721 if lease_id is not None: 722 header_parameters['x-ms-lease-id'] = self._serialize.header("lease_id", lease_id, 'str') 723 if if_match is not None: 724 header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') 725 if if_none_match is not None: 726 header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str') 727 if if_modified_since is not None: 728 header_parameters['If-Modified-Since'] = self._serialize.header("if_modified_since", if_modified_since, 'rfc-1123') 729 if if_unmodified_since is not None: 730 header_parameters['If-Unmodified-Since'] = self._serialize.header("if_unmodified_since", if_unmodified_since, 'rfc-1123') 731 732 # Construct and send request 733 request = self._client.head(url, query_parameters, header_parameters) 734 pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) 735 response = pipeline_response.http_response 736 737 if response.status_code not in [200]: 738 map_error(status_code=response.status_code, response=response, error_map=error_map) 739 raise models.DataLakeStorageErrorException(response, self._deserialize) 740 741 if cls: 742 response_headers = { 743 'Date': self._deserialize('rfc-1123', response.headers.get('Date')), 744 'ETag': self._deserialize('str', response.headers.get('ETag')), 745 'Last-Modified': self._deserialize('rfc-1123', response.headers.get('Last-Modified')), 746 'x-ms-owner': self._deserialize('str', response.headers.get('x-ms-owner')), 747 'x-ms-group': self._deserialize('str', response.headers.get('x-ms-group')), 748 'x-ms-permissions': self._deserialize('str', response.headers.get('x-ms-permissions')), 749 'x-ms-acl': self._deserialize('str', response.headers.get('x-ms-acl')), 750 'x-ms-request-id': self._deserialize('str', response.headers.get('x-ms-request-id')), 751 'x-ms-version': self._deserialize('str', response.headers.get('x-ms-version')), 752 'x-ms-client-request-id': self._deserialize('str', response.headers.get('x-ms-client-request-id')), 753 } 754 return cls(response, None, response_headers) 755 get_access_control.metadata = {'url': '/{filesystem}/{path}'} 756 757 def rename(self, rename_source, timeout=None, path_rename_mode=None, directory_properties=None, posix_permissions=None, posix_umask=None, source_lease_id=None, request_id=None, directory_http_headers=None, lease_access_conditions=None, modified_access_conditions=None, source_modified_access_conditions=None, cls=None, **kwargs): 758 """Rename a blob/file. By default, the destination is overwritten and if 759 the destination already exists and has a lease the lease is broken. 760 This operation supports conditional HTTP requests. For more 761 information, see [Specifying Conditional Headers for Blob Service 762 Operations](https://docs.microsoft.com/en-us/rest/api/storageservices/specifying-conditional-headers-for-blob-service-operations). 763 To fail if the destination already exists, use a conditional request 764 with If-None-Match: "*". 765 766 :param rename_source: The file or directory to be renamed. The value 767 must have the following format: "/{filesysystem}/{path}". If 768 "x-ms-properties" is specified, the properties will overwrite the 769 existing properties; otherwise, the existing properties will be 770 preserved. 771 :type rename_source: str 772 :param timeout: The timeout parameter is expressed in seconds. For 773 more information, see <a 774 href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting 775 Timeouts for Blob Service Operations.</a> 776 :type timeout: int 777 :param path_rename_mode: Determines the behavior of the rename 778 operation. Possible values include: 'legacy', 'posix' 779 :type path_rename_mode: str or 780 ~azure.storage.blob.models.PathRenameMode 781 :param directory_properties: Optional. User-defined properties to be 782 stored with the file or directory, in the format of a comma-separated 783 list of name and value pairs "n1=v1, n2=v2, ...", where each value is 784 base64 encoded. 785 :type directory_properties: str 786 :param posix_permissions: Optional and only valid if Hierarchical 787 Namespace is enabled for the account. Sets POSIX access permissions 788 for the file owner, the file owning group, and others. Each class may 789 be granted read, write, or execute permission. The sticky bit is also 790 supported. Both symbolic (rwxrw-rw-) and 4-digit octal notation (e.g. 791 0766) are supported. 792 :type posix_permissions: str 793 :param posix_umask: Only valid if Hierarchical Namespace is enabled 794 for the account. This umask restricts permission settings for file and 795 directory, and will only be applied when default Acl does not exist in 796 parent directory. If the umask bit has set, it means that the 797 corresponding permission will be disabled. Otherwise the corresponding 798 permission will be determined by the permission. A 4-digit octal 799 notation (e.g. 0022) is supported here. If no umask was specified, a 800 default umask - 0027 will be used. 801 :type posix_umask: str 802 :param source_lease_id: A lease ID for the source path. If specified, 803 the source path must have an active lease and the leaase ID must 804 match. 805 :type source_lease_id: str 806 :param request_id: Provides a client-generated, opaque value with a 1 807 KB character limit that is recorded in the analytics logs when storage 808 analytics logging is enabled. 809 :type request_id: str 810 :param directory_http_headers: Additional parameters for the operation 811 :type directory_http_headers: 812 ~azure.storage.blob.models.DirectoryHttpHeaders 813 :param lease_access_conditions: Additional parameters for the 814 operation 815 :type lease_access_conditions: 816 ~azure.storage.blob.models.LeaseAccessConditions 817 :param modified_access_conditions: Additional parameters for the 818 operation 819 :type modified_access_conditions: 820 ~azure.storage.blob.models.ModifiedAccessConditions 821 :param source_modified_access_conditions: Additional parameters for 822 the operation 823 :type source_modified_access_conditions: 824 ~azure.storage.blob.models.SourceModifiedAccessConditions 825 :param callable cls: A custom type or function that will be passed the 826 direct response 827 :return: None or the result of cls(response) 828 :rtype: None 829 :raises: 830 :class:`DataLakeStorageErrorException<azure.storage.blob.models.DataLakeStorageErrorException>` 831 """ 832 error_map = kwargs.pop('error_map', None) 833 cache_control = None 834 if directory_http_headers is not None: 835 cache_control = directory_http_headers.cache_control 836 content_type = None 837 if directory_http_headers is not None: 838 content_type = directory_http_headers.content_type 839 content_encoding = None 840 if directory_http_headers is not None: 841 content_encoding = directory_http_headers.content_encoding 842 content_language = None 843 if directory_http_headers is not None: 844 content_language = directory_http_headers.content_language 845 content_disposition = None 846 if directory_http_headers is not None: 847 content_disposition = directory_http_headers.content_disposition 848 lease_id = None 849 if lease_access_conditions is not None: 850 lease_id = lease_access_conditions.lease_id 851 if_modified_since = None 852 if modified_access_conditions is not None: 853 if_modified_since = modified_access_conditions.if_modified_since 854 if_unmodified_since = None 855 if modified_access_conditions is not None: 856 if_unmodified_since = modified_access_conditions.if_unmodified_since 857 if_match = None 858 if modified_access_conditions is not None: 859 if_match = modified_access_conditions.if_match 860 if_none_match = None 861 if modified_access_conditions is not None: 862 if_none_match = modified_access_conditions.if_none_match 863 source_if_modified_since = None 864 if source_modified_access_conditions is not None: 865 source_if_modified_since = source_modified_access_conditions.source_if_modified_since 866 source_if_unmodified_since = None 867 if source_modified_access_conditions is not None: 868 source_if_unmodified_since = source_modified_access_conditions.source_if_unmodified_since 869 source_if_match = None 870 if source_modified_access_conditions is not None: 871 source_if_match = source_modified_access_conditions.source_if_match 872 source_if_none_match = None 873 if source_modified_access_conditions is not None: 874 source_if_none_match = source_modified_access_conditions.source_if_none_match 875 876 # Construct URL 877 url = self.rename.metadata['url'] 878 path_format_arguments = { 879 'url': self._serialize.url("self._config.url", self._config.url, 'str', skip_quote=True) 880 } 881 url = self._client.format_url(url, **path_format_arguments) 882 883 # Construct parameters 884 query_parameters = {} 885 if timeout is not None: 886 query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int', minimum=0) 887 if path_rename_mode is not None: 888 query_parameters['mode'] = self._serialize.query("path_rename_mode", path_rename_mode, 'PathRenameMode') 889 890 # Construct headers 891 header_parameters = {} 892 header_parameters['x-ms-rename-source'] = self._serialize.header("rename_source", rename_source, 'str') 893 if directory_properties is not None: 894 header_parameters['x-ms-properties'] = self._serialize.header("directory_properties", directory_properties, 'str') 895 if posix_permissions is not None: 896 header_parameters['x-ms-permissions'] = self._serialize.header("posix_permissions", posix_permissions, 'str') 897 if posix_umask is not None: 898 header_parameters['x-ms-umask'] = self._serialize.header("posix_umask", posix_umask, 'str') 899 if source_lease_id is not None: 900 header_parameters['x-ms-source-lease-id'] = self._serialize.header("source_lease_id", source_lease_id, 'str') 901 header_parameters['x-ms-version'] = self._serialize.header("self._config.version", self._config.version, 'str') 902 if request_id is not None: 903 header_parameters['x-ms-client-request-id'] = self._serialize.header("request_id", request_id, 'str') 904 if cache_control is not None: 905 header_parameters['x-ms-cache-control'] = self._serialize.header("cache_control", cache_control, 'str') 906 if content_type is not None: 907 header_parameters['x-ms-content-type'] = self._serialize.header("content_type", content_type, 'str') 908 if content_encoding is not None: 909 header_parameters['x-ms-content-encoding'] = self._serialize.header("content_encoding", content_encoding, 'str') 910 if content_language is not None: 911 header_parameters['x-ms-content-language'] = self._serialize.header("content_language", content_language, 'str') 912 if content_disposition is not None: 913 header_parameters['x-ms-content-disposition'] = self._serialize.header("content_disposition", content_disposition, 'str') 914 if lease_id is not None: 915 header_parameters['x-ms-lease-id'] = self._serialize.header("lease_id", lease_id, 'str') 916 if if_modified_since is not None: 917 header_parameters['If-Modified-Since'] = self._serialize.header("if_modified_since", if_modified_since, 'rfc-1123') 918 if if_unmodified_since is not None: 919 header_parameters['If-Unmodified-Since'] = self._serialize.header("if_unmodified_since", if_unmodified_since, 'rfc-1123') 920 if if_match is not None: 921 header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') 922 if if_none_match is not None: 923 header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str') 924 if source_if_modified_since is not None: 925 header_parameters['x-ms-source-if-modified-since'] = self._serialize.header("source_if_modified_since", source_if_modified_since, 'rfc-1123') 926 if source_if_unmodified_since is not None: 927 header_parameters['x-ms-source-if-unmodified-since'] = self._serialize.header("source_if_unmodified_since", source_if_unmodified_since, 'rfc-1123') 928 if source_if_match is not None: 929 header_parameters['x-ms-source-if-match'] = self._serialize.header("source_if_match", source_if_match, 'str') 930 if source_if_none_match is not None: 931 header_parameters['x-ms-source-if-none-match'] = self._serialize.header("source_if_none_match", source_if_none_match, 'str') 932 933 # Construct and send request 934 request = self._client.put(url, query_parameters, header_parameters) 935 pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) 936 response = pipeline_response.http_response 937 938 if response.status_code not in [201]: 939 map_error(status_code=response.status_code, response=response, error_map=error_map) 940 raise models.DataLakeStorageErrorException(response, self._deserialize) 941 942 if cls: 943 response_headers = { 944 'ETag': self._deserialize('str', response.headers.get('ETag')), 945 'Last-Modified': self._deserialize('rfc-1123', response.headers.get('Last-Modified')), 946 'x-ms-client-request-id': self._deserialize('str', response.headers.get('x-ms-client-request-id')), 947 'x-ms-request-id': self._deserialize('str', response.headers.get('x-ms-request-id')), 948 'x-ms-version': self._deserialize('str', response.headers.get('x-ms-version')), 949 'Content-Length': self._deserialize('long', response.headers.get('Content-Length')), 950 'Date': self._deserialize('rfc-1123', response.headers.get('Date')), 951 } 952 return cls(response, None, response_headers) 953 rename.metadata = {'url': '/{filesystem}/{path}'} 954 955 def undelete(self, timeout=None, request_id=None, cls=None, **kwargs): 956 """Undelete a blob that was previously soft deleted. 957 958 :param timeout: The timeout parameter is expressed in seconds. For 959 more information, see <a 960 href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting 961 Timeouts for Blob Service Operations.</a> 962 :type timeout: int 963 :param request_id: Provides a client-generated, opaque value with a 1 964 KB character limit that is recorded in the analytics logs when storage 965 analytics logging is enabled. 966 :type request_id: str 967 :param callable cls: A custom type or function that will be passed the 968 direct response 969 :return: None or the result of cls(response) 970 :rtype: None 971 :raises: 972 :class:`StorageErrorException<azure.storage.blob.models.StorageErrorException>` 973 """ 974 error_map = kwargs.pop('error_map', None) 975 comp = "undelete" 976 977 # Construct URL 978 url = self.undelete.metadata['url'] 979 path_format_arguments = { 980 'url': self._serialize.url("self._config.url", self._config.url, 'str', skip_quote=True) 981 } 982 url = self._client.format_url(url, **path_format_arguments) 983 984 # Construct parameters 985 query_parameters = {} 986 if timeout is not None: 987 query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int', minimum=0) 988 query_parameters['comp'] = self._serialize.query("comp", comp, 'str') 989 990 # Construct headers 991 header_parameters = {} 992 header_parameters['x-ms-version'] = self._serialize.header("self._config.version", self._config.version, 'str') 993 if request_id is not None: 994 header_parameters['x-ms-client-request-id'] = self._serialize.header("request_id", request_id, 'str') 995 996 # Construct and send request 997 request = self._client.put(url, query_parameters, header_parameters) 998 pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) 999 response = pipeline_response.http_response 1000 1001 if response.status_code not in [200]: 1002 map_error(status_code=response.status_code, response=response, error_map=error_map) 1003 raise models.StorageErrorException(response, self._deserialize) 1004 1005 if cls: 1006 response_headers = { 1007 'x-ms-client-request-id': self._deserialize('str', response.headers.get('x-ms-client-request-id')), 1008 'x-ms-request-id': self._deserialize('str', response.headers.get('x-ms-request-id')), 1009 'x-ms-version': self._deserialize('str', response.headers.get('x-ms-version')), 1010 'Date': self._deserialize('rfc-1123', response.headers.get('Date')), 1011 'x-ms-error-code': self._deserialize('str', response.headers.get('x-ms-error-code')), 1012 } 1013 return cls(response, None, response_headers) 1014 undelete.metadata = {'url': '/{containerName}/{blob}'} 1015 1016 def set_http_headers(self, timeout=None, request_id=None, blob_http_headers=None, lease_access_conditions=None, modified_access_conditions=None, cls=None, **kwargs): 1017 """The Set HTTP Headers operation sets system properties on the blob. 1018 1019 :param timeout: The timeout parameter is expressed in seconds. For 1020 more information, see <a 1021 href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting 1022 Timeouts for Blob Service Operations.</a> 1023 :type timeout: int 1024 :param request_id: Provides a client-generated, opaque value with a 1 1025 KB character limit that is recorded in the analytics logs when storage 1026 analytics logging is enabled. 1027 :type request_id: str 1028 :param blob_http_headers: Additional parameters for the operation 1029 :type blob_http_headers: ~azure.storage.blob.models.BlobHTTPHeaders 1030 :param lease_access_conditions: Additional parameters for the 1031 operation 1032 :type lease_access_conditions: 1033 ~azure.storage.blob.models.LeaseAccessConditions 1034 :param modified_access_conditions: Additional parameters for the 1035 operation 1036 :type modified_access_conditions: 1037 ~azure.storage.blob.models.ModifiedAccessConditions 1038 :param callable cls: A custom type or function that will be passed the 1039 direct response 1040 :return: None or the result of cls(response) 1041 :rtype: None 1042 :raises: 1043 :class:`StorageErrorException<azure.storage.blob.models.StorageErrorException>` 1044 """ 1045 error_map = kwargs.pop('error_map', None) 1046 blob_cache_control = None 1047 if blob_http_headers is not None: 1048 blob_cache_control = blob_http_headers.blob_cache_control 1049 blob_content_type = None 1050 if blob_http_headers is not None: 1051 blob_content_type = blob_http_headers.blob_content_type 1052 blob_content_md5 = None 1053 if blob_http_headers is not None: 1054 blob_content_md5 = blob_http_headers.blob_content_md5 1055 blob_content_encoding = None 1056 if blob_http_headers is not None: 1057 blob_content_encoding = blob_http_headers.blob_content_encoding 1058 blob_content_language = None 1059 if blob_http_headers is not None: 1060 blob_content_language = blob_http_headers.blob_content_language 1061 blob_content_disposition = None 1062 if blob_http_headers is not None: 1063 blob_content_disposition = blob_http_headers.blob_content_disposition 1064 lease_id = None 1065 if lease_access_conditions is not None: 1066 lease_id = lease_access_conditions.lease_id 1067 if_modified_since = None 1068 if modified_access_conditions is not None: 1069 if_modified_since = modified_access_conditions.if_modified_since 1070 if_unmodified_since = None 1071 if modified_access_conditions is not None: 1072 if_unmodified_since = modified_access_conditions.if_unmodified_since 1073 if_match = None 1074 if modified_access_conditions is not None: 1075 if_match = modified_access_conditions.if_match 1076 if_none_match = None 1077 if modified_access_conditions is not None: 1078 if_none_match = modified_access_conditions.if_none_match 1079 1080 comp = "properties" 1081 1082 # Construct URL 1083 url = self.set_http_headers.metadata['url'] 1084 path_format_arguments = { 1085 'url': self._serialize.url("self._config.url", self._config.url, 'str', skip_quote=True) 1086 } 1087 url = self._client.format_url(url, **path_format_arguments) 1088 1089 # Construct parameters 1090 query_parameters = {} 1091 if timeout is not None: 1092 query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int', minimum=0) 1093 query_parameters['comp'] = self._serialize.query("comp", comp, 'str') 1094 1095 # Construct headers 1096 header_parameters = {} 1097 header_parameters['x-ms-version'] = self._serialize.header("self._config.version", self._config.version, 'str') 1098 if request_id is not None: 1099 header_parameters['x-ms-client-request-id'] = self._serialize.header("request_id", request_id, 'str') 1100 if blob_cache_control is not None: 1101 header_parameters['x-ms-blob-cache-control'] = self._serialize.header("blob_cache_control", blob_cache_control, 'str') 1102 if blob_content_type is not None: 1103 header_parameters['x-ms-blob-content-type'] = self._serialize.header("blob_content_type", blob_content_type, 'str') 1104 if blob_content_md5 is not None: 1105 header_parameters['x-ms-blob-content-md5'] = self._serialize.header("blob_content_md5", blob_content_md5, 'bytearray') 1106 if blob_content_encoding is not None: 1107 header_parameters['x-ms-blob-content-encoding'] = self._serialize.header("blob_content_encoding", blob_content_encoding, 'str') 1108 if blob_content_language is not None: 1109 header_parameters['x-ms-blob-content-language'] = self._serialize.header("blob_content_language", blob_content_language, 'str') 1110 if blob_content_disposition is not None: 1111 header_parameters['x-ms-blob-content-disposition'] = self._serialize.header("blob_content_disposition", blob_content_disposition, 'str') 1112 if lease_id is not None: 1113 header_parameters['x-ms-lease-id'] = self._serialize.header("lease_id", lease_id, 'str') 1114 if if_modified_since is not None: 1115 header_parameters['If-Modified-Since'] = self._serialize.header("if_modified_since", if_modified_since, 'rfc-1123') 1116 if if_unmodified_since is not None: 1117 header_parameters['If-Unmodified-Since'] = self._serialize.header("if_unmodified_since", if_unmodified_since, 'rfc-1123') 1118 if if_match is not None: 1119 header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') 1120 if if_none_match is not None: 1121 header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str') 1122 1123 # Construct and send request 1124 request = self._client.put(url, query_parameters, header_parameters) 1125 pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) 1126 response = pipeline_response.http_response 1127 1128 if response.status_code not in [200]: 1129 map_error(status_code=response.status_code, response=response, error_map=error_map) 1130 raise models.StorageErrorException(response, self._deserialize) 1131 1132 if cls: 1133 response_headers = { 1134 'ETag': self._deserialize('str', response.headers.get('ETag')), 1135 'Last-Modified': self._deserialize('rfc-1123', response.headers.get('Last-Modified')), 1136 'x-ms-blob-sequence-number': self._deserialize('long', response.headers.get('x-ms-blob-sequence-number')), 1137 'x-ms-client-request-id': self._deserialize('str', response.headers.get('x-ms-client-request-id')), 1138 'x-ms-request-id': self._deserialize('str', response.headers.get('x-ms-request-id')), 1139 'x-ms-version': self._deserialize('str', response.headers.get('x-ms-version')), 1140 'Date': self._deserialize('rfc-1123', response.headers.get('Date')), 1141 'x-ms-error-code': self._deserialize('str', response.headers.get('x-ms-error-code')), 1142 } 1143 return cls(response, None, response_headers) 1144 set_http_headers.metadata = {'url': '/{containerName}/{blob}'} 1145 1146 def set_metadata(self, timeout=None, metadata=None, request_id=None, lease_access_conditions=None, cpk_info=None, modified_access_conditions=None, cls=None, **kwargs): 1147 """The Set Blob Metadata operation sets user-defined metadata for the 1148 specified blob as one or more name-value pairs. 1149 1150 :param timeout: The timeout parameter is expressed in seconds. For 1151 more information, see <a 1152 href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting 1153 Timeouts for Blob Service Operations.</a> 1154 :type timeout: int 1155 :param metadata: Optional. Specifies a user-defined name-value pair 1156 associated with the blob. If no name-value pairs are specified, the 1157 operation will copy the metadata from the source blob or file to the 1158 destination blob. If one or more name-value pairs are specified, the 1159 destination blob is created with the specified metadata, and metadata 1160 is not copied from the source blob or file. Note that beginning with 1161 version 2009-09-19, metadata names must adhere to the naming rules for 1162 C# identifiers. See Naming and Referencing Containers, Blobs, and 1163 Metadata for more information. 1164 :type metadata: str 1165 :param request_id: Provides a client-generated, opaque value with a 1 1166 KB character limit that is recorded in the analytics logs when storage 1167 analytics logging is enabled. 1168 :type request_id: str 1169 :param lease_access_conditions: Additional parameters for the 1170 operation 1171 :type lease_access_conditions: 1172 ~azure.storage.blob.models.LeaseAccessConditions 1173 :param cpk_info: Additional parameters for the operation 1174 :type cpk_info: ~azure.storage.blob.models.CpkInfo 1175 :param modified_access_conditions: Additional parameters for the 1176 operation 1177 :type modified_access_conditions: 1178 ~azure.storage.blob.models.ModifiedAccessConditions 1179 :param callable cls: A custom type or function that will be passed the 1180 direct response 1181 :return: None or the result of cls(response) 1182 :rtype: None 1183 :raises: 1184 :class:`StorageErrorException<azure.storage.blob.models.StorageErrorException>` 1185 """ 1186 error_map = kwargs.pop('error_map', None) 1187 lease_id = None 1188 if lease_access_conditions is not None: 1189 lease_id = lease_access_conditions.lease_id 1190 encryption_key = None 1191 if cpk_info is not None: 1192 encryption_key = cpk_info.encryption_key 1193 encryption_key_sha256 = None 1194 if cpk_info is not None: 1195 encryption_key_sha256 = cpk_info.encryption_key_sha256 1196 encryption_algorithm = None 1197 if cpk_info is not None: 1198 encryption_algorithm = cpk_info.encryption_algorithm 1199 if_modified_since = None 1200 if modified_access_conditions is not None: 1201 if_modified_since = modified_access_conditions.if_modified_since 1202 if_unmodified_since = None 1203 if modified_access_conditions is not None: 1204 if_unmodified_since = modified_access_conditions.if_unmodified_since 1205 if_match = None 1206 if modified_access_conditions is not None: 1207 if_match = modified_access_conditions.if_match 1208 if_none_match = None 1209 if modified_access_conditions is not None: 1210 if_none_match = modified_access_conditions.if_none_match 1211 1212 comp = "metadata" 1213 1214 # Construct URL 1215 url = self.set_metadata.metadata['url'] 1216 path_format_arguments = { 1217 'url': self._serialize.url("self._config.url", self._config.url, 'str', skip_quote=True) 1218 } 1219 url = self._client.format_url(url, **path_format_arguments) 1220 1221 # Construct parameters 1222 query_parameters = {} 1223 if timeout is not None: 1224 query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int', minimum=0) 1225 query_parameters['comp'] = self._serialize.query("comp", comp, 'str') 1226 1227 # Construct headers 1228 header_parameters = {} 1229 if metadata is not None: 1230 header_parameters['x-ms-meta'] = self._serialize.header("metadata", metadata, 'str') 1231 header_parameters['x-ms-version'] = self._serialize.header("self._config.version", self._config.version, 'str') 1232 if request_id is not None: 1233 header_parameters['x-ms-client-request-id'] = self._serialize.header("request_id", request_id, 'str') 1234 if lease_id is not None: 1235 header_parameters['x-ms-lease-id'] = self._serialize.header("lease_id", lease_id, 'str') 1236 if encryption_key is not None: 1237 header_parameters['x-ms-encryption-key'] = self._serialize.header("encryption_key", encryption_key, 'str') 1238 if encryption_key_sha256 is not None: 1239 header_parameters['x-ms-encryption-key-sha256'] = self._serialize.header("encryption_key_sha256", encryption_key_sha256, 'str') 1240 if encryption_algorithm is not None: 1241 header_parameters['x-ms-encryption-algorithm'] = self._serialize.header("encryption_algorithm", encryption_algorithm, 'EncryptionAlgorithmType') 1242 if if_modified_since is not None: 1243 header_parameters['If-Modified-Since'] = self._serialize.header("if_modified_since", if_modified_since, 'rfc-1123') 1244 if if_unmodified_since is not None: 1245 header_parameters['If-Unmodified-Since'] = self._serialize.header("if_unmodified_since", if_unmodified_since, 'rfc-1123') 1246 if if_match is not None: 1247 header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') 1248 if if_none_match is not None: 1249 header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str') 1250 1251 # Construct and send request 1252 request = self._client.put(url, query_parameters, header_parameters) 1253 pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) 1254 response = pipeline_response.http_response 1255 1256 if response.status_code not in [200]: 1257 map_error(status_code=response.status_code, response=response, error_map=error_map) 1258 raise models.StorageErrorException(response, self._deserialize) 1259 1260 if cls: 1261 response_headers = { 1262 'ETag': self._deserialize('str', response.headers.get('ETag')), 1263 'Last-Modified': self._deserialize('rfc-1123', response.headers.get('Last-Modified')), 1264 'x-ms-client-request-id': self._deserialize('str', response.headers.get('x-ms-client-request-id')), 1265 'x-ms-request-id': self._deserialize('str', response.headers.get('x-ms-request-id')), 1266 'x-ms-version': self._deserialize('str', response.headers.get('x-ms-version')), 1267 'Date': self._deserialize('rfc-1123', response.headers.get('Date')), 1268 'x-ms-request-server-encrypted': self._deserialize('bool', response.headers.get('x-ms-request-server-encrypted')), 1269 'x-ms-encryption-key-sha256': self._deserialize('str', response.headers.get('x-ms-encryption-key-sha256')), 1270 'x-ms-error-code': self._deserialize('str', response.headers.get('x-ms-error-code')), 1271 } 1272 return cls(response, None, response_headers) 1273 set_metadata.metadata = {'url': '/{containerName}/{blob}'} 1274 1275 def acquire_lease(self, timeout=None, duration=None, proposed_lease_id=None, request_id=None, modified_access_conditions=None, cls=None, **kwargs): 1276 """[Update] The Lease Blob operation establishes and manages a lock on a 1277 blob for write and delete operations. 1278 1279 :param timeout: The timeout parameter is expressed in seconds. For 1280 more information, see <a 1281 href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting 1282 Timeouts for Blob Service Operations.</a> 1283 :type timeout: int 1284 :param duration: Specifies the duration of the lease, in seconds, or 1285 negative one (-1) for a lease that never expires. A non-infinite lease 1286 can be between 15 and 60 seconds. A lease duration cannot be changed 1287 using renew or change. 1288 :type duration: int 1289 :param proposed_lease_id: Proposed lease ID, in a GUID string format. 1290 The Blob service returns 400 (Invalid request) if the proposed lease 1291 ID is not in the correct format. See Guid Constructor (String) for a 1292 list of valid GUID string formats. 1293 :type proposed_lease_id: str 1294 :param request_id: Provides a client-generated, opaque value with a 1 1295 KB character limit that is recorded in the analytics logs when storage 1296 analytics logging is enabled. 1297 :type request_id: str 1298 :param modified_access_conditions: Additional parameters for the 1299 operation 1300 :type modified_access_conditions: 1301 ~azure.storage.blob.models.ModifiedAccessConditions 1302 :param callable cls: A custom type or function that will be passed the 1303 direct response 1304 :return: None or the result of cls(response) 1305 :rtype: None 1306 :raises: 1307 :class:`StorageErrorException<azure.storage.blob.models.StorageErrorException>` 1308 """ 1309 error_map = kwargs.pop('error_map', None) 1310 if_modified_since = None 1311 if modified_access_conditions is not None: 1312 if_modified_since = modified_access_conditions.if_modified_since 1313 if_unmodified_since = None 1314 if modified_access_conditions is not None: 1315 if_unmodified_since = modified_access_conditions.if_unmodified_since 1316 if_match = None 1317 if modified_access_conditions is not None: 1318 if_match = modified_access_conditions.if_match 1319 if_none_match = None 1320 if modified_access_conditions is not None: 1321 if_none_match = modified_access_conditions.if_none_match 1322 1323 comp = "lease" 1324 action = "acquire" 1325 1326 # Construct URL 1327 url = self.acquire_lease.metadata['url'] 1328 path_format_arguments = { 1329 'url': self._serialize.url("self._config.url", self._config.url, 'str', skip_quote=True) 1330 } 1331 url = self._client.format_url(url, **path_format_arguments) 1332 1333 # Construct parameters 1334 query_parameters = {} 1335 if timeout is not None: 1336 query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int', minimum=0) 1337 query_parameters['comp'] = self._serialize.query("comp", comp, 'str') 1338 1339 # Construct headers 1340 header_parameters = {} 1341 if duration is not None: 1342 header_parameters['x-ms-lease-duration'] = self._serialize.header("duration", duration, 'int') 1343 if proposed_lease_id is not None: 1344 header_parameters['x-ms-proposed-lease-id'] = self._serialize.header("proposed_lease_id", proposed_lease_id, 'str') 1345 header_parameters['x-ms-version'] = self._serialize.header("self._config.version", self._config.version, 'str') 1346 if request_id is not None: 1347 header_parameters['x-ms-client-request-id'] = self._serialize.header("request_id", request_id, 'str') 1348 header_parameters['x-ms-lease-action'] = self._serialize.header("action", action, 'str') 1349 if if_modified_since is not None: 1350 header_parameters['If-Modified-Since'] = self._serialize.header("if_modified_since", if_modified_since, 'rfc-1123') 1351 if if_unmodified_since is not None: 1352 header_parameters['If-Unmodified-Since'] = self._serialize.header("if_unmodified_since", if_unmodified_since, 'rfc-1123') 1353 if if_match is not None: 1354 header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') 1355 if if_none_match is not None: 1356 header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str') 1357 1358 # Construct and send request 1359 request = self._client.put(url, query_parameters, header_parameters) 1360 pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) 1361 response = pipeline_response.http_response 1362 1363 if response.status_code not in [201]: 1364 map_error(status_code=response.status_code, response=response, error_map=error_map) 1365 raise models.StorageErrorException(response, self._deserialize) 1366 1367 if cls: 1368 response_headers = { 1369 'ETag': self._deserialize('str', response.headers.get('ETag')), 1370 'Last-Modified': self._deserialize('rfc-1123', response.headers.get('Last-Modified')), 1371 'x-ms-lease-id': self._deserialize('str', response.headers.get('x-ms-lease-id')), 1372 'x-ms-client-request-id': self._deserialize('str', response.headers.get('x-ms-client-request-id')), 1373 'x-ms-request-id': self._deserialize('str', response.headers.get('x-ms-request-id')), 1374 'x-ms-version': self._deserialize('str', response.headers.get('x-ms-version')), 1375 'Date': self._deserialize('rfc-1123', response.headers.get('Date')), 1376 'x-ms-error-code': self._deserialize('str', response.headers.get('x-ms-error-code')), 1377 } 1378 return cls(response, None, response_headers) 1379 acquire_lease.metadata = {'url': '/{containerName}/{blob}'} 1380 1381 def release_lease(self, lease_id, timeout=None, request_id=None, modified_access_conditions=None, cls=None, **kwargs): 1382 """[Update] The Lease Blob operation establishes and manages a lock on a 1383 blob for write and delete operations. 1384 1385 :param lease_id: Specifies the current lease ID on the resource. 1386 :type lease_id: str 1387 :param timeout: The timeout parameter is expressed in seconds. For 1388 more information, see <a 1389 href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting 1390 Timeouts for Blob Service Operations.</a> 1391 :type timeout: int 1392 :param request_id: Provides a client-generated, opaque value with a 1 1393 KB character limit that is recorded in the analytics logs when storage 1394 analytics logging is enabled. 1395 :type request_id: str 1396 :param modified_access_conditions: Additional parameters for the 1397 operation 1398 :type modified_access_conditions: 1399 ~azure.storage.blob.models.ModifiedAccessConditions 1400 :param callable cls: A custom type or function that will be passed the 1401 direct response 1402 :return: None or the result of cls(response) 1403 :rtype: None 1404 :raises: 1405 :class:`StorageErrorException<azure.storage.blob.models.StorageErrorException>` 1406 """ 1407 error_map = kwargs.pop('error_map', None) 1408 if_modified_since = None 1409 if modified_access_conditions is not None: 1410 if_modified_since = modified_access_conditions.if_modified_since 1411 if_unmodified_since = None 1412 if modified_access_conditions is not None: 1413 if_unmodified_since = modified_access_conditions.if_unmodified_since 1414 if_match = None 1415 if modified_access_conditions is not None: 1416 if_match = modified_access_conditions.if_match 1417 if_none_match = None 1418 if modified_access_conditions is not None: 1419 if_none_match = modified_access_conditions.if_none_match 1420 1421 comp = "lease" 1422 action = "release" 1423 1424 # Construct URL 1425 url = self.release_lease.metadata['url'] 1426 path_format_arguments = { 1427 'url': self._serialize.url("self._config.url", self._config.url, 'str', skip_quote=True) 1428 } 1429 url = self._client.format_url(url, **path_format_arguments) 1430 1431 # Construct parameters 1432 query_parameters = {} 1433 if timeout is not None: 1434 query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int', minimum=0) 1435 query_parameters['comp'] = self._serialize.query("comp", comp, 'str') 1436 1437 # Construct headers 1438 header_parameters = {} 1439 header_parameters['x-ms-lease-id'] = self._serialize.header("lease_id", lease_id, 'str') 1440 header_parameters['x-ms-version'] = self._serialize.header("self._config.version", self._config.version, 'str') 1441 if request_id is not None: 1442 header_parameters['x-ms-client-request-id'] = self._serialize.header("request_id", request_id, 'str') 1443 header_parameters['x-ms-lease-action'] = self._serialize.header("action", action, 'str') 1444 if if_modified_since is not None: 1445 header_parameters['If-Modified-Since'] = self._serialize.header("if_modified_since", if_modified_since, 'rfc-1123') 1446 if if_unmodified_since is not None: 1447 header_parameters['If-Unmodified-Since'] = self._serialize.header("if_unmodified_since", if_unmodified_since, 'rfc-1123') 1448 if if_match is not None: 1449 header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') 1450 if if_none_match is not None: 1451 header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str') 1452 1453 # Construct and send request 1454 request = self._client.put(url, query_parameters, header_parameters) 1455 pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) 1456 response = pipeline_response.http_response 1457 1458 if response.status_code not in [200]: 1459 map_error(status_code=response.status_code, response=response, error_map=error_map) 1460 raise models.StorageErrorException(response, self._deserialize) 1461 1462 if cls: 1463 response_headers = { 1464 'ETag': self._deserialize('str', response.headers.get('ETag')), 1465 'Last-Modified': self._deserialize('rfc-1123', response.headers.get('Last-Modified')), 1466 'x-ms-client-request-id': self._deserialize('str', response.headers.get('x-ms-client-request-id')), 1467 'x-ms-request-id': self._deserialize('str', response.headers.get('x-ms-request-id')), 1468 'x-ms-version': self._deserialize('str', response.headers.get('x-ms-version')), 1469 'Date': self._deserialize('rfc-1123', response.headers.get('Date')), 1470 'x-ms-error-code': self._deserialize('str', response.headers.get('x-ms-error-code')), 1471 } 1472 return cls(response, None, response_headers) 1473 release_lease.metadata = {'url': '/{containerName}/{blob}'} 1474 1475 def renew_lease(self, lease_id, timeout=None, request_id=None, modified_access_conditions=None, cls=None, **kwargs): 1476 """[Update] The Lease Blob operation establishes and manages a lock on a 1477 blob for write and delete operations. 1478 1479 :param lease_id: Specifies the current lease ID on the resource. 1480 :type lease_id: str 1481 :param timeout: The timeout parameter is expressed in seconds. For 1482 more information, see <a 1483 href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting 1484 Timeouts for Blob Service Operations.</a> 1485 :type timeout: int 1486 :param request_id: Provides a client-generated, opaque value with a 1 1487 KB character limit that is recorded in the analytics logs when storage 1488 analytics logging is enabled. 1489 :type request_id: str 1490 :param modified_access_conditions: Additional parameters for the 1491 operation 1492 :type modified_access_conditions: 1493 ~azure.storage.blob.models.ModifiedAccessConditions 1494 :param callable cls: A custom type or function that will be passed the 1495 direct response 1496 :return: None or the result of cls(response) 1497 :rtype: None 1498 :raises: 1499 :class:`StorageErrorException<azure.storage.blob.models.StorageErrorException>` 1500 """ 1501 error_map = kwargs.pop('error_map', None) 1502 if_modified_since = None 1503 if modified_access_conditions is not None: 1504 if_modified_since = modified_access_conditions.if_modified_since 1505 if_unmodified_since = None 1506 if modified_access_conditions is not None: 1507 if_unmodified_since = modified_access_conditions.if_unmodified_since 1508 if_match = None 1509 if modified_access_conditions is not None: 1510 if_match = modified_access_conditions.if_match 1511 if_none_match = None 1512 if modified_access_conditions is not None: 1513 if_none_match = modified_access_conditions.if_none_match 1514 1515 comp = "lease" 1516 action = "renew" 1517 1518 # Construct URL 1519 url = self.renew_lease.metadata['url'] 1520 path_format_arguments = { 1521 'url': self._serialize.url("self._config.url", self._config.url, 'str', skip_quote=True) 1522 } 1523 url = self._client.format_url(url, **path_format_arguments) 1524 1525 # Construct parameters 1526 query_parameters = {} 1527 if timeout is not None: 1528 query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int', minimum=0) 1529 query_parameters['comp'] = self._serialize.query("comp", comp, 'str') 1530 1531 # Construct headers 1532 header_parameters = {} 1533 header_parameters['x-ms-lease-id'] = self._serialize.header("lease_id", lease_id, 'str') 1534 header_parameters['x-ms-version'] = self._serialize.header("self._config.version", self._config.version, 'str') 1535 if request_id is not None: 1536 header_parameters['x-ms-client-request-id'] = self._serialize.header("request_id", request_id, 'str') 1537 header_parameters['x-ms-lease-action'] = self._serialize.header("action", action, 'str') 1538 if if_modified_since is not None: 1539 header_parameters['If-Modified-Since'] = self._serialize.header("if_modified_since", if_modified_since, 'rfc-1123') 1540 if if_unmodified_since is not None: 1541 header_parameters['If-Unmodified-Since'] = self._serialize.header("if_unmodified_since", if_unmodified_since, 'rfc-1123') 1542 if if_match is not None: 1543 header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') 1544 if if_none_match is not None: 1545 header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str') 1546 1547 # Construct and send request 1548 request = self._client.put(url, query_parameters, header_parameters) 1549 pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) 1550 response = pipeline_response.http_response 1551 1552 if response.status_code not in [200]: 1553 map_error(status_code=response.status_code, response=response, error_map=error_map) 1554 raise models.StorageErrorException(response, self._deserialize) 1555 1556 if cls: 1557 response_headers = { 1558 'ETag': self._deserialize('str', response.headers.get('ETag')), 1559 'Last-Modified': self._deserialize('rfc-1123', response.headers.get('Last-Modified')), 1560 'x-ms-lease-id': self._deserialize('str', response.headers.get('x-ms-lease-id')), 1561 'x-ms-client-request-id': self._deserialize('str', response.headers.get('x-ms-client-request-id')), 1562 'x-ms-request-id': self._deserialize('str', response.headers.get('x-ms-request-id')), 1563 'x-ms-version': self._deserialize('str', response.headers.get('x-ms-version')), 1564 'Date': self._deserialize('rfc-1123', response.headers.get('Date')), 1565 'x-ms-error-code': self._deserialize('str', response.headers.get('x-ms-error-code')), 1566 } 1567 return cls(response, None, response_headers) 1568 renew_lease.metadata = {'url': '/{containerName}/{blob}'} 1569 1570 def change_lease(self, lease_id, proposed_lease_id, timeout=None, request_id=None, modified_access_conditions=None, cls=None, **kwargs): 1571 """[Update] The Lease Blob operation establishes and manages a lock on a 1572 blob for write and delete operations. 1573 1574 :param lease_id: Specifies the current lease ID on the resource. 1575 :type lease_id: str 1576 :param proposed_lease_id: Proposed lease ID, in a GUID string format. 1577 The Blob service returns 400 (Invalid request) if the proposed lease 1578 ID is not in the correct format. See Guid Constructor (String) for a 1579 list of valid GUID string formats. 1580 :type proposed_lease_id: str 1581 :param timeout: The timeout parameter is expressed in seconds. For 1582 more information, see <a 1583 href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting 1584 Timeouts for Blob Service Operations.</a> 1585 :type timeout: int 1586 :param request_id: Provides a client-generated, opaque value with a 1 1587 KB character limit that is recorded in the analytics logs when storage 1588 analytics logging is enabled. 1589 :type request_id: str 1590 :param modified_access_conditions: Additional parameters for the 1591 operation 1592 :type modified_access_conditions: 1593 ~azure.storage.blob.models.ModifiedAccessConditions 1594 :param callable cls: A custom type or function that will be passed the 1595 direct response 1596 :return: None or the result of cls(response) 1597 :rtype: None 1598 :raises: 1599 :class:`StorageErrorException<azure.storage.blob.models.StorageErrorException>` 1600 """ 1601 error_map = kwargs.pop('error_map', None) 1602 if_modified_since = None 1603 if modified_access_conditions is not None: 1604 if_modified_since = modified_access_conditions.if_modified_since 1605 if_unmodified_since = None 1606 if modified_access_conditions is not None: 1607 if_unmodified_since = modified_access_conditions.if_unmodified_since 1608 if_match = None 1609 if modified_access_conditions is not None: 1610 if_match = modified_access_conditions.if_match 1611 if_none_match = None 1612 if modified_access_conditions is not None: 1613 if_none_match = modified_access_conditions.if_none_match 1614 1615 comp = "lease" 1616 action = "change" 1617 1618 # Construct URL 1619 url = self.change_lease.metadata['url'] 1620 path_format_arguments = { 1621 'url': self._serialize.url("self._config.url", self._config.url, 'str', skip_quote=True) 1622 } 1623 url = self._client.format_url(url, **path_format_arguments) 1624 1625 # Construct parameters 1626 query_parameters = {} 1627 if timeout is not None: 1628 query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int', minimum=0) 1629 query_parameters['comp'] = self._serialize.query("comp", comp, 'str') 1630 1631 # Construct headers 1632 header_parameters = {} 1633 header_parameters['x-ms-lease-id'] = self._serialize.header("lease_id", lease_id, 'str') 1634 header_parameters['x-ms-proposed-lease-id'] = self._serialize.header("proposed_lease_id", proposed_lease_id, 'str') 1635 header_parameters['x-ms-version'] = self._serialize.header("self._config.version", self._config.version, 'str') 1636 if request_id is not None: 1637 header_parameters['x-ms-client-request-id'] = self._serialize.header("request_id", request_id, 'str') 1638 header_parameters['x-ms-lease-action'] = self._serialize.header("action", action, 'str') 1639 if if_modified_since is not None: 1640 header_parameters['If-Modified-Since'] = self._serialize.header("if_modified_since", if_modified_since, 'rfc-1123') 1641 if if_unmodified_since is not None: 1642 header_parameters['If-Unmodified-Since'] = self._serialize.header("if_unmodified_since", if_unmodified_since, 'rfc-1123') 1643 if if_match is not None: 1644 header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') 1645 if if_none_match is not None: 1646 header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str') 1647 1648 # Construct and send request 1649 request = self._client.put(url, query_parameters, header_parameters) 1650 pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) 1651 response = pipeline_response.http_response 1652 1653 if response.status_code not in [200]: 1654 map_error(status_code=response.status_code, response=response, error_map=error_map) 1655 raise models.StorageErrorException(response, self._deserialize) 1656 1657 if cls: 1658 response_headers = { 1659 'ETag': self._deserialize('str', response.headers.get('ETag')), 1660 'Last-Modified': self._deserialize('rfc-1123', response.headers.get('Last-Modified')), 1661 'x-ms-client-request-id': self._deserialize('str', response.headers.get('x-ms-client-request-id')), 1662 'x-ms-request-id': self._deserialize('str', response.headers.get('x-ms-request-id')), 1663 'x-ms-lease-id': self._deserialize('str', response.headers.get('x-ms-lease-id')), 1664 'x-ms-version': self._deserialize('str', response.headers.get('x-ms-version')), 1665 'Date': self._deserialize('rfc-1123', response.headers.get('Date')), 1666 'x-ms-error-code': self._deserialize('str', response.headers.get('x-ms-error-code')), 1667 } 1668 return cls(response, None, response_headers) 1669 change_lease.metadata = {'url': '/{containerName}/{blob}'} 1670 1671 def break_lease(self, timeout=None, break_period=None, request_id=None, modified_access_conditions=None, cls=None, **kwargs): 1672 """[Update] The Lease Blob operation establishes and manages a lock on a 1673 blob for write and delete operations. 1674 1675 :param timeout: The timeout parameter is expressed in seconds. For 1676 more information, see <a 1677 href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting 1678 Timeouts for Blob Service Operations.</a> 1679 :type timeout: int 1680 :param break_period: For a break operation, proposed duration the 1681 lease should continue before it is broken, in seconds, between 0 and 1682 60. This break period is only used if it is shorter than the time 1683 remaining on the lease. If longer, the time remaining on the lease is 1684 used. A new lease will not be available before the break period has 1685 expired, but the lease may be held for longer than the break period. 1686 If this header does not appear with a break operation, a 1687 fixed-duration lease breaks after the remaining lease period elapses, 1688 and an infinite lease breaks immediately. 1689 :type break_period: int 1690 :param request_id: Provides a client-generated, opaque value with a 1 1691 KB character limit that is recorded in the analytics logs when storage 1692 analytics logging is enabled. 1693 :type request_id: str 1694 :param modified_access_conditions: Additional parameters for the 1695 operation 1696 :type modified_access_conditions: 1697 ~azure.storage.blob.models.ModifiedAccessConditions 1698 :param callable cls: A custom type or function that will be passed the 1699 direct response 1700 :return: None or the result of cls(response) 1701 :rtype: None 1702 :raises: 1703 :class:`StorageErrorException<azure.storage.blob.models.StorageErrorException>` 1704 """ 1705 error_map = kwargs.pop('error_map', None) 1706 if_modified_since = None 1707 if modified_access_conditions is not None: 1708 if_modified_since = modified_access_conditions.if_modified_since 1709 if_unmodified_since = None 1710 if modified_access_conditions is not None: 1711 if_unmodified_since = modified_access_conditions.if_unmodified_since 1712 if_match = None 1713 if modified_access_conditions is not None: 1714 if_match = modified_access_conditions.if_match 1715 if_none_match = None 1716 if modified_access_conditions is not None: 1717 if_none_match = modified_access_conditions.if_none_match 1718 1719 comp = "lease" 1720 action = "break" 1721 1722 # Construct URL 1723 url = self.break_lease.metadata['url'] 1724 path_format_arguments = { 1725 'url': self._serialize.url("self._config.url", self._config.url, 'str', skip_quote=True) 1726 } 1727 url = self._client.format_url(url, **path_format_arguments) 1728 1729 # Construct parameters 1730 query_parameters = {} 1731 if timeout is not None: 1732 query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int', minimum=0) 1733 query_parameters['comp'] = self._serialize.query("comp", comp, 'str') 1734 1735 # Construct headers 1736 header_parameters = {} 1737 if break_period is not None: 1738 header_parameters['x-ms-lease-break-period'] = self._serialize.header("break_period", break_period, 'int') 1739 header_parameters['x-ms-version'] = self._serialize.header("self._config.version", self._config.version, 'str') 1740 if request_id is not None: 1741 header_parameters['x-ms-client-request-id'] = self._serialize.header("request_id", request_id, 'str') 1742 header_parameters['x-ms-lease-action'] = self._serialize.header("action", action, 'str') 1743 if if_modified_since is not None: 1744 header_parameters['If-Modified-Since'] = self._serialize.header("if_modified_since", if_modified_since, 'rfc-1123') 1745 if if_unmodified_since is not None: 1746 header_parameters['If-Unmodified-Since'] = self._serialize.header("if_unmodified_since", if_unmodified_since, 'rfc-1123') 1747 if if_match is not None: 1748 header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') 1749 if if_none_match is not None: 1750 header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str') 1751 1752 # Construct and send request 1753 request = self._client.put(url, query_parameters, header_parameters) 1754 pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) 1755 response = pipeline_response.http_response 1756 1757 if response.status_code not in [202]: 1758 map_error(status_code=response.status_code, response=response, error_map=error_map) 1759 raise models.StorageErrorException(response, self._deserialize) 1760 1761 if cls: 1762 response_headers = { 1763 'ETag': self._deserialize('str', response.headers.get('ETag')), 1764 'Last-Modified': self._deserialize('rfc-1123', response.headers.get('Last-Modified')), 1765 'x-ms-lease-time': self._deserialize('int', response.headers.get('x-ms-lease-time')), 1766 'x-ms-client-request-id': self._deserialize('str', response.headers.get('x-ms-client-request-id')), 1767 'x-ms-request-id': self._deserialize('str', response.headers.get('x-ms-request-id')), 1768 'x-ms-version': self._deserialize('str', response.headers.get('x-ms-version')), 1769 'Date': self._deserialize('rfc-1123', response.headers.get('Date')), 1770 'x-ms-error-code': self._deserialize('str', response.headers.get('x-ms-error-code')), 1771 } 1772 return cls(response, None, response_headers) 1773 break_lease.metadata = {'url': '/{containerName}/{blob}'} 1774 1775 def create_snapshot(self, timeout=None, metadata=None, request_id=None, cpk_info=None, modified_access_conditions=None, lease_access_conditions=None, cls=None, **kwargs): 1776 """The Create Snapshot operation creates a read-only snapshot of a blob. 1777 1778 :param timeout: The timeout parameter is expressed in seconds. For 1779 more information, see <a 1780 href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting 1781 Timeouts for Blob Service Operations.</a> 1782 :type timeout: int 1783 :param metadata: Optional. Specifies a user-defined name-value pair 1784 associated with the blob. If no name-value pairs are specified, the 1785 operation will copy the metadata from the source blob or file to the 1786 destination blob. If one or more name-value pairs are specified, the 1787 destination blob is created with the specified metadata, and metadata 1788 is not copied from the source blob or file. Note that beginning with 1789 version 2009-09-19, metadata names must adhere to the naming rules for 1790 C# identifiers. See Naming and Referencing Containers, Blobs, and 1791 Metadata for more information. 1792 :type metadata: str 1793 :param request_id: Provides a client-generated, opaque value with a 1 1794 KB character limit that is recorded in the analytics logs when storage 1795 analytics logging is enabled. 1796 :type request_id: str 1797 :param cpk_info: Additional parameters for the operation 1798 :type cpk_info: ~azure.storage.blob.models.CpkInfo 1799 :param modified_access_conditions: Additional parameters for the 1800 operation 1801 :type modified_access_conditions: 1802 ~azure.storage.blob.models.ModifiedAccessConditions 1803 :param lease_access_conditions: Additional parameters for the 1804 operation 1805 :type lease_access_conditions: 1806 ~azure.storage.blob.models.LeaseAccessConditions 1807 :param callable cls: A custom type or function that will be passed the 1808 direct response 1809 :return: None or the result of cls(response) 1810 :rtype: None 1811 :raises: 1812 :class:`StorageErrorException<azure.storage.blob.models.StorageErrorException>` 1813 """ 1814 error_map = kwargs.pop('error_map', None) 1815 encryption_key = None 1816 if cpk_info is not None: 1817 encryption_key = cpk_info.encryption_key 1818 encryption_key_sha256 = None 1819 if cpk_info is not None: 1820 encryption_key_sha256 = cpk_info.encryption_key_sha256 1821 encryption_algorithm = None 1822 if cpk_info is not None: 1823 encryption_algorithm = cpk_info.encryption_algorithm 1824 if_modified_since = None 1825 if modified_access_conditions is not None: 1826 if_modified_since = modified_access_conditions.if_modified_since 1827 if_unmodified_since = None 1828 if modified_access_conditions is not None: 1829 if_unmodified_since = modified_access_conditions.if_unmodified_since 1830 if_match = None 1831 if modified_access_conditions is not None: 1832 if_match = modified_access_conditions.if_match 1833 if_none_match = None 1834 if modified_access_conditions is not None: 1835 if_none_match = modified_access_conditions.if_none_match 1836 lease_id = None 1837 if lease_access_conditions is not None: 1838 lease_id = lease_access_conditions.lease_id 1839 1840 comp = "snapshot" 1841 1842 # Construct URL 1843 url = self.create_snapshot.metadata['url'] 1844 path_format_arguments = { 1845 'url': self._serialize.url("self._config.url", self._config.url, 'str', skip_quote=True) 1846 } 1847 url = self._client.format_url(url, **path_format_arguments) 1848 1849 # Construct parameters 1850 query_parameters = {} 1851 if timeout is not None: 1852 query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int', minimum=0) 1853 query_parameters['comp'] = self._serialize.query("comp", comp, 'str') 1854 1855 # Construct headers 1856 header_parameters = {} 1857 if metadata is not None: 1858 header_parameters['x-ms-meta'] = self._serialize.header("metadata", metadata, 'str') 1859 header_parameters['x-ms-version'] = self._serialize.header("self._config.version", self._config.version, 'str') 1860 if request_id is not None: 1861 header_parameters['x-ms-client-request-id'] = self._serialize.header("request_id", request_id, 'str') 1862 if encryption_key is not None: 1863 header_parameters['x-ms-encryption-key'] = self._serialize.header("encryption_key", encryption_key, 'str') 1864 if encryption_key_sha256 is not None: 1865 header_parameters['x-ms-encryption-key-sha256'] = self._serialize.header("encryption_key_sha256", encryption_key_sha256, 'str') 1866 if encryption_algorithm is not None: 1867 header_parameters['x-ms-encryption-algorithm'] = self._serialize.header("encryption_algorithm", encryption_algorithm, 'EncryptionAlgorithmType') 1868 if if_modified_since is not None: 1869 header_parameters['If-Modified-Since'] = self._serialize.header("if_modified_since", if_modified_since, 'rfc-1123') 1870 if if_unmodified_since is not None: 1871 header_parameters['If-Unmodified-Since'] = self._serialize.header("if_unmodified_since", if_unmodified_since, 'rfc-1123') 1872 if if_match is not None: 1873 header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') 1874 if if_none_match is not None: 1875 header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str') 1876 if lease_id is not None: 1877 header_parameters['x-ms-lease-id'] = self._serialize.header("lease_id", lease_id, 'str') 1878 1879 # Construct and send request 1880 request = self._client.put(url, query_parameters, header_parameters) 1881 pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) 1882 response = pipeline_response.http_response 1883 1884 if response.status_code not in [201]: 1885 map_error(status_code=response.status_code, response=response, error_map=error_map) 1886 raise models.StorageErrorException(response, self._deserialize) 1887 1888 if cls: 1889 response_headers = { 1890 'x-ms-snapshot': self._deserialize('str', response.headers.get('x-ms-snapshot')), 1891 'ETag': self._deserialize('str', response.headers.get('ETag')), 1892 'Last-Modified': self._deserialize('rfc-1123', response.headers.get('Last-Modified')), 1893 'x-ms-client-request-id': self._deserialize('str', response.headers.get('x-ms-client-request-id')), 1894 'x-ms-request-id': self._deserialize('str', response.headers.get('x-ms-request-id')), 1895 'x-ms-version': self._deserialize('str', response.headers.get('x-ms-version')), 1896 'Date': self._deserialize('rfc-1123', response.headers.get('Date')), 1897 'x-ms-request-server-encrypted': self._deserialize('bool', response.headers.get('x-ms-request-server-encrypted')), 1898 'x-ms-error-code': self._deserialize('str', response.headers.get('x-ms-error-code')), 1899 } 1900 return cls(response, None, response_headers) 1901 create_snapshot.metadata = {'url': '/{containerName}/{blob}'} 1902 1903 def start_copy_from_url(self, copy_source, timeout=None, metadata=None, tier=None, rehydrate_priority=None, request_id=None, source_modified_access_conditions=None, modified_access_conditions=None, lease_access_conditions=None, cls=None, **kwargs): 1904 """The Start Copy From URL operation copies a blob or an internet resource 1905 to a new blob. 1906 1907 :param copy_source: Specifies the name of the source page blob 1908 snapshot. This value is a URL of up to 2 KB in length that specifies a 1909 page blob snapshot. The value should be URL-encoded as it would appear 1910 in a request URI. The source blob must either be public or must be 1911 authenticated via a shared access signature. 1912 :type copy_source: str 1913 :param timeout: The timeout parameter is expressed in seconds. For 1914 more information, see <a 1915 href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting 1916 Timeouts for Blob Service Operations.</a> 1917 :type timeout: int 1918 :param metadata: Optional. Specifies a user-defined name-value pair 1919 associated with the blob. If no name-value pairs are specified, the 1920 operation will copy the metadata from the source blob or file to the 1921 destination blob. If one or more name-value pairs are specified, the 1922 destination blob is created with the specified metadata, and metadata 1923 is not copied from the source blob or file. Note that beginning with 1924 version 2009-09-19, metadata names must adhere to the naming rules for 1925 C# identifiers. See Naming and Referencing Containers, Blobs, and 1926 Metadata for more information. 1927 :type metadata: str 1928 :param tier: Optional. Indicates the tier to be set on the blob. 1929 Possible values include: 'P4', 'P6', 'P10', 'P15', 'P20', 'P30', 1930 'P40', 'P50', 'P60', 'P70', 'P80', 'Hot', 'Cool', 'Archive' 1931 :type tier: str or ~azure.storage.blob.models.AccessTierOptional 1932 :param rehydrate_priority: Optional: Indicates the priority with which 1933 to rehydrate an archived blob. Possible values include: 'High', 1934 'Standard' 1935 :type rehydrate_priority: str or 1936 ~azure.storage.blob.models.RehydratePriority 1937 :param request_id: Provides a client-generated, opaque value with a 1 1938 KB character limit that is recorded in the analytics logs when storage 1939 analytics logging is enabled. 1940 :type request_id: str 1941 :param source_modified_access_conditions: Additional parameters for 1942 the operation 1943 :type source_modified_access_conditions: 1944 ~azure.storage.blob.models.SourceModifiedAccessConditions 1945 :param modified_access_conditions: Additional parameters for the 1946 operation 1947 :type modified_access_conditions: 1948 ~azure.storage.blob.models.ModifiedAccessConditions 1949 :param lease_access_conditions: Additional parameters for the 1950 operation 1951 :type lease_access_conditions: 1952 ~azure.storage.blob.models.LeaseAccessConditions 1953 :param callable cls: A custom type or function that will be passed the 1954 direct response 1955 :return: None or the result of cls(response) 1956 :rtype: None 1957 :raises: 1958 :class:`StorageErrorException<azure.storage.blob.models.StorageErrorException>` 1959 """ 1960 error_map = kwargs.pop('error_map', None) 1961 source_if_modified_since = None 1962 if source_modified_access_conditions is not None: 1963 source_if_modified_since = source_modified_access_conditions.source_if_modified_since 1964 source_if_unmodified_since = None 1965 if source_modified_access_conditions is not None: 1966 source_if_unmodified_since = source_modified_access_conditions.source_if_unmodified_since 1967 source_if_match = None 1968 if source_modified_access_conditions is not None: 1969 source_if_match = source_modified_access_conditions.source_if_match 1970 source_if_none_match = None 1971 if source_modified_access_conditions is not None: 1972 source_if_none_match = source_modified_access_conditions.source_if_none_match 1973 if_modified_since = None 1974 if modified_access_conditions is not None: 1975 if_modified_since = modified_access_conditions.if_modified_since 1976 if_unmodified_since = None 1977 if modified_access_conditions is not None: 1978 if_unmodified_since = modified_access_conditions.if_unmodified_since 1979 if_match = None 1980 if modified_access_conditions is not None: 1981 if_match = modified_access_conditions.if_match 1982 if_none_match = None 1983 if modified_access_conditions is not None: 1984 if_none_match = modified_access_conditions.if_none_match 1985 lease_id = None 1986 if lease_access_conditions is not None: 1987 lease_id = lease_access_conditions.lease_id 1988 1989 # Construct URL 1990 url = self.start_copy_from_url.metadata['url'] 1991 path_format_arguments = { 1992 'url': self._serialize.url("self._config.url", self._config.url, 'str', skip_quote=True) 1993 } 1994 url = self._client.format_url(url, **path_format_arguments) 1995 1996 # Construct parameters 1997 query_parameters = {} 1998 if timeout is not None: 1999 query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int', minimum=0) 2000 2001 # Construct headers 2002 header_parameters = {} 2003 if metadata is not None: 2004 header_parameters['x-ms-meta'] = self._serialize.header("metadata", metadata, 'str') 2005 if tier is not None: 2006 header_parameters['x-ms-access-tier'] = self._serialize.header("tier", tier, 'str') 2007 if rehydrate_priority is not None: 2008 header_parameters['x-ms-rehydrate-priority'] = self._serialize.header("rehydrate_priority", rehydrate_priority, 'str') 2009 header_parameters['x-ms-copy-source'] = self._serialize.header("copy_source", copy_source, 'str') 2010 header_parameters['x-ms-version'] = self._serialize.header("self._config.version", self._config.version, 'str') 2011 if request_id is not None: 2012 header_parameters['x-ms-client-request-id'] = self._serialize.header("request_id", request_id, 'str') 2013 if source_if_modified_since is not None: 2014 header_parameters['x-ms-source-if-modified-since'] = self._serialize.header("source_if_modified_since", source_if_modified_since, 'rfc-1123') 2015 if source_if_unmodified_since is not None: 2016 header_parameters['x-ms-source-if-unmodified-since'] = self._serialize.header("source_if_unmodified_since", source_if_unmodified_since, 'rfc-1123') 2017 if source_if_match is not None: 2018 header_parameters['x-ms-source-if-match'] = self._serialize.header("source_if_match", source_if_match, 'str') 2019 if source_if_none_match is not None: 2020 header_parameters['x-ms-source-if-none-match'] = self._serialize.header("source_if_none_match", source_if_none_match, 'str') 2021 if if_modified_since is not None: 2022 header_parameters['If-Modified-Since'] = self._serialize.header("if_modified_since", if_modified_since, 'rfc-1123') 2023 if if_unmodified_since is not None: 2024 header_parameters['If-Unmodified-Since'] = self._serialize.header("if_unmodified_since", if_unmodified_since, 'rfc-1123') 2025 if if_match is not None: 2026 header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') 2027 if if_none_match is not None: 2028 header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str') 2029 if lease_id is not None: 2030 header_parameters['x-ms-lease-id'] = self._serialize.header("lease_id", lease_id, 'str') 2031 2032 # Construct and send request 2033 request = self._client.put(url, query_parameters, header_parameters) 2034 pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) 2035 response = pipeline_response.http_response 2036 2037 if response.status_code not in [202]: 2038 map_error(status_code=response.status_code, response=response, error_map=error_map) 2039 raise models.StorageErrorException(response, self._deserialize) 2040 2041 if cls: 2042 response_headers = { 2043 'ETag': self._deserialize('str', response.headers.get('ETag')), 2044 'Last-Modified': self._deserialize('rfc-1123', response.headers.get('Last-Modified')), 2045 'x-ms-client-request-id': self._deserialize('str', response.headers.get('x-ms-client-request-id')), 2046 'x-ms-request-id': self._deserialize('str', response.headers.get('x-ms-request-id')), 2047 'x-ms-version': self._deserialize('str', response.headers.get('x-ms-version')), 2048 'Date': self._deserialize('rfc-1123', response.headers.get('Date')), 2049 'x-ms-copy-id': self._deserialize('str', response.headers.get('x-ms-copy-id')), 2050 'x-ms-copy-status': self._deserialize(models.CopyStatusType, response.headers.get('x-ms-copy-status')), 2051 'x-ms-error-code': self._deserialize('str', response.headers.get('x-ms-error-code')), 2052 } 2053 return cls(response, None, response_headers) 2054 start_copy_from_url.metadata = {'url': '/{containerName}/{blob}'} 2055 2056 def copy_from_url(self, copy_source, timeout=None, metadata=None, tier=None, request_id=None, source_modified_access_conditions=None, modified_access_conditions=None, lease_access_conditions=None, cls=None, **kwargs): 2057 """The Copy From URL operation copies a blob or an internet resource to a 2058 new blob. It will not return a response until the copy is complete. 2059 2060 :param copy_source: Specifies the name of the source page blob 2061 snapshot. This value is a URL of up to 2 KB in length that specifies a 2062 page blob snapshot. The value should be URL-encoded as it would appear 2063 in a request URI. The source blob must either be public or must be 2064 authenticated via a shared access signature. 2065 :type copy_source: str 2066 :param timeout: The timeout parameter is expressed in seconds. For 2067 more information, see <a 2068 href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting 2069 Timeouts for Blob Service Operations.</a> 2070 :type timeout: int 2071 :param metadata: Optional. Specifies a user-defined name-value pair 2072 associated with the blob. If no name-value pairs are specified, the 2073 operation will copy the metadata from the source blob or file to the 2074 destination blob. If one or more name-value pairs are specified, the 2075 destination blob is created with the specified metadata, and metadata 2076 is not copied from the source blob or file. Note that beginning with 2077 version 2009-09-19, metadata names must adhere to the naming rules for 2078 C# identifiers. See Naming and Referencing Containers, Blobs, and 2079 Metadata for more information. 2080 :type metadata: str 2081 :param tier: Optional. Indicates the tier to be set on the blob. 2082 Possible values include: 'P4', 'P6', 'P10', 'P15', 'P20', 'P30', 2083 'P40', 'P50', 'P60', 'P70', 'P80', 'Hot', 'Cool', 'Archive' 2084 :type tier: str or ~azure.storage.blob.models.AccessTierOptional 2085 :param request_id: Provides a client-generated, opaque value with a 1 2086 KB character limit that is recorded in the analytics logs when storage 2087 analytics logging is enabled. 2088 :type request_id: str 2089 :param source_modified_access_conditions: Additional parameters for 2090 the operation 2091 :type source_modified_access_conditions: 2092 ~azure.storage.blob.models.SourceModifiedAccessConditions 2093 :param modified_access_conditions: Additional parameters for the 2094 operation 2095 :type modified_access_conditions: 2096 ~azure.storage.blob.models.ModifiedAccessConditions 2097 :param lease_access_conditions: Additional parameters for the 2098 operation 2099 :type lease_access_conditions: 2100 ~azure.storage.blob.models.LeaseAccessConditions 2101 :param callable cls: A custom type or function that will be passed the 2102 direct response 2103 :return: None or the result of cls(response) 2104 :rtype: None 2105 :raises: 2106 :class:`StorageErrorException<azure.storage.blob.models.StorageErrorException>` 2107 """ 2108 error_map = kwargs.pop('error_map', None) 2109 source_if_modified_since = None 2110 if source_modified_access_conditions is not None: 2111 source_if_modified_since = source_modified_access_conditions.source_if_modified_since 2112 source_if_unmodified_since = None 2113 if source_modified_access_conditions is not None: 2114 source_if_unmodified_since = source_modified_access_conditions.source_if_unmodified_since 2115 source_if_match = None 2116 if source_modified_access_conditions is not None: 2117 source_if_match = source_modified_access_conditions.source_if_match 2118 source_if_none_match = None 2119 if source_modified_access_conditions is not None: 2120 source_if_none_match = source_modified_access_conditions.source_if_none_match 2121 if_modified_since = None 2122 if modified_access_conditions is not None: 2123 if_modified_since = modified_access_conditions.if_modified_since 2124 if_unmodified_since = None 2125 if modified_access_conditions is not None: 2126 if_unmodified_since = modified_access_conditions.if_unmodified_since 2127 if_match = None 2128 if modified_access_conditions is not None: 2129 if_match = modified_access_conditions.if_match 2130 if_none_match = None 2131 if modified_access_conditions is not None: 2132 if_none_match = modified_access_conditions.if_none_match 2133 lease_id = None 2134 if lease_access_conditions is not None: 2135 lease_id = lease_access_conditions.lease_id 2136 2137 # Construct URL 2138 url = self.copy_from_url.metadata['url'] 2139 path_format_arguments = { 2140 'url': self._serialize.url("self._config.url", self._config.url, 'str', skip_quote=True) 2141 } 2142 url = self._client.format_url(url, **path_format_arguments) 2143 2144 # Construct parameters 2145 query_parameters = {} 2146 if timeout is not None: 2147 query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int', minimum=0) 2148 2149 # Construct headers 2150 header_parameters = {} 2151 if metadata is not None: 2152 header_parameters['x-ms-meta'] = self._serialize.header("metadata", metadata, 'str') 2153 if tier is not None: 2154 header_parameters['x-ms-access-tier'] = self._serialize.header("tier", tier, 'str') 2155 header_parameters['x-ms-copy-source'] = self._serialize.header("copy_source", copy_source, 'str') 2156 header_parameters['x-ms-version'] = self._serialize.header("self._config.version", self._config.version, 'str') 2157 if request_id is not None: 2158 header_parameters['x-ms-client-request-id'] = self._serialize.header("request_id", request_id, 'str') 2159 header_parameters['x-ms-requires-sync'] = self._serialize.header("self.x_ms_requires_sync", self.x_ms_requires_sync, 'str') 2160 if source_if_modified_since is not None: 2161 header_parameters['x-ms-source-if-modified-since'] = self._serialize.header("source_if_modified_since", source_if_modified_since, 'rfc-1123') 2162 if source_if_unmodified_since is not None: 2163 header_parameters['x-ms-source-if-unmodified-since'] = self._serialize.header("source_if_unmodified_since", source_if_unmodified_since, 'rfc-1123') 2164 if source_if_match is not None: 2165 header_parameters['x-ms-source-if-match'] = self._serialize.header("source_if_match", source_if_match, 'str') 2166 if source_if_none_match is not None: 2167 header_parameters['x-ms-source-if-none-match'] = self._serialize.header("source_if_none_match", source_if_none_match, 'str') 2168 if if_modified_since is not None: 2169 header_parameters['If-Modified-Since'] = self._serialize.header("if_modified_since", if_modified_since, 'rfc-1123') 2170 if if_unmodified_since is not None: 2171 header_parameters['If-Unmodified-Since'] = self._serialize.header("if_unmodified_since", if_unmodified_since, 'rfc-1123') 2172 if if_match is not None: 2173 header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') 2174 if if_none_match is not None: 2175 header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str') 2176 if lease_id is not None: 2177 header_parameters['x-ms-lease-id'] = self._serialize.header("lease_id", lease_id, 'str') 2178 2179 # Construct and send request 2180 request = self._client.put(url, query_parameters, header_parameters) 2181 pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) 2182 response = pipeline_response.http_response 2183 2184 if response.status_code not in [202]: 2185 map_error(status_code=response.status_code, response=response, error_map=error_map) 2186 raise models.StorageErrorException(response, self._deserialize) 2187 2188 if cls: 2189 response_headers = { 2190 'ETag': self._deserialize('str', response.headers.get('ETag')), 2191 'Last-Modified': self._deserialize('rfc-1123', response.headers.get('Last-Modified')), 2192 'x-ms-client-request-id': self._deserialize('str', response.headers.get('x-ms-client-request-id')), 2193 'x-ms-request-id': self._deserialize('str', response.headers.get('x-ms-request-id')), 2194 'x-ms-version': self._deserialize('str', response.headers.get('x-ms-version')), 2195 'Date': self._deserialize('rfc-1123', response.headers.get('Date')), 2196 'x-ms-copy-id': self._deserialize('str', response.headers.get('x-ms-copy-id')), 2197 'x-ms-copy-status': self._deserialize(models.SyncCopyStatusType, response.headers.get('x-ms-copy-status')), 2198 'x-ms-error-code': self._deserialize('str', response.headers.get('x-ms-error-code')), 2199 } 2200 return cls(response, None, response_headers) 2201 copy_from_url.metadata = {'url': '/{containerName}/{blob}'} 2202 2203 def abort_copy_from_url(self, copy_id, timeout=None, request_id=None, lease_access_conditions=None, cls=None, **kwargs): 2204 """The Abort Copy From URL operation aborts a pending Copy From URL 2205 operation, and leaves a destination blob with zero length and full 2206 metadata. 2207 2208 :param copy_id: The copy identifier provided in the x-ms-copy-id 2209 header of the original Copy Blob operation. 2210 :type copy_id: str 2211 :param timeout: The timeout parameter is expressed in seconds. For 2212 more information, see <a 2213 href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting 2214 Timeouts for Blob Service Operations.</a> 2215 :type timeout: int 2216 :param request_id: Provides a client-generated, opaque value with a 1 2217 KB character limit that is recorded in the analytics logs when storage 2218 analytics logging is enabled. 2219 :type request_id: str 2220 :param lease_access_conditions: Additional parameters for the 2221 operation 2222 :type lease_access_conditions: 2223 ~azure.storage.blob.models.LeaseAccessConditions 2224 :param callable cls: A custom type or function that will be passed the 2225 direct response 2226 :return: None or the result of cls(response) 2227 :rtype: None 2228 :raises: 2229 :class:`StorageErrorException<azure.storage.blob.models.StorageErrorException>` 2230 """ 2231 error_map = kwargs.pop('error_map', None) 2232 lease_id = None 2233 if lease_access_conditions is not None: 2234 lease_id = lease_access_conditions.lease_id 2235 2236 comp = "copy" 2237 2238 # Construct URL 2239 url = self.abort_copy_from_url.metadata['url'] 2240 path_format_arguments = { 2241 'url': self._serialize.url("self._config.url", self._config.url, 'str', skip_quote=True) 2242 } 2243 url = self._client.format_url(url, **path_format_arguments) 2244 2245 # Construct parameters 2246 query_parameters = {} 2247 query_parameters['copyid'] = self._serialize.query("copy_id", copy_id, 'str') 2248 if timeout is not None: 2249 query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int', minimum=0) 2250 query_parameters['comp'] = self._serialize.query("comp", comp, 'str') 2251 2252 # Construct headers 2253 header_parameters = {} 2254 header_parameters['x-ms-version'] = self._serialize.header("self._config.version", self._config.version, 'str') 2255 if request_id is not None: 2256 header_parameters['x-ms-client-request-id'] = self._serialize.header("request_id", request_id, 'str') 2257 header_parameters['x-ms-copy-action'] = self._serialize.header("self.x_ms_copy_action", self.x_ms_copy_action, 'str') 2258 if lease_id is not None: 2259 header_parameters['x-ms-lease-id'] = self._serialize.header("lease_id", lease_id, 'str') 2260 2261 # Construct and send request 2262 request = self._client.put(url, query_parameters, header_parameters) 2263 pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) 2264 response = pipeline_response.http_response 2265 2266 if response.status_code not in [204]: 2267 map_error(status_code=response.status_code, response=response, error_map=error_map) 2268 raise models.StorageErrorException(response, self._deserialize) 2269 2270 if cls: 2271 response_headers = { 2272 'x-ms-client-request-id': self._deserialize('str', response.headers.get('x-ms-client-request-id')), 2273 'x-ms-request-id': self._deserialize('str', response.headers.get('x-ms-request-id')), 2274 'x-ms-version': self._deserialize('str', response.headers.get('x-ms-version')), 2275 'Date': self._deserialize('rfc-1123', response.headers.get('Date')), 2276 'x-ms-error-code': self._deserialize('str', response.headers.get('x-ms-error-code')), 2277 } 2278 return cls(response, None, response_headers) 2279 abort_copy_from_url.metadata = {'url': '/{containerName}/{blob}'} 2280 2281 def set_tier(self, tier, timeout=None, rehydrate_priority=None, request_id=None, lease_access_conditions=None, cls=None, **kwargs): 2282 """The Set Tier operation sets the tier on a blob. The operation is 2283 allowed on a page blob in a premium storage account and on a block blob 2284 in a blob storage account (locally redundant storage only). A premium 2285 page blob's tier determines the allowed size, IOPS, and bandwidth of 2286 the blob. A block blob's tier determines Hot/Cool/Archive storage type. 2287 This operation does not update the blob's ETag. 2288 2289 :param tier: Indicates the tier to be set on the blob. Possible values 2290 include: 'P4', 'P6', 'P10', 'P15', 'P20', 'P30', 'P40', 'P50', 'P60', 2291 'P70', 'P80', 'Hot', 'Cool', 'Archive' 2292 :type tier: str or ~azure.storage.blob.models.AccessTierRequired 2293 :param timeout: The timeout parameter is expressed in seconds. For 2294 more information, see <a 2295 href="https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/setting-timeouts-for-blob-service-operations">Setting 2296 Timeouts for Blob Service Operations.</a> 2297 :type timeout: int 2298 :param rehydrate_priority: Optional: Indicates the priority with which 2299 to rehydrate an archived blob. Possible values include: 'High', 2300 'Standard' 2301 :type rehydrate_priority: str or 2302 ~azure.storage.blob.models.RehydratePriority 2303 :param request_id: Provides a client-generated, opaque value with a 1 2304 KB character limit that is recorded in the analytics logs when storage 2305 analytics logging is enabled. 2306 :type request_id: str 2307 :param lease_access_conditions: Additional parameters for the 2308 operation 2309 :type lease_access_conditions: 2310 ~azure.storage.blob.models.LeaseAccessConditions 2311 :param callable cls: A custom type or function that will be passed the 2312 direct response 2313 :return: None or the result of cls(response) 2314 :rtype: None 2315 :raises: 2316 :class:`StorageErrorException<azure.storage.blob.models.StorageErrorException>` 2317 """ 2318 error_map = kwargs.pop('error_map', None) 2319 lease_id = None 2320 if lease_access_conditions is not None: 2321 lease_id = lease_access_conditions.lease_id 2322 2323 comp = "tier" 2324 2325 # Construct URL 2326 url = self.set_tier.metadata['url'] 2327 path_format_arguments = { 2328 'url': self._serialize.url("self._config.url", self._config.url, 'str', skip_quote=True) 2329 } 2330 url = self._client.format_url(url, **path_format_arguments) 2331 2332 # Construct parameters 2333 query_parameters = {} 2334 if timeout is not None: 2335 query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int', minimum=0) 2336 query_parameters['comp'] = self._serialize.query("comp", comp, 'str') 2337 2338 # Construct headers 2339 header_parameters = {} 2340 header_parameters['x-ms-access-tier'] = self._serialize.header("tier", tier, 'str') 2341 if rehydrate_priority is not None: 2342 header_parameters['x-ms-rehydrate-priority'] = self._serialize.header("rehydrate_priority", rehydrate_priority, 'str') 2343 header_parameters['x-ms-version'] = self._serialize.header("self._config.version", self._config.version, 'str') 2344 if request_id is not None: 2345 header_parameters['x-ms-client-request-id'] = self._serialize.header("request_id", request_id, 'str') 2346 if lease_id is not None: 2347 header_parameters['x-ms-lease-id'] = self._serialize.header("lease_id", lease_id, 'str') 2348 2349 # Construct and send request 2350 request = self._client.put(url, query_parameters, header_parameters) 2351 pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) 2352 response = pipeline_response.http_response 2353 2354 if response.status_code not in [200, 202]: 2355 map_error(status_code=response.status_code, response=response, error_map=error_map) 2356 raise models.StorageErrorException(response, self._deserialize) 2357 2358 if cls: 2359 response_headers = { 2360 'x-ms-client-request-id': self._deserialize('str', response.headers.get('x-ms-client-request-id')), 2361 'x-ms-request-id': self._deserialize('str', response.headers.get('x-ms-request-id')), 2362 'x-ms-version': self._deserialize('str', response.headers.get('x-ms-version')), 2363 'x-ms-error-code': self._deserialize('str', response.headers.get('x-ms-error-code')), 2364 } 2365 return cls(response, None, response_headers) 2366 set_tier.metadata = {'url': '/{containerName}/{blob}'} 2367 2368 def get_account_info(self, cls=None, **kwargs): 2369 """Returns the sku name and account kind . 2370 2371 :param callable cls: A custom type or function that will be passed the 2372 direct response 2373 :return: None or the result of cls(response) 2374 :rtype: None 2375 :raises: 2376 :class:`StorageErrorException<azure.storage.blob.models.StorageErrorException>` 2377 """ 2378 error_map = kwargs.pop('error_map', None) 2379 comp = "properties" 2380 2381 # Construct URL 2382 url = self.get_account_info.metadata['url'] 2383 path_format_arguments = { 2384 'url': self._serialize.url("self._config.url", self._config.url, 'str', skip_quote=True) 2385 } 2386 url = self._client.format_url(url, **path_format_arguments) 2387 2388 # Construct parameters 2389 query_parameters = {} 2390 query_parameters['restype'] = self._serialize.query("self.restype", self.restype, 'str') 2391 query_parameters['comp'] = self._serialize.query("comp", comp, 'str') 2392 2393 # Construct headers 2394 header_parameters = {} 2395 header_parameters['x-ms-version'] = self._serialize.header("self._config.version", self._config.version, 'str') 2396 2397 # Construct and send request 2398 request = self._client.get(url, query_parameters, header_parameters) 2399 pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) 2400 response = pipeline_response.http_response 2401 2402 if response.status_code not in [200]: 2403 map_error(status_code=response.status_code, response=response, error_map=error_map) 2404 raise models.StorageErrorException(response, self._deserialize) 2405 2406 if cls: 2407 response_headers = { 2408 'x-ms-client-request-id': self._deserialize('str', response.headers.get('x-ms-client-request-id')), 2409 'x-ms-request-id': self._deserialize('str', response.headers.get('x-ms-request-id')), 2410 'x-ms-version': self._deserialize('str', response.headers.get('x-ms-version')), 2411 'Date': self._deserialize('rfc-1123', response.headers.get('Date')), 2412 'x-ms-sku-name': self._deserialize(models.SkuName, response.headers.get('x-ms-sku-name')), 2413 'x-ms-account-kind': self._deserialize(models.AccountKind, response.headers.get('x-ms-account-kind')), 2414 'x-ms-error-code': self._deserialize('str', response.headers.get('x-ms-error-code')), 2415 } 2416 return cls(response, None, response_headers) 2417 get_account_info.metadata = {'url': '/{containerName}/{blob}'} 2418