diff options
Diffstat (limited to '.venv/lib/python3.12/site-packages/azure/storage/fileshare/_generated/aio')
10 files changed, 5932 insertions, 0 deletions
diff --git a/.venv/lib/python3.12/site-packages/azure/storage/fileshare/_generated/aio/__init__.py b/.venv/lib/python3.12/site-packages/azure/storage/fileshare/_generated/aio/__init__.py new file mode 100644 index 00000000..b4f1dd31 --- /dev/null +++ b/.venv/lib/python3.12/site-packages/azure/storage/fileshare/_generated/aio/__init__.py @@ -0,0 +1,29 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._azure_file_storage import AzureFileStorage # type: ignore + +try: + from ._patch import __all__ as _patch_all + from ._patch import * +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "AzureFileStorage", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore + +_patch_sdk() diff --git a/.venv/lib/python3.12/site-packages/azure/storage/fileshare/_generated/aio/_azure_file_storage.py b/.venv/lib/python3.12/site-packages/azure/storage/fileshare/_generated/aio/_azure_file_storage.py new file mode 100644 index 00000000..22c80eec --- /dev/null +++ b/.venv/lib/python3.12/site-packages/azure/storage/fileshare/_generated/aio/_azure_file_storage.py @@ -0,0 +1,132 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable, Optional, Union +from typing_extensions import Self + +from azure.core import AsyncPipelineClient +from azure.core.pipeline import policies +from azure.core.rest import AsyncHttpResponse, HttpRequest + +from .. import models as _models +from .._serialization import Deserializer, Serializer +from ._configuration import AzureFileStorageConfiguration +from .operations import DirectoryOperations, FileOperations, ServiceOperations, ShareOperations + + +class AzureFileStorage: # pylint: disable=client-accepts-api-version-keyword + """AzureFileStorage. + + :ivar service: ServiceOperations operations + :vartype service: azure.storage.fileshare.aio.operations.ServiceOperations + :ivar share: ShareOperations operations + :vartype share: azure.storage.fileshare.aio.operations.ShareOperations + :ivar directory: DirectoryOperations operations + :vartype directory: azure.storage.fileshare.aio.operations.DirectoryOperations + :ivar file: FileOperations operations + :vartype file: azure.storage.fileshare.aio.operations.FileOperations + :param url: The URL of the service account, share, directory or file that is the target of the + desired operation. Required. + :type url: str + :param base_url: Service URL. Required. Default value is "". + :type base_url: str + :param file_request_intent: Valid value is backup. "backup" Default value is None. + :type file_request_intent: str or ~azure.storage.fileshare.models.ShareTokenIntent + :param allow_trailing_dot: If true, the trailing dot will not be trimmed from the target URI. + Default value is None. + :type allow_trailing_dot: bool + :param allow_source_trailing_dot: If true, the trailing dot will not be trimmed from the source + URI. Default value is None. + :type allow_source_trailing_dot: bool + :keyword version: Specifies the version of the operation to use for this request. Default value + is "2025-05-05". Note that overriding this default value may result in unsupported behavior. + :paramtype version: str + :keyword file_range_write_from_url: Only update is supported: - Update: Writes the bytes + downloaded from the source url into the specified range. Default value is "update". Note that + overriding this default value may result in unsupported behavior. + :paramtype file_range_write_from_url: str + """ + + def __init__( # pylint: disable=missing-client-constructor-parameter-credential + self, + url: str, + base_url: str = "", + file_request_intent: Optional[Union[str, _models.ShareTokenIntent]] = None, + allow_trailing_dot: Optional[bool] = None, + allow_source_trailing_dot: Optional[bool] = None, + **kwargs: Any + ) -> None: + self._config = AzureFileStorageConfiguration( + url=url, + file_request_intent=file_request_intent, + allow_trailing_dot=allow_trailing_dot, + allow_source_trailing_dot=allow_source_trailing_dot, + **kwargs + ) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: AsyncPipelineClient = AsyncPipelineClient(base_url=base_url, policies=_policies, **kwargs) + + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.service = ServiceOperations(self._client, self._config, self._serialize, self._deserialize) + self.share = ShareOperations(self._client, self._config, self._serialize, self._deserialize) + self.directory = DirectoryOperations(self._client, self._config, self._serialize, self._deserialize) + self.file = FileOperations(self._client, self._config, self._serialize, self._deserialize) + + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + <HttpRequest [GET], url: 'https://www.example.org/'> + >>> response = await client._send_request(request) + <AsyncHttpResponse: 200 OK> + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> Self: + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details: Any) -> None: + await self._client.__aexit__(*exc_details) diff --git a/.venv/lib/python3.12/site-packages/azure/storage/fileshare/_generated/aio/_configuration.py b/.venv/lib/python3.12/site-packages/azure/storage/fileshare/_generated/aio/_configuration.py new file mode 100644 index 00000000..7cc25f81 --- /dev/null +++ b/.venv/lib/python3.12/site-packages/azure/storage/fileshare/_generated/aio/_configuration.py @@ -0,0 +1,77 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, Literal, Optional, Union + +from azure.core.pipeline import policies + +from .. import models as _models + +VERSION = "unknown" + + +class AzureFileStorageConfiguration: # pylint: disable=too-many-instance-attributes + """Configuration for AzureFileStorage. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param url: The URL of the service account, share, directory or file that is the target of the + desired operation. Required. + :type url: str + :param file_request_intent: Valid value is backup. "backup" Default value is None. + :type file_request_intent: str or ~azure.storage.fileshare.models.ShareTokenIntent + :param allow_trailing_dot: If true, the trailing dot will not be trimmed from the target URI. + Default value is None. + :type allow_trailing_dot: bool + :param allow_source_trailing_dot: If true, the trailing dot will not be trimmed from the source + URI. Default value is None. + :type allow_source_trailing_dot: bool + :keyword version: Specifies the version of the operation to use for this request. Default value + is "2025-05-05". Note that overriding this default value may result in unsupported behavior. + :paramtype version: str + :keyword file_range_write_from_url: Only update is supported: - Update: Writes the bytes + downloaded from the source url into the specified range. Default value is "update". Note that + overriding this default value may result in unsupported behavior. + :paramtype file_range_write_from_url: str + """ + + def __init__( + self, + url: str, + file_request_intent: Optional[Union[str, _models.ShareTokenIntent]] = None, + allow_trailing_dot: Optional[bool] = None, + allow_source_trailing_dot: Optional[bool] = None, + **kwargs: Any + ) -> None: + version: Literal["2025-05-05"] = kwargs.pop("version", "2025-05-05") + file_range_write_from_url: Literal["update"] = kwargs.pop("file_range_write_from_url", "update") + + if url is None: + raise ValueError("Parameter 'url' must not be None.") + + self.url = url + self.file_request_intent = file_request_intent + self.allow_trailing_dot = allow_trailing_dot + self.allow_source_trailing_dot = allow_source_trailing_dot + self.version = version + self.file_range_write_from_url = file_range_write_from_url + kwargs.setdefault("sdk_moniker", "azurefilestorage/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) + self._configure(**kwargs) + + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") diff --git a/.venv/lib/python3.12/site-packages/azure/storage/fileshare/_generated/aio/_patch.py b/.venv/lib/python3.12/site-packages/azure/storage/fileshare/_generated/aio/_patch.py new file mode 100644 index 00000000..f7dd3251 --- /dev/null +++ b/.venv/lib/python3.12/site-packages/azure/storage/fileshare/_generated/aio/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/.venv/lib/python3.12/site-packages/azure/storage/fileshare/_generated/aio/operations/__init__.py b/.venv/lib/python3.12/site-packages/azure/storage/fileshare/_generated/aio/operations/__init__.py new file mode 100644 index 00000000..092b7efd --- /dev/null +++ b/.venv/lib/python3.12/site-packages/azure/storage/fileshare/_generated/aio/operations/__init__.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._service_operations import ServiceOperations # type: ignore +from ._share_operations import ShareOperations # type: ignore +from ._directory_operations import DirectoryOperations # type: ignore +from ._file_operations import FileOperations # type: ignore + +from ._patch import __all__ as _patch_all +from ._patch import * +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ServiceOperations", + "ShareOperations", + "DirectoryOperations", + "FileOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore +_patch_sdk() diff --git a/.venv/lib/python3.12/site-packages/azure/storage/fileshare/_generated/aio/operations/_directory_operations.py b/.venv/lib/python3.12/site-packages/azure/storage/fileshare/_generated/aio/operations/_directory_operations.py new file mode 100644 index 00000000..83a84985 --- /dev/null +++ b/.venv/lib/python3.12/site-packages/azure/storage/fileshare/_generated/aio/operations/_directory_operations.py @@ -0,0 +1,1056 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, List, Literal, Optional, TypeVar, Union + +from azure.core import AsyncPipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict + +from ... import models as _models +from ..._serialization import Deserializer, Serializer +from ...operations._directory_operations import ( + build_create_request, + build_delete_request, + build_force_close_handles_request, + build_get_properties_request, + build_list_files_and_directories_segment_request, + build_list_handles_request, + build_rename_request, + build_set_metadata_request, + build_set_properties_request, +) +from .._configuration import AzureFileStorageConfiguration + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class DirectoryOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.storage.fileshare.aio.AzureFileStorage`'s + :attr:`directory` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AzureFileStorageConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def create( + self, + timeout: Optional[int] = None, + metadata: Optional[Dict[str, str]] = None, + file_permission: str = "inherit", + file_permission_format: Optional[Union[str, _models.FilePermissionFormat]] = None, + file_permission_key: Optional[str] = None, + file_attributes: str = "none", + file_creation_time: str = "now", + file_last_write_time: str = "now", + file_change_time: Optional[str] = None, + owner: Optional[str] = None, + group: Optional[str] = None, + file_mode: Optional[str] = None, + **kwargs: Any + ) -> None: + # pylint: disable=line-too-long + """Creates a new directory under the specified share or parent directory. + + :param timeout: The timeout parameter is expressed in seconds. For more information, see + :code:`<a + href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting + Timeouts for File Service Operations.</a>`. Default value is None. + :type timeout: int + :param metadata: A name-value pair to associate with a file storage object. Default value is + None. + :type metadata: dict[str, str] + :param file_permission: If specified the permission (security descriptor) shall be set for the + directory/file. This header can be used if Permission size is <= 8KB, else + x-ms-file-permission-key header shall be used. Default value: Inherit. If SDDL is specified as + input, it must have owner, group and dacl. Note: Only one of the x-ms-file-permission or + x-ms-file-permission-key should be specified. Default value is "inherit". + :type file_permission: str + :param file_permission_format: Optional. Available for version 2023-06-01 and later. Specifies + the format in which the permission is returned. Acceptable values are SDDL or binary. If + x-ms-file-permission-format is unspecified or explicitly set to SDDL, the permission is + returned in SDDL format. If x-ms-file-permission-format is explicitly set to binary, the + permission is returned as a base64 string representing the binary encoding of the permission. + Known values are: "Sddl" and "Binary". Default value is None. + :type file_permission_format: str or ~azure.storage.fileshare.models.FilePermissionFormat + :param file_permission_key: Key of the permission to be set for the directory/file. Note: Only + one of the x-ms-file-permission or x-ms-file-permission-key should be specified. Default value + is None. + :type file_permission_key: str + :param file_attributes: If specified, the provided file attributes shall be set. Default value: + ‘Archive’ for file and ‘Directory’ for directory. ‘None’ can also be specified as default. + Default value is "none". + :type file_attributes: str + :param file_creation_time: Creation time for the file/directory. Default value: Now. Default + value is "now". + :type file_creation_time: str + :param file_last_write_time: Last write time for the file/directory. Default value: Now. + Default value is "now". + :type file_last_write_time: str + :param file_change_time: Change time for the file/directory. Default value: Now. Default value + is None. + :type file_change_time: str + :param owner: Optional, NFS only. The owner of the file or directory. Default value is None. + :type owner: str + :param group: Optional, NFS only. The owning group of the file or directory. Default value is + None. + :type group: str + :param file_mode: Optional, NFS only. The file mode of the file or directory. Default value is + None. + :type file_mode: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + restype: Literal["directory"] = kwargs.pop("restype", _params.pop("restype", "directory")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_create_request( + url=self._config.url, + timeout=timeout, + metadata=metadata, + file_permission=file_permission, + file_permission_format=file_permission_format, + file_permission_key=file_permission_key, + file_attributes=file_attributes, + file_creation_time=file_creation_time, + file_last_write_time=file_last_write_time, + file_change_time=file_change_time, + owner=owner, + group=group, + file_mode=file_mode, + allow_trailing_dot=self._config.allow_trailing_dot, + file_request_intent=self._config.file_request_intent, + restype=restype, + version=self._config.version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["Last-Modified"] = self._deserialize("rfc-1123", response.headers.get("Last-Modified")) + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-request-server-encrypted"] = self._deserialize( + "bool", response.headers.get("x-ms-request-server-encrypted") + ) + response_headers["x-ms-file-permission-key"] = self._deserialize( + "str", response.headers.get("x-ms-file-permission-key") + ) + response_headers["x-ms-file-attributes"] = self._deserialize( + "str", response.headers.get("x-ms-file-attributes") + ) + response_headers["x-ms-file-creation-time"] = self._deserialize( + "str", response.headers.get("x-ms-file-creation-time") + ) + response_headers["x-ms-file-last-write-time"] = self._deserialize( + "str", response.headers.get("x-ms-file-last-write-time") + ) + response_headers["x-ms-file-change-time"] = self._deserialize( + "str", response.headers.get("x-ms-file-change-time") + ) + response_headers["x-ms-file-id"] = self._deserialize("str", response.headers.get("x-ms-file-id")) + response_headers["x-ms-file-parent-id"] = self._deserialize("str", response.headers.get("x-ms-file-parent-id")) + response_headers["x-ms-mode"] = self._deserialize("str", response.headers.get("x-ms-mode")) + response_headers["x-ms-owner"] = self._deserialize("str", response.headers.get("x-ms-owner")) + response_headers["x-ms-group"] = self._deserialize("str", response.headers.get("x-ms-group")) + response_headers["x-ms-file-file-type"] = self._deserialize("str", response.headers.get("x-ms-file-file-type")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace_async + async def get_properties( + self, sharesnapshot: Optional[str] = None, timeout: Optional[int] = None, **kwargs: Any + ) -> None: + # pylint: disable=line-too-long + """Returns all system properties for the specified directory, and can also be used to check the + existence of a directory. The data returned does not include the files in the directory or any + subdirectories. + + :param sharesnapshot: The snapshot parameter is an opaque DateTime value that, when present, + specifies the share snapshot to query. Default value is None. + :type sharesnapshot: str + :param timeout: The timeout parameter is expressed in seconds. For more information, see + :code:`<a + href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting + Timeouts for File Service Operations.</a>`. Default value is None. + :type timeout: int + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + restype: Literal["directory"] = kwargs.pop("restype", _params.pop("restype", "directory")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_get_properties_request( + url=self._config.url, + sharesnapshot=sharesnapshot, + timeout=timeout, + allow_trailing_dot=self._config.allow_trailing_dot, + file_request_intent=self._config.file_request_intent, + restype=restype, + version=self._config.version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["x-ms-meta"] = self._deserialize("{str}", response.headers.get("x-ms-meta")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["Last-Modified"] = self._deserialize("rfc-1123", response.headers.get("Last-Modified")) + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-server-encrypted"] = self._deserialize( + "bool", response.headers.get("x-ms-server-encrypted") + ) + response_headers["x-ms-file-attributes"] = self._deserialize( + "str", response.headers.get("x-ms-file-attributes") + ) + response_headers["x-ms-file-creation-time"] = self._deserialize( + "str", response.headers.get("x-ms-file-creation-time") + ) + response_headers["x-ms-file-last-write-time"] = self._deserialize( + "str", response.headers.get("x-ms-file-last-write-time") + ) + response_headers["x-ms-file-change-time"] = self._deserialize( + "str", response.headers.get("x-ms-file-change-time") + ) + response_headers["x-ms-file-permission-key"] = self._deserialize( + "str", response.headers.get("x-ms-file-permission-key") + ) + response_headers["x-ms-file-id"] = self._deserialize("str", response.headers.get("x-ms-file-id")) + response_headers["x-ms-file-parent-id"] = self._deserialize("str", response.headers.get("x-ms-file-parent-id")) + response_headers["x-ms-mode"] = self._deserialize("str", response.headers.get("x-ms-mode")) + response_headers["x-ms-owner"] = self._deserialize("str", response.headers.get("x-ms-owner")) + response_headers["x-ms-group"] = self._deserialize("str", response.headers.get("x-ms-group")) + response_headers["x-ms-file-file-type"] = self._deserialize("str", response.headers.get("x-ms-file-file-type")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace_async + async def delete(self, timeout: Optional[int] = None, **kwargs: Any) -> None: + # pylint: disable=line-too-long + """Removes the specified empty directory. Note that the directory must be empty before it can be + deleted. + + :param timeout: The timeout parameter is expressed in seconds. For more information, see + :code:`<a + href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting + Timeouts for File Service Operations.</a>`. Default value is None. + :type timeout: int + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + restype: Literal["directory"] = kwargs.pop("restype", _params.pop("restype", "directory")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delete_request( + url=self._config.url, + timeout=timeout, + allow_trailing_dot=self._config.allow_trailing_dot, + file_request_intent=self._config.file_request_intent, + restype=restype, + version=self._config.version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace_async + async def set_properties( + self, + timeout: Optional[int] = None, + file_permission: str = "inherit", + file_permission_format: Optional[Union[str, _models.FilePermissionFormat]] = None, + file_permission_key: Optional[str] = None, + file_attributes: str = "none", + file_creation_time: str = "now", + file_last_write_time: str = "now", + file_change_time: Optional[str] = None, + owner: Optional[str] = None, + group: Optional[str] = None, + file_mode: Optional[str] = None, + **kwargs: Any + ) -> None: + # pylint: disable=line-too-long + """Sets properties on the directory. + + :param timeout: The timeout parameter is expressed in seconds. For more information, see + :code:`<a + href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting + Timeouts for File Service Operations.</a>`. Default value is None. + :type timeout: int + :param file_permission: If specified the permission (security descriptor) shall be set for the + directory/file. This header can be used if Permission size is <= 8KB, else + x-ms-file-permission-key header shall be used. Default value: Inherit. If SDDL is specified as + input, it must have owner, group and dacl. Note: Only one of the x-ms-file-permission or + x-ms-file-permission-key should be specified. Default value is "inherit". + :type file_permission: str + :param file_permission_format: Optional. Available for version 2023-06-01 and later. Specifies + the format in which the permission is returned. Acceptable values are SDDL or binary. If + x-ms-file-permission-format is unspecified or explicitly set to SDDL, the permission is + returned in SDDL format. If x-ms-file-permission-format is explicitly set to binary, the + permission is returned as a base64 string representing the binary encoding of the permission. + Known values are: "Sddl" and "Binary". Default value is None. + :type file_permission_format: str or ~azure.storage.fileshare.models.FilePermissionFormat + :param file_permission_key: Key of the permission to be set for the directory/file. Note: Only + one of the x-ms-file-permission or x-ms-file-permission-key should be specified. Default value + is None. + :type file_permission_key: str + :param file_attributes: If specified, the provided file attributes shall be set. Default value: + ‘Archive’ for file and ‘Directory’ for directory. ‘None’ can also be specified as default. + Default value is "none". + :type file_attributes: str + :param file_creation_time: Creation time for the file/directory. Default value: Now. Default + value is "now". + :type file_creation_time: str + :param file_last_write_time: Last write time for the file/directory. Default value: Now. + Default value is "now". + :type file_last_write_time: str + :param file_change_time: Change time for the file/directory. Default value: Now. Default value + is None. + :type file_change_time: str + :param owner: Optional, NFS only. The owner of the file or directory. Default value is None. + :type owner: str + :param group: Optional, NFS only. The owning group of the file or directory. Default value is + None. + :type group: str + :param file_mode: Optional, NFS only. The file mode of the file or directory. Default value is + None. + :type file_mode: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + restype: Literal["directory"] = kwargs.pop("restype", _params.pop("restype", "directory")) + comp: Literal["properties"] = kwargs.pop("comp", _params.pop("comp", "properties")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_set_properties_request( + url=self._config.url, + timeout=timeout, + file_permission=file_permission, + file_permission_format=file_permission_format, + file_permission_key=file_permission_key, + file_attributes=file_attributes, + file_creation_time=file_creation_time, + file_last_write_time=file_last_write_time, + file_change_time=file_change_time, + owner=owner, + group=group, + file_mode=file_mode, + allow_trailing_dot=self._config.allow_trailing_dot, + file_request_intent=self._config.file_request_intent, + restype=restype, + comp=comp, + version=self._config.version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + response_headers["Last-Modified"] = self._deserialize("rfc-1123", response.headers.get("Last-Modified")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-request-server-encrypted"] = self._deserialize( + "bool", response.headers.get("x-ms-request-server-encrypted") + ) + response_headers["x-ms-file-permission-key"] = self._deserialize( + "str", response.headers.get("x-ms-file-permission-key") + ) + response_headers["x-ms-file-attributes"] = self._deserialize( + "str", response.headers.get("x-ms-file-attributes") + ) + response_headers["x-ms-file-creation-time"] = self._deserialize( + "str", response.headers.get("x-ms-file-creation-time") + ) + response_headers["x-ms-file-last-write-time"] = self._deserialize( + "str", response.headers.get("x-ms-file-last-write-time") + ) + response_headers["x-ms-file-change-time"] = self._deserialize( + "str", response.headers.get("x-ms-file-change-time") + ) + response_headers["x-ms-file-id"] = self._deserialize("str", response.headers.get("x-ms-file-id")) + response_headers["x-ms-file-parent-id"] = self._deserialize("str", response.headers.get("x-ms-file-parent-id")) + response_headers["x-ms-mode"] = self._deserialize("str", response.headers.get("x-ms-mode")) + response_headers["x-ms-owner"] = self._deserialize("str", response.headers.get("x-ms-owner")) + response_headers["x-ms-group"] = self._deserialize("str", response.headers.get("x-ms-group")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace_async + async def set_metadata( + self, timeout: Optional[int] = None, metadata: Optional[Dict[str, str]] = None, **kwargs: Any + ) -> None: + # pylint: disable=line-too-long + """Updates user defined metadata for the specified directory. + + :param timeout: The timeout parameter is expressed in seconds. For more information, see + :code:`<a + href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting + Timeouts for File Service Operations.</a>`. Default value is None. + :type timeout: int + :param metadata: A name-value pair to associate with a file storage object. Default value is + None. + :type metadata: dict[str, str] + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + restype: Literal["directory"] = kwargs.pop("restype", _params.pop("restype", "directory")) + comp: Literal["metadata"] = kwargs.pop("comp", _params.pop("comp", "metadata")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_set_metadata_request( + url=self._config.url, + timeout=timeout, + metadata=metadata, + allow_trailing_dot=self._config.allow_trailing_dot, + file_request_intent=self._config.file_request_intent, + restype=restype, + comp=comp, + version=self._config.version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-request-server-encrypted"] = self._deserialize( + "bool", response.headers.get("x-ms-request-server-encrypted") + ) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace_async + async def list_files_and_directories_segment( + self, + prefix: Optional[str] = None, + sharesnapshot: Optional[str] = None, + marker: Optional[str] = None, + maxresults: Optional[int] = None, + timeout: Optional[int] = None, + include: Optional[List[Union[str, _models.ListFilesIncludeType]]] = None, + include_extended_info: Optional[bool] = None, + **kwargs: Any + ) -> _models.ListFilesAndDirectoriesSegmentResponse: + # pylint: disable=line-too-long + """Returns a list of files or directories under the specified share or directory. It lists the + contents only for a single level of the directory hierarchy. + + :param prefix: Filters the results to return only entries whose name begins with the specified + prefix. Default value is None. + :type prefix: str + :param sharesnapshot: The snapshot parameter is an opaque DateTime value that, when present, + specifies the share snapshot to query. Default value is None. + :type sharesnapshot: str + :param marker: A string value that identifies the portion of the list to be returned with the + next list operation. The operation returns a marker value within the response body if the list + returned was not complete. The marker value may then be used in a subsequent call to request + the next set of list items. The marker value is opaque to the client. Default value is None. + :type marker: str + :param maxresults: Specifies the maximum number of entries to return. If the request does not + specify maxresults, or specifies a value greater than 5,000, the server will return up to 5,000 + items. Default value is None. + :type maxresults: int + :param timeout: The timeout parameter is expressed in seconds. For more information, see + :code:`<a + href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting + Timeouts for File Service Operations.</a>`. Default value is None. + :type timeout: int + :param include: Include this parameter to specify one or more datasets to include in the + response. Default value is None. + :type include: list[str or ~azure.storage.fileshare.models.ListFilesIncludeType] + :param include_extended_info: Include extended information. Default value is None. + :type include_extended_info: bool + :return: ListFilesAndDirectoriesSegmentResponse or the result of cls(response) + :rtype: ~azure.storage.fileshare.models.ListFilesAndDirectoriesSegmentResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + restype: Literal["directory"] = kwargs.pop("restype", _params.pop("restype", "directory")) + comp: Literal["list"] = kwargs.pop("comp", _params.pop("comp", "list")) + cls: ClsType[_models.ListFilesAndDirectoriesSegmentResponse] = kwargs.pop("cls", None) + + _request = build_list_files_and_directories_segment_request( + url=self._config.url, + prefix=prefix, + sharesnapshot=sharesnapshot, + marker=marker, + maxresults=maxresults, + timeout=timeout, + include=include, + include_extended_info=include_extended_info, + allow_trailing_dot=self._config.allow_trailing_dot, + file_request_intent=self._config.file_request_intent, + restype=restype, + comp=comp, + version=self._config.version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["Content-Type"] = self._deserialize("str", response.headers.get("Content-Type")) + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + + deserialized = self._deserialize("ListFilesAndDirectoriesSegmentResponse", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def list_handles( + self, + marker: Optional[str] = None, + maxresults: Optional[int] = None, + timeout: Optional[int] = None, + sharesnapshot: Optional[str] = None, + recursive: Optional[bool] = None, + **kwargs: Any + ) -> _models.ListHandlesResponse: + # pylint: disable=line-too-long + """Lists handles for directory. + + :param marker: A string value that identifies the portion of the list to be returned with the + next list operation. The operation returns a marker value within the response body if the list + returned was not complete. The marker value may then be used in a subsequent call to request + the next set of list items. The marker value is opaque to the client. Default value is None. + :type marker: str + :param maxresults: Specifies the maximum number of entries to return. If the request does not + specify maxresults, or specifies a value greater than 5,000, the server will return up to 5,000 + items. Default value is None. + :type maxresults: int + :param timeout: The timeout parameter is expressed in seconds. For more information, see + :code:`<a + href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting + Timeouts for File Service Operations.</a>`. Default value is None. + :type timeout: int + :param sharesnapshot: The snapshot parameter is an opaque DateTime value that, when present, + specifies the share snapshot to query. Default value is None. + :type sharesnapshot: str + :param recursive: Specifies operation should apply to the directory specified in the URI, its + files, its subdirectories and their files. Default value is None. + :type recursive: bool + :return: ListHandlesResponse or the result of cls(response) + :rtype: ~azure.storage.fileshare.models.ListHandlesResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + comp: Literal["listhandles"] = kwargs.pop("comp", _params.pop("comp", "listhandles")) + cls: ClsType[_models.ListHandlesResponse] = kwargs.pop("cls", None) + + _request = build_list_handles_request( + url=self._config.url, + marker=marker, + maxresults=maxresults, + timeout=timeout, + sharesnapshot=sharesnapshot, + recursive=recursive, + allow_trailing_dot=self._config.allow_trailing_dot, + file_request_intent=self._config.file_request_intent, + comp=comp, + version=self._config.version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["Content-Type"] = self._deserialize("str", response.headers.get("Content-Type")) + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + + deserialized = self._deserialize("ListHandlesResponse", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def force_close_handles( + self, + handle_id: str, + timeout: Optional[int] = None, + marker: Optional[str] = None, + sharesnapshot: Optional[str] = None, + recursive: Optional[bool] = None, + **kwargs: Any + ) -> None: + # pylint: disable=line-too-long + """Closes all handles open for given directory. + + :param handle_id: Specifies handle ID opened on the file or directory to be closed. Asterisk + (‘*’) is a wildcard that specifies all handles. Required. + :type handle_id: str + :param timeout: The timeout parameter is expressed in seconds. For more information, see + :code:`<a + href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting + Timeouts for File Service Operations.</a>`. Default value is None. + :type timeout: int + :param marker: A string value that identifies the portion of the list to be returned with the + next list operation. The operation returns a marker value within the response body if the list + returned was not complete. The marker value may then be used in a subsequent call to request + the next set of list items. The marker value is opaque to the client. Default value is None. + :type marker: str + :param sharesnapshot: The snapshot parameter is an opaque DateTime value that, when present, + specifies the share snapshot to query. Default value is None. + :type sharesnapshot: str + :param recursive: Specifies operation should apply to the directory specified in the URI, its + files, its subdirectories and their files. Default value is None. + :type recursive: bool + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + comp: Literal["forceclosehandles"] = kwargs.pop("comp", _params.pop("comp", "forceclosehandles")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_force_close_handles_request( + url=self._config.url, + handle_id=handle_id, + timeout=timeout, + marker=marker, + sharesnapshot=sharesnapshot, + recursive=recursive, + allow_trailing_dot=self._config.allow_trailing_dot, + file_request_intent=self._config.file_request_intent, + comp=comp, + version=self._config.version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-marker"] = self._deserialize("str", response.headers.get("x-ms-marker")) + response_headers["x-ms-number-of-handles-closed"] = self._deserialize( + "int", response.headers.get("x-ms-number-of-handles-closed") + ) + response_headers["x-ms-number-of-handles-failed"] = self._deserialize( + "int", response.headers.get("x-ms-number-of-handles-failed") + ) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace_async + async def rename( + self, + rename_source: str, + timeout: Optional[int] = None, + replace_if_exists: Optional[bool] = None, + ignore_read_only: Optional[bool] = None, + file_permission: str = "inherit", + file_permission_format: Optional[Union[str, _models.FilePermissionFormat]] = None, + file_permission_key: Optional[str] = None, + metadata: Optional[Dict[str, str]] = None, + source_lease_access_conditions: Optional[_models.SourceLeaseAccessConditions] = None, + destination_lease_access_conditions: Optional[_models.DestinationLeaseAccessConditions] = None, + copy_file_smb_info: Optional[_models.CopyFileSmbInfo] = None, + **kwargs: Any + ) -> None: + # pylint: disable=line-too-long + """Renames a directory. + + :param rename_source: Required. Specifies the URI-style path of the source file, up to 2 KB in + length. Required. + :type rename_source: str + :param timeout: The timeout parameter is expressed in seconds. For more information, see + :code:`<a + href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting + Timeouts for File Service Operations.</a>`. Default value is None. + :type timeout: int + :param replace_if_exists: Optional. A boolean value for if the destination file already exists, + whether this request will overwrite the file or not. If true, the rename will succeed and will + overwrite the destination file. If not provided or if false and the destination file does + exist, the request will not overwrite the destination file. If provided and the destination + file doesn’t exist, the rename will succeed. Note: This value does not override the + x-ms-file-copy-ignore-read-only header value. Default value is None. + :type replace_if_exists: bool + :param ignore_read_only: Optional. A boolean value that specifies whether the ReadOnly + attribute on a preexisting destination file should be respected. If true, the rename will + succeed, otherwise, a previous file at the destination with the ReadOnly attribute set will + cause the rename to fail. Default value is None. + :type ignore_read_only: bool + :param file_permission: If specified the permission (security descriptor) shall be set for the + directory/file. This header can be used if Permission size is <= 8KB, else + x-ms-file-permission-key header shall be used. Default value: Inherit. If SDDL is specified as + input, it must have owner, group and dacl. Note: Only one of the x-ms-file-permission or + x-ms-file-permission-key should be specified. Default value is "inherit". + :type file_permission: str + :param file_permission_format: Optional. Available for version 2023-06-01 and later. Specifies + the format in which the permission is returned. Acceptable values are SDDL or binary. If + x-ms-file-permission-format is unspecified or explicitly set to SDDL, the permission is + returned in SDDL format. If x-ms-file-permission-format is explicitly set to binary, the + permission is returned as a base64 string representing the binary encoding of the permission. + Known values are: "Sddl" and "Binary". Default value is None. + :type file_permission_format: str or ~azure.storage.fileshare.models.FilePermissionFormat + :param file_permission_key: Key of the permission to be set for the directory/file. Note: Only + one of the x-ms-file-permission or x-ms-file-permission-key should be specified. Default value + is None. + :type file_permission_key: str + :param metadata: A name-value pair to associate with a file storage object. Default value is + None. + :type metadata: dict[str, str] + :param source_lease_access_conditions: Parameter group. Default value is None. + :type source_lease_access_conditions: + ~azure.storage.fileshare.models.SourceLeaseAccessConditions + :param destination_lease_access_conditions: Parameter group. Default value is None. + :type destination_lease_access_conditions: + ~azure.storage.fileshare.models.DestinationLeaseAccessConditions + :param copy_file_smb_info: Parameter group. Default value is None. + :type copy_file_smb_info: ~azure.storage.fileshare.models.CopyFileSmbInfo + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + restype: Literal["directory"] = kwargs.pop("restype", _params.pop("restype", "directory")) + comp: Literal["rename"] = kwargs.pop("comp", _params.pop("comp", "rename")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _source_lease_id = None + _destination_lease_id = None + _file_attributes = None + _file_creation_time = None + _file_last_write_time = None + _file_change_time = None + if source_lease_access_conditions is not None: + _source_lease_id = source_lease_access_conditions.source_lease_id + if destination_lease_access_conditions is not None: + _destination_lease_id = destination_lease_access_conditions.destination_lease_id + if copy_file_smb_info is not None: + _file_attributes = copy_file_smb_info.file_attributes + _file_change_time = copy_file_smb_info.file_change_time + _file_creation_time = copy_file_smb_info.file_creation_time + _file_last_write_time = copy_file_smb_info.file_last_write_time + + _request = build_rename_request( + url=self._config.url, + rename_source=rename_source, + timeout=timeout, + replace_if_exists=replace_if_exists, + ignore_read_only=ignore_read_only, + source_lease_id=_source_lease_id, + destination_lease_id=_destination_lease_id, + file_attributes=_file_attributes, + file_creation_time=_file_creation_time, + file_last_write_time=_file_last_write_time, + file_change_time=_file_change_time, + file_permission=file_permission, + file_permission_format=file_permission_format, + file_permission_key=file_permission_key, + metadata=metadata, + allow_trailing_dot=self._config.allow_trailing_dot, + allow_source_trailing_dot=self._config.allow_source_trailing_dot, + file_request_intent=self._config.file_request_intent, + restype=restype, + comp=comp, + version=self._config.version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["Last-Modified"] = self._deserialize("rfc-1123", response.headers.get("Last-Modified")) + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-request-server-encrypted"] = self._deserialize( + "bool", response.headers.get("x-ms-request-server-encrypted") + ) + response_headers["x-ms-file-permission-key"] = self._deserialize( + "str", response.headers.get("x-ms-file-permission-key") + ) + response_headers["x-ms-file-attributes"] = self._deserialize( + "str", response.headers.get("x-ms-file-attributes") + ) + response_headers["x-ms-file-creation-time"] = self._deserialize( + "str", response.headers.get("x-ms-file-creation-time") + ) + response_headers["x-ms-file-last-write-time"] = self._deserialize( + "str", response.headers.get("x-ms-file-last-write-time") + ) + response_headers["x-ms-file-change-time"] = self._deserialize( + "str", response.headers.get("x-ms-file-change-time") + ) + response_headers["x-ms-file-id"] = self._deserialize("str", response.headers.get("x-ms-file-id")) + response_headers["x-ms-file-parent-id"] = self._deserialize("str", response.headers.get("x-ms-file-parent-id")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore diff --git a/.venv/lib/python3.12/site-packages/azure/storage/fileshare/_generated/aio/operations/_file_operations.py b/.venv/lib/python3.12/site-packages/azure/storage/fileshare/_generated/aio/operations/_file_operations.py new file mode 100644 index 00000000..93f91f24 --- /dev/null +++ b/.venv/lib/python3.12/site-packages/azure/storage/fileshare/_generated/aio/operations/_file_operations.py @@ -0,0 +1,2518 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterator, Callable, Dict, IO, Literal, Optional, TypeVar, Union + +from azure.core import AsyncPipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict + +from ... import models as _models +from ..._serialization import Deserializer, Serializer +from ...operations._file_operations import ( + build_abort_copy_request, + build_acquire_lease_request, + build_break_lease_request, + build_change_lease_request, + build_create_hard_link_request, + build_create_request, + build_create_symbolic_link_request, + build_delete_request, + build_download_request, + build_force_close_handles_request, + build_get_properties_request, + build_get_range_list_request, + build_get_symbolic_link_request, + build_list_handles_request, + build_release_lease_request, + build_rename_request, + build_set_http_headers_request, + build_set_metadata_request, + build_start_copy_request, + build_upload_range_from_url_request, + build_upload_range_request, +) +from .._configuration import AzureFileStorageConfiguration + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class FileOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.storage.fileshare.aio.AzureFileStorage`'s + :attr:`file` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AzureFileStorageConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def create( + self, + file_content_length: int, + timeout: Optional[int] = None, + metadata: Optional[Dict[str, str]] = None, + file_permission: str = "inherit", + file_permission_format: Optional[Union[str, _models.FilePermissionFormat]] = None, + file_permission_key: Optional[str] = None, + file_attributes: str = "none", + file_creation_time: str = "now", + file_last_write_time: str = "now", + file_change_time: Optional[str] = None, + owner: Optional[str] = None, + group: Optional[str] = None, + file_mode: Optional[str] = None, + nfs_file_type: Optional[Union[str, _models.NfsFileType]] = None, + file_http_headers: Optional[_models.FileHTTPHeaders] = None, + lease_access_conditions: Optional[_models.LeaseAccessConditions] = None, + **kwargs: Any + ) -> None: + # pylint: disable=line-too-long + """Creates a new file or replaces a file. Note it only initializes the file with no content. + + :param file_content_length: Specifies the maximum size for the file, up to 4 TB. Required. + :type file_content_length: int + :param timeout: The timeout parameter is expressed in seconds. For more information, see + :code:`<a + href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting + Timeouts for File Service Operations.</a>`. Default value is None. + :type timeout: int + :param metadata: A name-value pair to associate with a file storage object. Default value is + None. + :type metadata: dict[str, str] + :param file_permission: If specified the permission (security descriptor) shall be set for the + directory/file. This header can be used if Permission size is <= 8KB, else + x-ms-file-permission-key header shall be used. Default value: Inherit. If SDDL is specified as + input, it must have owner, group and dacl. Note: Only one of the x-ms-file-permission or + x-ms-file-permission-key should be specified. Default value is "inherit". + :type file_permission: str + :param file_permission_format: Optional. Available for version 2023-06-01 and later. Specifies + the format in which the permission is returned. Acceptable values are SDDL or binary. If + x-ms-file-permission-format is unspecified or explicitly set to SDDL, the permission is + returned in SDDL format. If x-ms-file-permission-format is explicitly set to binary, the + permission is returned as a base64 string representing the binary encoding of the permission. + Known values are: "Sddl" and "Binary". Default value is None. + :type file_permission_format: str or ~azure.storage.fileshare.models.FilePermissionFormat + :param file_permission_key: Key of the permission to be set for the directory/file. Note: Only + one of the x-ms-file-permission or x-ms-file-permission-key should be specified. Default value + is None. + :type file_permission_key: str + :param file_attributes: If specified, the provided file attributes shall be set. Default value: + ‘Archive’ for file and ‘Directory’ for directory. ‘None’ can also be specified as default. + Default value is "none". + :type file_attributes: str + :param file_creation_time: Creation time for the file/directory. Default value: Now. Default + value is "now". + :type file_creation_time: str + :param file_last_write_time: Last write time for the file/directory. Default value: Now. + Default value is "now". + :type file_last_write_time: str + :param file_change_time: Change time for the file/directory. Default value: Now. Default value + is None. + :type file_change_time: str + :param owner: Optional, NFS only. The owner of the file or directory. Default value is None. + :type owner: str + :param group: Optional, NFS only. The owning group of the file or directory. Default value is + None. + :type group: str + :param file_mode: Optional, NFS only. The file mode of the file or directory. Default value is + None. + :type file_mode: str + :param nfs_file_type: Optional, NFS only. Type of the file or directory. Known values are: + "Regular", "Directory", and "SymLink". Default value is None. + :type nfs_file_type: str or ~azure.storage.fileshare.models.NfsFileType + :param file_http_headers: Parameter group. Default value is None. + :type file_http_headers: ~azure.storage.fileshare.models.FileHTTPHeaders + :param lease_access_conditions: Parameter group. Default value is None. + :type lease_access_conditions: ~azure.storage.fileshare.models.LeaseAccessConditions + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + file_type_constant: Literal["file"] = kwargs.pop("file_type_constant", _headers.pop("x-ms-type", "file")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _file_content_type = None + _file_content_encoding = None + _file_content_language = None + _file_cache_control = None + _file_content_md5 = None + _file_content_disposition = None + _lease_id = None + if file_http_headers is not None: + _file_cache_control = file_http_headers.file_cache_control + _file_content_disposition = file_http_headers.file_content_disposition + _file_content_encoding = file_http_headers.file_content_encoding + _file_content_language = file_http_headers.file_content_language + _file_content_md5 = file_http_headers.file_content_md5 + _file_content_type = file_http_headers.file_content_type + if lease_access_conditions is not None: + _lease_id = lease_access_conditions.lease_id + + _request = build_create_request( + url=self._config.url, + file_content_length=file_content_length, + timeout=timeout, + file_content_type=_file_content_type, + file_content_encoding=_file_content_encoding, + file_content_language=_file_content_language, + file_cache_control=_file_cache_control, + file_content_md5=_file_content_md5, + file_content_disposition=_file_content_disposition, + metadata=metadata, + file_permission=file_permission, + file_permission_format=file_permission_format, + file_permission_key=file_permission_key, + file_attributes=file_attributes, + file_creation_time=file_creation_time, + file_last_write_time=file_last_write_time, + file_change_time=file_change_time, + lease_id=_lease_id, + owner=owner, + group=group, + file_mode=file_mode, + nfs_file_type=nfs_file_type, + allow_trailing_dot=self._config.allow_trailing_dot, + file_request_intent=self._config.file_request_intent, + file_type_constant=file_type_constant, + version=self._config.version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["Last-Modified"] = self._deserialize("rfc-1123", response.headers.get("Last-Modified")) + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-request-server-encrypted"] = self._deserialize( + "bool", response.headers.get("x-ms-request-server-encrypted") + ) + response_headers["x-ms-file-permission-key"] = self._deserialize( + "str", response.headers.get("x-ms-file-permission-key") + ) + response_headers["x-ms-file-attributes"] = self._deserialize( + "str", response.headers.get("x-ms-file-attributes") + ) + response_headers["x-ms-file-creation-time"] = self._deserialize( + "str", response.headers.get("x-ms-file-creation-time") + ) + response_headers["x-ms-file-last-write-time"] = self._deserialize( + "str", response.headers.get("x-ms-file-last-write-time") + ) + response_headers["x-ms-file-change-time"] = self._deserialize( + "str", response.headers.get("x-ms-file-change-time") + ) + response_headers["x-ms-file-id"] = self._deserialize("str", response.headers.get("x-ms-file-id")) + response_headers["x-ms-file-parent-id"] = self._deserialize("str", response.headers.get("x-ms-file-parent-id")) + response_headers["x-ms-mode"] = self._deserialize("str", response.headers.get("x-ms-mode")) + response_headers["x-ms-owner"] = self._deserialize("str", response.headers.get("x-ms-owner")) + response_headers["x-ms-group"] = self._deserialize("str", response.headers.get("x-ms-group")) + response_headers["x-ms-file-file-type"] = self._deserialize("str", response.headers.get("x-ms-file-file-type")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace_async + async def download( + self, + timeout: Optional[int] = None, + range: Optional[str] = None, + range_get_content_md5: Optional[bool] = None, + structured_body_type: Optional[str] = None, + lease_access_conditions: Optional[_models.LeaseAccessConditions] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + # pylint: disable=line-too-long + """Reads or downloads a file from the system, including its metadata and properties. + + :param timeout: The timeout parameter is expressed in seconds. For more information, see + :code:`<a + href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting + Timeouts for File Service Operations.</a>`. Default value is None. + :type timeout: int + :param range: Return file data only from the specified byte range. Default value is None. + :type range: str + :param range_get_content_md5: When this header is set to true and specified together with the + Range header, the service returns the MD5 hash for the range, as long as the range is less than + or equal to 4 MB in size. Default value is None. + :type range_get_content_md5: bool + :param structured_body_type: Specifies the response content should be returned as a structured + message and specifies the message schema version and properties. Default value is None. + :type structured_body_type: str + :param lease_access_conditions: Parameter group. Default value is None. + :type lease_access_conditions: ~azure.storage.fileshare.models.LeaseAccessConditions + :return: AsyncIterator[bytes] or the result of cls(response) + :rtype: AsyncIterator[bytes] + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _lease_id = None + if lease_access_conditions is not None: + _lease_id = lease_access_conditions.lease_id + + _request = build_download_request( + url=self._config.url, + timeout=timeout, + range=range, + range_get_content_md5=range_get_content_md5, + structured_body_type=structured_body_type, + lease_id=_lease_id, + allow_trailing_dot=self._config.allow_trailing_dot, + file_request_intent=self._config.file_request_intent, + version=self._config.version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 206]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["Last-Modified"] = self._deserialize("rfc-1123", response.headers.get("Last-Modified")) + response_headers["x-ms-meta"] = self._deserialize("{str}", response.headers.get("x-ms-meta")) + response_headers["Content-Length"] = self._deserialize("int", response.headers.get("Content-Length")) + response_headers["Content-Type"] = self._deserialize("str", response.headers.get("Content-Type")) + response_headers["Content-Range"] = self._deserialize("str", response.headers.get("Content-Range")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["Content-MD5"] = self._deserialize("bytearray", response.headers.get("Content-MD5")) + response_headers["Content-Encoding"] = self._deserialize("str", response.headers.get("Content-Encoding")) + response_headers["Cache-Control"] = self._deserialize("str", response.headers.get("Cache-Control")) + response_headers["Content-Disposition"] = self._deserialize("str", response.headers.get("Content-Disposition")) + response_headers["Content-Language"] = self._deserialize("str", response.headers.get("Content-Language")) + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + response_headers["Accept-Ranges"] = self._deserialize("str", response.headers.get("Accept-Ranges")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-copy-completion-time"] = self._deserialize( + "rfc-1123", response.headers.get("x-ms-copy-completion-time") + ) + response_headers["x-ms-copy-status-description"] = self._deserialize( + "str", response.headers.get("x-ms-copy-status-description") + ) + response_headers["x-ms-copy-id"] = self._deserialize("str", response.headers.get("x-ms-copy-id")) + response_headers["x-ms-copy-progress"] = self._deserialize("str", response.headers.get("x-ms-copy-progress")) + response_headers["x-ms-copy-source"] = self._deserialize("str", response.headers.get("x-ms-copy-source")) + response_headers["x-ms-copy-status"] = self._deserialize("str", response.headers.get("x-ms-copy-status")) + response_headers["x-ms-content-md5"] = self._deserialize("bytearray", response.headers.get("x-ms-content-md5")) + response_headers["x-ms-server-encrypted"] = self._deserialize( + "bool", response.headers.get("x-ms-server-encrypted") + ) + response_headers["x-ms-file-attributes"] = self._deserialize( + "str", response.headers.get("x-ms-file-attributes") + ) + response_headers["x-ms-file-creation-time"] = self._deserialize( + "str", response.headers.get("x-ms-file-creation-time") + ) + response_headers["x-ms-file-last-write-time"] = self._deserialize( + "str", response.headers.get("x-ms-file-last-write-time") + ) + response_headers["x-ms-file-change-time"] = self._deserialize( + "str", response.headers.get("x-ms-file-change-time") + ) + response_headers["x-ms-file-permission-key"] = self._deserialize( + "str", response.headers.get("x-ms-file-permission-key") + ) + response_headers["x-ms-file-id"] = self._deserialize("str", response.headers.get("x-ms-file-id")) + response_headers["x-ms-file-parent-id"] = self._deserialize("str", response.headers.get("x-ms-file-parent-id")) + response_headers["x-ms-lease-duration"] = self._deserialize("str", response.headers.get("x-ms-lease-duration")) + response_headers["x-ms-lease-state"] = self._deserialize("str", response.headers.get("x-ms-lease-state")) + response_headers["x-ms-lease-status"] = self._deserialize("str", response.headers.get("x-ms-lease-status")) + response_headers["x-ms-structured-body"] = self._deserialize( + "str", response.headers.get("x-ms-structured-body") + ) + response_headers["x-ms-structured-content-length"] = self._deserialize( + "int", response.headers.get("x-ms-structured-content-length") + ) + response_headers["x-ms-mode"] = self._deserialize("str", response.headers.get("x-ms-mode")) + response_headers["x-ms-owner"] = self._deserialize("str", response.headers.get("x-ms-owner")) + response_headers["x-ms-group"] = self._deserialize("str", response.headers.get("x-ms-group")) + response_headers["x-ms-link-count"] = self._deserialize("int", response.headers.get("x-ms-link-count")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_properties( + self, + sharesnapshot: Optional[str] = None, + timeout: Optional[int] = None, + lease_access_conditions: Optional[_models.LeaseAccessConditions] = None, + **kwargs: Any + ) -> None: + # pylint: disable=line-too-long + """Returns all user-defined metadata, standard HTTP properties, and system properties for the + file. It does not return the content of the file. + + :param sharesnapshot: The snapshot parameter is an opaque DateTime value that, when present, + specifies the share snapshot to query. Default value is None. + :type sharesnapshot: str + :param timeout: The timeout parameter is expressed in seconds. For more information, see + :code:`<a + href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting + Timeouts for File Service Operations.</a>`. Default value is None. + :type timeout: int + :param lease_access_conditions: Parameter group. Default value is None. + :type lease_access_conditions: ~azure.storage.fileshare.models.LeaseAccessConditions + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _lease_id = None + if lease_access_conditions is not None: + _lease_id = lease_access_conditions.lease_id + + _request = build_get_properties_request( + url=self._config.url, + sharesnapshot=sharesnapshot, + timeout=timeout, + lease_id=_lease_id, + allow_trailing_dot=self._config.allow_trailing_dot, + file_request_intent=self._config.file_request_intent, + version=self._config.version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["Last-Modified"] = self._deserialize("rfc-1123", response.headers.get("Last-Modified")) + response_headers["x-ms-meta"] = self._deserialize("{str}", response.headers.get("x-ms-meta")) + response_headers["x-ms-type"] = self._deserialize("str", response.headers.get("x-ms-type")) + response_headers["Content-Length"] = self._deserialize("int", response.headers.get("Content-Length")) + response_headers["Content-Type"] = self._deserialize("str", response.headers.get("Content-Type")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["Content-MD5"] = self._deserialize("bytearray", response.headers.get("Content-MD5")) + response_headers["Content-Encoding"] = self._deserialize("str", response.headers.get("Content-Encoding")) + response_headers["Cache-Control"] = self._deserialize("str", response.headers.get("Cache-Control")) + response_headers["Content-Disposition"] = self._deserialize("str", response.headers.get("Content-Disposition")) + response_headers["Content-Language"] = self._deserialize("str", response.headers.get("Content-Language")) + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-copy-completion-time"] = self._deserialize( + "rfc-1123", response.headers.get("x-ms-copy-completion-time") + ) + response_headers["x-ms-copy-status-description"] = self._deserialize( + "str", response.headers.get("x-ms-copy-status-description") + ) + response_headers["x-ms-copy-id"] = self._deserialize("str", response.headers.get("x-ms-copy-id")) + response_headers["x-ms-copy-progress"] = self._deserialize("str", response.headers.get("x-ms-copy-progress")) + response_headers["x-ms-copy-source"] = self._deserialize("str", response.headers.get("x-ms-copy-source")) + response_headers["x-ms-copy-status"] = self._deserialize("str", response.headers.get("x-ms-copy-status")) + response_headers["x-ms-server-encrypted"] = self._deserialize( + "bool", response.headers.get("x-ms-server-encrypted") + ) + response_headers["x-ms-file-attributes"] = self._deserialize( + "str", response.headers.get("x-ms-file-attributes") + ) + response_headers["x-ms-file-creation-time"] = self._deserialize( + "str", response.headers.get("x-ms-file-creation-time") + ) + response_headers["x-ms-file-last-write-time"] = self._deserialize( + "str", response.headers.get("x-ms-file-last-write-time") + ) + response_headers["x-ms-file-change-time"] = self._deserialize( + "str", response.headers.get("x-ms-file-change-time") + ) + response_headers["x-ms-file-permission-key"] = self._deserialize( + "str", response.headers.get("x-ms-file-permission-key") + ) + response_headers["x-ms-file-id"] = self._deserialize("str", response.headers.get("x-ms-file-id")) + response_headers["x-ms-file-parent-id"] = self._deserialize("str", response.headers.get("x-ms-file-parent-id")) + response_headers["x-ms-lease-duration"] = self._deserialize("str", response.headers.get("x-ms-lease-duration")) + response_headers["x-ms-lease-state"] = self._deserialize("str", response.headers.get("x-ms-lease-state")) + response_headers["x-ms-lease-status"] = self._deserialize("str", response.headers.get("x-ms-lease-status")) + response_headers["x-ms-mode"] = self._deserialize("str", response.headers.get("x-ms-mode")) + response_headers["x-ms-owner"] = self._deserialize("str", response.headers.get("x-ms-owner")) + response_headers["x-ms-group"] = self._deserialize("str", response.headers.get("x-ms-group")) + response_headers["x-ms-link-count"] = self._deserialize("int", response.headers.get("x-ms-link-count")) + response_headers["x-ms-file-file-type"] = self._deserialize("str", response.headers.get("x-ms-file-file-type")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace_async + async def delete( + self, + timeout: Optional[int] = None, + lease_access_conditions: Optional[_models.LeaseAccessConditions] = None, + **kwargs: Any + ) -> None: + # pylint: disable=line-too-long + """removes the file from the storage account. + + :param timeout: The timeout parameter is expressed in seconds. For more information, see + :code:`<a + href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting + Timeouts for File Service Operations.</a>`. Default value is None. + :type timeout: int + :param lease_access_conditions: Parameter group. Default value is None. + :type lease_access_conditions: ~azure.storage.fileshare.models.LeaseAccessConditions + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _lease_id = None + if lease_access_conditions is not None: + _lease_id = lease_access_conditions.lease_id + + _request = build_delete_request( + url=self._config.url, + timeout=timeout, + lease_id=_lease_id, + allow_trailing_dot=self._config.allow_trailing_dot, + file_request_intent=self._config.file_request_intent, + version=self._config.version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-link-count"] = self._deserialize("int", response.headers.get("x-ms-link-count")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace_async + async def set_http_headers( + self, + timeout: Optional[int] = None, + file_content_length: Optional[int] = None, + file_permission: str = "inherit", + file_permission_format: Optional[Union[str, _models.FilePermissionFormat]] = None, + file_permission_key: Optional[str] = None, + file_attributes: str = "none", + file_creation_time: str = "now", + file_last_write_time: str = "now", + file_change_time: Optional[str] = None, + owner: Optional[str] = None, + group: Optional[str] = None, + file_mode: Optional[str] = None, + file_http_headers: Optional[_models.FileHTTPHeaders] = None, + lease_access_conditions: Optional[_models.LeaseAccessConditions] = None, + **kwargs: Any + ) -> None: + # pylint: disable=line-too-long + """Sets HTTP headers on the file. + + :param timeout: The timeout parameter is expressed in seconds. For more information, see + :code:`<a + href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting + Timeouts for File Service Operations.</a>`. Default value is None. + :type timeout: int + :param file_content_length: Resizes a file to the specified size. If the specified byte value + is less than the current size of the file, then all ranges above the specified byte value are + cleared. Default value is None. + :type file_content_length: int + :param file_permission: If specified the permission (security descriptor) shall be set for the + directory/file. This header can be used if Permission size is <= 8KB, else + x-ms-file-permission-key header shall be used. Default value: Inherit. If SDDL is specified as + input, it must have owner, group and dacl. Note: Only one of the x-ms-file-permission or + x-ms-file-permission-key should be specified. Default value is "inherit". + :type file_permission: str + :param file_permission_format: Optional. Available for version 2023-06-01 and later. Specifies + the format in which the permission is returned. Acceptable values are SDDL or binary. If + x-ms-file-permission-format is unspecified or explicitly set to SDDL, the permission is + returned in SDDL format. If x-ms-file-permission-format is explicitly set to binary, the + permission is returned as a base64 string representing the binary encoding of the permission. + Known values are: "Sddl" and "Binary". Default value is None. + :type file_permission_format: str or ~azure.storage.fileshare.models.FilePermissionFormat + :param file_permission_key: Key of the permission to be set for the directory/file. Note: Only + one of the x-ms-file-permission or x-ms-file-permission-key should be specified. Default value + is None. + :type file_permission_key: str + :param file_attributes: If specified, the provided file attributes shall be set. Default value: + ‘Archive’ for file and ‘Directory’ for directory. ‘None’ can also be specified as default. + Default value is "none". + :type file_attributes: str + :param file_creation_time: Creation time for the file/directory. Default value: Now. Default + value is "now". + :type file_creation_time: str + :param file_last_write_time: Last write time for the file/directory. Default value: Now. + Default value is "now". + :type file_last_write_time: str + :param file_change_time: Change time for the file/directory. Default value: Now. Default value + is None. + :type file_change_time: str + :param owner: Optional, NFS only. The owner of the file or directory. Default value is None. + :type owner: str + :param group: Optional, NFS only. The owning group of the file or directory. Default value is + None. + :type group: str + :param file_mode: Optional, NFS only. The file mode of the file or directory. Default value is + None. + :type file_mode: str + :param file_http_headers: Parameter group. Default value is None. + :type file_http_headers: ~azure.storage.fileshare.models.FileHTTPHeaders + :param lease_access_conditions: Parameter group. Default value is None. + :type lease_access_conditions: ~azure.storage.fileshare.models.LeaseAccessConditions + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + comp: Literal["properties"] = kwargs.pop("comp", _params.pop("comp", "properties")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _file_content_type = None + _file_content_encoding = None + _file_content_language = None + _file_cache_control = None + _file_content_md5 = None + _file_content_disposition = None + _lease_id = None + if file_http_headers is not None: + _file_cache_control = file_http_headers.file_cache_control + _file_content_disposition = file_http_headers.file_content_disposition + _file_content_encoding = file_http_headers.file_content_encoding + _file_content_language = file_http_headers.file_content_language + _file_content_md5 = file_http_headers.file_content_md5 + _file_content_type = file_http_headers.file_content_type + if lease_access_conditions is not None: + _lease_id = lease_access_conditions.lease_id + + _request = build_set_http_headers_request( + url=self._config.url, + timeout=timeout, + file_content_length=file_content_length, + file_content_type=_file_content_type, + file_content_encoding=_file_content_encoding, + file_content_language=_file_content_language, + file_cache_control=_file_cache_control, + file_content_md5=_file_content_md5, + file_content_disposition=_file_content_disposition, + file_permission=file_permission, + file_permission_format=file_permission_format, + file_permission_key=file_permission_key, + file_attributes=file_attributes, + file_creation_time=file_creation_time, + file_last_write_time=file_last_write_time, + file_change_time=file_change_time, + lease_id=_lease_id, + owner=owner, + group=group, + file_mode=file_mode, + allow_trailing_dot=self._config.allow_trailing_dot, + file_request_intent=self._config.file_request_intent, + comp=comp, + version=self._config.version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["Last-Modified"] = self._deserialize("rfc-1123", response.headers.get("Last-Modified")) + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-request-server-encrypted"] = self._deserialize( + "bool", response.headers.get("x-ms-request-server-encrypted") + ) + response_headers["x-ms-file-permission-key"] = self._deserialize( + "str", response.headers.get("x-ms-file-permission-key") + ) + response_headers["x-ms-file-attributes"] = self._deserialize( + "str", response.headers.get("x-ms-file-attributes") + ) + response_headers["x-ms-file-creation-time"] = self._deserialize( + "str", response.headers.get("x-ms-file-creation-time") + ) + response_headers["x-ms-file-last-write-time"] = self._deserialize( + "str", response.headers.get("x-ms-file-last-write-time") + ) + response_headers["x-ms-file-change-time"] = self._deserialize( + "str", response.headers.get("x-ms-file-change-time") + ) + response_headers["x-ms-file-id"] = self._deserialize("str", response.headers.get("x-ms-file-id")) + response_headers["x-ms-file-parent-id"] = self._deserialize("str", response.headers.get("x-ms-file-parent-id")) + response_headers["x-ms-mode"] = self._deserialize("str", response.headers.get("x-ms-mode")) + response_headers["x-ms-owner"] = self._deserialize("str", response.headers.get("x-ms-owner")) + response_headers["x-ms-group"] = self._deserialize("str", response.headers.get("x-ms-group")) + response_headers["x-ms-link-count"] = self._deserialize("int", response.headers.get("x-ms-link-count")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace_async + async def set_metadata( + self, + timeout: Optional[int] = None, + metadata: Optional[Dict[str, str]] = None, + lease_access_conditions: Optional[_models.LeaseAccessConditions] = None, + **kwargs: Any + ) -> None: + # pylint: disable=line-too-long + """Updates user-defined metadata for the specified file. + + :param timeout: The timeout parameter is expressed in seconds. For more information, see + :code:`<a + href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting + Timeouts for File Service Operations.</a>`. Default value is None. + :type timeout: int + :param metadata: A name-value pair to associate with a file storage object. Default value is + None. + :type metadata: dict[str, str] + :param lease_access_conditions: Parameter group. Default value is None. + :type lease_access_conditions: ~azure.storage.fileshare.models.LeaseAccessConditions + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + comp: Literal["metadata"] = kwargs.pop("comp", _params.pop("comp", "metadata")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _lease_id = None + if lease_access_conditions is not None: + _lease_id = lease_access_conditions.lease_id + + _request = build_set_metadata_request( + url=self._config.url, + timeout=timeout, + metadata=metadata, + lease_id=_lease_id, + allow_trailing_dot=self._config.allow_trailing_dot, + file_request_intent=self._config.file_request_intent, + comp=comp, + version=self._config.version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-request-server-encrypted"] = self._deserialize( + "bool", response.headers.get("x-ms-request-server-encrypted") + ) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace_async + async def acquire_lease( + self, + timeout: Optional[int] = None, + duration: Optional[int] = None, + proposed_lease_id: Optional[str] = None, + request_id_parameter: Optional[str] = None, + **kwargs: Any + ) -> None: + # pylint: disable=line-too-long + """[Update] The Lease File operation establishes and manages a lock on a file for write and delete + operations. + + :param timeout: The timeout parameter is expressed in seconds. For more information, see + :code:`<a + href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting + Timeouts for File Service Operations.</a>`. Default value is None. + :type timeout: int + :param duration: Specifies the duration of the lease, in seconds, or negative one (-1) for a + lease that never expires. A non-infinite lease can be between 15 and 60 seconds. A lease + duration cannot be changed using renew or change. Default value is None. + :type duration: int + :param proposed_lease_id: Proposed lease ID, in a GUID string format. The File service returns + 400 (Invalid request) if the proposed lease ID is not in the correct format. See Guid + Constructor (String) for a list of valid GUID string formats. Default value is None. + :type proposed_lease_id: str + :param request_id_parameter: Provides a client-generated, opaque value with a 1 KB character + limit that is recorded in the analytics logs when storage analytics logging is enabled. Default + value is None. + :type request_id_parameter: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + comp: Literal["lease"] = kwargs.pop("comp", _params.pop("comp", "lease")) + action: Literal["acquire"] = kwargs.pop("action", _headers.pop("x-ms-lease-action", "acquire")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_acquire_lease_request( + url=self._config.url, + timeout=timeout, + duration=duration, + proposed_lease_id=proposed_lease_id, + request_id_parameter=request_id_parameter, + allow_trailing_dot=self._config.allow_trailing_dot, + file_request_intent=self._config.file_request_intent, + comp=comp, + action=action, + version=self._config.version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["Last-Modified"] = self._deserialize("rfc-1123", response.headers.get("Last-Modified")) + response_headers["x-ms-lease-id"] = self._deserialize("str", response.headers.get("x-ms-lease-id")) + response_headers["x-ms-client-request-id"] = self._deserialize( + "str", response.headers.get("x-ms-client-request-id") + ) + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace_async + async def release_lease( + self, lease_id: str, timeout: Optional[int] = None, request_id_parameter: Optional[str] = None, **kwargs: Any + ) -> None: + # pylint: disable=line-too-long + """[Update] The Lease File operation establishes and manages a lock on a file for write and delete + operations. + + :param lease_id: Specifies the current lease ID on the resource. Required. + :type lease_id: str + :param timeout: The timeout parameter is expressed in seconds. For more information, see + :code:`<a + href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting + Timeouts for File Service Operations.</a>`. Default value is None. + :type timeout: int + :param request_id_parameter: Provides a client-generated, opaque value with a 1 KB character + limit that is recorded in the analytics logs when storage analytics logging is enabled. Default + value is None. + :type request_id_parameter: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + comp: Literal["lease"] = kwargs.pop("comp", _params.pop("comp", "lease")) + action: Literal["release"] = kwargs.pop("action", _headers.pop("x-ms-lease-action", "release")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_release_lease_request( + url=self._config.url, + lease_id=lease_id, + timeout=timeout, + request_id_parameter=request_id_parameter, + allow_trailing_dot=self._config.allow_trailing_dot, + file_request_intent=self._config.file_request_intent, + comp=comp, + action=action, + version=self._config.version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["Last-Modified"] = self._deserialize("rfc-1123", response.headers.get("Last-Modified")) + response_headers["x-ms-client-request-id"] = self._deserialize( + "str", response.headers.get("x-ms-client-request-id") + ) + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace_async + async def change_lease( + self, + lease_id: str, + timeout: Optional[int] = None, + proposed_lease_id: Optional[str] = None, + request_id_parameter: Optional[str] = None, + **kwargs: Any + ) -> None: + # pylint: disable=line-too-long + """[Update] The Lease File operation establishes and manages a lock on a file for write and delete + operations. + + :param lease_id: Specifies the current lease ID on the resource. Required. + :type lease_id: str + :param timeout: The timeout parameter is expressed in seconds. For more information, see + :code:`<a + href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting + Timeouts for File Service Operations.</a>`. Default value is None. + :type timeout: int + :param proposed_lease_id: Proposed lease ID, in a GUID string format. The File service returns + 400 (Invalid request) if the proposed lease ID is not in the correct format. See Guid + Constructor (String) for a list of valid GUID string formats. Default value is None. + :type proposed_lease_id: str + :param request_id_parameter: Provides a client-generated, opaque value with a 1 KB character + limit that is recorded in the analytics logs when storage analytics logging is enabled. Default + value is None. + :type request_id_parameter: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + comp: Literal["lease"] = kwargs.pop("comp", _params.pop("comp", "lease")) + action: Literal["change"] = kwargs.pop("action", _headers.pop("x-ms-lease-action", "change")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_change_lease_request( + url=self._config.url, + lease_id=lease_id, + timeout=timeout, + proposed_lease_id=proposed_lease_id, + request_id_parameter=request_id_parameter, + allow_trailing_dot=self._config.allow_trailing_dot, + file_request_intent=self._config.file_request_intent, + comp=comp, + action=action, + version=self._config.version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["Last-Modified"] = self._deserialize("rfc-1123", response.headers.get("Last-Modified")) + response_headers["x-ms-lease-id"] = self._deserialize("str", response.headers.get("x-ms-lease-id")) + response_headers["x-ms-client-request-id"] = self._deserialize( + "str", response.headers.get("x-ms-client-request-id") + ) + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace_async + async def break_lease( + self, + timeout: Optional[int] = None, + request_id_parameter: Optional[str] = None, + lease_access_conditions: Optional[_models.LeaseAccessConditions] = None, + **kwargs: Any + ) -> None: + # pylint: disable=line-too-long + """[Update] The Lease File operation establishes and manages a lock on a file for write and delete + operations. + + :param timeout: The timeout parameter is expressed in seconds. For more information, see + :code:`<a + href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting + Timeouts for File Service Operations.</a>`. Default value is None. + :type timeout: int + :param request_id_parameter: Provides a client-generated, opaque value with a 1 KB character + limit that is recorded in the analytics logs when storage analytics logging is enabled. Default + value is None. + :type request_id_parameter: str + :param lease_access_conditions: Parameter group. Default value is None. + :type lease_access_conditions: ~azure.storage.fileshare.models.LeaseAccessConditions + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + comp: Literal["lease"] = kwargs.pop("comp", _params.pop("comp", "lease")) + action: Literal["break"] = kwargs.pop("action", _headers.pop("x-ms-lease-action", "break")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _lease_id = None + if lease_access_conditions is not None: + _lease_id = lease_access_conditions.lease_id + + _request = build_break_lease_request( + url=self._config.url, + timeout=timeout, + lease_id=_lease_id, + request_id_parameter=request_id_parameter, + allow_trailing_dot=self._config.allow_trailing_dot, + file_request_intent=self._config.file_request_intent, + comp=comp, + action=action, + version=self._config.version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["Last-Modified"] = self._deserialize("rfc-1123", response.headers.get("Last-Modified")) + response_headers["x-ms-lease-id"] = self._deserialize("str", response.headers.get("x-ms-lease-id")) + response_headers["x-ms-client-request-id"] = self._deserialize( + "str", response.headers.get("x-ms-client-request-id") + ) + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace_async + async def upload_range( + self, + range: str, + content_length: int, + timeout: Optional[int] = None, + file_range_write: Union[str, _models.FileRangeWriteType] = "update", + content_md5: Optional[bytes] = None, + file_last_written_mode: Optional[Union[str, _models.FileLastWrittenMode]] = None, + structured_body_type: Optional[str] = None, + structured_content_length: Optional[int] = None, + lease_access_conditions: Optional[_models.LeaseAccessConditions] = None, + optionalbody: Optional[IO[bytes]] = None, + **kwargs: Any + ) -> None: + # pylint: disable=line-too-long + """Upload a range of bytes to a file. + + :param range: Specifies the range of bytes to be written. Both the start and end of the range + must be specified. For an update operation, the range can be up to 4 MB in size. For a clear + operation, the range can be up to the value of the file's full size. The File service accepts + only a single byte range for the Range and 'x-ms-range' headers, and the byte range must be + specified in the following format: bytes=startByte-endByte. Required. + :type range: str + :param content_length: Specifies the number of bytes being transmitted in the request body. + When the x-ms-write header is set to clear, the value of this header must be set to zero. + Required. + :type content_length: int + :param timeout: The timeout parameter is expressed in seconds. For more information, see + :code:`<a + href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting + Timeouts for File Service Operations.</a>`. Default value is None. + :type timeout: int + :param file_range_write: Specify one of the following options: - Update: Writes the bytes + specified by the request body into the specified range. The Range and Content-Length headers + must match to perform the update. - Clear: Clears the specified range and releases the space + used in storage for that range. To clear a range, set the Content-Length header to zero, and + set the Range header to a value that indicates the range to clear, up to maximum file size. + Known values are: "update" and "clear". Default value is "update". + :type file_range_write: str or ~azure.storage.fileshare.models.FileRangeWriteType + :param content_md5: An MD5 hash of the content. This hash is used to verify the integrity of + the data during transport. When the Content-MD5 header is specified, the File service compares + the hash of the content that has arrived with the header value that was sent. If the two hashes + do not match, the operation will fail with error code 400 (Bad Request). Default value is None. + :type content_md5: bytes + :param file_last_written_mode: If the file last write time should be preserved or overwritten. + Known values are: "Now" and "Preserve". Default value is None. + :type file_last_written_mode: str or ~azure.storage.fileshare.models.FileLastWrittenMode + :param structured_body_type: Required if the request body is a structured message. Specifies + the message schema version and properties. Default value is None. + :type structured_body_type: str + :param structured_content_length: Required if the request body is a structured message. + Specifies the length of the blob/file content inside the message body. Will always be smaller + than Content-Length. Default value is None. + :type structured_content_length: int + :param lease_access_conditions: Parameter group. Default value is None. + :type lease_access_conditions: ~azure.storage.fileshare.models.LeaseAccessConditions + :param optionalbody: Initial data. Default value is None. + :type optionalbody: IO[bytes] + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + comp: Literal["range"] = kwargs.pop("comp", _params.pop("comp", "range")) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/octet-stream")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _lease_id = None + if lease_access_conditions is not None: + _lease_id = lease_access_conditions.lease_id + _content = optionalbody + + _request = build_upload_range_request( + url=self._config.url, + range=range, + content_length=content_length, + timeout=timeout, + file_range_write=file_range_write, + content_md5=content_md5, + lease_id=_lease_id, + file_last_written_mode=file_last_written_mode, + structured_body_type=structured_body_type, + structured_content_length=structured_content_length, + allow_trailing_dot=self._config.allow_trailing_dot, + file_request_intent=self._config.file_request_intent, + comp=comp, + content_type=content_type, + version=self._config.version, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["Last-Modified"] = self._deserialize("rfc-1123", response.headers.get("Last-Modified")) + response_headers["Content-MD5"] = self._deserialize("bytearray", response.headers.get("Content-MD5")) + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-request-server-encrypted"] = self._deserialize( + "bool", response.headers.get("x-ms-request-server-encrypted") + ) + response_headers["x-ms-file-last-write-time"] = self._deserialize( + "str", response.headers.get("x-ms-file-last-write-time") + ) + response_headers["x-ms-structured-body"] = self._deserialize( + "str", response.headers.get("x-ms-structured-body") + ) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace_async + async def upload_range_from_url( + self, + range: str, + copy_source: str, + content_length: int, + timeout: Optional[int] = None, + source_range: Optional[str] = None, + source_content_crc64: Optional[bytes] = None, + copy_source_authorization: Optional[str] = None, + file_last_written_mode: Optional[Union[str, _models.FileLastWrittenMode]] = None, + source_modified_access_conditions: Optional[_models.SourceModifiedAccessConditions] = None, + lease_access_conditions: Optional[_models.LeaseAccessConditions] = None, + **kwargs: Any + ) -> None: + # pylint: disable=line-too-long + """Upload a range of bytes to a file where the contents are read from a URL. + + :param range: Writes data to the specified byte range in the file. Required. + :type range: str + :param copy_source: Specifies the URL of the source file or blob, up to 2 KB in length. To copy + a file to another file within the same storage account, you may use Shared Key to authenticate + the source file. If you are copying a file from another storage account, or if you are copying + a blob from the same storage account or another storage account, then you must authenticate the + source file or blob using a shared access signature. If the source is a public blob, no + authentication is required to perform the copy operation. A file in a share snapshot can also + be specified as a copy source. Required. + :type copy_source: str + :param content_length: Specifies the number of bytes being transmitted in the request body. + When the x-ms-write header is set to clear, the value of this header must be set to zero. + Required. + :type content_length: int + :param timeout: The timeout parameter is expressed in seconds. For more information, see + :code:`<a + href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting + Timeouts for File Service Operations.</a>`. Default value is None. + :type timeout: int + :param source_range: Bytes of source data in the specified range. Default value is None. + :type source_range: str + :param source_content_crc64: Specify the crc64 calculated for the range of bytes that must be + read from the copy source. Default value is None. + :type source_content_crc64: bytes + :param copy_source_authorization: Only Bearer type is supported. Credentials should be a valid + OAuth access token to copy source. Default value is None. + :type copy_source_authorization: str + :param file_last_written_mode: If the file last write time should be preserved or overwritten. + Known values are: "Now" and "Preserve". Default value is None. + :type file_last_written_mode: str or ~azure.storage.fileshare.models.FileLastWrittenMode + :param source_modified_access_conditions: Parameter group. Default value is None. + :type source_modified_access_conditions: + ~azure.storage.fileshare.models.SourceModifiedAccessConditions + :param lease_access_conditions: Parameter group. Default value is None. + :type lease_access_conditions: ~azure.storage.fileshare.models.LeaseAccessConditions + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + comp: Literal["range"] = kwargs.pop("comp", _params.pop("comp", "range")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _source_if_match_crc64 = None + _source_if_none_match_crc64 = None + _lease_id = None + if source_modified_access_conditions is not None: + _source_if_match_crc64 = source_modified_access_conditions.source_if_match_crc64 + _source_if_none_match_crc64 = source_modified_access_conditions.source_if_none_match_crc64 + if lease_access_conditions is not None: + _lease_id = lease_access_conditions.lease_id + + _request = build_upload_range_from_url_request( + url=self._config.url, + range=range, + copy_source=copy_source, + content_length=content_length, + timeout=timeout, + source_range=source_range, + source_content_crc64=source_content_crc64, + source_if_match_crc64=_source_if_match_crc64, + source_if_none_match_crc64=_source_if_none_match_crc64, + lease_id=_lease_id, + copy_source_authorization=copy_source_authorization, + file_last_written_mode=file_last_written_mode, + allow_trailing_dot=self._config.allow_trailing_dot, + allow_source_trailing_dot=self._config.allow_source_trailing_dot, + file_request_intent=self._config.file_request_intent, + comp=comp, + file_range_write_from_url=self._config.file_range_write_from_url, + version=self._config.version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["Last-Modified"] = self._deserialize("rfc-1123", response.headers.get("Last-Modified")) + response_headers["x-ms-content-crc64"] = self._deserialize( + "bytearray", response.headers.get("x-ms-content-crc64") + ) + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-request-server-encrypted"] = self._deserialize( + "bool", response.headers.get("x-ms-request-server-encrypted") + ) + response_headers["x-ms-file-last-write-time"] = self._deserialize( + "str", response.headers.get("x-ms-file-last-write-time") + ) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace_async + async def get_range_list( + self, + sharesnapshot: Optional[str] = None, + prevsharesnapshot: Optional[str] = None, + timeout: Optional[int] = None, + range: Optional[str] = None, + support_rename: Optional[bool] = None, + lease_access_conditions: Optional[_models.LeaseAccessConditions] = None, + **kwargs: Any + ) -> _models.ShareFileRangeList: + # pylint: disable=line-too-long + """Returns the list of valid ranges for a file. + + :param sharesnapshot: The snapshot parameter is an opaque DateTime value that, when present, + specifies the share snapshot to query. Default value is None. + :type sharesnapshot: str + :param prevsharesnapshot: The previous snapshot parameter is an opaque DateTime value that, + when present, specifies the previous snapshot. Default value is None. + :type prevsharesnapshot: str + :param timeout: The timeout parameter is expressed in seconds. For more information, see + :code:`<a + href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting + Timeouts for File Service Operations.</a>`. Default value is None. + :type timeout: int + :param range: Specifies the range of bytes over which to list ranges, inclusively. Default + value is None. + :type range: str + :param support_rename: This header is allowed only when PrevShareSnapshot query parameter is + set. Determines whether the changed ranges for a file that has been renamed or moved between + the target snapshot (or the live file) and the previous snapshot should be listed. If the value + is true, the valid changed ranges for the file will be returned. If the value is false, the + operation will result in a failure with 409 (Conflict) response. The default value is false. + Default value is None. + :type support_rename: bool + :param lease_access_conditions: Parameter group. Default value is None. + :type lease_access_conditions: ~azure.storage.fileshare.models.LeaseAccessConditions + :return: ShareFileRangeList or the result of cls(response) + :rtype: ~azure.storage.fileshare.models.ShareFileRangeList + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + comp: Literal["rangelist"] = kwargs.pop("comp", _params.pop("comp", "rangelist")) + cls: ClsType[_models.ShareFileRangeList] = kwargs.pop("cls", None) + + _lease_id = None + if lease_access_conditions is not None: + _lease_id = lease_access_conditions.lease_id + + _request = build_get_range_list_request( + url=self._config.url, + sharesnapshot=sharesnapshot, + prevsharesnapshot=prevsharesnapshot, + timeout=timeout, + range=range, + lease_id=_lease_id, + support_rename=support_rename, + allow_trailing_dot=self._config.allow_trailing_dot, + file_request_intent=self._config.file_request_intent, + comp=comp, + version=self._config.version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["Last-Modified"] = self._deserialize("rfc-1123", response.headers.get("Last-Modified")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["x-ms-content-length"] = self._deserialize("int", response.headers.get("x-ms-content-length")) + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + + deserialized = self._deserialize("ShareFileRangeList", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def start_copy( + self, + copy_source: str, + timeout: Optional[int] = None, + metadata: Optional[Dict[str, str]] = None, + file_permission: str = "inherit", + file_permission_format: Optional[Union[str, _models.FilePermissionFormat]] = None, + file_permission_key: Optional[str] = None, + owner: Optional[str] = None, + group: Optional[str] = None, + file_mode: Optional[str] = None, + file_mode_copy_mode: Optional[Union[str, _models.ModeCopyMode]] = None, + file_owner_copy_mode: Optional[Union[str, _models.OwnerCopyMode]] = None, + copy_file_smb_info: Optional[_models.CopyFileSmbInfo] = None, + lease_access_conditions: Optional[_models.LeaseAccessConditions] = None, + **kwargs: Any + ) -> None: + # pylint: disable=line-too-long + """Copies a blob or file to a destination file within the storage account. + + :param copy_source: Specifies the URL of the source file or blob, up to 2 KB in length. To copy + a file to another file within the same storage account, you may use Shared Key to authenticate + the source file. If you are copying a file from another storage account, or if you are copying + a blob from the same storage account or another storage account, then you must authenticate the + source file or blob using a shared access signature. If the source is a public blob, no + authentication is required to perform the copy operation. A file in a share snapshot can also + be specified as a copy source. Required. + :type copy_source: str + :param timeout: The timeout parameter is expressed in seconds. For more information, see + :code:`<a + href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting + Timeouts for File Service Operations.</a>`. Default value is None. + :type timeout: int + :param metadata: A name-value pair to associate with a file storage object. Default value is + None. + :type metadata: dict[str, str] + :param file_permission: If specified the permission (security descriptor) shall be set for the + directory/file. This header can be used if Permission size is <= 8KB, else + x-ms-file-permission-key header shall be used. Default value: Inherit. If SDDL is specified as + input, it must have owner, group and dacl. Note: Only one of the x-ms-file-permission or + x-ms-file-permission-key should be specified. Default value is "inherit". + :type file_permission: str + :param file_permission_format: Optional. Available for version 2023-06-01 and later. Specifies + the format in which the permission is returned. Acceptable values are SDDL or binary. If + x-ms-file-permission-format is unspecified or explicitly set to SDDL, the permission is + returned in SDDL format. If x-ms-file-permission-format is explicitly set to binary, the + permission is returned as a base64 string representing the binary encoding of the permission. + Known values are: "Sddl" and "Binary". Default value is None. + :type file_permission_format: str or ~azure.storage.fileshare.models.FilePermissionFormat + :param file_permission_key: Key of the permission to be set for the directory/file. Note: Only + one of the x-ms-file-permission or x-ms-file-permission-key should be specified. Default value + is None. + :type file_permission_key: str + :param owner: Optional, NFS only. The owner of the file or directory. Default value is None. + :type owner: str + :param group: Optional, NFS only. The owning group of the file or directory. Default value is + None. + :type group: str + :param file_mode: Optional, NFS only. The file mode of the file or directory. Default value is + None. + :type file_mode: str + :param file_mode_copy_mode: NFS only. Applicable only when the copy source is a File. + Determines the copy behavior of the mode bits of the file. source: The mode on the destination + file is copied from the source file. override: The mode on the destination file is determined + via the x-ms-mode header. Known values are: "source" and "override". Default value is None. + :type file_mode_copy_mode: str or ~azure.storage.fileshare.models.ModeCopyMode + :param file_owner_copy_mode: NFS only. Determines the copy behavior of the owner user + identifier (UID) and group identifier (GID) of the file. source: The owner user identifier + (UID) and group identifier (GID) on the destination file is copied from the source file. + override: The owner user identifier (UID) and group identifier (GID) on the destination file is + determined via the x-ms-owner and x-ms-group headers. Known values are: "source" and + "override". Default value is None. + :type file_owner_copy_mode: str or ~azure.storage.fileshare.models.OwnerCopyMode + :param copy_file_smb_info: Parameter group. Default value is None. + :type copy_file_smb_info: ~azure.storage.fileshare.models.CopyFileSmbInfo + :param lease_access_conditions: Parameter group. Default value is None. + :type lease_access_conditions: ~azure.storage.fileshare.models.LeaseAccessConditions + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _file_permission_copy_mode = None + _ignore_read_only = None + _file_attributes = None + _file_creation_time = None + _file_last_write_time = None + _file_change_time = None + _set_archive_attribute = None + _lease_id = None + if copy_file_smb_info is not None: + _file_attributes = copy_file_smb_info.file_attributes + _file_change_time = copy_file_smb_info.file_change_time + _file_creation_time = copy_file_smb_info.file_creation_time + _file_last_write_time = copy_file_smb_info.file_last_write_time + _file_permission_copy_mode = copy_file_smb_info.file_permission_copy_mode + _ignore_read_only = copy_file_smb_info.ignore_read_only + _set_archive_attribute = copy_file_smb_info.set_archive_attribute + if lease_access_conditions is not None: + _lease_id = lease_access_conditions.lease_id + + _request = build_start_copy_request( + url=self._config.url, + copy_source=copy_source, + timeout=timeout, + metadata=metadata, + file_permission=file_permission, + file_permission_format=file_permission_format, + file_permission_key=file_permission_key, + file_permission_copy_mode=_file_permission_copy_mode, + ignore_read_only=_ignore_read_only, + file_attributes=_file_attributes, + file_creation_time=_file_creation_time, + file_last_write_time=_file_last_write_time, + file_change_time=_file_change_time, + set_archive_attribute=_set_archive_attribute, + lease_id=_lease_id, + owner=owner, + group=group, + file_mode=file_mode, + file_mode_copy_mode=file_mode_copy_mode, + file_owner_copy_mode=file_owner_copy_mode, + allow_trailing_dot=self._config.allow_trailing_dot, + allow_source_trailing_dot=self._config.allow_source_trailing_dot, + file_request_intent=self._config.file_request_intent, + version=self._config.version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["Last-Modified"] = self._deserialize("rfc-1123", response.headers.get("Last-Modified")) + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-copy-id"] = self._deserialize("str", response.headers.get("x-ms-copy-id")) + response_headers["x-ms-copy-status"] = self._deserialize("str", response.headers.get("x-ms-copy-status")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace_async + async def abort_copy( + self, + copy_id: str, + timeout: Optional[int] = None, + lease_access_conditions: Optional[_models.LeaseAccessConditions] = None, + **kwargs: Any + ) -> None: + # pylint: disable=line-too-long + """Aborts a pending Copy File operation, and leaves a destination file with zero length and full + metadata. + + :param copy_id: The copy identifier provided in the x-ms-copy-id header of the original Copy + File operation. Required. + :type copy_id: str + :param timeout: The timeout parameter is expressed in seconds. For more information, see + :code:`<a + href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting + Timeouts for File Service Operations.</a>`. Default value is None. + :type timeout: int + :param lease_access_conditions: Parameter group. Default value is None. + :type lease_access_conditions: ~azure.storage.fileshare.models.LeaseAccessConditions + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + comp: Literal["copy"] = kwargs.pop("comp", _params.pop("comp", "copy")) + copy_action_abort_constant: Literal["abort"] = kwargs.pop( + "copy_action_abort_constant", _headers.pop("x-ms-copy-action", "abort") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + _lease_id = None + if lease_access_conditions is not None: + _lease_id = lease_access_conditions.lease_id + + _request = build_abort_copy_request( + url=self._config.url, + copy_id=copy_id, + timeout=timeout, + lease_id=_lease_id, + allow_trailing_dot=self._config.allow_trailing_dot, + file_request_intent=self._config.file_request_intent, + comp=comp, + copy_action_abort_constant=copy_action_abort_constant, + version=self._config.version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace_async + async def list_handles( + self, + marker: Optional[str] = None, + maxresults: Optional[int] = None, + timeout: Optional[int] = None, + sharesnapshot: Optional[str] = None, + **kwargs: Any + ) -> _models.ListHandlesResponse: + # pylint: disable=line-too-long + """Lists handles for file. + + :param marker: A string value that identifies the portion of the list to be returned with the + next list operation. The operation returns a marker value within the response body if the list + returned was not complete. The marker value may then be used in a subsequent call to request + the next set of list items. The marker value is opaque to the client. Default value is None. + :type marker: str + :param maxresults: Specifies the maximum number of entries to return. If the request does not + specify maxresults, or specifies a value greater than 5,000, the server will return up to 5,000 + items. Default value is None. + :type maxresults: int + :param timeout: The timeout parameter is expressed in seconds. For more information, see + :code:`<a + href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting + Timeouts for File Service Operations.</a>`. Default value is None. + :type timeout: int + :param sharesnapshot: The snapshot parameter is an opaque DateTime value that, when present, + specifies the share snapshot to query. Default value is None. + :type sharesnapshot: str + :return: ListHandlesResponse or the result of cls(response) + :rtype: ~azure.storage.fileshare.models.ListHandlesResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + comp: Literal["listhandles"] = kwargs.pop("comp", _params.pop("comp", "listhandles")) + cls: ClsType[_models.ListHandlesResponse] = kwargs.pop("cls", None) + + _request = build_list_handles_request( + url=self._config.url, + marker=marker, + maxresults=maxresults, + timeout=timeout, + sharesnapshot=sharesnapshot, + allow_trailing_dot=self._config.allow_trailing_dot, + file_request_intent=self._config.file_request_intent, + comp=comp, + version=self._config.version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["Content-Type"] = self._deserialize("str", response.headers.get("Content-Type")) + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + + deserialized = self._deserialize("ListHandlesResponse", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def force_close_handles( + self, + handle_id: str, + timeout: Optional[int] = None, + marker: Optional[str] = None, + sharesnapshot: Optional[str] = None, + **kwargs: Any + ) -> None: + # pylint: disable=line-too-long + """Closes all handles open for given file. + + :param handle_id: Specifies handle ID opened on the file or directory to be closed. Asterisk + (‘*’) is a wildcard that specifies all handles. Required. + :type handle_id: str + :param timeout: The timeout parameter is expressed in seconds. For more information, see + :code:`<a + href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting + Timeouts for File Service Operations.</a>`. Default value is None. + :type timeout: int + :param marker: A string value that identifies the portion of the list to be returned with the + next list operation. The operation returns a marker value within the response body if the list + returned was not complete. The marker value may then be used in a subsequent call to request + the next set of list items. The marker value is opaque to the client. Default value is None. + :type marker: str + :param sharesnapshot: The snapshot parameter is an opaque DateTime value that, when present, + specifies the share snapshot to query. Default value is None. + :type sharesnapshot: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + comp: Literal["forceclosehandles"] = kwargs.pop("comp", _params.pop("comp", "forceclosehandles")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_force_close_handles_request( + url=self._config.url, + handle_id=handle_id, + timeout=timeout, + marker=marker, + sharesnapshot=sharesnapshot, + allow_trailing_dot=self._config.allow_trailing_dot, + file_request_intent=self._config.file_request_intent, + comp=comp, + version=self._config.version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-marker"] = self._deserialize("str", response.headers.get("x-ms-marker")) + response_headers["x-ms-number-of-handles-closed"] = self._deserialize( + "int", response.headers.get("x-ms-number-of-handles-closed") + ) + response_headers["x-ms-number-of-handles-failed"] = self._deserialize( + "int", response.headers.get("x-ms-number-of-handles-failed") + ) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace_async + async def rename( + self, + rename_source: str, + timeout: Optional[int] = None, + replace_if_exists: Optional[bool] = None, + ignore_read_only: Optional[bool] = None, + file_permission: str = "inherit", + file_permission_format: Optional[Union[str, _models.FilePermissionFormat]] = None, + file_permission_key: Optional[str] = None, + metadata: Optional[Dict[str, str]] = None, + source_lease_access_conditions: Optional[_models.SourceLeaseAccessConditions] = None, + destination_lease_access_conditions: Optional[_models.DestinationLeaseAccessConditions] = None, + copy_file_smb_info: Optional[_models.CopyFileSmbInfo] = None, + file_http_headers: Optional[_models.FileHTTPHeaders] = None, + **kwargs: Any + ) -> None: + # pylint: disable=line-too-long + """Renames a file. + + :param rename_source: Required. Specifies the URI-style path of the source file, up to 2 KB in + length. Required. + :type rename_source: str + :param timeout: The timeout parameter is expressed in seconds. For more information, see + :code:`<a + href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting + Timeouts for File Service Operations.</a>`. Default value is None. + :type timeout: int + :param replace_if_exists: Optional. A boolean value for if the destination file already exists, + whether this request will overwrite the file or not. If true, the rename will succeed and will + overwrite the destination file. If not provided or if false and the destination file does + exist, the request will not overwrite the destination file. If provided and the destination + file doesn’t exist, the rename will succeed. Note: This value does not override the + x-ms-file-copy-ignore-read-only header value. Default value is None. + :type replace_if_exists: bool + :param ignore_read_only: Optional. A boolean value that specifies whether the ReadOnly + attribute on a preexisting destination file should be respected. If true, the rename will + succeed, otherwise, a previous file at the destination with the ReadOnly attribute set will + cause the rename to fail. Default value is None. + :type ignore_read_only: bool + :param file_permission: If specified the permission (security descriptor) shall be set for the + directory/file. This header can be used if Permission size is <= 8KB, else + x-ms-file-permission-key header shall be used. Default value: Inherit. If SDDL is specified as + input, it must have owner, group and dacl. Note: Only one of the x-ms-file-permission or + x-ms-file-permission-key should be specified. Default value is "inherit". + :type file_permission: str + :param file_permission_format: Optional. Available for version 2023-06-01 and later. Specifies + the format in which the permission is returned. Acceptable values are SDDL or binary. If + x-ms-file-permission-format is unspecified or explicitly set to SDDL, the permission is + returned in SDDL format. If x-ms-file-permission-format is explicitly set to binary, the + permission is returned as a base64 string representing the binary encoding of the permission. + Known values are: "Sddl" and "Binary". Default value is None. + :type file_permission_format: str or ~azure.storage.fileshare.models.FilePermissionFormat + :param file_permission_key: Key of the permission to be set for the directory/file. Note: Only + one of the x-ms-file-permission or x-ms-file-permission-key should be specified. Default value + is None. + :type file_permission_key: str + :param metadata: A name-value pair to associate with a file storage object. Default value is + None. + :type metadata: dict[str, str] + :param source_lease_access_conditions: Parameter group. Default value is None. + :type source_lease_access_conditions: + ~azure.storage.fileshare.models.SourceLeaseAccessConditions + :param destination_lease_access_conditions: Parameter group. Default value is None. + :type destination_lease_access_conditions: + ~azure.storage.fileshare.models.DestinationLeaseAccessConditions + :param copy_file_smb_info: Parameter group. Default value is None. + :type copy_file_smb_info: ~azure.storage.fileshare.models.CopyFileSmbInfo + :param file_http_headers: Parameter group. Default value is None. + :type file_http_headers: ~azure.storage.fileshare.models.FileHTTPHeaders + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + comp: Literal["rename"] = kwargs.pop("comp", _params.pop("comp", "rename")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _source_lease_id = None + _destination_lease_id = None + _file_attributes = None + _file_creation_time = None + _file_last_write_time = None + _file_change_time = None + _file_content_type = None + if source_lease_access_conditions is not None: + _source_lease_id = source_lease_access_conditions.source_lease_id + if destination_lease_access_conditions is not None: + _destination_lease_id = destination_lease_access_conditions.destination_lease_id + if copy_file_smb_info is not None: + _file_attributes = copy_file_smb_info.file_attributes + _file_change_time = copy_file_smb_info.file_change_time + _file_creation_time = copy_file_smb_info.file_creation_time + _file_last_write_time = copy_file_smb_info.file_last_write_time + if file_http_headers is not None: + _file_content_type = file_http_headers.file_content_type + + _request = build_rename_request( + url=self._config.url, + rename_source=rename_source, + timeout=timeout, + replace_if_exists=replace_if_exists, + ignore_read_only=ignore_read_only, + source_lease_id=_source_lease_id, + destination_lease_id=_destination_lease_id, + file_attributes=_file_attributes, + file_creation_time=_file_creation_time, + file_last_write_time=_file_last_write_time, + file_change_time=_file_change_time, + file_permission=file_permission, + file_permission_format=file_permission_format, + file_permission_key=file_permission_key, + metadata=metadata, + file_content_type=_file_content_type, + allow_trailing_dot=self._config.allow_trailing_dot, + allow_source_trailing_dot=self._config.allow_source_trailing_dot, + file_request_intent=self._config.file_request_intent, + comp=comp, + version=self._config.version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["Last-Modified"] = self._deserialize("rfc-1123", response.headers.get("Last-Modified")) + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-request-server-encrypted"] = self._deserialize( + "bool", response.headers.get("x-ms-request-server-encrypted") + ) + response_headers["x-ms-file-permission-key"] = self._deserialize( + "str", response.headers.get("x-ms-file-permission-key") + ) + response_headers["x-ms-file-attributes"] = self._deserialize( + "str", response.headers.get("x-ms-file-attributes") + ) + response_headers["x-ms-file-creation-time"] = self._deserialize( + "str", response.headers.get("x-ms-file-creation-time") + ) + response_headers["x-ms-file-last-write-time"] = self._deserialize( + "str", response.headers.get("x-ms-file-last-write-time") + ) + response_headers["x-ms-file-change-time"] = self._deserialize( + "str", response.headers.get("x-ms-file-change-time") + ) + response_headers["x-ms-file-id"] = self._deserialize("str", response.headers.get("x-ms-file-id")) + response_headers["x-ms-file-parent-id"] = self._deserialize("str", response.headers.get("x-ms-file-parent-id")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace_async + async def create_symbolic_link( + self, + link_text: str, + timeout: Optional[int] = None, + metadata: Optional[Dict[str, str]] = None, + file_creation_time: str = "now", + file_last_write_time: str = "now", + request_id_parameter: Optional[str] = None, + owner: Optional[str] = None, + group: Optional[str] = None, + lease_access_conditions: Optional[_models.LeaseAccessConditions] = None, + **kwargs: Any + ) -> None: + # pylint: disable=line-too-long + """Creates a symbolic link. + + :param link_text: NFS only. Required. The path to the original file, the symbolic link is + pointing to. The path is of type string which is not resolved and is stored as is. The path can + be absolute path or the relative path depending on the content stored in the symbolic link + file. Required. + :type link_text: str + :param timeout: The timeout parameter is expressed in seconds. For more information, see + :code:`<a + href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting + Timeouts for File Service Operations.</a>`. Default value is None. + :type timeout: int + :param metadata: A name-value pair to associate with a file storage object. Default value is + None. + :type metadata: dict[str, str] + :param file_creation_time: Creation time for the file/directory. Default value: Now. Default + value is "now". + :type file_creation_time: str + :param file_last_write_time: Last write time for the file/directory. Default value: Now. + Default value is "now". + :type file_last_write_time: str + :param request_id_parameter: Provides a client-generated, opaque value with a 1 KB character + limit that is recorded in the analytics logs when storage analytics logging is enabled. Default + value is None. + :type request_id_parameter: str + :param owner: Optional, NFS only. The owner of the file or directory. Default value is None. + :type owner: str + :param group: Optional, NFS only. The owning group of the file or directory. Default value is + None. + :type group: str + :param lease_access_conditions: Parameter group. Default value is None. + :type lease_access_conditions: ~azure.storage.fileshare.models.LeaseAccessConditions + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + restype: Literal["symboliclink"] = kwargs.pop("restype", _params.pop("restype", "symboliclink")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _lease_id = None + if lease_access_conditions is not None: + _lease_id = lease_access_conditions.lease_id + + _request = build_create_symbolic_link_request( + url=self._config.url, + link_text=link_text, + timeout=timeout, + metadata=metadata, + file_creation_time=file_creation_time, + file_last_write_time=file_last_write_time, + request_id_parameter=request_id_parameter, + lease_id=_lease_id, + owner=owner, + group=group, + file_request_intent=self._config.file_request_intent, + restype=restype, + version=self._config.version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["Last-Modified"] = self._deserialize("rfc-1123", response.headers.get("Last-Modified")) + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-file-creation-time"] = self._deserialize( + "str", response.headers.get("x-ms-file-creation-time") + ) + response_headers["x-ms-file-last-write-time"] = self._deserialize( + "str", response.headers.get("x-ms-file-last-write-time") + ) + response_headers["x-ms-file-change-time"] = self._deserialize( + "str", response.headers.get("x-ms-file-change-time") + ) + response_headers["x-ms-file-id"] = self._deserialize("str", response.headers.get("x-ms-file-id")) + response_headers["x-ms-file-parent-id"] = self._deserialize("str", response.headers.get("x-ms-file-parent-id")) + response_headers["x-ms-client-request-id"] = self._deserialize( + "str", response.headers.get("x-ms-client-request-id") + ) + response_headers["x-ms-mode"] = self._deserialize("str", response.headers.get("x-ms-mode")) + response_headers["x-ms-owner"] = self._deserialize("str", response.headers.get("x-ms-owner")) + response_headers["x-ms-group"] = self._deserialize("str", response.headers.get("x-ms-group")) + response_headers["x-ms-file-file-type"] = self._deserialize("str", response.headers.get("x-ms-file-file-type")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace_async + async def get_symbolic_link( + self, + timeout: Optional[int] = None, + sharesnapshot: Optional[str] = None, + request_id_parameter: Optional[str] = None, + **kwargs: Any + ) -> None: + # pylint: disable=line-too-long + """get_symbolic_link. + + :param timeout: The timeout parameter is expressed in seconds. For more information, see + :code:`<a + href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting + Timeouts for File Service Operations.</a>`. Default value is None. + :type timeout: int + :param sharesnapshot: The snapshot parameter is an opaque DateTime value that, when present, + specifies the share snapshot to query. Default value is None. + :type sharesnapshot: str + :param request_id_parameter: Provides a client-generated, opaque value with a 1 KB character + limit that is recorded in the analytics logs when storage analytics logging is enabled. Default + value is None. + :type request_id_parameter: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + restype: Literal["symboliclink"] = kwargs.pop("restype", _params.pop("restype", "symboliclink")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_get_symbolic_link_request( + url=self._config.url, + timeout=timeout, + sharesnapshot=sharesnapshot, + request_id_parameter=request_id_parameter, + file_request_intent=self._config.file_request_intent, + restype=restype, + version=self._config.version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["Last-Modified"] = self._deserialize("rfc-1123", response.headers.get("Last-Modified")) + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-link-text"] = self._deserialize("str", response.headers.get("x-ms-link-text")) + response_headers["x-ms-client-request-id"] = self._deserialize( + "str", response.headers.get("x-ms-client-request-id") + ) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace_async + async def create_hard_link( + self, + target_file: str, + timeout: Optional[int] = None, + request_id_parameter: Optional[str] = None, + lease_access_conditions: Optional[_models.LeaseAccessConditions] = None, + **kwargs: Any + ) -> None: + # pylint: disable=line-too-long + """Creates a hard link. + + :param target_file: NFS only. Required. Specifies the path of the target file to which the link + will be created, up to 2 KiB in length. It should be full path of the target from the root.The + target file must be in the same share and hence the same storage account. Required. + :type target_file: str + :param timeout: The timeout parameter is expressed in seconds. For more information, see + :code:`<a + href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting + Timeouts for File Service Operations.</a>`. Default value is None. + :type timeout: int + :param request_id_parameter: Provides a client-generated, opaque value with a 1 KB character + limit that is recorded in the analytics logs when storage analytics logging is enabled. Default + value is None. + :type request_id_parameter: str + :param lease_access_conditions: Parameter group. Default value is None. + :type lease_access_conditions: ~azure.storage.fileshare.models.LeaseAccessConditions + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + restype: Literal["hardlink"] = kwargs.pop("restype", _params.pop("restype", "hardlink")) + file_type_constant: Literal["file"] = kwargs.pop("file_type_constant", _headers.pop("x-ms-type", "file")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _lease_id = None + if lease_access_conditions is not None: + _lease_id = lease_access_conditions.lease_id + + _request = build_create_hard_link_request( + url=self._config.url, + target_file=target_file, + timeout=timeout, + request_id_parameter=request_id_parameter, + lease_id=_lease_id, + file_request_intent=self._config.file_request_intent, + restype=restype, + file_type_constant=file_type_constant, + version=self._config.version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["Last-Modified"] = self._deserialize("rfc-1123", response.headers.get("Last-Modified")) + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-file-creation-time"] = self._deserialize( + "str", response.headers.get("x-ms-file-creation-time") + ) + response_headers["x-ms-file-last-write-time"] = self._deserialize( + "str", response.headers.get("x-ms-file-last-write-time") + ) + response_headers["x-ms-file-change-time"] = self._deserialize( + "str", response.headers.get("x-ms-file-change-time") + ) + response_headers["x-ms-file-id"] = self._deserialize("str", response.headers.get("x-ms-file-id")) + response_headers["x-ms-file-parent-id"] = self._deserialize("str", response.headers.get("x-ms-file-parent-id")) + response_headers["x-ms-client-request-id"] = self._deserialize( + "str", response.headers.get("x-ms-client-request-id") + ) + response_headers["x-ms-link-count"] = self._deserialize("int", response.headers.get("x-ms-link-count")) + response_headers["x-ms-mode"] = self._deserialize("str", response.headers.get("x-ms-mode")) + response_headers["x-ms-owner"] = self._deserialize("str", response.headers.get("x-ms-owner")) + response_headers["x-ms-group"] = self._deserialize("str", response.headers.get("x-ms-group")) + response_headers["x-ms-file-file-type"] = self._deserialize("str", response.headers.get("x-ms-file-file-type")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore diff --git a/.venv/lib/python3.12/site-packages/azure/storage/fileshare/_generated/aio/operations/_patch.py b/.venv/lib/python3.12/site-packages/azure/storage/fileshare/_generated/aio/operations/_patch.py new file mode 100644 index 00000000..f7dd3251 --- /dev/null +++ b/.venv/lib/python3.12/site-packages/azure/storage/fileshare/_generated/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/.venv/lib/python3.12/site-packages/azure/storage/fileshare/_generated/aio/operations/_service_operations.py b/.venv/lib/python3.12/site-packages/azure/storage/fileshare/_generated/aio/operations/_service_operations.py new file mode 100644 index 00000000..4814e221 --- /dev/null +++ b/.venv/lib/python3.12/site-packages/azure/storage/fileshare/_generated/aio/operations/_service_operations.py @@ -0,0 +1,284 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, List, Literal, Optional, TypeVar, Union + +from azure.core import AsyncPipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict + +from ... import models as _models +from ..._serialization import Deserializer, Serializer +from ...operations._service_operations import ( + build_get_properties_request, + build_list_shares_segment_request, + build_set_properties_request, +) +from .._configuration import AzureFileStorageConfiguration + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ServiceOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.storage.fileshare.aio.AzureFileStorage`'s + :attr:`service` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AzureFileStorageConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def set_properties( + self, storage_service_properties: _models.StorageServiceProperties, timeout: Optional[int] = None, **kwargs: Any + ) -> None: + # pylint: disable=line-too-long + """Sets properties for a storage account's File service endpoint, including properties for Storage + Analytics metrics and CORS (Cross-Origin Resource Sharing) rules. + + :param storage_service_properties: The StorageService properties. Required. + :type storage_service_properties: ~azure.storage.fileshare.models.StorageServiceProperties + :param timeout: The timeout parameter is expressed in seconds. For more information, see + :code:`<a + href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting + Timeouts for File Service Operations.</a>`. Default value is None. + :type timeout: int + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + restype: Literal["service"] = kwargs.pop("restype", _params.pop("restype", "service")) + comp: Literal["properties"] = kwargs.pop("comp", _params.pop("comp", "properties")) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/xml")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _content = self._serialize.body(storage_service_properties, "StorageServiceProperties", is_xml=True) + + _request = build_set_properties_request( + url=self._config.url, + timeout=timeout, + file_request_intent=self._config.file_request_intent, + restype=restype, + comp=comp, + content_type=content_type, + version=self._config.version, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace_async + async def get_properties(self, timeout: Optional[int] = None, **kwargs: Any) -> _models.StorageServiceProperties: + # pylint: disable=line-too-long + """Gets the properties of a storage account's File service, including properties for Storage + Analytics metrics and CORS (Cross-Origin Resource Sharing) rules. + + :param timeout: The timeout parameter is expressed in seconds. For more information, see + :code:`<a + href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting + Timeouts for File Service Operations.</a>`. Default value is None. + :type timeout: int + :return: StorageServiceProperties or the result of cls(response) + :rtype: ~azure.storage.fileshare.models.StorageServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + restype: Literal["service"] = kwargs.pop("restype", _params.pop("restype", "service")) + comp: Literal["properties"] = kwargs.pop("comp", _params.pop("comp", "properties")) + cls: ClsType[_models.StorageServiceProperties] = kwargs.pop("cls", None) + + _request = build_get_properties_request( + url=self._config.url, + timeout=timeout, + file_request_intent=self._config.file_request_intent, + restype=restype, + comp=comp, + version=self._config.version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + + deserialized = self._deserialize("StorageServiceProperties", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def list_shares_segment( + self, + prefix: Optional[str] = None, + marker: Optional[str] = None, + maxresults: Optional[int] = None, + include: Optional[List[Union[str, _models.ListSharesIncludeType]]] = None, + timeout: Optional[int] = None, + **kwargs: Any + ) -> _models.ListSharesResponse: + # pylint: disable=line-too-long + """The List Shares Segment operation returns a list of the shares and share snapshots under the + specified account. + + :param prefix: Filters the results to return only entries whose name begins with the specified + prefix. Default value is None. + :type prefix: str + :param marker: A string value that identifies the portion of the list to be returned with the + next list operation. The operation returns a marker value within the response body if the list + returned was not complete. The marker value may then be used in a subsequent call to request + the next set of list items. The marker value is opaque to the client. Default value is None. + :type marker: str + :param maxresults: Specifies the maximum number of entries to return. If the request does not + specify maxresults, or specifies a value greater than 5,000, the server will return up to 5,000 + items. Default value is None. + :type maxresults: int + :param include: Include this parameter to specify one or more datasets to include in the + response. Default value is None. + :type include: list[str or ~azure.storage.fileshare.models.ListSharesIncludeType] + :param timeout: The timeout parameter is expressed in seconds. For more information, see + :code:`<a + href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting + Timeouts for File Service Operations.</a>`. Default value is None. + :type timeout: int + :return: ListSharesResponse or the result of cls(response) + :rtype: ~azure.storage.fileshare.models.ListSharesResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + comp: Literal["list"] = kwargs.pop("comp", _params.pop("comp", "list")) + cls: ClsType[_models.ListSharesResponse] = kwargs.pop("cls", None) + + _request = build_list_shares_segment_request( + url=self._config.url, + prefix=prefix, + marker=marker, + maxresults=maxresults, + include=include, + timeout=timeout, + file_request_intent=self._config.file_request_intent, + comp=comp, + version=self._config.version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + + deserialized = self._deserialize("ListSharesResponse", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore diff --git a/.venv/lib/python3.12/site-packages/azure/storage/fileshare/_generated/aio/operations/_share_operations.py b/.venv/lib/python3.12/site-packages/azure/storage/fileshare/_generated/aio/operations/_share_operations.py new file mode 100644 index 00000000..373424ef --- /dev/null +++ b/.venv/lib/python3.12/site-packages/azure/storage/fileshare/_generated/aio/operations/_share_operations.py @@ -0,0 +1,1765 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, List, Literal, Optional, TypeVar, Union, overload + +from azure.core import AsyncPipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict + +from ... import models as _models +from ..._serialization import Deserializer, Serializer +from ...operations._share_operations import ( + build_acquire_lease_request, + build_break_lease_request, + build_change_lease_request, + build_create_permission_request, + build_create_request, + build_create_snapshot_request, + build_delete_request, + build_get_access_policy_request, + build_get_permission_request, + build_get_properties_request, + build_get_statistics_request, + build_release_lease_request, + build_renew_lease_request, + build_restore_request, + build_set_access_policy_request, + build_set_metadata_request, + build_set_properties_request, +) +from .._configuration import AzureFileStorageConfiguration + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ShareOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.storage.fileshare.aio.AzureFileStorage`'s + :attr:`share` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AzureFileStorageConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def create( + self, + timeout: Optional[int] = None, + metadata: Optional[Dict[str, str]] = None, + quota: Optional[int] = None, + access_tier: Optional[Union[str, _models.ShareAccessTier]] = None, + enabled_protocols: Optional[str] = None, + root_squash: Optional[Union[str, _models.ShareRootSquash]] = None, + enable_snapshot_virtual_directory_access: Optional[bool] = None, + paid_bursting_enabled: Optional[bool] = None, + paid_bursting_max_bandwidth_mibps: Optional[int] = None, + paid_bursting_max_iops: Optional[int] = None, + share_provisioned_iops: Optional[int] = None, + share_provisioned_bandwidth_mibps: Optional[int] = None, + **kwargs: Any + ) -> None: + # pylint: disable=line-too-long + """Creates a new share under the specified account. If the share with the same name already + exists, the operation fails. + + :param timeout: The timeout parameter is expressed in seconds. For more information, see + :code:`<a + href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting + Timeouts for File Service Operations.</a>`. Default value is None. + :type timeout: int + :param metadata: A name-value pair to associate with a file storage object. Default value is + None. + :type metadata: dict[str, str] + :param quota: Specifies the maximum size of the share, in gigabytes. Default value is None. + :type quota: int + :param access_tier: Specifies the access tier of the share. Known values are: + "TransactionOptimized", "Hot", "Cool", and "Premium". Default value is None. + :type access_tier: str or ~azure.storage.fileshare.models.ShareAccessTier + :param enabled_protocols: Protocols to enable on the share. Default value is None. + :type enabled_protocols: str + :param root_squash: Root squash to set on the share. Only valid for NFS shares. Known values + are: "NoRootSquash", "RootSquash", and "AllSquash". Default value is None. + :type root_squash: str or ~azure.storage.fileshare.models.ShareRootSquash + :param enable_snapshot_virtual_directory_access: Default value is None. + :type enable_snapshot_virtual_directory_access: bool + :param paid_bursting_enabled: Optional. Boolean. Default if not specified is false. This + property enables paid bursting. Default value is None. + :type paid_bursting_enabled: bool + :param paid_bursting_max_bandwidth_mibps: Optional. Integer. Default if not specified is the + maximum throughput the file share can support. Current maximum for a file share is 10,340 + MiB/sec. Default value is None. + :type paid_bursting_max_bandwidth_mibps: int + :param paid_bursting_max_iops: Optional. Integer. Default if not specified is the maximum IOPS + the file share can support. Current maximum for a file share is 102,400 IOPS. Default value is + None. + :type paid_bursting_max_iops: int + :param share_provisioned_iops: Optional. Supported in version 2025-01-05 and later. Only + allowed for provisioned v2 file shares. Specifies the provisioned number of input/output + operations per second (IOPS) of the share. If this is not specified, the provisioned IOPS is + set to value calculated based on recommendation formula. Default value is None. + :type share_provisioned_iops: int + :param share_provisioned_bandwidth_mibps: Optional. Supported in version 2025-01-05 and later. + Only allowed for provisioned v2 file shares. Specifies the provisioned bandwidth of the share, + in mebibytes per second (MiBps). If this is not specified, the provisioned bandwidth is set to + value calculated based on recommendation formula. Default value is None. + :type share_provisioned_bandwidth_mibps: int + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + restype: Literal["share"] = kwargs.pop("restype", _params.pop("restype", "share")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_create_request( + url=self._config.url, + timeout=timeout, + metadata=metadata, + quota=quota, + access_tier=access_tier, + enabled_protocols=enabled_protocols, + root_squash=root_squash, + enable_snapshot_virtual_directory_access=enable_snapshot_virtual_directory_access, + paid_bursting_enabled=paid_bursting_enabled, + paid_bursting_max_bandwidth_mibps=paid_bursting_max_bandwidth_mibps, + paid_bursting_max_iops=paid_bursting_max_iops, + share_provisioned_iops=share_provisioned_iops, + share_provisioned_bandwidth_mibps=share_provisioned_bandwidth_mibps, + file_request_intent=self._config.file_request_intent, + restype=restype, + version=self._config.version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["Last-Modified"] = self._deserialize("rfc-1123", response.headers.get("Last-Modified")) + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-share-quota"] = self._deserialize("int", response.headers.get("x-ms-share-quota")) + response_headers["x-ms-share-provisioned-iops"] = self._deserialize( + "int", response.headers.get("x-ms-share-provisioned-iops") + ) + response_headers["x-ms-share-provisioned-bandwidth-mibps"] = self._deserialize( + "int", response.headers.get("x-ms-share-provisioned-bandwidth-mibps") + ) + response_headers["x-ms-share-included-burst-iops"] = self._deserialize( + "int", response.headers.get("x-ms-share-included-burst-iops") + ) + response_headers["x-ms-share-max-burst-credits-for-iops"] = self._deserialize( + "int", response.headers.get("x-ms-share-max-burst-credits-for-iops") + ) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace_async + async def get_properties( + self, + sharesnapshot: Optional[str] = None, + timeout: Optional[int] = None, + lease_access_conditions: Optional[_models.LeaseAccessConditions] = None, + **kwargs: Any + ) -> None: + # pylint: disable=line-too-long + """Returns all user-defined metadata and system properties for the specified share or share + snapshot. The data returned does not include the share's list of files. + + :param sharesnapshot: The snapshot parameter is an opaque DateTime value that, when present, + specifies the share snapshot to query. Default value is None. + :type sharesnapshot: str + :param timeout: The timeout parameter is expressed in seconds. For more information, see + :code:`<a + href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting + Timeouts for File Service Operations.</a>`. Default value is None. + :type timeout: int + :param lease_access_conditions: Parameter group. Default value is None. + :type lease_access_conditions: ~azure.storage.fileshare.models.LeaseAccessConditions + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + restype: Literal["share"] = kwargs.pop("restype", _params.pop("restype", "share")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _lease_id = None + if lease_access_conditions is not None: + _lease_id = lease_access_conditions.lease_id + + _request = build_get_properties_request( + url=self._config.url, + sharesnapshot=sharesnapshot, + timeout=timeout, + lease_id=_lease_id, + file_request_intent=self._config.file_request_intent, + restype=restype, + version=self._config.version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["x-ms-meta"] = self._deserialize("{str}", response.headers.get("x-ms-meta")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["Last-Modified"] = self._deserialize("rfc-1123", response.headers.get("Last-Modified")) + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-share-quota"] = self._deserialize("int", response.headers.get("x-ms-share-quota")) + response_headers["x-ms-share-provisioned-iops"] = self._deserialize( + "int", response.headers.get("x-ms-share-provisioned-iops") + ) + response_headers["x-ms-share-provisioned-ingress-mbps"] = self._deserialize( + "int", response.headers.get("x-ms-share-provisioned-ingress-mbps") + ) + response_headers["x-ms-share-provisioned-egress-mbps"] = self._deserialize( + "int", response.headers.get("x-ms-share-provisioned-egress-mbps") + ) + response_headers["x-ms-share-next-allowed-quota-downgrade-time"] = self._deserialize( + "rfc-1123", response.headers.get("x-ms-share-next-allowed-quota-downgrade-time") + ) + response_headers["x-ms-share-provisioned-bandwidth-mibps"] = self._deserialize( + "int", response.headers.get("x-ms-share-provisioned-bandwidth-mibps") + ) + response_headers["x-ms-lease-duration"] = self._deserialize("str", response.headers.get("x-ms-lease-duration")) + response_headers["x-ms-lease-state"] = self._deserialize("str", response.headers.get("x-ms-lease-state")) + response_headers["x-ms-lease-status"] = self._deserialize("str", response.headers.get("x-ms-lease-status")) + response_headers["x-ms-access-tier"] = self._deserialize("str", response.headers.get("x-ms-access-tier")) + response_headers["x-ms-access-tier-change-time"] = self._deserialize( + "rfc-1123", response.headers.get("x-ms-access-tier-change-time") + ) + response_headers["x-ms-access-tier-transition-state"] = self._deserialize( + "str", response.headers.get("x-ms-access-tier-transition-state") + ) + response_headers["x-ms-enabled-protocols"] = self._deserialize( + "str", response.headers.get("x-ms-enabled-protocols") + ) + response_headers["x-ms-root-squash"] = self._deserialize("str", response.headers.get("x-ms-root-squash")) + response_headers["x-ms-enable-snapshot-virtual-directory-access"] = self._deserialize( + "bool", response.headers.get("x-ms-enable-snapshot-virtual-directory-access") + ) + response_headers["x-ms-share-paid-bursting-enabled"] = self._deserialize( + "bool", response.headers.get("x-ms-share-paid-bursting-enabled") + ) + response_headers["x-ms-share-paid-bursting-max-iops"] = self._deserialize( + "int", response.headers.get("x-ms-share-paid-bursting-max-iops") + ) + response_headers["x-ms-share-paid-bursting-max-bandwidth-mibps"] = self._deserialize( + "int", response.headers.get("x-ms-share-paid-bursting-max-bandwidth-mibps") + ) + response_headers["x-ms-share-included-burst-iops"] = self._deserialize( + "int", response.headers.get("x-ms-share-included-burst-iops") + ) + response_headers["x-ms-share-max-burst-credits-for-iops"] = self._deserialize( + "int", response.headers.get("x-ms-share-max-burst-credits-for-iops") + ) + response_headers["x-ms-share-next-allowed-provisioned-iops-downgrade-time"] = self._deserialize( + "rfc-1123", response.headers.get("x-ms-share-next-allowed-provisioned-iops-downgrade-time") + ) + response_headers["x-ms-share-next-allowed-provisioned-bandwidth-downgrade-time"] = self._deserialize( + "rfc-1123", response.headers.get("x-ms-share-next-allowed-provisioned-bandwidth-downgrade-time") + ) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace_async + async def delete( + self, + sharesnapshot: Optional[str] = None, + timeout: Optional[int] = None, + delete_snapshots: Optional[Union[str, _models.DeleteSnapshotsOptionType]] = None, + lease_access_conditions: Optional[_models.LeaseAccessConditions] = None, + **kwargs: Any + ) -> None: + # pylint: disable=line-too-long + """Operation marks the specified share or share snapshot for deletion. The share or share snapshot + and any files contained within it are later deleted during garbage collection. + + :param sharesnapshot: The snapshot parameter is an opaque DateTime value that, when present, + specifies the share snapshot to query. Default value is None. + :type sharesnapshot: str + :param timeout: The timeout parameter is expressed in seconds. For more information, see + :code:`<a + href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting + Timeouts for File Service Operations.</a>`. Default value is None. + :type timeout: int + :param delete_snapshots: Specifies the option include to delete the base share and all of its + snapshots. Known values are: "include" and "include-leased". Default value is None. + :type delete_snapshots: str or ~azure.storage.fileshare.models.DeleteSnapshotsOptionType + :param lease_access_conditions: Parameter group. Default value is None. + :type lease_access_conditions: ~azure.storage.fileshare.models.LeaseAccessConditions + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + restype: Literal["share"] = kwargs.pop("restype", _params.pop("restype", "share")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _lease_id = None + if lease_access_conditions is not None: + _lease_id = lease_access_conditions.lease_id + + _request = build_delete_request( + url=self._config.url, + sharesnapshot=sharesnapshot, + timeout=timeout, + delete_snapshots=delete_snapshots, + lease_id=_lease_id, + file_request_intent=self._config.file_request_intent, + restype=restype, + version=self._config.version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-file-share-usage-bytes"] = self._deserialize( + "int", response.headers.get("x-ms-file-share-usage-bytes") + ) + response_headers["x-ms-file-share-snapshot-usage-bytes"] = self._deserialize( + "int", response.headers.get("x-ms-file-share-snapshot-usage-bytes") + ) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace_async + async def acquire_lease( + self, + timeout: Optional[int] = None, + duration: Optional[int] = None, + proposed_lease_id: Optional[str] = None, + sharesnapshot: Optional[str] = None, + request_id_parameter: Optional[str] = None, + **kwargs: Any + ) -> None: + # pylint: disable=line-too-long + """The Lease Share operation establishes and manages a lock on a share, or the specified snapshot + for set and delete share operations. + + :param timeout: The timeout parameter is expressed in seconds. For more information, see + :code:`<a + href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting + Timeouts for File Service Operations.</a>`. Default value is None. + :type timeout: int + :param duration: Specifies the duration of the lease, in seconds, or negative one (-1) for a + lease that never expires. A non-infinite lease can be between 15 and 60 seconds. A lease + duration cannot be changed using renew or change. Default value is None. + :type duration: int + :param proposed_lease_id: Proposed lease ID, in a GUID string format. The File service returns + 400 (Invalid request) if the proposed lease ID is not in the correct format. See Guid + Constructor (String) for a list of valid GUID string formats. Default value is None. + :type proposed_lease_id: str + :param sharesnapshot: The snapshot parameter is an opaque DateTime value that, when present, + specifies the share snapshot to query. Default value is None. + :type sharesnapshot: str + :param request_id_parameter: Provides a client-generated, opaque value with a 1 KB character + limit that is recorded in the analytics logs when storage analytics logging is enabled. Default + value is None. + :type request_id_parameter: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + comp: Literal["lease"] = kwargs.pop("comp", _params.pop("comp", "lease")) + action: Literal["acquire"] = kwargs.pop("action", _headers.pop("x-ms-lease-action", "acquire")) + restype: Literal["share"] = kwargs.pop("restype", _params.pop("restype", "share")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_acquire_lease_request( + url=self._config.url, + timeout=timeout, + duration=duration, + proposed_lease_id=proposed_lease_id, + sharesnapshot=sharesnapshot, + request_id_parameter=request_id_parameter, + file_request_intent=self._config.file_request_intent, + comp=comp, + action=action, + restype=restype, + version=self._config.version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["Last-Modified"] = self._deserialize("rfc-1123", response.headers.get("Last-Modified")) + response_headers["x-ms-lease-id"] = self._deserialize("str", response.headers.get("x-ms-lease-id")) + response_headers["x-ms-client-request-id"] = self._deserialize( + "str", response.headers.get("x-ms-client-request-id") + ) + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace_async + async def release_lease( + self, + lease_id: str, + timeout: Optional[int] = None, + sharesnapshot: Optional[str] = None, + request_id_parameter: Optional[str] = None, + **kwargs: Any + ) -> None: + # pylint: disable=line-too-long + """The Lease Share operation establishes and manages a lock on a share, or the specified snapshot + for set and delete share operations. + + :param lease_id: Specifies the current lease ID on the resource. Required. + :type lease_id: str + :param timeout: The timeout parameter is expressed in seconds. For more information, see + :code:`<a + href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting + Timeouts for File Service Operations.</a>`. Default value is None. + :type timeout: int + :param sharesnapshot: The snapshot parameter is an opaque DateTime value that, when present, + specifies the share snapshot to query. Default value is None. + :type sharesnapshot: str + :param request_id_parameter: Provides a client-generated, opaque value with a 1 KB character + limit that is recorded in the analytics logs when storage analytics logging is enabled. Default + value is None. + :type request_id_parameter: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + comp: Literal["lease"] = kwargs.pop("comp", _params.pop("comp", "lease")) + action: Literal["release"] = kwargs.pop("action", _headers.pop("x-ms-lease-action", "release")) + restype: Literal["share"] = kwargs.pop("restype", _params.pop("restype", "share")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_release_lease_request( + url=self._config.url, + lease_id=lease_id, + timeout=timeout, + sharesnapshot=sharesnapshot, + request_id_parameter=request_id_parameter, + file_request_intent=self._config.file_request_intent, + comp=comp, + action=action, + restype=restype, + version=self._config.version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["Last-Modified"] = self._deserialize("rfc-1123", response.headers.get("Last-Modified")) + response_headers["x-ms-client-request-id"] = self._deserialize( + "str", response.headers.get("x-ms-client-request-id") + ) + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace_async + async def change_lease( + self, + lease_id: str, + timeout: Optional[int] = None, + proposed_lease_id: Optional[str] = None, + sharesnapshot: Optional[str] = None, + request_id_parameter: Optional[str] = None, + **kwargs: Any + ) -> None: + # pylint: disable=line-too-long + """The Lease Share operation establishes and manages a lock on a share, or the specified snapshot + for set and delete share operations. + + :param lease_id: Specifies the current lease ID on the resource. Required. + :type lease_id: str + :param timeout: The timeout parameter is expressed in seconds. For more information, see + :code:`<a + href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting + Timeouts for File Service Operations.</a>`. Default value is None. + :type timeout: int + :param proposed_lease_id: Proposed lease ID, in a GUID string format. The File service returns + 400 (Invalid request) if the proposed lease ID is not in the correct format. See Guid + Constructor (String) for a list of valid GUID string formats. Default value is None. + :type proposed_lease_id: str + :param sharesnapshot: The snapshot parameter is an opaque DateTime value that, when present, + specifies the share snapshot to query. Default value is None. + :type sharesnapshot: str + :param request_id_parameter: Provides a client-generated, opaque value with a 1 KB character + limit that is recorded in the analytics logs when storage analytics logging is enabled. Default + value is None. + :type request_id_parameter: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + comp: Literal["lease"] = kwargs.pop("comp", _params.pop("comp", "lease")) + action: Literal["change"] = kwargs.pop("action", _headers.pop("x-ms-lease-action", "change")) + restype: Literal["share"] = kwargs.pop("restype", _params.pop("restype", "share")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_change_lease_request( + url=self._config.url, + lease_id=lease_id, + timeout=timeout, + proposed_lease_id=proposed_lease_id, + sharesnapshot=sharesnapshot, + request_id_parameter=request_id_parameter, + file_request_intent=self._config.file_request_intent, + comp=comp, + action=action, + restype=restype, + version=self._config.version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["Last-Modified"] = self._deserialize("rfc-1123", response.headers.get("Last-Modified")) + response_headers["x-ms-lease-id"] = self._deserialize("str", response.headers.get("x-ms-lease-id")) + response_headers["x-ms-client-request-id"] = self._deserialize( + "str", response.headers.get("x-ms-client-request-id") + ) + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace_async + async def renew_lease( + self, + lease_id: str, + timeout: Optional[int] = None, + sharesnapshot: Optional[str] = None, + request_id_parameter: Optional[str] = None, + **kwargs: Any + ) -> None: + # pylint: disable=line-too-long + """The Lease Share operation establishes and manages a lock on a share, or the specified snapshot + for set and delete share operations. + + :param lease_id: Specifies the current lease ID on the resource. Required. + :type lease_id: str + :param timeout: The timeout parameter is expressed in seconds. For more information, see + :code:`<a + href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting + Timeouts for File Service Operations.</a>`. Default value is None. + :type timeout: int + :param sharesnapshot: The snapshot parameter is an opaque DateTime value that, when present, + specifies the share snapshot to query. Default value is None. + :type sharesnapshot: str + :param request_id_parameter: Provides a client-generated, opaque value with a 1 KB character + limit that is recorded in the analytics logs when storage analytics logging is enabled. Default + value is None. + :type request_id_parameter: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + comp: Literal["lease"] = kwargs.pop("comp", _params.pop("comp", "lease")) + action: Literal["renew"] = kwargs.pop("action", _headers.pop("x-ms-lease-action", "renew")) + restype: Literal["share"] = kwargs.pop("restype", _params.pop("restype", "share")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_renew_lease_request( + url=self._config.url, + lease_id=lease_id, + timeout=timeout, + sharesnapshot=sharesnapshot, + request_id_parameter=request_id_parameter, + file_request_intent=self._config.file_request_intent, + comp=comp, + action=action, + restype=restype, + version=self._config.version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["Last-Modified"] = self._deserialize("rfc-1123", response.headers.get("Last-Modified")) + response_headers["x-ms-lease-id"] = self._deserialize("str", response.headers.get("x-ms-lease-id")) + response_headers["x-ms-client-request-id"] = self._deserialize( + "str", response.headers.get("x-ms-client-request-id") + ) + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace_async + async def break_lease( + self, + timeout: Optional[int] = None, + break_period: Optional[int] = None, + request_id_parameter: Optional[str] = None, + sharesnapshot: Optional[str] = None, + lease_access_conditions: Optional[_models.LeaseAccessConditions] = None, + **kwargs: Any + ) -> None: + # pylint: disable=line-too-long + """The Lease Share operation establishes and manages a lock on a share, or the specified snapshot + for set and delete share operations. + + :param timeout: The timeout parameter is expressed in seconds. For more information, see + :code:`<a + href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting + Timeouts for File Service Operations.</a>`. Default value is None. + :type timeout: int + :param break_period: For a break operation, proposed duration the lease should continue before + it is broken, in seconds, between 0 and 60. This break period is only used if it is shorter + than the time remaining on the lease. If longer, the time remaining on the lease is used. A new + lease will not be available before the break period has expired, but the lease may be held for + longer than the break period. If this header does not appear with a break operation, a + fixed-duration lease breaks after the remaining lease period elapses, and an infinite lease + breaks immediately. Default value is None. + :type break_period: int + :param request_id_parameter: Provides a client-generated, opaque value with a 1 KB character + limit that is recorded in the analytics logs when storage analytics logging is enabled. Default + value is None. + :type request_id_parameter: str + :param sharesnapshot: The snapshot parameter is an opaque DateTime value that, when present, + specifies the share snapshot to query. Default value is None. + :type sharesnapshot: str + :param lease_access_conditions: Parameter group. Default value is None. + :type lease_access_conditions: ~azure.storage.fileshare.models.LeaseAccessConditions + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + comp: Literal["lease"] = kwargs.pop("comp", _params.pop("comp", "lease")) + action: Literal["break"] = kwargs.pop("action", _headers.pop("x-ms-lease-action", "break")) + restype: Literal["share"] = kwargs.pop("restype", _params.pop("restype", "share")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _lease_id = None + if lease_access_conditions is not None: + _lease_id = lease_access_conditions.lease_id + + _request = build_break_lease_request( + url=self._config.url, + timeout=timeout, + break_period=break_period, + lease_id=_lease_id, + request_id_parameter=request_id_parameter, + sharesnapshot=sharesnapshot, + file_request_intent=self._config.file_request_intent, + comp=comp, + action=action, + restype=restype, + version=self._config.version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["Last-Modified"] = self._deserialize("rfc-1123", response.headers.get("Last-Modified")) + response_headers["x-ms-lease-time"] = self._deserialize("int", response.headers.get("x-ms-lease-time")) + response_headers["x-ms-lease-id"] = self._deserialize("str", response.headers.get("x-ms-lease-id")) + response_headers["x-ms-client-request-id"] = self._deserialize( + "str", response.headers.get("x-ms-client-request-id") + ) + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace_async + async def create_snapshot( + self, timeout: Optional[int] = None, metadata: Optional[Dict[str, str]] = None, **kwargs: Any + ) -> None: + # pylint: disable=line-too-long + """Creates a read-only snapshot of a share. + + :param timeout: The timeout parameter is expressed in seconds. For more information, see + :code:`<a + href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting + Timeouts for File Service Operations.</a>`. Default value is None. + :type timeout: int + :param metadata: A name-value pair to associate with a file storage object. Default value is + None. + :type metadata: dict[str, str] + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + restype: Literal["share"] = kwargs.pop("restype", _params.pop("restype", "share")) + comp: Literal["snapshot"] = kwargs.pop("comp", _params.pop("comp", "snapshot")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_create_snapshot_request( + url=self._config.url, + timeout=timeout, + metadata=metadata, + file_request_intent=self._config.file_request_intent, + restype=restype, + comp=comp, + version=self._config.version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["x-ms-snapshot"] = self._deserialize("str", response.headers.get("x-ms-snapshot")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["Last-Modified"] = self._deserialize("rfc-1123", response.headers.get("Last-Modified")) + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @overload + async def create_permission( + self, + share_permission: _models.SharePermission, + timeout: Optional[int] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + # pylint: disable=line-too-long + """Create a permission (a security descriptor). + + :param share_permission: A permission (a security descriptor) at the share level. Required. + :type share_permission: ~azure.storage.fileshare.models.SharePermission + :param timeout: The timeout parameter is expressed in seconds. For more information, see + :code:`<a + href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting + Timeouts for File Service Operations.</a>`. Default value is None. + :type timeout: int + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_permission( + self, + share_permission: IO[bytes], + timeout: Optional[int] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + # pylint: disable=line-too-long + """Create a permission (a security descriptor). + + :param share_permission: A permission (a security descriptor) at the share level. Required. + :type share_permission: IO[bytes] + :param timeout: The timeout parameter is expressed in seconds. For more information, see + :code:`<a + href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting + Timeouts for File Service Operations.</a>`. Default value is None. + :type timeout: int + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_permission( + self, share_permission: Union[_models.SharePermission, IO[bytes]], timeout: Optional[int] = None, **kwargs: Any + ) -> None: + # pylint: disable=line-too-long + """Create a permission (a security descriptor). + + :param share_permission: A permission (a security descriptor) at the share level. Is either a + SharePermission type or a IO[bytes] type. Required. + :type share_permission: ~azure.storage.fileshare.models.SharePermission or IO[bytes] + :param timeout: The timeout parameter is expressed in seconds. For more information, see + :code:`<a + href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting + Timeouts for File Service Operations.</a>`. Default value is None. + :type timeout: int + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + restype: Literal["share"] = kwargs.pop("restype", _params.pop("restype", "share")) + comp: Literal["filepermission"] = kwargs.pop("comp", _params.pop("comp", "filepermission")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(share_permission, (IOBase, bytes)): + _content = share_permission + else: + _json = self._serialize.body(share_permission, "SharePermission") + + _request = build_create_permission_request( + url=self._config.url, + timeout=timeout, + file_request_intent=self._config.file_request_intent, + restype=restype, + comp=comp, + content_type=content_type, + version=self._config.version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-file-permission-key"] = self._deserialize( + "str", response.headers.get("x-ms-file-permission-key") + ) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace_async + async def get_permission( + self, + file_permission_key: str, + file_permission_format: Optional[Union[str, _models.FilePermissionFormat]] = None, + timeout: Optional[int] = None, + **kwargs: Any + ) -> _models.SharePermission: + # pylint: disable=line-too-long + """Returns the permission (security descriptor) for a given key. + + :param file_permission_key: Key of the permission to be set for the directory/file. Required. + :type file_permission_key: str + :param file_permission_format: Optional. Available for version 2023-06-01 and later. Specifies + the format in which the permission is returned. Acceptable values are SDDL or binary. If + x-ms-file-permission-format is unspecified or explicitly set to SDDL, the permission is + returned in SDDL format. If x-ms-file-permission-format is explicitly set to binary, the + permission is returned as a base64 string representing the binary encoding of the permission. + Known values are: "Sddl" and "Binary". Default value is None. + :type file_permission_format: str or ~azure.storage.fileshare.models.FilePermissionFormat + :param timeout: The timeout parameter is expressed in seconds. For more information, see + :code:`<a + href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting + Timeouts for File Service Operations.</a>`. Default value is None. + :type timeout: int + :return: SharePermission or the result of cls(response) + :rtype: ~azure.storage.fileshare.models.SharePermission + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + restype: Literal["share"] = kwargs.pop("restype", _params.pop("restype", "share")) + comp: Literal["filepermission"] = kwargs.pop("comp", _params.pop("comp", "filepermission")) + cls: ClsType[_models.SharePermission] = kwargs.pop("cls", None) + + _request = build_get_permission_request( + url=self._config.url, + file_permission_key=file_permission_key, + file_permission_format=file_permission_format, + timeout=timeout, + file_request_intent=self._config.file_request_intent, + restype=restype, + comp=comp, + version=self._config.version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + + deserialized = self._deserialize("SharePermission", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def set_properties( + self, + timeout: Optional[int] = None, + quota: Optional[int] = None, + access_tier: Optional[Union[str, _models.ShareAccessTier]] = None, + root_squash: Optional[Union[str, _models.ShareRootSquash]] = None, + enable_snapshot_virtual_directory_access: Optional[bool] = None, + paid_bursting_enabled: Optional[bool] = None, + paid_bursting_max_bandwidth_mibps: Optional[int] = None, + paid_bursting_max_iops: Optional[int] = None, + share_provisioned_iops: Optional[int] = None, + share_provisioned_bandwidth_mibps: Optional[int] = None, + lease_access_conditions: Optional[_models.LeaseAccessConditions] = None, + **kwargs: Any + ) -> None: + # pylint: disable=line-too-long + """Sets properties for the specified share. + + :param timeout: The timeout parameter is expressed in seconds. For more information, see + :code:`<a + href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting + Timeouts for File Service Operations.</a>`. Default value is None. + :type timeout: int + :param quota: Specifies the maximum size of the share, in gigabytes. Default value is None. + :type quota: int + :param access_tier: Specifies the access tier of the share. Known values are: + "TransactionOptimized", "Hot", "Cool", and "Premium". Default value is None. + :type access_tier: str or ~azure.storage.fileshare.models.ShareAccessTier + :param root_squash: Root squash to set on the share. Only valid for NFS shares. Known values + are: "NoRootSquash", "RootSquash", and "AllSquash". Default value is None. + :type root_squash: str or ~azure.storage.fileshare.models.ShareRootSquash + :param enable_snapshot_virtual_directory_access: Default value is None. + :type enable_snapshot_virtual_directory_access: bool + :param paid_bursting_enabled: Optional. Boolean. Default if not specified is false. This + property enables paid bursting. Default value is None. + :type paid_bursting_enabled: bool + :param paid_bursting_max_bandwidth_mibps: Optional. Integer. Default if not specified is the + maximum throughput the file share can support. Current maximum for a file share is 10,340 + MiB/sec. Default value is None. + :type paid_bursting_max_bandwidth_mibps: int + :param paid_bursting_max_iops: Optional. Integer. Default if not specified is the maximum IOPS + the file share can support. Current maximum for a file share is 102,400 IOPS. Default value is + None. + :type paid_bursting_max_iops: int + :param share_provisioned_iops: Optional. Supported in version 2025-01-05 and later. Only + allowed for provisioned v2 file shares. Specifies the provisioned number of input/output + operations per second (IOPS) of the share. If this is not specified, the provisioned IOPS is + set to value calculated based on recommendation formula. Default value is None. + :type share_provisioned_iops: int + :param share_provisioned_bandwidth_mibps: Optional. Supported in version 2025-01-05 and later. + Only allowed for provisioned v2 file shares. Specifies the provisioned bandwidth of the share, + in mebibytes per second (MiBps). If this is not specified, the provisioned bandwidth is set to + value calculated based on recommendation formula. Default value is None. + :type share_provisioned_bandwidth_mibps: int + :param lease_access_conditions: Parameter group. Default value is None. + :type lease_access_conditions: ~azure.storage.fileshare.models.LeaseAccessConditions + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + restype: Literal["share"] = kwargs.pop("restype", _params.pop("restype", "share")) + comp: Literal["properties"] = kwargs.pop("comp", _params.pop("comp", "properties")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _lease_id = None + if lease_access_conditions is not None: + _lease_id = lease_access_conditions.lease_id + + _request = build_set_properties_request( + url=self._config.url, + timeout=timeout, + quota=quota, + access_tier=access_tier, + lease_id=_lease_id, + root_squash=root_squash, + enable_snapshot_virtual_directory_access=enable_snapshot_virtual_directory_access, + paid_bursting_enabled=paid_bursting_enabled, + paid_bursting_max_bandwidth_mibps=paid_bursting_max_bandwidth_mibps, + paid_bursting_max_iops=paid_bursting_max_iops, + share_provisioned_iops=share_provisioned_iops, + share_provisioned_bandwidth_mibps=share_provisioned_bandwidth_mibps, + file_request_intent=self._config.file_request_intent, + restype=restype, + comp=comp, + version=self._config.version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["Last-Modified"] = self._deserialize("rfc-1123", response.headers.get("Last-Modified")) + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-share-quota"] = self._deserialize("int", response.headers.get("x-ms-share-quota")) + response_headers["x-ms-share-provisioned-iops"] = self._deserialize( + "int", response.headers.get("x-ms-share-provisioned-iops") + ) + response_headers["x-ms-share-provisioned-bandwidth-mibps"] = self._deserialize( + "int", response.headers.get("x-ms-share-provisioned-bandwidth-mibps") + ) + response_headers["x-ms-share-included-burst-iops"] = self._deserialize( + "int", response.headers.get("x-ms-share-included-burst-iops") + ) + response_headers["x-ms-share-max-burst-credits-for-iops"] = self._deserialize( + "int", response.headers.get("x-ms-share-max-burst-credits-for-iops") + ) + response_headers["x-ms-share-next-allowed-quota-downgrade-time"] = self._deserialize( + "rfc-1123", response.headers.get("x-ms-share-next-allowed-quota-downgrade-time") + ) + response_headers["x-ms-share-next-allowed-provisioned-iops-downgrade-time"] = self._deserialize( + "rfc-1123", response.headers.get("x-ms-share-next-allowed-provisioned-iops-downgrade-time") + ) + response_headers["x-ms-share-next-allowed-provisioned-bandwidth-downgrade-time"] = self._deserialize( + "rfc-1123", response.headers.get("x-ms-share-next-allowed-provisioned-bandwidth-downgrade-time") + ) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace_async + async def set_metadata( + self, + timeout: Optional[int] = None, + metadata: Optional[Dict[str, str]] = None, + lease_access_conditions: Optional[_models.LeaseAccessConditions] = None, + **kwargs: Any + ) -> None: + # pylint: disable=line-too-long + """Sets one or more user-defined name-value pairs for the specified share. + + :param timeout: The timeout parameter is expressed in seconds. For more information, see + :code:`<a + href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting + Timeouts for File Service Operations.</a>`. Default value is None. + :type timeout: int + :param metadata: A name-value pair to associate with a file storage object. Default value is + None. + :type metadata: dict[str, str] + :param lease_access_conditions: Parameter group. Default value is None. + :type lease_access_conditions: ~azure.storage.fileshare.models.LeaseAccessConditions + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + restype: Literal["share"] = kwargs.pop("restype", _params.pop("restype", "share")) + comp: Literal["metadata"] = kwargs.pop("comp", _params.pop("comp", "metadata")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _lease_id = None + if lease_access_conditions is not None: + _lease_id = lease_access_conditions.lease_id + + _request = build_set_metadata_request( + url=self._config.url, + timeout=timeout, + metadata=metadata, + lease_id=_lease_id, + file_request_intent=self._config.file_request_intent, + restype=restype, + comp=comp, + version=self._config.version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["Last-Modified"] = self._deserialize("rfc-1123", response.headers.get("Last-Modified")) + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace_async + async def get_access_policy( + self, + timeout: Optional[int] = None, + lease_access_conditions: Optional[_models.LeaseAccessConditions] = None, + **kwargs: Any + ) -> List[_models.SignedIdentifier]: + # pylint: disable=line-too-long + """Returns information about stored access policies specified on the share. + + :param timeout: The timeout parameter is expressed in seconds. For more information, see + :code:`<a + href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting + Timeouts for File Service Operations.</a>`. Default value is None. + :type timeout: int + :param lease_access_conditions: Parameter group. Default value is None. + :type lease_access_conditions: ~azure.storage.fileshare.models.LeaseAccessConditions + :return: list of SignedIdentifier or the result of cls(response) + :rtype: list[~azure.storage.fileshare.models.SignedIdentifier] + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + restype: Literal["share"] = kwargs.pop("restype", _params.pop("restype", "share")) + comp: Literal["acl"] = kwargs.pop("comp", _params.pop("comp", "acl")) + cls: ClsType[List[_models.SignedIdentifier]] = kwargs.pop("cls", None) + + _lease_id = None + if lease_access_conditions is not None: + _lease_id = lease_access_conditions.lease_id + + _request = build_get_access_policy_request( + url=self._config.url, + timeout=timeout, + lease_id=_lease_id, + file_request_intent=self._config.file_request_intent, + restype=restype, + comp=comp, + version=self._config.version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["Last-Modified"] = self._deserialize("rfc-1123", response.headers.get("Last-Modified")) + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + + deserialized = self._deserialize("[SignedIdentifier]", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def set_access_policy( + self, + timeout: Optional[int] = None, + lease_access_conditions: Optional[_models.LeaseAccessConditions] = None, + share_acl: Optional[List[_models.SignedIdentifier]] = None, + **kwargs: Any + ) -> None: + # pylint: disable=line-too-long + """Sets a stored access policy for use with shared access signatures. + + :param timeout: The timeout parameter is expressed in seconds. For more information, see + :code:`<a + href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting + Timeouts for File Service Operations.</a>`. Default value is None. + :type timeout: int + :param lease_access_conditions: Parameter group. Default value is None. + :type lease_access_conditions: ~azure.storage.fileshare.models.LeaseAccessConditions + :param share_acl: The ACL for the share. Default value is None. + :type share_acl: list[~azure.storage.fileshare.models.SignedIdentifier] + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + restype: Literal["share"] = kwargs.pop("restype", _params.pop("restype", "share")) + comp: Literal["acl"] = kwargs.pop("comp", _params.pop("comp", "acl")) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/xml")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _lease_id = None + if lease_access_conditions is not None: + _lease_id = lease_access_conditions.lease_id + serialization_ctxt = {"xml": {"name": "SignedIdentifiers", "wrapped": True}} + if share_acl is not None: + _content = self._serialize.body( + share_acl, "[SignedIdentifier]", is_xml=True, serialization_ctxt=serialization_ctxt + ) + else: + _content = None + + _request = build_set_access_policy_request( + url=self._config.url, + timeout=timeout, + lease_id=_lease_id, + file_request_intent=self._config.file_request_intent, + restype=restype, + comp=comp, + content_type=content_type, + version=self._config.version, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["Last-Modified"] = self._deserialize("rfc-1123", response.headers.get("Last-Modified")) + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace_async + async def get_statistics( + self, + timeout: Optional[int] = None, + lease_access_conditions: Optional[_models.LeaseAccessConditions] = None, + **kwargs: Any + ) -> _models.ShareStats: + # pylint: disable=line-too-long + """Retrieves statistics related to the share. + + :param timeout: The timeout parameter is expressed in seconds. For more information, see + :code:`<a + href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting + Timeouts for File Service Operations.</a>`. Default value is None. + :type timeout: int + :param lease_access_conditions: Parameter group. Default value is None. + :type lease_access_conditions: ~azure.storage.fileshare.models.LeaseAccessConditions + :return: ShareStats or the result of cls(response) + :rtype: ~azure.storage.fileshare.models.ShareStats + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + restype: Literal["share"] = kwargs.pop("restype", _params.pop("restype", "share")) + comp: Literal["stats"] = kwargs.pop("comp", _params.pop("comp", "stats")) + cls: ClsType[_models.ShareStats] = kwargs.pop("cls", None) + + _lease_id = None + if lease_access_conditions is not None: + _lease_id = lease_access_conditions.lease_id + + _request = build_get_statistics_request( + url=self._config.url, + timeout=timeout, + lease_id=_lease_id, + file_request_intent=self._config.file_request_intent, + restype=restype, + comp=comp, + version=self._config.version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["Last-Modified"] = self._deserialize("rfc-1123", response.headers.get("Last-Modified")) + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + + deserialized = self._deserialize("ShareStats", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def restore( + self, + timeout: Optional[int] = None, + request_id_parameter: Optional[str] = None, + deleted_share_name: Optional[str] = None, + deleted_share_version: Optional[str] = None, + **kwargs: Any + ) -> None: + # pylint: disable=line-too-long + """Restores a previously deleted Share. + + :param timeout: The timeout parameter is expressed in seconds. For more information, see + :code:`<a + href="https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN">Setting + Timeouts for File Service Operations.</a>`. Default value is None. + :type timeout: int + :param request_id_parameter: Provides a client-generated, opaque value with a 1 KB character + limit that is recorded in the analytics logs when storage analytics logging is enabled. Default + value is None. + :type request_id_parameter: str + :param deleted_share_name: Specifies the name of the previously-deleted share. Default value is + None. + :type deleted_share_name: str + :param deleted_share_version: Specifies the version of the previously-deleted share. Default + value is None. + :type deleted_share_version: str + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + restype: Literal["share"] = kwargs.pop("restype", _params.pop("restype", "share")) + comp: Literal["undelete"] = kwargs.pop("comp", _params.pop("comp", "undelete")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_restore_request( + url=self._config.url, + timeout=timeout, + request_id_parameter=request_id_parameter, + deleted_share_name=deleted_share_name, + deleted_share_version=deleted_share_version, + file_request_intent=self._config.file_request_intent, + restype=restype, + comp=comp, + version=self._config.version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.StorageError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["Last-Modified"] = self._deserialize("rfc-1123", response.headers.get("Last-Modified")) + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + response_headers["x-ms-client-request-id"] = self._deserialize( + "str", response.headers.get("x-ms-client-request-id") + ) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-share-quota"] = self._deserialize("int", response.headers.get("x-ms-share-quota")) + response_headers["x-ms-share-provisioned-iops"] = self._deserialize( + "int", response.headers.get("x-ms-share-provisioned-iops") + ) + response_headers["x-ms-share-provisioned-bandwidth-mibps"] = self._deserialize( + "int", response.headers.get("x-ms-share-provisioned-bandwidth-mibps") + ) + response_headers["x-ms-share-included-burst-iops"] = self._deserialize( + "int", response.headers.get("x-ms-share-included-burst-iops") + ) + response_headers["x-ms-share-max-burst-credits-for-iops"] = self._deserialize( + "int", response.headers.get("x-ms-share-max-burst-credits-for-iops") + ) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore |
