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 ShareOperations:
18    """ShareOperations async 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 restype: . Constant value: "share".
27    """
28
29    models = models
30
31    def __init__(self, client, config, serializer, deserializer) -> None:
32
33        self._client = client
34        self._serialize = serializer
35        self._deserialize = deserializer
36
37        self._config = config
38        self.restype = "share"
39
40    async def create(self, timeout=None, metadata=None, quota=None, *, cls=None, **kwargs):
41        """Creates a new share under the specified account. If the share with the
42        same name already exists, the operation fails.
43
44        :param timeout: The timeout parameter is expressed in seconds. For
45         more information, see <a
46         href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting
47         Timeouts for File Service Operations.</a>
48        :type timeout: int
49        :param metadata: A name-value pair to associate with a file storage
50         object.
51        :type metadata: str
52        :param quota: Specifies the maximum size of the share, in gigabytes.
53        :type quota: int
54        :param callable cls: A custom type or function that will be passed the
55         direct response
56        :return: None or the result of cls(response)
57        :rtype: None
58        :raises:
59         :class:`StorageErrorException<azure.storage.fileshare.models.StorageErrorException>`
60        """
61        error_map = kwargs.pop('error_map', None)
62        # Construct URL
63        url = self.create.metadata['url']
64        path_format_arguments = {
65            'url': self._serialize.url("self._config.url", self._config.url, 'str', skip_quote=True)
66        }
67        url = self._client.format_url(url, **path_format_arguments)
68
69        # Construct parameters
70        query_parameters = {}
71        if timeout is not None:
72            query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int', minimum=0)
73        query_parameters['restype'] = self._serialize.query("self.restype", self.restype, 'str')
74
75        # Construct headers
76        header_parameters = {}
77        if metadata is not None:
78            header_parameters['x-ms-meta'] = self._serialize.header("metadata", metadata, 'str')
79        if quota is not None:
80            header_parameters['x-ms-share-quota'] = self._serialize.header("quota", quota, 'int', minimum=1)
81        header_parameters['x-ms-version'] = self._serialize.header("self._config.version", self._config.version, 'str')
82
83        # Construct and send request
84        request = self._client.put(url, query_parameters, header_parameters)
85        pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
86        response = pipeline_response.http_response
87
88        if response.status_code not in [201]:
89            map_error(status_code=response.status_code, response=response, error_map=error_map)
90            raise models.StorageErrorException(response, self._deserialize)
91
92        if cls:
93            response_headers = {
94                'ETag': self._deserialize('str', response.headers.get('ETag')),
95                'Last-Modified': self._deserialize('rfc-1123', response.headers.get('Last-Modified')),
96                'x-ms-request-id': self._deserialize('str', response.headers.get('x-ms-request-id')),
97                'x-ms-version': self._deserialize('str', response.headers.get('x-ms-version')),
98                'Date': self._deserialize('rfc-1123', response.headers.get('Date')),
99                'x-ms-error-code': self._deserialize('str', response.headers.get('x-ms-error-code')),
100            }
101            return cls(response, None, response_headers)
102    create.metadata = {'url': '/{shareName}'}
103
104    async def get_properties(self, sharesnapshot=None, timeout=None, *, cls=None, **kwargs):
105        """Returns all user-defined metadata and system properties for the
106        specified share or share snapshot. The data returned does not include
107        the share's list of files.
108
109        :param sharesnapshot: The snapshot parameter is an opaque DateTime
110         value that, when present, specifies the share snapshot to query.
111        :type sharesnapshot: str
112        :param timeout: The timeout parameter is expressed in seconds. For
113         more information, see <a
114         href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting
115         Timeouts for File Service Operations.</a>
116        :type timeout: int
117        :param callable cls: A custom type or function that will be passed the
118         direct response
119        :return: None or the result of cls(response)
120        :rtype: None
121        :raises:
122         :class:`StorageErrorException<azure.storage.fileshare.models.StorageErrorException>`
123        """
124        error_map = kwargs.pop('error_map', None)
125        # Construct URL
126        url = self.get_properties.metadata['url']
127        path_format_arguments = {
128            'url': self._serialize.url("self._config.url", self._config.url, 'str', skip_quote=True)
129        }
130        url = self._client.format_url(url, **path_format_arguments)
131
132        # Construct parameters
133        query_parameters = {}
134        if sharesnapshot is not None:
135            query_parameters['sharesnapshot'] = self._serialize.query("sharesnapshot", sharesnapshot, 'str')
136        if timeout is not None:
137            query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int', minimum=0)
138        query_parameters['restype'] = self._serialize.query("self.restype", self.restype, 'str')
139
140        # Construct headers
141        header_parameters = {}
142        header_parameters['x-ms-version'] = self._serialize.header("self._config.version", self._config.version, 'str')
143
144        # Construct and send request
145        request = self._client.get(url, query_parameters, header_parameters)
146        pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
147        response = pipeline_response.http_response
148
149        if response.status_code not in [200]:
150            map_error(status_code=response.status_code, response=response, error_map=error_map)
151            raise models.StorageErrorException(response, self._deserialize)
152
153        if cls:
154            response_headers = {
155                'x-ms-meta': self._deserialize('{str}', response.headers.get('x-ms-meta')),
156                'ETag': self._deserialize('str', response.headers.get('ETag')),
157                'Last-Modified': self._deserialize('rfc-1123', response.headers.get('Last-Modified')),
158                'x-ms-request-id': self._deserialize('str', response.headers.get('x-ms-request-id')),
159                'x-ms-version': self._deserialize('str', response.headers.get('x-ms-version')),
160                'Date': self._deserialize('rfc-1123', response.headers.get('Date')),
161                'x-ms-share-quota': self._deserialize('int', response.headers.get('x-ms-share-quota')),
162                'x-ms-share-provisioned-iops': self._deserialize('int', response.headers.get('x-ms-share-provisioned-iops')),
163                'x-ms-share-provisioned-ingress-mbps': self._deserialize('int', response.headers.get('x-ms-share-provisioned-ingress-mbps')),
164                'x-ms-share-provisioned-egress-mbps': self._deserialize('int', response.headers.get('x-ms-share-provisioned-egress-mbps')),
165                'x-ms-share-next-allowed-quota-downgrade-time': self._deserialize('rfc-1123', response.headers.get('x-ms-share-next-allowed-quota-downgrade-time')),
166                'x-ms-error-code': self._deserialize('str', response.headers.get('x-ms-error-code')),
167            }
168            return cls(response, None, response_headers)
169    get_properties.metadata = {'url': '/{shareName}'}
170
171    async def delete(self, sharesnapshot=None, timeout=None, delete_snapshots=None, *, cls=None, **kwargs):
172        """Operation marks the specified share or share snapshot for deletion. The
173        share or share snapshot and any files contained within it are later
174        deleted during garbage collection.
175
176        :param sharesnapshot: The snapshot parameter is an opaque DateTime
177         value that, when present, specifies the share snapshot to query.
178        :type sharesnapshot: str
179        :param timeout: The timeout parameter is expressed in seconds. For
180         more information, see <a
181         href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting
182         Timeouts for File Service Operations.</a>
183        :type timeout: int
184        :param delete_snapshots: Specifies the option include to delete the
185         base share and all of its snapshots. Possible values include:
186         'include'
187        :type delete_snapshots: str or
188         ~azure.storage.fileshare.models.DeleteSnapshotsOptionType
189        :param callable cls: A custom type or function that will be passed the
190         direct response
191        :return: None or the result of cls(response)
192        :rtype: None
193        :raises:
194         :class:`StorageErrorException<azure.storage.fileshare.models.StorageErrorException>`
195        """
196        error_map = kwargs.pop('error_map', None)
197        # Construct URL
198        url = self.delete.metadata['url']
199        path_format_arguments = {
200            'url': self._serialize.url("self._config.url", self._config.url, 'str', skip_quote=True)
201        }
202        url = self._client.format_url(url, **path_format_arguments)
203
204        # Construct parameters
205        query_parameters = {}
206        if sharesnapshot is not None:
207            query_parameters['sharesnapshot'] = self._serialize.query("sharesnapshot", sharesnapshot, 'str')
208        if timeout is not None:
209            query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int', minimum=0)
210        query_parameters['restype'] = self._serialize.query("self.restype", self.restype, 'str')
211
212        # Construct headers
213        header_parameters = {}
214        header_parameters['x-ms-version'] = self._serialize.header("self._config.version", self._config.version, 'str')
215        if delete_snapshots is not None:
216            header_parameters['x-ms-delete-snapshots'] = self._serialize.header("delete_snapshots", delete_snapshots, 'DeleteSnapshotsOptionType')
217
218        # Construct and send request
219        request = self._client.delete(url, query_parameters, header_parameters)
220        pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
221        response = pipeline_response.http_response
222
223        if response.status_code not in [202]:
224            map_error(status_code=response.status_code, response=response, error_map=error_map)
225            raise models.StorageErrorException(response, self._deserialize)
226
227        if cls:
228            response_headers = {
229                'x-ms-request-id': self._deserialize('str', response.headers.get('x-ms-request-id')),
230                'x-ms-version': self._deserialize('str', response.headers.get('x-ms-version')),
231                'Date': self._deserialize('rfc-1123', response.headers.get('Date')),
232                'x-ms-error-code': self._deserialize('str', response.headers.get('x-ms-error-code')),
233            }
234            return cls(response, None, response_headers)
235    delete.metadata = {'url': '/{shareName}'}
236
237    async def create_snapshot(self, timeout=None, metadata=None, *, cls=None, **kwargs):
238        """Creates a read-only snapshot of a share.
239
240        :param timeout: The timeout parameter is expressed in seconds. For
241         more information, see <a
242         href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting
243         Timeouts for File Service Operations.</a>
244        :type timeout: int
245        :param metadata: A name-value pair to associate with a file storage
246         object.
247        :type metadata: str
248        :param callable cls: A custom type or function that will be passed the
249         direct response
250        :return: None or the result of cls(response)
251        :rtype: None
252        :raises:
253         :class:`StorageErrorException<azure.storage.fileshare.models.StorageErrorException>`
254        """
255        error_map = kwargs.pop('error_map', None)
256        comp = "snapshot"
257
258        # Construct URL
259        url = self.create_snapshot.metadata['url']
260        path_format_arguments = {
261            'url': self._serialize.url("self._config.url", self._config.url, 'str', skip_quote=True)
262        }
263        url = self._client.format_url(url, **path_format_arguments)
264
265        # Construct parameters
266        query_parameters = {}
267        if timeout is not None:
268            query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int', minimum=0)
269        query_parameters['restype'] = self._serialize.query("self.restype", self.restype, 'str')
270        query_parameters['comp'] = self._serialize.query("comp", comp, 'str')
271
272        # Construct headers
273        header_parameters = {}
274        if metadata is not None:
275            header_parameters['x-ms-meta'] = self._serialize.header("metadata", metadata, 'str')
276        header_parameters['x-ms-version'] = self._serialize.header("self._config.version", self._config.version, 'str')
277
278        # Construct and send request
279        request = self._client.put(url, query_parameters, header_parameters)
280        pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
281        response = pipeline_response.http_response
282
283        if response.status_code not in [201]:
284            map_error(status_code=response.status_code, response=response, error_map=error_map)
285            raise models.StorageErrorException(response, self._deserialize)
286
287        if cls:
288            response_headers = {
289                'x-ms-snapshot': self._deserialize('str', response.headers.get('x-ms-snapshot')),
290                'ETag': self._deserialize('str', response.headers.get('ETag')),
291                'Last-Modified': self._deserialize('rfc-1123', response.headers.get('Last-Modified')),
292                'x-ms-request-id': self._deserialize('str', response.headers.get('x-ms-request-id')),
293                'x-ms-version': self._deserialize('str', response.headers.get('x-ms-version')),
294                'Date': self._deserialize('rfc-1123', response.headers.get('Date')),
295                'x-ms-error-code': self._deserialize('str', response.headers.get('x-ms-error-code')),
296            }
297            return cls(response, None, response_headers)
298    create_snapshot.metadata = {'url': '/{shareName}'}
299
300    async def create_permission(self, share_permission, timeout=None, *, cls=None, **kwargs):
301        """Create a permission (a security descriptor).
302
303        :param share_permission: A permission (a security descriptor) at the
304         share level.
305        :type share_permission:
306         ~azure.storage.fileshare.models.SharePermission
307        :param timeout: The timeout parameter is expressed in seconds. For
308         more information, see <a
309         href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting
310         Timeouts for File Service Operations.</a>
311        :type timeout: int
312        :param callable cls: A custom type or function that will be passed the
313         direct response
314        :return: None or the result of cls(response)
315        :rtype: None
316        :raises:
317         :class:`StorageErrorException<azure.storage.fileshare.models.StorageErrorException>`
318        """
319        error_map = kwargs.pop('error_map', None)
320        comp = "filepermission"
321
322        # Construct URL
323        url = self.create_permission.metadata['url']
324        path_format_arguments = {
325            'url': self._serialize.url("self._config.url", self._config.url, 'str', skip_quote=True)
326        }
327        url = self._client.format_url(url, **path_format_arguments)
328
329        # Construct parameters
330        query_parameters = {}
331        if timeout is not None:
332            query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int', minimum=0)
333        query_parameters['restype'] = self._serialize.query("self.restype", self.restype, 'str')
334        query_parameters['comp'] = self._serialize.query("comp", comp, 'str')
335
336        # Construct headers
337        header_parameters = {}
338        header_parameters['Content-Type'] = 'application/json; charset=utf-8'
339        header_parameters['x-ms-version'] = self._serialize.header("self._config.version", self._config.version, 'str')
340
341        # Construct body
342        body_content = self._serialize.body(share_permission, 'SharePermission', is_xml=False)
343
344        # Construct and send request
345        request = self._client.put(url, query_parameters, header_parameters, body_content)
346        pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
347        response = pipeline_response.http_response
348
349        if response.status_code not in [201]:
350            map_error(status_code=response.status_code, response=response, error_map=error_map)
351            raise models.StorageErrorException(response, self._deserialize)
352
353        if cls:
354            response_headers = {
355                'x-ms-request-id': self._deserialize('str', response.headers.get('x-ms-request-id')),
356                'x-ms-version': self._deserialize('str', response.headers.get('x-ms-version')),
357                'Date': self._deserialize('rfc-1123', response.headers.get('Date')),
358                'x-ms-file-permission-key': self._deserialize('str', response.headers.get('x-ms-file-permission-key')),
359                'x-ms-error-code': self._deserialize('str', response.headers.get('x-ms-error-code')),
360            }
361            return cls(response, None, response_headers)
362    create_permission.metadata = {'url': '/{shareName}'}
363
364    async def get_permission(self, file_permission_key, timeout=None, *, cls=None, **kwargs):
365        """Returns the permission (security descriptor) for a given key.
366
367        :param file_permission_key: Key of the permission to be set for the
368         directory/file.
369        :type file_permission_key: str
370        :param timeout: The timeout parameter is expressed in seconds. For
371         more information, see <a
372         href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting
373         Timeouts for File Service Operations.</a>
374        :type timeout: int
375        :param callable cls: A custom type or function that will be passed the
376         direct response
377        :return: SharePermission or the result of cls(response)
378        :rtype: ~azure.storage.fileshare.models.SharePermission
379        :raises:
380         :class:`StorageErrorException<azure.storage.fileshare.models.StorageErrorException>`
381        """
382        error_map = kwargs.pop('error_map', None)
383        comp = "filepermission"
384
385        # Construct URL
386        url = self.get_permission.metadata['url']
387        path_format_arguments = {
388            'url': self._serialize.url("self._config.url", self._config.url, 'str', skip_quote=True)
389        }
390        url = self._client.format_url(url, **path_format_arguments)
391
392        # Construct parameters
393        query_parameters = {}
394        if timeout is not None:
395            query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int', minimum=0)
396        query_parameters['restype'] = self._serialize.query("self.restype", self.restype, 'str')
397        query_parameters['comp'] = self._serialize.query("comp", comp, 'str')
398
399        # Construct headers
400        header_parameters = {}
401        header_parameters['Accept'] = 'application/json'
402        header_parameters['x-ms-file-permission-key'] = self._serialize.header("file_permission_key", file_permission_key, 'str')
403        header_parameters['x-ms-version'] = self._serialize.header("self._config.version", self._config.version, 'str')
404
405        # Construct and send request
406        request = self._client.get(url, query_parameters, header_parameters)
407        pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
408        response = pipeline_response.http_response
409
410        if response.status_code not in [200]:
411            map_error(status_code=response.status_code, response=response, error_map=error_map)
412            raise models.StorageErrorException(response, self._deserialize)
413
414        header_dict = {}
415        deserialized = None
416        if response.status_code == 200:
417            deserialized = self._deserialize('SharePermission', response)
418            header_dict = {
419                'x-ms-request-id': self._deserialize('str', response.headers.get('x-ms-request-id')),
420                'x-ms-version': self._deserialize('str', response.headers.get('x-ms-version')),
421                'Date': self._deserialize('rfc-1123', response.headers.get('Date')),
422                'x-ms-error-code': self._deserialize('str', response.headers.get('x-ms-error-code')),
423            }
424
425        if cls:
426            return cls(response, deserialized, header_dict)
427
428        return deserialized
429    get_permission.metadata = {'url': '/{shareName}'}
430
431    async def set_quota(self, timeout=None, quota=None, *, cls=None, **kwargs):
432        """Sets quota for the specified share.
433
434        :param timeout: The timeout parameter is expressed in seconds. For
435         more information, see <a
436         href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting
437         Timeouts for File Service Operations.</a>
438        :type timeout: int
439        :param quota: Specifies the maximum size of the share, in gigabytes.
440        :type quota: int
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        comp = "properties"
450
451        # Construct URL
452        url = self.set_quota.metadata['url']
453        path_format_arguments = {
454            'url': self._serialize.url("self._config.url", self._config.url, 'str', skip_quote=True)
455        }
456        url = self._client.format_url(url, **path_format_arguments)
457
458        # Construct parameters
459        query_parameters = {}
460        if timeout is not None:
461            query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int', minimum=0)
462        query_parameters['restype'] = self._serialize.query("self.restype", self.restype, 'str')
463        query_parameters['comp'] = self._serialize.query("comp", comp, 'str')
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 quota is not None:
469            header_parameters['x-ms-share-quota'] = self._serialize.header("quota", quota, 'int', minimum=1)
470
471        # Construct and send request
472        request = self._client.put(url, query_parameters, header_parameters)
473        pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
474        response = pipeline_response.http_response
475
476        if response.status_code not in [200]:
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                'ETag': self._deserialize('str', response.headers.get('ETag')),
483                'Last-Modified': self._deserialize('rfc-1123', response.headers.get('Last-Modified')),
484                'x-ms-request-id': self._deserialize('str', response.headers.get('x-ms-request-id')),
485                'x-ms-version': self._deserialize('str', response.headers.get('x-ms-version')),
486                'Date': self._deserialize('rfc-1123', response.headers.get('Date')),
487                'x-ms-error-code': self._deserialize('str', response.headers.get('x-ms-error-code')),
488            }
489            return cls(response, None, response_headers)
490    set_quota.metadata = {'url': '/{shareName}'}
491
492    async def set_metadata(self, timeout=None, metadata=None, *, cls=None, **kwargs):
493        """Sets one or more user-defined name-value pairs for the specified share.
494
495        :param timeout: The timeout parameter is expressed in seconds. For
496         more information, see <a
497         href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting
498         Timeouts for File Service Operations.</a>
499        :type timeout: int
500        :param metadata: A name-value pair to associate with a file storage
501         object.
502        :type metadata: str
503        :param callable cls: A custom type or function that will be passed the
504         direct response
505        :return: None or the result of cls(response)
506        :rtype: None
507        :raises:
508         :class:`StorageErrorException<azure.storage.fileshare.models.StorageErrorException>`
509        """
510        error_map = kwargs.pop('error_map', None)
511        comp = "metadata"
512
513        # Construct URL
514        url = self.set_metadata.metadata['url']
515        path_format_arguments = {
516            'url': self._serialize.url("self._config.url", self._config.url, 'str', skip_quote=True)
517        }
518        url = self._client.format_url(url, **path_format_arguments)
519
520        # Construct parameters
521        query_parameters = {}
522        if timeout is not None:
523            query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int', minimum=0)
524        query_parameters['restype'] = self._serialize.query("self.restype", self.restype, 'str')
525        query_parameters['comp'] = self._serialize.query("comp", comp, 'str')
526
527        # Construct headers
528        header_parameters = {}
529        if metadata is not None:
530            header_parameters['x-ms-meta'] = self._serialize.header("metadata", metadata, 'str')
531        header_parameters['x-ms-version'] = self._serialize.header("self._config.version", self._config.version, 'str')
532
533        # Construct and send request
534        request = self._client.put(url, query_parameters, header_parameters)
535        pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
536        response = pipeline_response.http_response
537
538        if response.status_code not in [200]:
539            map_error(status_code=response.status_code, response=response, error_map=error_map)
540            raise models.StorageErrorException(response, self._deserialize)
541
542        if cls:
543            response_headers = {
544                'ETag': self._deserialize('str', response.headers.get('ETag')),
545                'Last-Modified': self._deserialize('rfc-1123', response.headers.get('Last-Modified')),
546                'x-ms-request-id': self._deserialize('str', response.headers.get('x-ms-request-id')),
547                'x-ms-version': self._deserialize('str', response.headers.get('x-ms-version')),
548                'Date': self._deserialize('rfc-1123', response.headers.get('Date')),
549                'x-ms-error-code': self._deserialize('str', response.headers.get('x-ms-error-code')),
550            }
551            return cls(response, None, response_headers)
552    set_metadata.metadata = {'url': '/{shareName}'}
553
554    async def get_access_policy(self, timeout=None, *, cls=None, **kwargs):
555        """Returns information about stored access policies specified on the
556        share.
557
558        :param timeout: The timeout parameter is expressed in seconds. For
559         more information, see <a
560         href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting
561         Timeouts for File Service Operations.</a>
562        :type timeout: int
563        :param callable cls: A custom type or function that will be passed the
564         direct response
565        :return: list or the result of cls(response)
566        :rtype: list[~azure.storage.fileshare.models.SignedIdentifier]
567        :raises:
568         :class:`StorageErrorException<azure.storage.fileshare.models.StorageErrorException>`
569        """
570        error_map = kwargs.pop('error_map', None)
571        comp = "acl"
572
573        # Construct URL
574        url = self.get_access_policy.metadata['url']
575        path_format_arguments = {
576            'url': self._serialize.url("self._config.url", self._config.url, 'str', skip_quote=True)
577        }
578        url = self._client.format_url(url, **path_format_arguments)
579
580        # Construct parameters
581        query_parameters = {}
582        if timeout is not None:
583            query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int', minimum=0)
584        query_parameters['restype'] = self._serialize.query("self.restype", self.restype, 'str')
585        query_parameters['comp'] = self._serialize.query("comp", comp, 'str')
586
587        # Construct headers
588        header_parameters = {}
589        header_parameters['Accept'] = 'application/xml'
590        header_parameters['x-ms-version'] = self._serialize.header("self._config.version", self._config.version, 'str')
591
592        # Construct and send request
593        request = self._client.get(url, query_parameters, header_parameters)
594        pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
595        response = pipeline_response.http_response
596
597        if response.status_code not in [200]:
598            map_error(status_code=response.status_code, response=response, error_map=error_map)
599            raise models.StorageErrorException(response, self._deserialize)
600
601        header_dict = {}
602        deserialized = None
603        if response.status_code == 200:
604            deserialized = self._deserialize('[SignedIdentifier]', response)
605            header_dict = {
606                'ETag': self._deserialize('str', response.headers.get('ETag')),
607                'Last-Modified': self._deserialize('rfc-1123', response.headers.get('Last-Modified')),
608                'x-ms-request-id': self._deserialize('str', response.headers.get('x-ms-request-id')),
609                'x-ms-version': self._deserialize('str', response.headers.get('x-ms-version')),
610                'Date': self._deserialize('rfc-1123', response.headers.get('Date')),
611                'x-ms-error-code': self._deserialize('str', response.headers.get('x-ms-error-code')),
612            }
613
614        if cls:
615            return cls(response, deserialized, header_dict)
616
617        return deserialized
618    get_access_policy.metadata = {'url': '/{shareName}'}
619
620    async def set_access_policy(self, share_acl=None, timeout=None, *, cls=None, **kwargs):
621        """Sets a stored access policy for use with shared access signatures.
622
623        :param share_acl: The ACL for the share.
624        :type share_acl:
625         list[~azure.storage.fileshare.models.SignedIdentifier]
626        :param timeout: The timeout parameter is expressed in seconds. For
627         more information, see <a
628         href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting
629         Timeouts for File Service Operations.</a>
630        :type timeout: int
631        :param callable cls: A custom type or function that will be passed the
632         direct response
633        :return: None or the result of cls(response)
634        :rtype: None
635        :raises:
636         :class:`StorageErrorException<azure.storage.fileshare.models.StorageErrorException>`
637        """
638        error_map = kwargs.pop('error_map', None)
639        comp = "acl"
640
641        # Construct URL
642        url = self.set_access_policy.metadata['url']
643        path_format_arguments = {
644            'url': self._serialize.url("self._config.url", self._config.url, 'str', skip_quote=True)
645        }
646        url = self._client.format_url(url, **path_format_arguments)
647
648        # Construct parameters
649        query_parameters = {}
650        if timeout is not None:
651            query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int', minimum=0)
652        query_parameters['restype'] = self._serialize.query("self.restype", self.restype, 'str')
653        query_parameters['comp'] = self._serialize.query("comp", comp, 'str')
654
655        # Construct headers
656        header_parameters = {}
657        header_parameters['Content-Type'] = 'application/xml; charset=utf-8'
658        header_parameters['x-ms-version'] = self._serialize.header("self._config.version", self._config.version, 'str')
659
660        # Construct body
661        serialization_ctxt = {'xml': {'name': 'SignedIdentifiers', 'itemsName': 'SignedIdentifier', 'wrapped': True}}
662        if share_acl is not None:
663            body_content = self._serialize.body(share_acl, '[SignedIdentifier]', serialization_ctxt=serialization_ctxt)
664        else:
665            body_content = None
666
667        # Construct and send request
668        request = self._client.put(url, query_parameters, header_parameters, body_content)
669        pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
670        response = pipeline_response.http_response
671
672        if response.status_code not in [200]:
673            map_error(status_code=response.status_code, response=response, error_map=error_map)
674            raise models.StorageErrorException(response, self._deserialize)
675
676        if cls:
677            response_headers = {
678                'ETag': self._deserialize('str', response.headers.get('ETag')),
679                'Last-Modified': self._deserialize('rfc-1123', response.headers.get('Last-Modified')),
680                'x-ms-request-id': self._deserialize('str', response.headers.get('x-ms-request-id')),
681                'x-ms-version': self._deserialize('str', response.headers.get('x-ms-version')),
682                'Date': self._deserialize('rfc-1123', response.headers.get('Date')),
683                'x-ms-error-code': self._deserialize('str', response.headers.get('x-ms-error-code')),
684            }
685            return cls(response, None, response_headers)
686    set_access_policy.metadata = {'url': '/{shareName}'}
687
688    async def get_statistics(self, timeout=None, *, cls=None, **kwargs):
689        """Retrieves statistics related to the share.
690
691        :param timeout: The timeout parameter is expressed in seconds. For
692         more information, see <a
693         href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting
694         Timeouts for File Service Operations.</a>
695        :type timeout: int
696        :param callable cls: A custom type or function that will be passed the
697         direct response
698        :return: ShareStats or the result of cls(response)
699        :rtype: ~azure.storage.fileshare.models.ShareStats
700        :raises:
701         :class:`StorageErrorException<azure.storage.fileshare.models.StorageErrorException>`
702        """
703        error_map = kwargs.pop('error_map', None)
704        comp = "stats"
705
706        # Construct URL
707        url = self.get_statistics.metadata['url']
708        path_format_arguments = {
709            'url': self._serialize.url("self._config.url", self._config.url, 'str', skip_quote=True)
710        }
711        url = self._client.format_url(url, **path_format_arguments)
712
713        # Construct parameters
714        query_parameters = {}
715        if timeout is not None:
716            query_parameters['timeout'] = self._serialize.query("timeout", timeout, 'int', minimum=0)
717        query_parameters['restype'] = self._serialize.query("self.restype", self.restype, 'str')
718        query_parameters['comp'] = self._serialize.query("comp", comp, 'str')
719
720        # Construct headers
721        header_parameters = {}
722        header_parameters['Accept'] = 'application/xml'
723        header_parameters['x-ms-version'] = self._serialize.header("self._config.version", self._config.version, 'str')
724
725        # Construct and send request
726        request = self._client.get(url, query_parameters, header_parameters)
727        pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
728        response = pipeline_response.http_response
729
730        if response.status_code not in [200]:
731            map_error(status_code=response.status_code, response=response, error_map=error_map)
732            raise models.StorageErrorException(response, self._deserialize)
733
734        header_dict = {}
735        deserialized = None
736        if response.status_code == 200:
737            deserialized = self._deserialize('ShareStats', response)
738            header_dict = {
739                'ETag': self._deserialize('str', response.headers.get('ETag')),
740                'Last-Modified': self._deserialize('rfc-1123', response.headers.get('Last-Modified')),
741                'x-ms-request-id': self._deserialize('str', response.headers.get('x-ms-request-id')),
742                'x-ms-version': self._deserialize('str', response.headers.get('x-ms-version')),
743                'Date': self._deserialize('rfc-1123', response.headers.get('Date')),
744                'x-ms-error-code': self._deserialize('str', response.headers.get('x-ms-error-code')),
745            }
746
747        if cls:
748            return cls(response, deserialized, header_dict)
749
750        return deserialized
751    get_statistics.metadata = {'url': '/{shareName}'}
752