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 FileOperations(object): 18 """FileOperations 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_type: Dummy constant parameter, file type can only be file. Constant value: "file". 27 :ivar x_ms_copy_action: . Constant value: "abort". 28 """ 29 30 models = models 31 32 def __init__(self, client, config, serializer, deserializer): 33 34 self._client = client 35 self._serialize = serializer 36 self._deserialize = deserializer 37 38 self._config = config 39 self.x_ms_type = "file" 40 self.x_ms_copy_action = "abort" 41 42 def create(self, file_content_length, file_attributes="none", file_creation_time="now", file_last_write_time="now", timeout=None, metadata=None, file_permission="inherit", file_permission_key=None, file_http_headers=None, lease_access_conditions=None, cls=None, **kwargs): 43 """Creates a new file or replaces a file. Note it only initializes the 44 file with no content. 45 46 :param file_content_length: Specifies the maximum size for the file, 47 up to 4 TB. 48 :type file_content_length: long 49 :param file_attributes: If specified, the provided file attributes 50 shall be set. Default value: ‘Archive’ for file and ‘Directory’ for 51 directory. ‘None’ can also be specified as default. 52 :type file_attributes: str 53 :param file_creation_time: Creation time for the file/directory. 54 Default value: Now. 55 :type file_creation_time: str 56 :param file_last_write_time: Last write time for the file/directory. 57 Default value: Now. 58 :type file_last_write_time: str 59 :param timeout: The timeout parameter is expressed in seconds. For 60 more information, see <a 61 href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting 62 Timeouts for File Service Operations.</a> 63 :type timeout: int 64 :param metadata: A name-value pair to associate with a file storage 65 object. 66 :type metadata: str 67 :param file_permission: If specified the permission (security 68 descriptor) shall be set for the directory/file. This header can be 69 used if Permission size is <= 8KB, else x-ms-file-permission-key 70 header shall be used. Default value: Inherit. If SDDL is specified as 71 input, it must have owner, group and dacl. Note: Only one of the 72 x-ms-file-permission or x-ms-file-permission-key should be specified. 73 :type file_permission: str 74 :param file_permission_key: Key of the permission to be set for the 75 directory/file. Note: Only one of the x-ms-file-permission or 76 x-ms-file-permission-key should be specified. 77 :type file_permission_key: str 78 :param file_http_headers: Additional parameters for the operation 79 :type file_http_headers: 80 ~azure.storage.fileshare.models.FileHTTPHeaders 81 :param lease_access_conditions: Additional parameters for the 82 operation 83 :type lease_access_conditions: 84 ~azure.storage.fileshare.models.LeaseAccessConditions 85 :param callable cls: A custom type or function that will be passed the 86 direct response 87 :return: None or the result of cls(response) 88 :rtype: None 89 :raises: 90 :class:`StorageErrorException<azure.storage.fileshare.models.StorageErrorException>` 91 """ 92 error_map = kwargs.pop('error_map', None) 93 file_content_type = None 94 if file_http_headers is not None: 95 file_content_type = file_http_headers.file_content_type 96 file_content_encoding = None 97 if file_http_headers is not None: 98 file_content_encoding = file_http_headers.file_content_encoding 99 file_content_language = None 100 if file_http_headers is not None: 101 file_content_language = file_http_headers.file_content_language 102 file_cache_control = None 103 if file_http_headers is not None: 104 file_cache_control = file_http_headers.file_cache_control 105 file_content_md5 = None 106 if file_http_headers is not None: 107 file_content_md5 = file_http_headers.file_content_md5 108 file_content_disposition = None 109 if file_http_headers is not None: 110 file_content_disposition = file_http_headers.file_content_disposition 111 lease_id = None 112 if lease_access_conditions is not None: 113 lease_id = lease_access_conditions.lease_id 114 115 # Construct URL 116 url = self.create.metadata['url'] 117 path_format_arguments = { 118 'url': self._serialize.url("self._config.url", self._config.url, 'str', skip_quote=True) 119 } 120 url = self._client.format_url(url, **path_format_arguments) 121 122 # Construct parameters 123 query_parameters = {} 124 if timeout is not None: 125 query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int', minimum=0) 126 127 # Construct headers 128 header_parameters = {} 129 header_parameters['x-ms-version'] = self._serialize.header("self._config.version", self._config.version, 'str') 130 header_parameters['x-ms-content-length'] = self._serialize.header("file_content_length", file_content_length, 'long') 131 header_parameters['x-ms-type'] = self._serialize.header("self.x_ms_type", self.x_ms_type, 'str') 132 if metadata is not None: 133 header_parameters['x-ms-meta'] = self._serialize.header("metadata", metadata, 'str') 134 if file_permission is not None: 135 header_parameters['x-ms-file-permission'] = self._serialize.header("file_permission", file_permission, 'str') 136 if file_permission_key is not None: 137 header_parameters['x-ms-file-permission-key'] = self._serialize.header("file_permission_key", file_permission_key, 'str') 138 header_parameters['x-ms-file-attributes'] = self._serialize.header("file_attributes", file_attributes, 'str') 139 header_parameters['x-ms-file-creation-time'] = self._serialize.header("file_creation_time", file_creation_time, 'str') 140 header_parameters['x-ms-file-last-write-time'] = self._serialize.header("file_last_write_time", file_last_write_time, 'str') 141 if file_content_type is not None: 142 header_parameters['x-ms-content-type'] = self._serialize.header("file_content_type", file_content_type, 'str') 143 if file_content_encoding is not None: 144 header_parameters['x-ms-content-encoding'] = self._serialize.header("file_content_encoding", file_content_encoding, 'str') 145 if file_content_language is not None: 146 header_parameters['x-ms-content-language'] = self._serialize.header("file_content_language", file_content_language, 'str') 147 if file_cache_control is not None: 148 header_parameters['x-ms-cache-control'] = self._serialize.header("file_cache_control", file_cache_control, 'str') 149 if file_content_md5 is not None: 150 header_parameters['x-ms-content-md5'] = self._serialize.header("file_content_md5", file_content_md5, 'bytearray') 151 if file_content_disposition is not None: 152 header_parameters['x-ms-content-disposition'] = self._serialize.header("file_content_disposition", file_content_disposition, 'str') 153 if lease_id is not None: 154 header_parameters['x-ms-lease-id'] = self._serialize.header("lease_id", lease_id, 'str') 155 156 # Construct and send request 157 request = self._client.put(url, query_parameters, header_parameters) 158 pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) 159 response = pipeline_response.http_response 160 161 if response.status_code not in [201]: 162 map_error(status_code=response.status_code, response=response, error_map=error_map) 163 raise models.StorageErrorException(response, self._deserialize) 164 165 if cls: 166 response_headers = { 167 'ETag': self._deserialize('str', response.headers.get('ETag')), 168 'Last-Modified': self._deserialize('rfc-1123', response.headers.get('Last-Modified')), 169 'x-ms-request-id': self._deserialize('str', response.headers.get('x-ms-request-id')), 170 'x-ms-version': self._deserialize('str', response.headers.get('x-ms-version')), 171 'Date': self._deserialize('rfc-1123', response.headers.get('Date')), 172 'x-ms-request-server-encrypted': self._deserialize('bool', response.headers.get('x-ms-request-server-encrypted')), 173 'x-ms-file-permission-key': self._deserialize('str', response.headers.get('x-ms-file-permission-key')), 174 'x-ms-file-attributes': self._deserialize('str', response.headers.get('x-ms-file-attributes')), 175 'x-ms-file-creation-time': self._deserialize('str', response.headers.get('x-ms-file-creation-time')), 176 'x-ms-file-last-write-time': self._deserialize('str', response.headers.get('x-ms-file-last-write-time')), 177 'x-ms-file-change-time': self._deserialize('str', response.headers.get('x-ms-file-change-time')), 178 'x-ms-file-id': self._deserialize('str', response.headers.get('x-ms-file-id')), 179 'x-ms-file-parent-id': self._deserialize('str', response.headers.get('x-ms-file-parent-id')), 180 'x-ms-error-code': self._deserialize('str', response.headers.get('x-ms-error-code')), 181 } 182 return cls(response, None, response_headers) 183 create.metadata = {'url': '/{shareName}/{directory}/{fileName}'} 184 185 def download(self, timeout=None, range=None, range_get_content_md5=None, lease_access_conditions=None, cls=None, **kwargs): 186 """Reads or downloads a file from the system, including its metadata and 187 properties. 188 189 :param timeout: The timeout parameter is expressed in seconds. For 190 more information, see <a 191 href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting 192 Timeouts for File Service Operations.</a> 193 :type timeout: int 194 :param range: Return file data only from the specified byte range. 195 :type range: str 196 :param range_get_content_md5: When this header is set to true and 197 specified together with the Range header, the service returns the MD5 198 hash for the range, as long as the range is less than or equal to 4 MB 199 in size. 200 :type range_get_content_md5: bool 201 :param lease_access_conditions: Additional parameters for the 202 operation 203 :type lease_access_conditions: 204 ~azure.storage.fileshare.models.LeaseAccessConditions 205 :param callable cls: A custom type or function that will be passed the 206 direct response 207 :return: object or the result of cls(response) 208 :rtype: Generator 209 :raises: 210 :class:`StorageErrorException<azure.storage.fileshare.models.StorageErrorException>` 211 """ 212 error_map = kwargs.pop('error_map', None) 213 lease_id = None 214 if lease_access_conditions is not None: 215 lease_id = lease_access_conditions.lease_id 216 217 # Construct URL 218 url = self.download.metadata['url'] 219 path_format_arguments = { 220 'url': self._serialize.url("self._config.url", self._config.url, 'str', skip_quote=True) 221 } 222 url = self._client.format_url(url, **path_format_arguments) 223 224 # Construct parameters 225 query_parameters = {} 226 if timeout is not None: 227 query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int', minimum=0) 228 229 # Construct headers 230 header_parameters = {} 231 header_parameters['Accept'] = 'application/xml' 232 header_parameters['x-ms-version'] = self._serialize.header("self._config.version", self._config.version, 'str') 233 if range is not None: 234 header_parameters['x-ms-range'] = self._serialize.header("range", range, 'str') 235 if range_get_content_md5 is not None: 236 header_parameters['x-ms-range-get-content-md5'] = self._serialize.header("range_get_content_md5", range_get_content_md5, 'bool') 237 if lease_id is not None: 238 header_parameters['x-ms-lease-id'] = self._serialize.header("lease_id", lease_id, 'str') 239 240 # Construct and send request 241 request = self._client.get(url, query_parameters, header_parameters) 242 pipeline_response = self._client._pipeline.run(request, stream=True, **kwargs) 243 response = pipeline_response.http_response 244 245 if response.status_code not in [200, 206]: 246 map_error(status_code=response.status_code, response=response, error_map=error_map) 247 raise models.StorageErrorException(response, self._deserialize) 248 249 header_dict = {} 250 deserialized = None 251 if response.status_code == 200: 252 deserialized = response.stream_download(self._client._pipeline) 253 header_dict = { 254 'Last-Modified': self._deserialize('rfc-1123', response.headers.get('Last-Modified')), 255 'x-ms-meta': self._deserialize('{str}', response.headers.get('x-ms-meta')), 256 'Content-Length': self._deserialize('long', response.headers.get('Content-Length')), 257 'Content-Type': self._deserialize('str', response.headers.get('Content-Type')), 258 'Content-Range': self._deserialize('str', response.headers.get('Content-Range')), 259 'ETag': self._deserialize('str', response.headers.get('ETag')), 260 'Content-MD5': self._deserialize('bytearray', response.headers.get('Content-MD5')), 261 'Content-Encoding': self._deserialize('str', response.headers.get('Content-Encoding')), 262 'Cache-Control': self._deserialize('str', response.headers.get('Cache-Control')), 263 'Content-Disposition': self._deserialize('str', response.headers.get('Content-Disposition')), 264 'Content-Language': self._deserialize('str', response.headers.get('Content-Language')), 265 'x-ms-request-id': self._deserialize('str', response.headers.get('x-ms-request-id')), 266 'x-ms-version': self._deserialize('str', response.headers.get('x-ms-version')), 267 'Accept-Ranges': self._deserialize('str', response.headers.get('Accept-Ranges')), 268 'Date': self._deserialize('rfc-1123', response.headers.get('Date')), 269 'x-ms-copy-completion-time': self._deserialize('rfc-1123', response.headers.get('x-ms-copy-completion-time')), 270 'x-ms-copy-status-description': self._deserialize('str', response.headers.get('x-ms-copy-status-description')), 271 'x-ms-copy-id': self._deserialize('str', response.headers.get('x-ms-copy-id')), 272 'x-ms-copy-progress': self._deserialize('str', response.headers.get('x-ms-copy-progress')), 273 'x-ms-copy-source': self._deserialize('str', response.headers.get('x-ms-copy-source')), 274 'x-ms-copy-status': self._deserialize(models.CopyStatusType, response.headers.get('x-ms-copy-status')), 275 'x-ms-content-md5': self._deserialize('bytearray', response.headers.get('x-ms-content-md5')), 276 'x-ms-server-encrypted': self._deserialize('bool', response.headers.get('x-ms-server-encrypted')), 277 'x-ms-file-attributes': self._deserialize('str', response.headers.get('x-ms-file-attributes')), 278 'x-ms-file-creation-time': self._deserialize('str', response.headers.get('x-ms-file-creation-time')), 279 'x-ms-file-last-write-time': self._deserialize('str', response.headers.get('x-ms-file-last-write-time')), 280 'x-ms-file-change-time': self._deserialize('str', response.headers.get('x-ms-file-change-time')), 281 'x-ms-file-permission-key': self._deserialize('str', response.headers.get('x-ms-file-permission-key')), 282 'x-ms-file-id': self._deserialize('str', response.headers.get('x-ms-file-id')), 283 'x-ms-file-parent-id': self._deserialize('str', response.headers.get('x-ms-file-parent-id')), 284 'x-ms-lease-duration': self._deserialize(models.LeaseDurationType, response.headers.get('x-ms-lease-duration')), 285 'x-ms-lease-state': self._deserialize(models.LeaseStateType, response.headers.get('x-ms-lease-state')), 286 'x-ms-lease-status': self._deserialize(models.LeaseStatusType, response.headers.get('x-ms-lease-status')), 287 'x-ms-error-code': self._deserialize('str', response.headers.get('x-ms-error-code')), 288 } 289 if response.status_code == 206: 290 deserialized = response.stream_download(self._client._pipeline) 291 header_dict = { 292 'Last-Modified': self._deserialize('rfc-1123', response.headers.get('Last-Modified')), 293 'x-ms-meta': self._deserialize('{str}', response.headers.get('x-ms-meta')), 294 'Content-Length': self._deserialize('long', response.headers.get('Content-Length')), 295 'Content-Type': self._deserialize('str', response.headers.get('Content-Type')), 296 'Content-Range': self._deserialize('str', response.headers.get('Content-Range')), 297 'ETag': self._deserialize('str', response.headers.get('ETag')), 298 'Content-MD5': self._deserialize('bytearray', response.headers.get('Content-MD5')), 299 'Content-Encoding': self._deserialize('str', response.headers.get('Content-Encoding')), 300 'Cache-Control': self._deserialize('str', response.headers.get('Cache-Control')), 301 'Content-Disposition': self._deserialize('str', response.headers.get('Content-Disposition')), 302 'Content-Language': self._deserialize('str', response.headers.get('Content-Language')), 303 'x-ms-request-id': self._deserialize('str', response.headers.get('x-ms-request-id')), 304 'x-ms-version': self._deserialize('str', response.headers.get('x-ms-version')), 305 'Accept-Ranges': self._deserialize('str', response.headers.get('Accept-Ranges')), 306 'Date': self._deserialize('rfc-1123', response.headers.get('Date')), 307 'x-ms-copy-completion-time': self._deserialize('rfc-1123', response.headers.get('x-ms-copy-completion-time')), 308 'x-ms-copy-status-description': self._deserialize('str', response.headers.get('x-ms-copy-status-description')), 309 'x-ms-copy-id': self._deserialize('str', response.headers.get('x-ms-copy-id')), 310 'x-ms-copy-progress': self._deserialize('str', response.headers.get('x-ms-copy-progress')), 311 'x-ms-copy-source': self._deserialize('str', response.headers.get('x-ms-copy-source')), 312 'x-ms-copy-status': self._deserialize(models.CopyStatusType, response.headers.get('x-ms-copy-status')), 313 'x-ms-content-md5': self._deserialize('bytearray', response.headers.get('x-ms-content-md5')), 314 'x-ms-server-encrypted': self._deserialize('bool', response.headers.get('x-ms-server-encrypted')), 315 'x-ms-file-attributes': self._deserialize('str', response.headers.get('x-ms-file-attributes')), 316 'x-ms-file-creation-time': self._deserialize('str', response.headers.get('x-ms-file-creation-time')), 317 'x-ms-file-last-write-time': self._deserialize('str', response.headers.get('x-ms-file-last-write-time')), 318 'x-ms-file-change-time': self._deserialize('str', response.headers.get('x-ms-file-change-time')), 319 'x-ms-file-permission-key': self._deserialize('str', response.headers.get('x-ms-file-permission-key')), 320 'x-ms-file-id': self._deserialize('str', response.headers.get('x-ms-file-id')), 321 'x-ms-file-parent-id': self._deserialize('str', response.headers.get('x-ms-file-parent-id')), 322 'x-ms-lease-duration': self._deserialize(models.LeaseDurationType, response.headers.get('x-ms-lease-duration')), 323 'x-ms-lease-state': self._deserialize(models.LeaseStateType, response.headers.get('x-ms-lease-state')), 324 'x-ms-lease-status': self._deserialize(models.LeaseStatusType, response.headers.get('x-ms-lease-status')), 325 'x-ms-error-code': self._deserialize('str', response.headers.get('x-ms-error-code')), 326 } 327 328 if cls: 329 return cls(response, deserialized, header_dict) 330 331 return deserialized 332 download.metadata = {'url': '/{shareName}/{directory}/{fileName}'} 333 334 def get_properties(self, sharesnapshot=None, timeout=None, lease_access_conditions=None, cls=None, **kwargs): 335 """Returns all user-defined metadata, standard HTTP properties, and system 336 properties for the file. It does not return the content of the file. 337 338 :param sharesnapshot: The snapshot parameter is an opaque DateTime 339 value that, when present, specifies the share snapshot to query. 340 :type sharesnapshot: str 341 :param timeout: The timeout parameter is expressed in seconds. For 342 more information, see <a 343 href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting 344 Timeouts for File Service Operations.</a> 345 :type timeout: int 346 :param lease_access_conditions: Additional parameters for the 347 operation 348 :type lease_access_conditions: 349 ~azure.storage.fileshare.models.LeaseAccessConditions 350 :param callable cls: A custom type or function that will be passed the 351 direct response 352 :return: None or the result of cls(response) 353 :rtype: None 354 :raises: 355 :class:`StorageErrorException<azure.storage.fileshare.models.StorageErrorException>` 356 """ 357 error_map = kwargs.pop('error_map', None) 358 lease_id = None 359 if lease_access_conditions is not None: 360 lease_id = lease_access_conditions.lease_id 361 362 # Construct URL 363 url = self.get_properties.metadata['url'] 364 path_format_arguments = { 365 'url': self._serialize.url("self._config.url", self._config.url, 'str', skip_quote=True) 366 } 367 url = self._client.format_url(url, **path_format_arguments) 368 369 # Construct parameters 370 query_parameters = {} 371 if sharesnapshot is not None: 372 query_parameters['sharesnapshot'] = self._serialize.query("sharesnapshot", sharesnapshot, 'str') 373 if timeout is not None: 374 query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int', minimum=0) 375 376 # Construct headers 377 header_parameters = {} 378 header_parameters['x-ms-version'] = self._serialize.header("self._config.version", self._config.version, 'str') 379 if lease_id is not None: 380 header_parameters['x-ms-lease-id'] = self._serialize.header("lease_id", lease_id, 'str') 381 382 # Construct and send request 383 request = self._client.head(url, query_parameters, header_parameters) 384 pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) 385 response = pipeline_response.http_response 386 387 if response.status_code not in [200]: 388 map_error(status_code=response.status_code, response=response, error_map=error_map) 389 raise models.StorageErrorException(response, self._deserialize) 390 391 if cls: 392 response_headers = { 393 'Last-Modified': self._deserialize('rfc-1123', response.headers.get('Last-Modified')), 394 'x-ms-meta': self._deserialize('{str}', response.headers.get('x-ms-meta')), 395 'x-ms-type': self._deserialize('str', response.headers.get('x-ms-type')), 396 'Content-Length': self._deserialize('long', response.headers.get('Content-Length')), 397 'Content-Type': self._deserialize('str', response.headers.get('Content-Type')), 398 'ETag': self._deserialize('str', response.headers.get('ETag')), 399 'Content-MD5': self._deserialize('bytearray', response.headers.get('Content-MD5')), 400 'Content-Encoding': self._deserialize('str', response.headers.get('Content-Encoding')), 401 'Cache-Control': self._deserialize('str', response.headers.get('Cache-Control')), 402 'Content-Disposition': self._deserialize('str', response.headers.get('Content-Disposition')), 403 'Content-Language': self._deserialize('str', response.headers.get('Content-Language')), 404 'x-ms-request-id': self._deserialize('str', response.headers.get('x-ms-request-id')), 405 'x-ms-version': self._deserialize('str', response.headers.get('x-ms-version')), 406 'Date': self._deserialize('rfc-1123', response.headers.get('Date')), 407 'x-ms-copy-completion-time': self._deserialize('rfc-1123', response.headers.get('x-ms-copy-completion-time')), 408 'x-ms-copy-status-description': self._deserialize('str', response.headers.get('x-ms-copy-status-description')), 409 'x-ms-copy-id': self._deserialize('str', response.headers.get('x-ms-copy-id')), 410 'x-ms-copy-progress': self._deserialize('str', response.headers.get('x-ms-copy-progress')), 411 'x-ms-copy-source': self._deserialize('str', response.headers.get('x-ms-copy-source')), 412 'x-ms-copy-status': self._deserialize(models.CopyStatusType, response.headers.get('x-ms-copy-status')), 413 'x-ms-server-encrypted': self._deserialize('bool', response.headers.get('x-ms-server-encrypted')), 414 'x-ms-file-attributes': self._deserialize('str', response.headers.get('x-ms-file-attributes')), 415 'x-ms-file-creation-time': self._deserialize('str', response.headers.get('x-ms-file-creation-time')), 416 'x-ms-file-last-write-time': self._deserialize('str', response.headers.get('x-ms-file-last-write-time')), 417 'x-ms-file-change-time': self._deserialize('str', response.headers.get('x-ms-file-change-time')), 418 'x-ms-file-permission-key': self._deserialize('str', response.headers.get('x-ms-file-permission-key')), 419 'x-ms-file-id': self._deserialize('str', response.headers.get('x-ms-file-id')), 420 'x-ms-file-parent-id': self._deserialize('str', response.headers.get('x-ms-file-parent-id')), 421 'x-ms-lease-duration': self._deserialize(models.LeaseDurationType, response.headers.get('x-ms-lease-duration')), 422 'x-ms-lease-state': self._deserialize(models.LeaseStateType, response.headers.get('x-ms-lease-state')), 423 'x-ms-lease-status': self._deserialize(models.LeaseStatusType, response.headers.get('x-ms-lease-status')), 424 'x-ms-error-code': self._deserialize('str', response.headers.get('x-ms-error-code')), 425 } 426 return cls(response, None, response_headers) 427 get_properties.metadata = {'url': '/{shareName}/{directory}/{fileName}'} 428 429 def delete(self, timeout=None, lease_access_conditions=None, cls=None, **kwargs): 430 """removes the file from the storage account. 431 432 :param timeout: The timeout parameter is expressed in seconds. For 433 more information, see <a 434 href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting 435 Timeouts for File Service Operations.</a> 436 :type timeout: int 437 :param lease_access_conditions: Additional parameters for the 438 operation 439 :type lease_access_conditions: 440 ~azure.storage.fileshare.models.LeaseAccessConditions 441 :param callable cls: A custom type or function that will be passed the 442 direct response 443 :return: None or the result of cls(response) 444 :rtype: None 445 :raises: 446 :class:`StorageErrorException<azure.storage.fileshare.models.StorageErrorException>` 447 """ 448 error_map = kwargs.pop('error_map', None) 449 lease_id = None 450 if lease_access_conditions is not None: 451 lease_id = lease_access_conditions.lease_id 452 453 # Construct URL 454 url = self.delete.metadata['url'] 455 path_format_arguments = { 456 'url': self._serialize.url("self._config.url", self._config.url, 'str', skip_quote=True) 457 } 458 url = self._client.format_url(url, **path_format_arguments) 459 460 # Construct parameters 461 query_parameters = {} 462 if timeout is not None: 463 query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int', minimum=0) 464 465 # Construct headers 466 header_parameters = {} 467 header_parameters['x-ms-version'] = self._serialize.header("self._config.version", self._config.version, 'str') 468 if lease_id is not None: 469 header_parameters['x-ms-lease-id'] = self._serialize.header("lease_id", lease_id, 'str') 470 471 # Construct and send request 472 request = self._client.delete(url, query_parameters, header_parameters) 473 pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) 474 response = pipeline_response.http_response 475 476 if response.status_code not in [202]: 477 map_error(status_code=response.status_code, response=response, error_map=error_map) 478 raise models.StorageErrorException(response, self._deserialize) 479 480 if cls: 481 response_headers = { 482 'x-ms-request-id': self._deserialize('str', response.headers.get('x-ms-request-id')), 483 'x-ms-version': self._deserialize('str', response.headers.get('x-ms-version')), 484 'Date': self._deserialize('rfc-1123', response.headers.get('Date')), 485 'x-ms-error-code': self._deserialize('str', response.headers.get('x-ms-error-code')), 486 } 487 return cls(response, None, response_headers) 488 delete.metadata = {'url': '/{shareName}/{directory}/{fileName}'} 489 490 def set_http_headers(self, file_attributes="none", file_creation_time="now", file_last_write_time="now", timeout=None, file_content_length=None, file_permission="inherit", file_permission_key=None, file_http_headers=None, lease_access_conditions=None, cls=None, **kwargs): 491 """Sets HTTP headers on the file. 492 493 :param file_attributes: If specified, the provided file attributes 494 shall be set. Default value: ‘Archive’ for file and ‘Directory’ for 495 directory. ‘None’ can also be specified as default. 496 :type file_attributes: str 497 :param file_creation_time: Creation time for the file/directory. 498 Default value: Now. 499 :type file_creation_time: str 500 :param file_last_write_time: Last write time for the file/directory. 501 Default value: Now. 502 :type file_last_write_time: str 503 :param timeout: The timeout parameter is expressed in seconds. For 504 more information, see <a 505 href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting 506 Timeouts for File Service Operations.</a> 507 :type timeout: int 508 :param file_content_length: Resizes a file to the specified size. If 509 the specified byte value is less than the current size of the file, 510 then all ranges above the specified byte value are cleared. 511 :type file_content_length: long 512 :param file_permission: If specified the permission (security 513 descriptor) shall be set for the directory/file. This header can be 514 used if Permission size is <= 8KB, else x-ms-file-permission-key 515 header shall be used. Default value: Inherit. If SDDL is specified as 516 input, it must have owner, group and dacl. Note: Only one of the 517 x-ms-file-permission or x-ms-file-permission-key should be specified. 518 :type file_permission: str 519 :param file_permission_key: Key of the permission to be set for the 520 directory/file. Note: Only one of the x-ms-file-permission or 521 x-ms-file-permission-key should be specified. 522 :type file_permission_key: str 523 :param file_http_headers: Additional parameters for the operation 524 :type file_http_headers: 525 ~azure.storage.fileshare.models.FileHTTPHeaders 526 :param lease_access_conditions: Additional parameters for the 527 operation 528 :type lease_access_conditions: 529 ~azure.storage.fileshare.models.LeaseAccessConditions 530 :param callable cls: A custom type or function that will be passed the 531 direct response 532 :return: None or the result of cls(response) 533 :rtype: None 534 :raises: 535 :class:`StorageErrorException<azure.storage.fileshare.models.StorageErrorException>` 536 """ 537 error_map = kwargs.pop('error_map', None) 538 file_content_type = None 539 if file_http_headers is not None: 540 file_content_type = file_http_headers.file_content_type 541 file_content_encoding = None 542 if file_http_headers is not None: 543 file_content_encoding = file_http_headers.file_content_encoding 544 file_content_language = None 545 if file_http_headers is not None: 546 file_content_language = file_http_headers.file_content_language 547 file_cache_control = None 548 if file_http_headers is not None: 549 file_cache_control = file_http_headers.file_cache_control 550 file_content_md5 = None 551 if file_http_headers is not None: 552 file_content_md5 = file_http_headers.file_content_md5 553 file_content_disposition = None 554 if file_http_headers is not None: 555 file_content_disposition = file_http_headers.file_content_disposition 556 lease_id = None 557 if lease_access_conditions is not None: 558 lease_id = lease_access_conditions.lease_id 559 560 comp = "properties" 561 562 # Construct URL 563 url = self.set_http_headers.metadata['url'] 564 path_format_arguments = { 565 'url': self._serialize.url("self._config.url", self._config.url, 'str', skip_quote=True) 566 } 567 url = self._client.format_url(url, **path_format_arguments) 568 569 # Construct parameters 570 query_parameters = {} 571 if timeout is not None: 572 query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int', minimum=0) 573 query_parameters['comp'] = self._serialize.query("comp", comp, 'str') 574 575 # Construct headers 576 header_parameters = {} 577 header_parameters['x-ms-version'] = self._serialize.header("self._config.version", self._config.version, 'str') 578 if file_content_length is not None: 579 header_parameters['x-ms-content-length'] = self._serialize.header("file_content_length", file_content_length, 'long') 580 if file_permission is not None: 581 header_parameters['x-ms-file-permission'] = self._serialize.header("file_permission", file_permission, 'str') 582 if file_permission_key is not None: 583 header_parameters['x-ms-file-permission-key'] = self._serialize.header("file_permission_key", file_permission_key, 'str') 584 header_parameters['x-ms-file-attributes'] = self._serialize.header("file_attributes", file_attributes, 'str') 585 header_parameters['x-ms-file-creation-time'] = self._serialize.header("file_creation_time", file_creation_time, 'str') 586 header_parameters['x-ms-file-last-write-time'] = self._serialize.header("file_last_write_time", file_last_write_time, 'str') 587 if file_content_type is not None: 588 header_parameters['x-ms-content-type'] = self._serialize.header("file_content_type", file_content_type, 'str') 589 if file_content_encoding is not None: 590 header_parameters['x-ms-content-encoding'] = self._serialize.header("file_content_encoding", file_content_encoding, 'str') 591 if file_content_language is not None: 592 header_parameters['x-ms-content-language'] = self._serialize.header("file_content_language", file_content_language, 'str') 593 if file_cache_control is not None: 594 header_parameters['x-ms-cache-control'] = self._serialize.header("file_cache_control", file_cache_control, 'str') 595 if file_content_md5 is not None: 596 header_parameters['x-ms-content-md5'] = self._serialize.header("file_content_md5", file_content_md5, 'bytearray') 597 if file_content_disposition is not None: 598 header_parameters['x-ms-content-disposition'] = self._serialize.header("file_content_disposition", file_content_disposition, 'str') 599 if lease_id is not None: 600 header_parameters['x-ms-lease-id'] = self._serialize.header("lease_id", lease_id, 'str') 601 602 # Construct and send request 603 request = self._client.put(url, query_parameters, header_parameters) 604 pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) 605 response = pipeline_response.http_response 606 607 if response.status_code not in [200]: 608 map_error(status_code=response.status_code, response=response, error_map=error_map) 609 raise models.StorageErrorException(response, self._deserialize) 610 611 if cls: 612 response_headers = { 613 'ETag': self._deserialize('str', response.headers.get('ETag')), 614 'Last-Modified': self._deserialize('rfc-1123', response.headers.get('Last-Modified')), 615 'x-ms-request-id': self._deserialize('str', response.headers.get('x-ms-request-id')), 616 'x-ms-version': self._deserialize('str', response.headers.get('x-ms-version')), 617 'Date': self._deserialize('rfc-1123', response.headers.get('Date')), 618 'x-ms-request-server-encrypted': self._deserialize('bool', response.headers.get('x-ms-request-server-encrypted')), 619 'x-ms-file-permission-key': self._deserialize('str', response.headers.get('x-ms-file-permission-key')), 620 'x-ms-file-attributes': self._deserialize('str', response.headers.get('x-ms-file-attributes')), 621 'x-ms-file-creation-time': self._deserialize('str', response.headers.get('x-ms-file-creation-time')), 622 'x-ms-file-last-write-time': self._deserialize('str', response.headers.get('x-ms-file-last-write-time')), 623 'x-ms-file-change-time': self._deserialize('str', response.headers.get('x-ms-file-change-time')), 624 'x-ms-file-id': self._deserialize('str', response.headers.get('x-ms-file-id')), 625 'x-ms-file-parent-id': self._deserialize('str', response.headers.get('x-ms-file-parent-id')), 626 'x-ms-error-code': self._deserialize('str', response.headers.get('x-ms-error-code')), 627 } 628 return cls(response, None, response_headers) 629 set_http_headers.metadata = {'url': '/{shareName}/{directory}/{fileName}'} 630 631 def set_metadata(self, timeout=None, metadata=None, lease_access_conditions=None, cls=None, **kwargs): 632 """Updates user-defined metadata for the specified file. 633 634 :param timeout: The timeout parameter is expressed in seconds. For 635 more information, see <a 636 href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting 637 Timeouts for File Service Operations.</a> 638 :type timeout: int 639 :param metadata: A name-value pair to associate with a file storage 640 object. 641 :type metadata: str 642 :param lease_access_conditions: Additional parameters for the 643 operation 644 :type lease_access_conditions: 645 ~azure.storage.fileshare.models.LeaseAccessConditions 646 :param callable cls: A custom type or function that will be passed the 647 direct response 648 :return: None or the result of cls(response) 649 :rtype: None 650 :raises: 651 :class:`StorageErrorException<azure.storage.fileshare.models.StorageErrorException>` 652 """ 653 error_map = kwargs.pop('error_map', None) 654 lease_id = None 655 if lease_access_conditions is not None: 656 lease_id = lease_access_conditions.lease_id 657 658 comp = "metadata" 659 660 # Construct URL 661 url = self.set_metadata.metadata['url'] 662 path_format_arguments = { 663 'url': self._serialize.url("self._config.url", self._config.url, 'str', skip_quote=True) 664 } 665 url = self._client.format_url(url, **path_format_arguments) 666 667 # Construct parameters 668 query_parameters = {} 669 if timeout is not None: 670 query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int', minimum=0) 671 query_parameters['comp'] = self._serialize.query("comp", comp, 'str') 672 673 # Construct headers 674 header_parameters = {} 675 if metadata is not None: 676 header_parameters['x-ms-meta'] = self._serialize.header("metadata", metadata, 'str') 677 header_parameters['x-ms-version'] = self._serialize.header("self._config.version", self._config.version, 'str') 678 if lease_id is not None: 679 header_parameters['x-ms-lease-id'] = self._serialize.header("lease_id", lease_id, 'str') 680 681 # Construct and send request 682 request = self._client.put(url, query_parameters, header_parameters) 683 pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) 684 response = pipeline_response.http_response 685 686 if response.status_code not in [200]: 687 map_error(status_code=response.status_code, response=response, error_map=error_map) 688 raise models.StorageErrorException(response, self._deserialize) 689 690 if cls: 691 response_headers = { 692 'ETag': self._deserialize('str', response.headers.get('ETag')), 693 'x-ms-request-id': self._deserialize('str', response.headers.get('x-ms-request-id')), 694 'x-ms-version': self._deserialize('str', response.headers.get('x-ms-version')), 695 'Date': self._deserialize('rfc-1123', response.headers.get('Date')), 696 'x-ms-request-server-encrypted': self._deserialize('bool', response.headers.get('x-ms-request-server-encrypted')), 697 'x-ms-error-code': self._deserialize('str', response.headers.get('x-ms-error-code')), 698 } 699 return cls(response, None, response_headers) 700 set_metadata.metadata = {'url': '/{shareName}/{directory}/{fileName}'} 701 702 def acquire_lease(self, timeout=None, duration=None, proposed_lease_id=None, request_id=None, cls=None, **kwargs): 703 """[Update] The Lease File operation establishes and manages a lock on a 704 file for write and delete operations. 705 706 :param timeout: The timeout parameter is expressed in seconds. For 707 more information, see <a 708 href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting 709 Timeouts for File Service Operations.</a> 710 :type timeout: int 711 :param duration: Specifies the duration of the lease, in seconds, or 712 negative one (-1) for a lease that never expires. A non-infinite lease 713 can be between 15 and 60 seconds. A lease duration cannot be changed 714 using renew or change. 715 :type duration: int 716 :param proposed_lease_id: Proposed lease ID, in a GUID string format. 717 The File service returns 400 (Invalid request) if the proposed lease 718 ID is not in the correct format. See Guid Constructor (String) for a 719 list of valid GUID string formats. 720 :type proposed_lease_id: str 721 :param request_id: Provides a client-generated, opaque value with a 1 722 KB character limit that is recorded in the analytics logs when storage 723 analytics logging is enabled. 724 :type request_id: str 725 :param callable cls: A custom type or function that will be passed the 726 direct response 727 :return: None or the result of cls(response) 728 :rtype: None 729 :raises: 730 :class:`StorageErrorException<azure.storage.fileshare.models.StorageErrorException>` 731 """ 732 error_map = kwargs.pop('error_map', None) 733 comp = "lease" 734 action = "acquire" 735 736 # Construct URL 737 url = self.acquire_lease.metadata['url'] 738 path_format_arguments = { 739 'url': self._serialize.url("self._config.url", self._config.url, 'str', skip_quote=True) 740 } 741 url = self._client.format_url(url, **path_format_arguments) 742 743 # Construct parameters 744 query_parameters = {} 745 if timeout is not None: 746 query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int', minimum=0) 747 query_parameters['comp'] = self._serialize.query("comp", comp, 'str') 748 749 # Construct headers 750 header_parameters = {} 751 if duration is not None: 752 header_parameters['x-ms-lease-duration'] = self._serialize.header("duration", duration, 'int') 753 if proposed_lease_id is not None: 754 header_parameters['x-ms-proposed-lease-id'] = self._serialize.header("proposed_lease_id", proposed_lease_id, 'str') 755 header_parameters['x-ms-version'] = self._serialize.header("self._config.version", self._config.version, 'str') 756 if request_id is not None: 757 header_parameters['x-ms-client-request-id'] = self._serialize.header("request_id", request_id, 'str') 758 header_parameters['x-ms-lease-action'] = self._serialize.header("action", action, 'str') 759 760 # Construct and send request 761 request = self._client.put(url, query_parameters, header_parameters) 762 pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) 763 response = pipeline_response.http_response 764 765 if response.status_code not in [201]: 766 map_error(status_code=response.status_code, response=response, error_map=error_map) 767 raise models.StorageErrorException(response, self._deserialize) 768 769 if cls: 770 response_headers = { 771 'ETag': self._deserialize('str', response.headers.get('ETag')), 772 'Last-Modified': self._deserialize('rfc-1123', response.headers.get('Last-Modified')), 773 'x-ms-lease-id': self._deserialize('str', response.headers.get('x-ms-lease-id')), 774 'x-ms-client-request-id': self._deserialize('str', response.headers.get('x-ms-client-request-id')), 775 'x-ms-request-id': self._deserialize('str', response.headers.get('x-ms-request-id')), 776 'x-ms-version': self._deserialize('str', response.headers.get('x-ms-version')), 777 'Date': self._deserialize('rfc-1123', response.headers.get('Date')), 778 'x-ms-error-code': self._deserialize('str', response.headers.get('x-ms-error-code')), 779 } 780 return cls(response, None, response_headers) 781 acquire_lease.metadata = {'url': '/{shareName}/{directory}/{fileName}'} 782 783 def release_lease(self, lease_id, timeout=None, request_id=None, cls=None, **kwargs): 784 """[Update] The Lease File operation establishes and manages a lock on a 785 file for write and delete operations. 786 787 :param lease_id: Specifies the current lease ID on the resource. 788 :type lease_id: str 789 :param timeout: The timeout parameter is expressed in seconds. For 790 more information, see <a 791 href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting 792 Timeouts for File Service Operations.</a> 793 :type timeout: int 794 :param request_id: Provides a client-generated, opaque value with a 1 795 KB character limit that is recorded in the analytics logs when storage 796 analytics logging is enabled. 797 :type request_id: str 798 :param callable cls: A custom type or function that will be passed the 799 direct response 800 :return: None or the result of cls(response) 801 :rtype: None 802 :raises: 803 :class:`StorageErrorException<azure.storage.fileshare.models.StorageErrorException>` 804 """ 805 error_map = kwargs.pop('error_map', None) 806 comp = "lease" 807 action = "release" 808 809 # Construct URL 810 url = self.release_lease.metadata['url'] 811 path_format_arguments = { 812 'url': self._serialize.url("self._config.url", self._config.url, 'str', skip_quote=True) 813 } 814 url = self._client.format_url(url, **path_format_arguments) 815 816 # Construct parameters 817 query_parameters = {} 818 if timeout is not None: 819 query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int', minimum=0) 820 query_parameters['comp'] = self._serialize.query("comp", comp, 'str') 821 822 # Construct headers 823 header_parameters = {} 824 header_parameters['x-ms-lease-id'] = self._serialize.header("lease_id", lease_id, 'str') 825 header_parameters['x-ms-version'] = self._serialize.header("self._config.version", self._config.version, 'str') 826 if request_id is not None: 827 header_parameters['x-ms-client-request-id'] = self._serialize.header("request_id", request_id, 'str') 828 header_parameters['x-ms-lease-action'] = self._serialize.header("action", action, 'str') 829 830 # Construct and send request 831 request = self._client.put(url, query_parameters, header_parameters) 832 pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) 833 response = pipeline_response.http_response 834 835 if response.status_code not in [200]: 836 map_error(status_code=response.status_code, response=response, error_map=error_map) 837 raise models.StorageErrorException(response, self._deserialize) 838 839 if cls: 840 response_headers = { 841 'ETag': self._deserialize('str', response.headers.get('ETag')), 842 'Last-Modified': self._deserialize('rfc-1123', response.headers.get('Last-Modified')), 843 'x-ms-client-request-id': self._deserialize('str', response.headers.get('x-ms-client-request-id')), 844 'x-ms-request-id': self._deserialize('str', response.headers.get('x-ms-request-id')), 845 'x-ms-version': self._deserialize('str', response.headers.get('x-ms-version')), 846 'Date': self._deserialize('rfc-1123', response.headers.get('Date')), 847 'x-ms-error-code': self._deserialize('str', response.headers.get('x-ms-error-code')), 848 } 849 return cls(response, None, response_headers) 850 release_lease.metadata = {'url': '/{shareName}/{directory}/{fileName}'} 851 852 def change_lease(self, lease_id, timeout=None, proposed_lease_id=None, request_id=None, cls=None, **kwargs): 853 """[Update] The Lease File operation establishes and manages a lock on a 854 file for write and delete operations. 855 856 :param lease_id: Specifies the current lease ID on the resource. 857 :type lease_id: str 858 :param timeout: The timeout parameter is expressed in seconds. For 859 more information, see <a 860 href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting 861 Timeouts for File Service Operations.</a> 862 :type timeout: int 863 :param proposed_lease_id: Proposed lease ID, in a GUID string format. 864 The File service returns 400 (Invalid request) if the proposed lease 865 ID is not in the correct format. See Guid Constructor (String) for a 866 list of valid GUID string formats. 867 :type proposed_lease_id: str 868 :param request_id: Provides a client-generated, opaque value with a 1 869 KB character limit that is recorded in the analytics logs when storage 870 analytics logging is enabled. 871 :type request_id: str 872 :param callable cls: A custom type or function that will be passed the 873 direct response 874 :return: None or the result of cls(response) 875 :rtype: None 876 :raises: 877 :class:`StorageErrorException<azure.storage.fileshare.models.StorageErrorException>` 878 """ 879 error_map = kwargs.pop('error_map', None) 880 comp = "lease" 881 action = "change" 882 883 # Construct URL 884 url = self.change_lease.metadata['url'] 885 path_format_arguments = { 886 'url': self._serialize.url("self._config.url", self._config.url, 'str', skip_quote=True) 887 } 888 url = self._client.format_url(url, **path_format_arguments) 889 890 # Construct parameters 891 query_parameters = {} 892 if timeout is not None: 893 query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int', minimum=0) 894 query_parameters['comp'] = self._serialize.query("comp", comp, 'str') 895 896 # Construct headers 897 header_parameters = {} 898 header_parameters['x-ms-lease-id'] = self._serialize.header("lease_id", lease_id, 'str') 899 if proposed_lease_id is not None: 900 header_parameters['x-ms-proposed-lease-id'] = self._serialize.header("proposed_lease_id", proposed_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 header_parameters['x-ms-lease-action'] = self._serialize.header("action", action, 'str') 905 906 # Construct and send request 907 request = self._client.put(url, query_parameters, header_parameters) 908 pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) 909 response = pipeline_response.http_response 910 911 if response.status_code not in [200]: 912 map_error(status_code=response.status_code, response=response, error_map=error_map) 913 raise models.StorageErrorException(response, self._deserialize) 914 915 if cls: 916 response_headers = { 917 'ETag': self._deserialize('str', response.headers.get('ETag')), 918 'Last-Modified': self._deserialize('rfc-1123', response.headers.get('Last-Modified')), 919 'x-ms-lease-id': self._deserialize('str', response.headers.get('x-ms-lease-id')), 920 'x-ms-client-request-id': self._deserialize('str', response.headers.get('x-ms-client-request-id')), 921 'x-ms-request-id': self._deserialize('str', response.headers.get('x-ms-request-id')), 922 'x-ms-version': self._deserialize('str', response.headers.get('x-ms-version')), 923 'Date': self._deserialize('rfc-1123', response.headers.get('Date')), 924 'x-ms-error-code': self._deserialize('str', response.headers.get('x-ms-error-code')), 925 } 926 return cls(response, None, response_headers) 927 change_lease.metadata = {'url': '/{shareName}/{directory}/{fileName}'} 928 929 def break_lease(self, timeout=None, request_id=None, lease_access_conditions=None, cls=None, **kwargs): 930 """[Update] The Lease File operation establishes and manages a lock on a 931 file for write and delete operations. 932 933 :param timeout: The timeout parameter is expressed in seconds. For 934 more information, see <a 935 href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting 936 Timeouts for File Service Operations.</a> 937 :type timeout: int 938 :param request_id: Provides a client-generated, opaque value with a 1 939 KB character limit that is recorded in the analytics logs when storage 940 analytics logging is enabled. 941 :type request_id: str 942 :param lease_access_conditions: Additional parameters for the 943 operation 944 :type lease_access_conditions: 945 ~azure.storage.fileshare.models.LeaseAccessConditions 946 :param callable cls: A custom type or function that will be passed the 947 direct response 948 :return: None or the result of cls(response) 949 :rtype: None 950 :raises: 951 :class:`StorageErrorException<azure.storage.fileshare.models.StorageErrorException>` 952 """ 953 error_map = kwargs.pop('error_map', None) 954 lease_id = None 955 if lease_access_conditions is not None: 956 lease_id = lease_access_conditions.lease_id 957 958 comp = "lease" 959 action = "break" 960 961 # Construct URL 962 url = self.break_lease.metadata['url'] 963 path_format_arguments = { 964 'url': self._serialize.url("self._config.url", self._config.url, 'str', skip_quote=True) 965 } 966 url = self._client.format_url(url, **path_format_arguments) 967 968 # Construct parameters 969 query_parameters = {} 970 if timeout is not None: 971 query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int', minimum=0) 972 query_parameters['comp'] = self._serialize.query("comp", comp, 'str') 973 974 # Construct headers 975 header_parameters = {} 976 header_parameters['x-ms-version'] = self._serialize.header("self._config.version", self._config.version, 'str') 977 if request_id is not None: 978 header_parameters['x-ms-client-request-id'] = self._serialize.header("request_id", request_id, 'str') 979 header_parameters['x-ms-lease-action'] = self._serialize.header("action", action, 'str') 980 if lease_id is not None: 981 header_parameters['x-ms-lease-id'] = self._serialize.header("lease_id", lease_id, 'str') 982 983 # Construct and send request 984 request = self._client.put(url, query_parameters, header_parameters) 985 pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) 986 response = pipeline_response.http_response 987 988 if response.status_code not in [202]: 989 map_error(status_code=response.status_code, response=response, error_map=error_map) 990 raise models.StorageErrorException(response, self._deserialize) 991 992 if cls: 993 response_headers = { 994 'ETag': self._deserialize('str', response.headers.get('ETag')), 995 'Last-Modified': self._deserialize('rfc-1123', response.headers.get('Last-Modified')), 996 'x-ms-lease-id': self._deserialize('str', response.headers.get('x-ms-lease-id')), 997 'x-ms-client-request-id': self._deserialize('str', response.headers.get('x-ms-client-request-id')), 998 'x-ms-request-id': self._deserialize('str', response.headers.get('x-ms-request-id')), 999 'x-ms-version': self._deserialize('str', response.headers.get('x-ms-version')), 1000 'Date': self._deserialize('rfc-1123', response.headers.get('Date')), 1001 'x-ms-error-code': self._deserialize('str', response.headers.get('x-ms-error-code')), 1002 } 1003 return cls(response, None, response_headers) 1004 break_lease.metadata = {'url': '/{shareName}/{directory}/{fileName}'} 1005 1006 def upload_range(self, range, content_length, file_range_write="update", optionalbody=None, timeout=None, content_md5=None, lease_access_conditions=None, cls=None, **kwargs): 1007 """Upload a range of bytes to a file. 1008 1009 :param range: Specifies the range of bytes to be written. Both the 1010 start and end of the range must be specified. For an update operation, 1011 the range can be up to 4 MB in size. For a clear operation, the range 1012 can be up to the value of the file's full size. The File service 1013 accepts only a single byte range for the Range and 'x-ms-range' 1014 headers, and the byte range must be specified in the following format: 1015 bytes=startByte-endByte. 1016 :type range: str 1017 :param file_range_write: Specify one of the following options: - 1018 Update: Writes the bytes specified by the request body into the 1019 specified range. The Range and Content-Length headers must match to 1020 perform the update. - Clear: Clears the specified range and releases 1021 the space used in storage for that range. To clear a range, set the 1022 Content-Length header to zero, and set the Range header to a value 1023 that indicates the range to clear, up to maximum file size. Possible 1024 values include: 'update', 'clear' 1025 :type file_range_write: str or 1026 ~azure.storage.fileshare.models.FileRangeWriteType 1027 :param content_length: Specifies the number of bytes being transmitted 1028 in the request body. When the x-ms-write header is set to clear, the 1029 value of this header must be set to zero. 1030 :type content_length: long 1031 :param optionalbody: Initial data. 1032 :type optionalbody: Generator 1033 :param timeout: The timeout parameter is expressed in seconds. For 1034 more information, see <a 1035 href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting 1036 Timeouts for File Service Operations.</a> 1037 :type timeout: int 1038 :param content_md5: An MD5 hash of the content. This hash is used to 1039 verify the integrity of the data during transport. When the 1040 Content-MD5 header is specified, the File service compares the hash of 1041 the content that has arrived with the header value that was sent. If 1042 the two hashes do not match, the operation will fail with error code 1043 400 (Bad Request). 1044 :type content_md5: bytearray 1045 :param lease_access_conditions: Additional parameters for the 1046 operation 1047 :type lease_access_conditions: 1048 ~azure.storage.fileshare.models.LeaseAccessConditions 1049 :param callable cls: A custom type or function that will be passed the 1050 direct response 1051 :return: None or the result of cls(response) 1052 :rtype: None 1053 :raises: 1054 :class:`StorageErrorException<azure.storage.fileshare.models.StorageErrorException>` 1055 """ 1056 error_map = kwargs.pop('error_map', None) 1057 lease_id = None 1058 if lease_access_conditions is not None: 1059 lease_id = lease_access_conditions.lease_id 1060 1061 comp = "range" 1062 1063 # Construct URL 1064 url = self.upload_range.metadata['url'] 1065 path_format_arguments = { 1066 'url': self._serialize.url("self._config.url", self._config.url, 'str', skip_quote=True) 1067 } 1068 url = self._client.format_url(url, **path_format_arguments) 1069 1070 # Construct parameters 1071 query_parameters = {} 1072 if timeout is not None: 1073 query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int', minimum=0) 1074 query_parameters['comp'] = self._serialize.query("comp", comp, 'str') 1075 1076 # Construct headers 1077 header_parameters = {} 1078 header_parameters['Content-Type'] = 'application/octet-stream' 1079 header_parameters['x-ms-range'] = self._serialize.header("range", range, 'str') 1080 header_parameters['x-ms-write'] = self._serialize.header("file_range_write", file_range_write, 'FileRangeWriteType') 1081 header_parameters['Content-Length'] = self._serialize.header("content_length", content_length, 'long') 1082 if content_md5 is not None: 1083 header_parameters['Content-MD5'] = self._serialize.header("content_md5", content_md5, 'bytearray') 1084 header_parameters['x-ms-version'] = self._serialize.header("self._config.version", self._config.version, 'str') 1085 if lease_id is not None: 1086 header_parameters['x-ms-lease-id'] = self._serialize.header("lease_id", lease_id, 'str') 1087 1088 # Construct body 1089 1090 # Construct and send request 1091 request = self._client.put(url, query_parameters, header_parameters, stream_content=optionalbody) 1092 pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) 1093 response = pipeline_response.http_response 1094 1095 if response.status_code not in [201]: 1096 map_error(status_code=response.status_code, response=response, error_map=error_map) 1097 raise models.StorageErrorException(response, self._deserialize) 1098 1099 if cls: 1100 response_headers = { 1101 'ETag': self._deserialize('str', response.headers.get('ETag')), 1102 'Last-Modified': self._deserialize('rfc-1123', response.headers.get('Last-Modified')), 1103 'Content-MD5': self._deserialize('bytearray', response.headers.get('Content-MD5')), 1104 'x-ms-request-id': self._deserialize('str', response.headers.get('x-ms-request-id')), 1105 'x-ms-version': self._deserialize('str', response.headers.get('x-ms-version')), 1106 'Date': self._deserialize('rfc-1123', response.headers.get('Date')), 1107 'x-ms-request-server-encrypted': self._deserialize('bool', response.headers.get('x-ms-request-server-encrypted')), 1108 'x-ms-error-code': self._deserialize('str', response.headers.get('x-ms-error-code')), 1109 } 1110 return cls(response, None, response_headers) 1111 upload_range.metadata = {'url': '/{shareName}/{directory}/{fileName}'} 1112 1113 def upload_range_from_url(self, range, copy_source, content_length, timeout=None, source_range=None, source_content_crc64=None, source_modified_access_conditions=None, lease_access_conditions=None, cls=None, **kwargs): 1114 """Upload a range of bytes to a file where the contents are read from a 1115 URL. 1116 1117 :param range: Writes data to the specified byte range in the file. 1118 :type range: str 1119 :param copy_source: Specifies the URL of the source file or blob, up 1120 to 2 KB in length. To copy a file to another file within the same 1121 storage account, you may use Shared Key to authenticate the source 1122 file. If you are copying a file from another storage account, or if 1123 you are copying a blob from the same storage account or another 1124 storage account, then you must authenticate the source file or blob 1125 using a shared access signature. If the source is a public blob, no 1126 authentication is required to perform the copy operation. A file in a 1127 share snapshot can also be specified as a copy source. 1128 :type copy_source: str 1129 :param content_length: Specifies the number of bytes being transmitted 1130 in the request body. When the x-ms-write header is set to clear, the 1131 value of this header must be set to zero. 1132 :type content_length: long 1133 :param timeout: The timeout parameter is expressed in seconds. For 1134 more information, see <a 1135 href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting 1136 Timeouts for File Service Operations.</a> 1137 :type timeout: int 1138 :param source_range: Bytes of source data in the specified range. 1139 :type source_range: str 1140 :param source_content_crc64: Specify the crc64 calculated for the 1141 range of bytes that must be read from the copy source. 1142 :type source_content_crc64: bytearray 1143 :param source_modified_access_conditions: Additional parameters for 1144 the operation 1145 :type source_modified_access_conditions: 1146 ~azure.storage.fileshare.models.SourceModifiedAccessConditions 1147 :param lease_access_conditions: Additional parameters for the 1148 operation 1149 :type lease_access_conditions: 1150 ~azure.storage.fileshare.models.LeaseAccessConditions 1151 :param callable cls: A custom type or function that will be passed the 1152 direct response 1153 :return: None or the result of cls(response) 1154 :rtype: None 1155 :raises: 1156 :class:`StorageErrorException<azure.storage.fileshare.models.StorageErrorException>` 1157 """ 1158 error_map = kwargs.pop('error_map', None) 1159 source_if_match_crc64 = None 1160 if source_modified_access_conditions is not None: 1161 source_if_match_crc64 = source_modified_access_conditions.source_if_match_crc64 1162 source_if_none_match_crc64 = None 1163 if source_modified_access_conditions is not None: 1164 source_if_none_match_crc64 = source_modified_access_conditions.source_if_none_match_crc64 1165 lease_id = None 1166 if lease_access_conditions is not None: 1167 lease_id = lease_access_conditions.lease_id 1168 1169 comp = "range" 1170 1171 # Construct URL 1172 url = self.upload_range_from_url.metadata['url'] 1173 path_format_arguments = { 1174 'url': self._serialize.url("self._config.url", self._config.url, 'str', skip_quote=True) 1175 } 1176 url = self._client.format_url(url, **path_format_arguments) 1177 1178 # Construct parameters 1179 query_parameters = {} 1180 if timeout is not None: 1181 query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int', minimum=0) 1182 query_parameters['comp'] = self._serialize.query("comp", comp, 'str') 1183 1184 # Construct headers 1185 header_parameters = {} 1186 header_parameters['x-ms-range'] = self._serialize.header("range", range, 'str') 1187 header_parameters['x-ms-copy-source'] = self._serialize.header("copy_source", copy_source, 'str') 1188 if source_range is not None: 1189 header_parameters['x-ms-source-range'] = self._serialize.header("source_range", source_range, 'str') 1190 header_parameters['x-ms-write'] = self._serialize.header("self._config.file_range_write_from_url", self._config.file_range_write_from_url, 'str') 1191 header_parameters['Content-Length'] = self._serialize.header("content_length", content_length, 'long') 1192 if source_content_crc64 is not None: 1193 header_parameters['x-ms-source-content-crc64'] = self._serialize.header("source_content_crc64", source_content_crc64, 'bytearray') 1194 header_parameters['x-ms-version'] = self._serialize.header("self._config.version", self._config.version, 'str') 1195 if source_if_match_crc64 is not None: 1196 header_parameters['x-ms-source-if-match-crc64'] = self._serialize.header("source_if_match_crc64", source_if_match_crc64, 'bytearray') 1197 if source_if_none_match_crc64 is not None: 1198 header_parameters['x-ms-source-if-none-match-crc64'] = self._serialize.header("source_if_none_match_crc64", source_if_none_match_crc64, 'bytearray') 1199 if lease_id is not None: 1200 header_parameters['x-ms-lease-id'] = self._serialize.header("lease_id", lease_id, 'str') 1201 1202 # Construct and send request 1203 request = self._client.put(url, query_parameters, header_parameters) 1204 pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) 1205 response = pipeline_response.http_response 1206 1207 if response.status_code not in [201]: 1208 map_error(status_code=response.status_code, response=response, error_map=error_map) 1209 raise models.StorageErrorException(response, self._deserialize) 1210 1211 if cls: 1212 response_headers = { 1213 'ETag': self._deserialize('str', response.headers.get('ETag')), 1214 'Last-Modified': self._deserialize('rfc-1123', response.headers.get('Last-Modified')), 1215 'x-ms-content-crc64': self._deserialize('bytearray', response.headers.get('x-ms-content-crc64')), 1216 'x-ms-request-id': self._deserialize('str', response.headers.get('x-ms-request-id')), 1217 'x-ms-version': self._deserialize('str', response.headers.get('x-ms-version')), 1218 'Date': self._deserialize('rfc-1123', response.headers.get('Date')), 1219 'x-ms-request-server-encrypted': self._deserialize('bool', response.headers.get('x-ms-request-server-encrypted')), 1220 'x-ms-error-code': self._deserialize('str', response.headers.get('x-ms-error-code')), 1221 } 1222 return cls(response, None, response_headers) 1223 upload_range_from_url.metadata = {'url': '/{shareName}/{directory}/{fileName}'} 1224 1225 def get_range_list(self, sharesnapshot=None, prevsharesnapshot=None, timeout=None, range=None, lease_access_conditions=None, cls=None, **kwargs): 1226 """Returns the list of valid ranges for a file. 1227 1228 :param sharesnapshot: The snapshot parameter is an opaque DateTime 1229 value that, when present, specifies the share snapshot to query. 1230 :type sharesnapshot: str 1231 :param prevsharesnapshot: The previous snapshot parameter is an opaque 1232 DateTime value that, when present, specifies the previous snapshot. 1233 :type prevsharesnapshot: str 1234 :param timeout: The timeout parameter is expressed in seconds. For 1235 more information, see <a 1236 href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting 1237 Timeouts for File Service Operations.</a> 1238 :type timeout: int 1239 :param range: Specifies the range of bytes over which to list ranges, 1240 inclusively. 1241 :type range: str 1242 :param lease_access_conditions: Additional parameters for the 1243 operation 1244 :type lease_access_conditions: 1245 ~azure.storage.fileshare.models.LeaseAccessConditions 1246 :param callable cls: A custom type or function that will be passed the 1247 direct response 1248 :return: ShareFileRangeList or the result of cls(response) 1249 :rtype: ~azure.storage.fileshare.models.ShareFileRangeList 1250 :raises: 1251 :class:`StorageErrorException<azure.storage.fileshare.models.StorageErrorException>` 1252 """ 1253 error_map = kwargs.pop('error_map', None) 1254 lease_id = None 1255 if lease_access_conditions is not None: 1256 lease_id = lease_access_conditions.lease_id 1257 1258 comp = "rangelist" 1259 1260 # Construct URL 1261 url = self.get_range_list.metadata['url'] 1262 path_format_arguments = { 1263 'url': self._serialize.url("self._config.url", self._config.url, 'str', skip_quote=True) 1264 } 1265 url = self._client.format_url(url, **path_format_arguments) 1266 1267 # Construct parameters 1268 query_parameters = {} 1269 if sharesnapshot is not None: 1270 query_parameters['sharesnapshot'] = self._serialize.query("sharesnapshot", sharesnapshot, 'str') 1271 if prevsharesnapshot is not None: 1272 query_parameters['prevsharesnapshot'] = self._serialize.query("prevsharesnapshot", prevsharesnapshot, 'str') 1273 if timeout is not None: 1274 query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int', minimum=0) 1275 query_parameters['comp'] = self._serialize.query("comp", comp, 'str') 1276 1277 # Construct headers 1278 header_parameters = {} 1279 header_parameters['Accept'] = 'application/xml' 1280 header_parameters['x-ms-version'] = self._serialize.header("self._config.version", self._config.version, 'str') 1281 if range is not None: 1282 header_parameters['x-ms-range'] = self._serialize.header("range", range, 'str') 1283 if lease_id is not None: 1284 header_parameters['x-ms-lease-id'] = self._serialize.header("lease_id", lease_id, 'str') 1285 1286 # Construct and send request 1287 request = self._client.get(url, query_parameters, header_parameters) 1288 pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) 1289 response = pipeline_response.http_response 1290 1291 if response.status_code not in [200]: 1292 map_error(status_code=response.status_code, response=response, error_map=error_map) 1293 raise models.StorageErrorException(response, self._deserialize) 1294 1295 header_dict = {} 1296 deserialized = None 1297 if response.status_code == 200: 1298 deserialized = self._deserialize('ShareFileRangeList', response) 1299 header_dict = { 1300 'Last-Modified': self._deserialize('rfc-1123', response.headers.get('Last-Modified')), 1301 'ETag': self._deserialize('str', response.headers.get('ETag')), 1302 'x-ms-content-length': self._deserialize('long', response.headers.get('x-ms-content-length')), 1303 'x-ms-request-id': self._deserialize('str', response.headers.get('x-ms-request-id')), 1304 'x-ms-version': self._deserialize('str', response.headers.get('x-ms-version')), 1305 'Date': self._deserialize('rfc-1123', response.headers.get('Date')), 1306 'x-ms-error-code': self._deserialize('str', response.headers.get('x-ms-error-code')), 1307 } 1308 1309 if cls: 1310 return cls(response, deserialized, header_dict) 1311 1312 return deserialized 1313 get_range_list.metadata = {'url': '/{shareName}/{directory}/{fileName}'} 1314 1315 def start_copy(self, copy_source, timeout=None, metadata=None, file_permission="inherit", file_permission_key=None, copy_file_smb_info=None, lease_access_conditions=None, cls=None, **kwargs): 1316 """Copies a blob or file to a destination file within the storage account. 1317 1318 :param copy_source: Specifies the URL of the source file or blob, up 1319 to 2 KB in length. To copy a file to another file within the same 1320 storage account, you may use Shared Key to authenticate the source 1321 file. If you are copying a file from another storage account, or if 1322 you are copying a blob from the same storage account or another 1323 storage account, then you must authenticate the source file or blob 1324 using a shared access signature. If the source is a public blob, no 1325 authentication is required to perform the copy operation. A file in a 1326 share snapshot can also be specified as a copy source. 1327 :type copy_source: str 1328 :param timeout: The timeout parameter is expressed in seconds. For 1329 more information, see <a 1330 href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting 1331 Timeouts for File Service Operations.</a> 1332 :type timeout: int 1333 :param metadata: A name-value pair to associate with a file storage 1334 object. 1335 :type metadata: str 1336 :param file_permission: If specified the permission (security 1337 descriptor) shall be set for the directory/file. This header can be 1338 used if Permission size is <= 8KB, else x-ms-file-permission-key 1339 header shall be used. Default value: Inherit. If SDDL is specified as 1340 input, it must have owner, group and dacl. Note: Only one of the 1341 x-ms-file-permission or x-ms-file-permission-key should be specified. 1342 :type file_permission: str 1343 :param file_permission_key: Key of the permission to be set for the 1344 directory/file. Note: Only one of the x-ms-file-permission or 1345 x-ms-file-permission-key should be specified. 1346 :type file_permission_key: str 1347 :param copy_file_smb_info: Additional parameters for the operation 1348 :type copy_file_smb_info: 1349 ~azure.storage.fileshare.models.CopyFileSmbInfo 1350 :param lease_access_conditions: Additional parameters for the 1351 operation 1352 :type lease_access_conditions: 1353 ~azure.storage.fileshare.models.LeaseAccessConditions 1354 :param callable cls: A custom type or function that will be passed the 1355 direct response 1356 :return: None or the result of cls(response) 1357 :rtype: None 1358 :raises: 1359 :class:`StorageErrorException<azure.storage.fileshare.models.StorageErrorException>` 1360 """ 1361 error_map = kwargs.pop('error_map', None) 1362 file_permission_copy_mode = None 1363 if copy_file_smb_info is not None: 1364 file_permission_copy_mode = copy_file_smb_info.file_permission_copy_mode 1365 ignore_read_only = None 1366 if copy_file_smb_info is not None: 1367 ignore_read_only = copy_file_smb_info.ignore_read_only 1368 file_attributes = None 1369 if copy_file_smb_info is not None: 1370 file_attributes = copy_file_smb_info.file_attributes 1371 file_creation_time = None 1372 if copy_file_smb_info is not None: 1373 file_creation_time = copy_file_smb_info.file_creation_time 1374 file_last_write_time = None 1375 if copy_file_smb_info is not None: 1376 file_last_write_time = copy_file_smb_info.file_last_write_time 1377 set_archive_attribute = None 1378 if copy_file_smb_info is not None: 1379 set_archive_attribute = copy_file_smb_info.set_archive_attribute 1380 lease_id = None 1381 if lease_access_conditions is not None: 1382 lease_id = lease_access_conditions.lease_id 1383 1384 # Construct URL 1385 url = self.start_copy.metadata['url'] 1386 path_format_arguments = { 1387 'url': self._serialize.url("self._config.url", self._config.url, 'str', skip_quote=True) 1388 } 1389 url = self._client.format_url(url, **path_format_arguments) 1390 1391 # Construct parameters 1392 query_parameters = {} 1393 if timeout is not None: 1394 query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int', minimum=0) 1395 1396 # Construct headers 1397 header_parameters = {} 1398 header_parameters['x-ms-version'] = self._serialize.header("self._config.version", self._config.version, 'str') 1399 if metadata is not None: 1400 header_parameters['x-ms-meta'] = self._serialize.header("metadata", metadata, 'str') 1401 header_parameters['x-ms-copy-source'] = self._serialize.header("copy_source", copy_source, 'str') 1402 if file_permission is not None: 1403 header_parameters['x-ms-file-permission'] = self._serialize.header("file_permission", file_permission, 'str') 1404 if file_permission_key is not None: 1405 header_parameters['x-ms-file-permission-key'] = self._serialize.header("file_permission_key", file_permission_key, 'str') 1406 if file_permission_copy_mode is not None: 1407 header_parameters['x-ms-file-permission-copy-mode'] = self._serialize.header("file_permission_copy_mode", file_permission_copy_mode, 'PermissionCopyModeType') 1408 if ignore_read_only is not None: 1409 header_parameters['x-ms-file-copy-ignore-read-only'] = self._serialize.header("ignore_read_only", ignore_read_only, 'bool') 1410 if file_attributes is not None: 1411 header_parameters['x-ms-file-attributes'] = self._serialize.header("file_attributes", file_attributes, 'str') 1412 if file_creation_time is not None: 1413 header_parameters['x-ms-file-creation-time'] = self._serialize.header("file_creation_time", file_creation_time, 'str') 1414 if file_last_write_time is not None: 1415 header_parameters['x-ms-file-last-write-time'] = self._serialize.header("file_last_write_time", file_last_write_time, 'str') 1416 if set_archive_attribute is not None: 1417 header_parameters['x-ms-file-copy-set-archive'] = self._serialize.header("set_archive_attribute", set_archive_attribute, 'bool') 1418 if lease_id is not None: 1419 header_parameters['x-ms-lease-id'] = self._serialize.header("lease_id", lease_id, 'str') 1420 1421 # Construct and send request 1422 request = self._client.put(url, query_parameters, header_parameters) 1423 pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) 1424 response = pipeline_response.http_response 1425 1426 if response.status_code not in [202]: 1427 map_error(status_code=response.status_code, response=response, error_map=error_map) 1428 raise models.StorageErrorException(response, self._deserialize) 1429 1430 if cls: 1431 response_headers = { 1432 'ETag': self._deserialize('str', response.headers.get('ETag')), 1433 'Last-Modified': self._deserialize('rfc-1123', response.headers.get('Last-Modified')), 1434 'x-ms-request-id': self._deserialize('str', response.headers.get('x-ms-request-id')), 1435 'x-ms-version': self._deserialize('str', response.headers.get('x-ms-version')), 1436 'Date': self._deserialize('rfc-1123', response.headers.get('Date')), 1437 'x-ms-copy-id': self._deserialize('str', response.headers.get('x-ms-copy-id')), 1438 'x-ms-copy-status': self._deserialize(models.CopyStatusType, response.headers.get('x-ms-copy-status')), 1439 'x-ms-error-code': self._deserialize('str', response.headers.get('x-ms-error-code')), 1440 } 1441 return cls(response, None, response_headers) 1442 start_copy.metadata = {'url': '/{shareName}/{directory}/{fileName}'} 1443 1444 def abort_copy(self, copy_id, timeout=None, lease_access_conditions=None, cls=None, **kwargs): 1445 """Aborts a pending Copy File operation, and leaves a destination file 1446 with zero length and full metadata. 1447 1448 :param copy_id: The copy identifier provided in the x-ms-copy-id 1449 header of the original Copy File operation. 1450 :type copy_id: str 1451 :param timeout: The timeout parameter is expressed in seconds. For 1452 more information, see <a 1453 href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting 1454 Timeouts for File Service Operations.</a> 1455 :type timeout: int 1456 :param lease_access_conditions: Additional parameters for the 1457 operation 1458 :type lease_access_conditions: 1459 ~azure.storage.fileshare.models.LeaseAccessConditions 1460 :param callable cls: A custom type or function that will be passed the 1461 direct response 1462 :return: None or the result of cls(response) 1463 :rtype: None 1464 :raises: 1465 :class:`StorageErrorException<azure.storage.fileshare.models.StorageErrorException>` 1466 """ 1467 error_map = kwargs.pop('error_map', None) 1468 lease_id = None 1469 if lease_access_conditions is not None: 1470 lease_id = lease_access_conditions.lease_id 1471 1472 comp = "copy" 1473 1474 # Construct URL 1475 url = self.abort_copy.metadata['url'] 1476 path_format_arguments = { 1477 'url': self._serialize.url("self._config.url", self._config.url, 'str', skip_quote=True) 1478 } 1479 url = self._client.format_url(url, **path_format_arguments) 1480 1481 # Construct parameters 1482 query_parameters = {} 1483 query_parameters['copyid'] = self._serialize.query("copy_id", copy_id, 'str') 1484 if timeout is not None: 1485 query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int', minimum=0) 1486 query_parameters['comp'] = self._serialize.query("comp", comp, 'str') 1487 1488 # Construct headers 1489 header_parameters = {} 1490 header_parameters['x-ms-copy-action'] = self._serialize.header("self.x_ms_copy_action", self.x_ms_copy_action, 'str') 1491 header_parameters['x-ms-version'] = self._serialize.header("self._config.version", self._config.version, 'str') 1492 if lease_id is not None: 1493 header_parameters['x-ms-lease-id'] = self._serialize.header("lease_id", lease_id, 'str') 1494 1495 # Construct and send request 1496 request = self._client.put(url, query_parameters, header_parameters) 1497 pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) 1498 response = pipeline_response.http_response 1499 1500 if response.status_code not in [204]: 1501 map_error(status_code=response.status_code, response=response, error_map=error_map) 1502 raise models.StorageErrorException(response, self._deserialize) 1503 1504 if cls: 1505 response_headers = { 1506 'x-ms-request-id': self._deserialize('str', response.headers.get('x-ms-request-id')), 1507 'x-ms-version': self._deserialize('str', response.headers.get('x-ms-version')), 1508 'Date': self._deserialize('rfc-1123', response.headers.get('Date')), 1509 'x-ms-error-code': self._deserialize('str', response.headers.get('x-ms-error-code')), 1510 } 1511 return cls(response, None, response_headers) 1512 abort_copy.metadata = {'url': '/{shareName}/{directory}/{fileName}'} 1513 1514 def list_handles(self, marker=None, maxresults=None, timeout=None, sharesnapshot=None, cls=None, **kwargs): 1515 """Lists handles for file. 1516 1517 :param marker: A string value that identifies the portion of the list 1518 to be returned with the next list operation. The operation returns a 1519 marker value within the response body if the list returned was not 1520 complete. The marker value may then be used in a subsequent call to 1521 request the next set of list items. The marker value is opaque to the 1522 client. 1523 :type marker: str 1524 :param maxresults: Specifies the maximum number of entries to return. 1525 If the request does not specify maxresults, or specifies a value 1526 greater than 5,000, the server will return up to 5,000 items. 1527 :type maxresults: int 1528 :param timeout: The timeout parameter is expressed in seconds. For 1529 more information, see <a 1530 href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting 1531 Timeouts for File Service Operations.</a> 1532 :type timeout: int 1533 :param sharesnapshot: The snapshot parameter is an opaque DateTime 1534 value that, when present, specifies the share snapshot to query. 1535 :type sharesnapshot: str 1536 :param callable cls: A custom type or function that will be passed the 1537 direct response 1538 :return: ListHandlesResponse or the result of cls(response) 1539 :rtype: ~azure.storage.fileshare.models.ListHandlesResponse 1540 :raises: 1541 :class:`StorageErrorException<azure.storage.fileshare.models.StorageErrorException>` 1542 """ 1543 error_map = kwargs.pop('error_map', None) 1544 comp = "listhandles" 1545 1546 # Construct URL 1547 url = self.list_handles.metadata['url'] 1548 path_format_arguments = { 1549 'url': self._serialize.url("self._config.url", self._config.url, 'str', skip_quote=True) 1550 } 1551 url = self._client.format_url(url, **path_format_arguments) 1552 1553 # Construct parameters 1554 query_parameters = {} 1555 if marker is not None: 1556 query_parameters['marker'] = self._serialize.query("marker", marker, 'str') 1557 if maxresults is not None: 1558 query_parameters['maxresults'] = self._serialize.query("maxresults", maxresults, 'int', minimum=1) 1559 if timeout is not None: 1560 query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int', minimum=0) 1561 if sharesnapshot is not None: 1562 query_parameters['sharesnapshot'] = self._serialize.query("sharesnapshot", sharesnapshot, 'str') 1563 query_parameters['comp'] = self._serialize.query("comp", comp, 'str') 1564 1565 # Construct headers 1566 header_parameters = {} 1567 header_parameters['Accept'] = 'application/xml' 1568 header_parameters['x-ms-version'] = self._serialize.header("self._config.version", self._config.version, 'str') 1569 1570 # Construct and send request 1571 request = self._client.get(url, query_parameters, header_parameters) 1572 pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) 1573 response = pipeline_response.http_response 1574 1575 if response.status_code not in [200]: 1576 map_error(status_code=response.status_code, response=response, error_map=error_map) 1577 raise models.StorageErrorException(response, self._deserialize) 1578 1579 header_dict = {} 1580 deserialized = None 1581 if response.status_code == 200: 1582 deserialized = self._deserialize('ListHandlesResponse', response) 1583 header_dict = { 1584 'Content-Type': self._deserialize('str', response.headers.get('Content-Type')), 1585 'x-ms-request-id': self._deserialize('str', response.headers.get('x-ms-request-id')), 1586 'x-ms-version': self._deserialize('str', response.headers.get('x-ms-version')), 1587 'Date': self._deserialize('rfc-1123', response.headers.get('Date')), 1588 'x-ms-error-code': self._deserialize('str', response.headers.get('x-ms-error-code')), 1589 } 1590 1591 if cls: 1592 return cls(response, deserialized, header_dict) 1593 1594 return deserialized 1595 list_handles.metadata = {'url': '/{shareName}/{directory}/{fileName}'} 1596 1597 def force_close_handles(self, handle_id, timeout=None, marker=None, sharesnapshot=None, cls=None, **kwargs): 1598 """Closes all handles open for given file. 1599 1600 :param handle_id: Specifies handle ID opened on the file or directory 1601 to be closed. Asterisk (‘*’) is a wildcard that specifies all handles. 1602 :type handle_id: str 1603 :param timeout: The timeout parameter is expressed in seconds. For 1604 more information, see <a 1605 href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting 1606 Timeouts for File Service Operations.</a> 1607 :type timeout: int 1608 :param marker: A string value that identifies the portion of the list 1609 to be returned with the next list operation. The operation returns a 1610 marker value within the response body if the list returned was not 1611 complete. The marker value may then be used in a subsequent call to 1612 request the next set of list items. The marker value is opaque to the 1613 client. 1614 :type marker: str 1615 :param sharesnapshot: The snapshot parameter is an opaque DateTime 1616 value that, when present, specifies the share snapshot to query. 1617 :type sharesnapshot: str 1618 :param callable cls: A custom type or function that will be passed the 1619 direct response 1620 :return: None or the result of cls(response) 1621 :rtype: None 1622 :raises: 1623 :class:`StorageErrorException<azure.storage.fileshare.models.StorageErrorException>` 1624 """ 1625 error_map = kwargs.pop('error_map', None) 1626 comp = "forceclosehandles" 1627 1628 # Construct URL 1629 url = self.force_close_handles.metadata['url'] 1630 path_format_arguments = { 1631 'url': self._serialize.url("self._config.url", self._config.url, 'str', skip_quote=True) 1632 } 1633 url = self._client.format_url(url, **path_format_arguments) 1634 1635 # Construct parameters 1636 query_parameters = {} 1637 if timeout is not None: 1638 query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int', minimum=0) 1639 if marker is not None: 1640 query_parameters['marker'] = self._serialize.query("marker", marker, 'str') 1641 if sharesnapshot is not None: 1642 query_parameters['sharesnapshot'] = self._serialize.query("sharesnapshot", sharesnapshot, 'str') 1643 query_parameters['comp'] = self._serialize.query("comp", comp, 'str') 1644 1645 # Construct headers 1646 header_parameters = {} 1647 header_parameters['x-ms-handle-id'] = self._serialize.header("handle_id", handle_id, 'str') 1648 header_parameters['x-ms-version'] = self._serialize.header("self._config.version", self._config.version, 'str') 1649 1650 # Construct and send request 1651 request = self._client.put(url, query_parameters, header_parameters) 1652 pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) 1653 response = pipeline_response.http_response 1654 1655 if response.status_code not in [200]: 1656 map_error(status_code=response.status_code, response=response, error_map=error_map) 1657 raise models.StorageErrorException(response, self._deserialize) 1658 1659 if cls: 1660 response_headers = { 1661 'x-ms-request-id': self._deserialize('str', response.headers.get('x-ms-request-id')), 1662 'x-ms-version': self._deserialize('str', response.headers.get('x-ms-version')), 1663 'Date': self._deserialize('rfc-1123', response.headers.get('Date')), 1664 'x-ms-marker': self._deserialize('str', response.headers.get('x-ms-marker')), 1665 'x-ms-number-of-handles-closed': self._deserialize('int', response.headers.get('x-ms-number-of-handles-closed')), 1666 'x-ms-number-of-handles-failed': self._deserialize('int', response.headers.get('x-ms-number-of-handles-failed')), 1667 'x-ms-error-code': self._deserialize('str', response.headers.get('x-ms-error-code')), 1668 } 1669 return cls(response, None, response_headers) 1670 force_close_handles.metadata = {'url': '/{shareName}/{directory}/{fileName}'} 1671