diff --git a/sdk/storage/azure-storage-file-datalake/CHANGELOG.md b/sdk/storage/azure-storage-file-datalake/CHANGELOG.md index e4cb48574560..f68dc772a5d3 100644 --- a/sdk/storage/azure-storage-file-datalake/CHANGELOG.md +++ b/sdk/storage/azure-storage-file-datalake/CHANGELOG.md @@ -4,10 +4,9 @@ ### Features Added -## 12.25.0 (2026-06-08) - -### Features Added -- Stable release of features from 12.25.0b1 +### Other Changes +- Content-Type for append_data has changed from application/json to octet-stream +- Dropped support for legacy transports ## 12.24.0 (2026-05-14) @@ -23,7 +22,7 @@ basis and with retries. Prior to this fix logging may have not behaved as expect ### Features Added - Added support for service version 2026-06-06. -- Added support for connection strings and `account_url`s to accept URLs with `-ipv6` and `-dualstack` suffixes +- Added support for connection strings and `account_url`s to accept URLs with `-ipv6` and `-dualstack` suffixes for `DataLakeServiceClient`, `FileSystemClient`, `DataLakeDirectoryClient`, and `DataLakeFileClient`. - Added support for `DataLakeDirectoryClient` and `DataLakeFileClient`'s `set_tags` and `get_tags` APIs to conditionally set and get tags associated with a directory or file client, respectively. @@ -35,15 +34,15 @@ to conditionally set and get tags associated with a directory or file client, re ### Features Added - Added support for service version 2026-04-06. -- Added support for the keyword `user_delegation_tid` to `DataLakeServiceClient.get_user_delegation_key` -API, which can be used in `generate_file_system_sas`, `generate_directory_sas`, and `generate_file_sas` -to specify the Tenant ID that is authorized to use the generated SAS URL. Note that `user_delegation_tid` +- Added support for the keyword `user_delegation_tid` to `DataLakeServiceClient.get_user_delegation_key` +API, which can be used in `generate_file_system_sas`, `generate_directory_sas`, and `generate_file_sas` +to specify the Tenant ID that is authorized to use the generated SAS URL. Note that `user_delegation_tid` must be used together with `user_delegation_oid`. -- Added support for the keyword `request_headers` to `generate_file_system_sas`, `generate_directory_sas`, -and `generate_file_sas` which specifies a set of headers and their corresponding values that +- Added support for the keyword `request_headers` to `generate_file_system_sas`, `generate_directory_sas`, +and `generate_file_sas` which specifies a set of headers and their corresponding values that must be present in the request header when using the generated SAS. -- Added support for the keyword `request_query_params` to `generate_file_system_sas`, `generate_directory_sas`, -and `generate_file_sas` which specifies a set of query parameters and their corresponding values that +- Added support for the keyword `request_query_params` to `generate_file_system_sas`, `generate_directory_sas`, +and `generate_file_sas` which specifies a set of query parameters and their corresponding values that must be present in the request URL when using the generated SAS. ### Other Changes @@ -70,9 +69,9 @@ significantly better throughput on large file downloads for most environments. - Added the ability to skip auto decompression on `DataLakeFileClient.download_file` via the `decompress` keyword. ### Other Changes -- Migrated any previously documented `kwarg` arguments to be named keywords. +- Migrated any previously documented `kwarg` arguments to be named keywords. Some public types may have been adjusted if they were previously erroneous or incomplete. -- Removed `__enter__` and `__exit__` attributes for all asynchronous client objects for raising explicit `TypeError`, +- Removed `__enter__` and `__exit__` attributes for all asynchronous client objects for raising explicit `TypeError`, and let the `AttributeError` raise directly. ## 12.22.0 (2025-10-15) @@ -81,7 +80,7 @@ and let the `AttributeError` raise directly. - Stable release of features from 12.22.0b1 ### Other Changes -- Removed `__enter__` and `__exit__` attributes for all asynchronous client objects for raising explicit `TypeError`, +- Removed `__enter__` and `__exit__` attributes for all asynchronous client objects for raising explicit `TypeError`, and let the `AttributeError` raise directly. ## 12.21.0 (2025-07-16) @@ -100,7 +99,7 @@ This version and all future versions will require Python 3.9+. Python 3.8 is no ### Features Added - Added support for service version 2025-07-05. -- Added support for OAuth authentication in `FileSystemClient`'s `get_file_system_access_policy` +- Added support for OAuth authentication in `FileSystemClient`'s `get_file_system_access_policy` and `set_file_system_access_policy` APIs. - Added support for progress tracking to `DataLakeFileClient`'s `upload_data` and `download_file` APIs via a new optional callback, `progress_hook`. diff --git a/sdk/storage/azure-storage-file-datalake/MANIFEST.in b/sdk/storage/azure-storage-file-datalake/MANIFEST.in index 7bac0512bc31..957f639ff1ed 100644 --- a/sdk/storage/azure-storage-file-datalake/MANIFEST.in +++ b/sdk/storage/azure-storage-file-datalake/MANIFEST.in @@ -1,7 +1,7 @@ include *.md -include azure/__init__.py -include azure/storage/__init__.py include LICENSE +include azure/storage/filedatalake/py.typed recursive-include tests *.py recursive-include samples *.py *.md -include azure/storage/filedatalake/py.typed +include azure/__init__.py +include azure/storage/__init__.py diff --git a/sdk/storage/azure-storage-file-datalake/_metadata.json b/sdk/storage/azure-storage-file-datalake/_metadata.json new file mode 100644 index 000000000000..fcbb32e1267f --- /dev/null +++ b/sdk/storage/azure-storage-file-datalake/_metadata.json @@ -0,0 +1,6 @@ +{ + "apiVersion": "2026-06-06", + "apiVersions": { + "Storage.DataLake": "2026-06-06" + } +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-file-datalake/apiview-properties.json b/sdk/storage/azure-storage-file-datalake/apiview-properties.json new file mode 100644 index 000000000000..c2830314888a --- /dev/null +++ b/sdk/storage/azure-storage-file-datalake/apiview-properties.json @@ -0,0 +1,69 @@ +{ + "CrossLanguagePackageId": "Storage.DataLake", + "CrossLanguageDefinitionId": { + "azure.storage.filedatalake.models.AclFailedEntry": "Storage.DataLake.AclFailedEntry", + "azure.storage.filedatalake.models.BlobHierarchyListSegment": "Storage.DataLake.BlobHierarchyListSegment", + "azure.storage.filedatalake.models.BlobItemInternal": "Storage.DataLake.BlobItem", + "azure.storage.filedatalake.models.BlobPrefix": "Storage.DataLake.BlobPrefix", + "azure.storage.filedatalake.models.BlobPropertiesInternal": "Storage.DataLake.BlobPropertiesInternal", + "azure.storage.filedatalake.models.FileSystemItem": "Storage.DataLake.FileSystemItem", + "azure.storage.filedatalake.models.FileSystemList": "Storage.DataLake.FileSystemList", + "azure.storage.filedatalake.models.ListBlobsHierarchySegmentResponse": "Storage.DataLake.ListBlobsHierarchySegmentResponse", + "azure.storage.filedatalake.models.Path": "Storage.DataLake.PathItem", + "azure.storage.filedatalake.models.PathList": "Storage.DataLake.PathList", + "azure.storage.filedatalake.models.SetAccessControlRecursiveResponse": "Storage.DataLake.SetAccessControlRecursiveResponse", + "azure.storage.filedatalake.models.StorageError": "Storage.DataLake.StorageError", + "azure.storage.filedatalake.models.StorageErrorBody": "Storage.DataLake.StorageErrorBody", + "azure.storage.filedatalake.models.FileSystemResourceType": "Storage.DataLake.FileSystemResourceType", + "azure.storage.filedatalake.models.ListBlobsIncludeItem": "Storage.DataLake.ListBlobsIncludeItem", + "azure.storage.filedatalake.models.ListBlobsShowOnly": "Storage.DataLake.ListBlobsShowOnly", + "azure.storage.filedatalake.models.PathResourceType": "Storage.DataLake.PathResourceType", + "azure.storage.filedatalake.models.PathRenameMode": "Storage.DataLake.PathRenameMode", + "azure.storage.filedatalake.models.EncryptionAlgorithmType": "Storage.DataLake.EncryptionAlgorithmType", + "azure.storage.filedatalake.models.PathExpiryOptions": "Storage.DataLake.PathExpiryOptions", + "azure.storage.filedatalake.models.PathUpdateAction": "Storage.DataLake.PathUpdateAction", + "azure.storage.filedatalake.models.PathSetAccessControlRecursiveMode": "Storage.DataLake.PathSetAccessControlRecursiveMode", + "azure.storage.filedatalake.models.PathLeaseAction": "Storage.DataLake.PathLeaseAction", + "azure.storage.filedatalake.models.PathGetPropertiesAction": "Storage.DataLake.PathGetPropertiesAction", + "azure.storage.filedatalake.models.LeaseAction": "Storage.DataLake.LeaseAction", + "azure.storage.filedatalake.models.AccountResourceType": "Storage.DataLake.AccountResourceType", + "azure.storage.filedatalake.operations.FileSystemOperations.create": "Storage.DataLake.FileSystem.create", + "azure.storage.filedatalake.aio.operations.FileSystemOperations.create": "Storage.DataLake.FileSystem.create", + "azure.storage.filedatalake.operations.FileSystemOperations.set_properties": "Storage.DataLake.FileSystem.setProperties", + "azure.storage.filedatalake.aio.operations.FileSystemOperations.set_properties": "Storage.DataLake.FileSystem.setProperties", + "azure.storage.filedatalake.operations.FileSystemOperations.get_properties": "Storage.DataLake.FileSystem.getProperties", + "azure.storage.filedatalake.aio.operations.FileSystemOperations.get_properties": "Storage.DataLake.FileSystem.getProperties", + "azure.storage.filedatalake.operations.FileSystemOperations.delete": "Storage.DataLake.FileSystem.delete", + "azure.storage.filedatalake.aio.operations.FileSystemOperations.delete": "Storage.DataLake.FileSystem.delete", + "azure.storage.filedatalake.operations.FileSystemOperations.list_paths": "Storage.DataLake.FileSystem.listPaths", + "azure.storage.filedatalake.aio.operations.FileSystemOperations.list_paths": "Storage.DataLake.FileSystem.listPaths", + "azure.storage.filedatalake.operations.FileSystemOperations.list_blob_hierarchy_segment": "Storage.DataLake.FileSystem.listBlobHierarchySegment", + "azure.storage.filedatalake.aio.operations.FileSystemOperations.list_blob_hierarchy_segment": "Storage.DataLake.FileSystem.listBlobHierarchySegment", + "azure.storage.filedatalake.operations.PathOperations.create": "Storage.DataLake.Path.create", + "azure.storage.filedatalake.aio.operations.PathOperations.create": "Storage.DataLake.Path.create", + "azure.storage.filedatalake.operations.PathOperations.update": "Storage.DataLake.Path.update", + "azure.storage.filedatalake.aio.operations.PathOperations.update": "Storage.DataLake.Path.update", + "azure.storage.filedatalake.operations.PathOperations.lease": "Storage.DataLake.Path.lease", + "azure.storage.filedatalake.aio.operations.PathOperations.lease": "Storage.DataLake.Path.lease", + "azure.storage.filedatalake.operations.PathOperations.read": "Storage.DataLake.Path.read", + "azure.storage.filedatalake.aio.operations.PathOperations.read": "Storage.DataLake.Path.read", + "azure.storage.filedatalake.operations.PathOperations.get_properties": "Storage.DataLake.Path.getProperties", + "azure.storage.filedatalake.aio.operations.PathOperations.get_properties": "Storage.DataLake.Path.getProperties", + "azure.storage.filedatalake.operations.PathOperations.delete": "Storage.DataLake.Path.delete", + "azure.storage.filedatalake.aio.operations.PathOperations.delete": "Storage.DataLake.Path.delete", + "azure.storage.filedatalake.operations.PathOperations.set_access_control": "Storage.DataLake.Path.setAccessControl", + "azure.storage.filedatalake.aio.operations.PathOperations.set_access_control": "Storage.DataLake.Path.setAccessControl", + "azure.storage.filedatalake.operations.PathOperations.set_access_control_recursive": "Storage.DataLake.Path.setAccessControlRecursive", + "azure.storage.filedatalake.aio.operations.PathOperations.set_access_control_recursive": "Storage.DataLake.Path.setAccessControlRecursive", + "azure.storage.filedatalake.operations.PathOperations.flush_data": "Storage.DataLake.Path.flushData", + "azure.storage.filedatalake.aio.operations.PathOperations.flush_data": "Storage.DataLake.Path.flushData", + "azure.storage.filedatalake.operations.PathOperations.append_data": "Storage.DataLake.Path.appendData", + "azure.storage.filedatalake.aio.operations.PathOperations.append_data": "Storage.DataLake.Path.appendData", + "azure.storage.filedatalake.operations.PathOperations.set_expiry": "Storage.DataLake.Path.setExpiry", + "azure.storage.filedatalake.aio.operations.PathOperations.set_expiry": "Storage.DataLake.Path.setExpiry", + "azure.storage.filedatalake.operations.PathOperations.undelete": "Storage.DataLake.Path.undelete", + "azure.storage.filedatalake.aio.operations.PathOperations.undelete": "Storage.DataLake.Path.undelete", + "azure.storage.filedatalake.operations.ServiceOperations.list_file_systems": "Storage.DataLake.Service.listFileSystems", + "azure.storage.filedatalake.aio.operations.ServiceOperations.list_file_systems": "Storage.DataLake.Service.listFileSystems" + } +} \ No newline at end of file diff --git a/sdk/storage/azure-storage-file-datalake/assets.json b/sdk/storage/azure-storage-file-datalake/assets.json index a0c79aa64e2b..695aa6460967 100644 --- a/sdk/storage/azure-storage-file-datalake/assets.json +++ b/sdk/storage/azure-storage-file-datalake/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "python", "TagPrefix": "python/storage/azure-storage-file-datalake", - "Tag": "python/storage/azure-storage-file-datalake_34be4c4176" + "Tag": "python/storage/azure-storage-file-datalake_b74774dee3" } diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/__init__.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/__init__.py index 3bfde882096f..904ff89f01f0 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/__init__.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/__init__.py @@ -76,6 +76,7 @@ "DataLakeDirectoryClient", "DataLakeFileClient", "DataLakeFileQueryError", + "DataLakeFileQueryError", "DataLakeLeaseClient", "DataLakeServiceClient", "DeletedPathProperties", diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_data_lake_directory_client.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_data_lake_directory_client.py index 365dc685b6f1..55c5b0f78822 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_data_lake_directory_client.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_data_lake_directory_client.py @@ -87,7 +87,7 @@ def __init__( directory_name: str, credential: Optional[ Union[str, Dict[str, str], "AzureNamedKeyCredential", "AzureSasCredential", "TokenCredential"] - ] = None, + ] = None, # pylint: disable=line-too-long **kwargs: Any, ) -> None: super(DataLakeDirectoryClient, self).__init__( @@ -102,7 +102,7 @@ def from_connection_string( directory_name: str, credential: Optional[ Union[str, Dict[str, str], "AzureNamedKeyCredential", "AzureSasCredential", "TokenCredential"] - ] = None, + ] = None, # pylint: disable=line-too-long **kwargs: Any, ) -> Self: """ diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_data_lake_file_client.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_data_lake_file_client.py index 6a35eeec7e5b..349b092ce6fb 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_data_lake_file_client.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_data_lake_file_client.py @@ -90,7 +90,7 @@ def __init__( file_path: str, credential: Optional[ Union[str, Dict[str, str], "AzureNamedKeyCredential", "AzureSasCredential", "TokenCredential"] - ] = None, + ] = None, # pylint: disable=line-too-long **kwargs: Any, ) -> None: super(DataLakeFileClient, self).__init__( @@ -105,7 +105,7 @@ def from_connection_string( file_path: str, credential: Optional[ Union[str, Dict[str, str], "AzureNamedKeyCredential", "AzureSasCredential", "TokenCredential"] - ] = None, + ] = None, # pylint: disable=line-too-long **kwargs: Any, ) -> Self: """ @@ -379,7 +379,9 @@ def set_file_expiry( expiry_time = convert_datetime_to_rfc1123(expires_on) elif expires_on is not None: expiry_time = str(expires_on) - self._datalake_client_for_blob_operation.path.set_expiry(expiry_options, expires_on=expiry_time, **kwargs) + self._datalake_client_for_blob_operation.path.set_expiry( + expiry_options=expiry_options, expires_on=expiry_time, **kwargs + ) @distributed_trace def upload_data( diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_data_lake_file_client_helpers.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_data_lake_file_client_helpers.py index 2af453a9919d..376e76981f0a 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_data_lake_file_client_helpers.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_data_lake_file_client_helpers.py @@ -66,10 +66,11 @@ def _append_data_options( "position": offset, "content_length": length, "validate_content": validate_content, - "cpk_info": cpk_info, "timeout": kwargs.pop("timeout", None), "cls": return_response_headers, } + if cpk_info: + options.update(cpk_info) options.update(kwargs) return options @@ -83,7 +84,7 @@ def _flush_data_options( ) -> Dict[str, Any]: mod_conditions = get_mod_conditions(kwargs) - path_http_headers = None + path_http_headers = {} if content_settings: path_http_headers = get_path_http_headers(content_settings) @@ -93,14 +94,15 @@ def _flush_data_options( options = { "position": offset, "content_length": 0, - "path_http_headers": path_http_headers, "retain_uncommitted_data": retain_uncommitted_data, "close": kwargs.pop("close", False), - "modified_access_conditions": mod_conditions, - "cpk_info": cpk_info, "timeout": kwargs.pop("timeout", None), "cls": return_response_headers, } + options.update(path_http_headers) + options.update(mod_conditions) + if cpk_info: + options.update(cpk_info) options.update(kwargs) return options @@ -141,12 +143,17 @@ def _upload_options( max_concurrency = DEFAULT_MAX_CONCURRENCY kwargs["properties"] = add_metadata_headers(metadata) - kwargs["lease_access_conditions"] = get_access_conditions(kwargs.pop("lease", None)) - kwargs["modified_access_conditions"] = get_mod_conditions(kwargs) - kwargs["cpk_info"] = get_cpk_info(scheme, kwargs) + lease_id = get_access_conditions(kwargs.pop("lease", None)) + if lease_id: + kwargs["lease_id"] = lease_id + mod_conditions = get_mod_conditions(kwargs) + kwargs.update(mod_conditions) + cpk_info = get_cpk_info(scheme, kwargs) + if cpk_info: + kwargs.update(cpk_info) if content_settings: - kwargs["path_http_headers"] = get_path_http_headers(content_settings) + kwargs.update(get_path_http_headers(content_settings)) kwargs["stream"] = stream kwargs["length"] = length diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_data_lake_lease.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_data_lake_lease.py index 603a233ea6dc..40efc6d421ae 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_data_lake_lease.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_data_lake_lease.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_data_lake_service_client.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_data_lake_service_client.py index c5d85128e2db..0823360f1194 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_data_lake_service_client.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_data_lake_service_client.py @@ -17,13 +17,18 @@ from ._data_lake_service_client_helpers import _format_url, _parse_url from ._deserialize import get_datalake_service_properties from ._file_system_client import FileSystemClient -from ._generated import AzureDataLakeStorageRESTAPI +from ._generated import DataLakeClient as AzureDataLakeStorageRESTAPI from ._models import ( + AnalyticsLogging, + CorsRule, DirectoryProperties, FileProperties, FileSystemProperties, FileSystemPropertiesPaged, LocationMode, + Metrics, + RetentionPolicy, + StaticWebsite, UserDelegationKey, ) from ._serialize import convert_dfs_url_to_blob_url, get_api_version @@ -98,7 +103,7 @@ def __init__( account_url: str, credential: Optional[ Union[str, Dict[str, str], "AzureNamedKeyCredential", "AzureSasCredential", "TokenCredential"] - ] = None, + ] = None, # pylint: disable=line-too-long **kwargs: Any ) -> None: parsed_url = _parse_url(account_url=account_url) @@ -156,7 +161,7 @@ def from_connection_string( conn_str: str, credential: Optional[ Union[str, Dict[str, str], "AzureNamedKeyCredential", "AzureSasCredential", "TokenCredential"] - ] = None, + ] = None, # pylint: disable=line-too-long **kwargs: Any ) -> Self: """ @@ -641,6 +646,29 @@ def set_service_properties(self, **kwargs: Any) -> None: #other-client--per-operation-configuration>`_. :rtype: None """ + # Convert datalake-public service-property models to blob-public types so + # this code path remains correct once azure-storage-blob migrates to typespec + # models (msrest duck-typing through StorageServiceProperties goes away). + if "analytics_logging" in kwargs: + kwargs["analytics_logging"] = AnalyticsLogging._to_generated( # pylint: disable=protected-access + kwargs["analytics_logging"] + ) + if "hour_metrics" in kwargs: + kwargs["hour_metrics"] = Metrics._to_generated(kwargs["hour_metrics"]) # pylint: disable=protected-access + if "minute_metrics" in kwargs: + kwargs["minute_metrics"] = Metrics._to_generated( # pylint: disable=protected-access + kwargs["minute_metrics"] + ) + if "cors" in kwargs: + kwargs["cors"] = CorsRule._to_generated(kwargs["cors"]) # pylint: disable=protected-access + if "delete_retention_policy" in kwargs: + kwargs["delete_retention_policy"] = RetentionPolicy._to_generated( # pylint: disable=protected-access + kwargs["delete_retention_policy"] + ) + if "static_website" in kwargs: + kwargs["static_website"] = StaticWebsite._to_generated( # pylint: disable=protected-access + kwargs["static_website"] + ) return self._blob_service_client.set_service_properties(**kwargs) @distributed_trace diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_deserialize.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_deserialize.py index 078efd8329dc..6b1daae5b2f4 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_deserialize.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_deserialize.py @@ -157,8 +157,16 @@ def process_storage_error(storage_error) -> NoReturn: # type: ignore [misc] # p serialized = False if not storage_error.response: raise storage_error - # If it is one of those three then it has been serialized prior by the generated layer. - if isinstance(storage_error, (ResourceNotFoundError, ClientAuthenticationError, ResourceExistsError)): + # The generated layer now pre-maps 412 (Precondition Failed) responses to typed + # exceptions based on the request's match condition (e.g. ResourceExistsError for + # IfMissing, ResourceNotFoundError for IfPresent). Historically 412 was not + # pre-mapped and always flowed through the error-code mapping below, surfacing as + # ResourceModifiedError. Skip the "already serialized" shortcut for 412 so it is + # re-mapped from x-ms-error-code (ConditionNotMet -> ResourceModifiedError) and the + # public exception type is preserved for users. + if storage_error.response.status_code != 412 and isinstance( + storage_error, (ResourceNotFoundError, ClientAuthenticationError, ResourceExistsError) + ): serialized = True error_code = storage_error.response.headers.get("x-ms-error-code") error_message = storage_error.message diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_file_system_client.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_file_system_client.py index 6ccbc1911760..978a55090a0f 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_file_system_client.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_file_system_client.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for @@ -19,7 +20,7 @@ from ._data_lake_lease import DataLakeLeaseClient from ._deserialize import is_file_path, process_storage_error from ._file_system_client_helpers import _format_url, _parse_url, _undelete_path_options -from ._generated import AzureDataLakeStorageRESTAPI +from ._generated import DataLakeClient as AzureDataLakeStorageRESTAPI from ._list_paths_helper import DeletedPathPropertiesPaged, PathPropertiesPaged from ._models import ( DeletedPathProperties, @@ -95,7 +96,7 @@ def __init__( file_system_name: str, credential: Optional[ Union[str, Dict[str, str], "AzureNamedKeyCredential", "AzureSasCredential", "TokenCredential"] - ] = None, + ] = None, # pylint: disable=line-too-long **kwargs: Any, ) -> None: if not file_system_name: @@ -153,7 +154,7 @@ def close(self) -> None: def _build_generated_client(self, url: str) -> AzureDataLakeStorageRESTAPI: client = AzureDataLakeStorageRESTAPI( - url, version=self._api_version, base_url=url, file_system=self.file_system_name, pipeline=self._pipeline + url, base_url=url, file_system=self.file_system_name, version=self._api_version, pipeline=self._pipeline ) return client @@ -167,7 +168,7 @@ def from_connection_string( file_system_name: str, credential: Optional[ Union[str, Dict[str, str], "AzureNamedKeyCredential", "AzureSasCredential", "TokenCredential"] - ] = None, + ] = None, # pylint: disable=line-too-long **kwargs: Any, ) -> Self: """ @@ -952,7 +953,7 @@ def _undelete_path( policies=self._pipeline._impl_policies, # pylint: disable=protected-access ) path_client = AzureDataLakeStorageRESTAPI( - url, version=self._api_version, filesystem=self.file_system_name, path=deleted_path_name, pipeline=pipeline + url, filesystem=self.file_system_name, path=deleted_path_name, pipeline=pipeline ) try: is_file = path_client.path.undelete(undelete_source=undelete_source, cls=is_file_path, **kwargs) diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/__init__.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/__init__.py index 8a9f7149c0f5..a61eee2e3450 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/__init__.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/__init__.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- # pylint: disable=wrong-import-position @@ -12,7 +12,10 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import -from ._azure_data_lake_storage_restapi import AzureDataLakeStorageRESTAPI # type: ignore +from ._client import DataLakeClient # type: ignore +from ._version import VERSION + +__version__ = VERSION try: from ._patch import __all__ as _patch_all @@ -22,7 +25,7 @@ from ._patch import patch_sdk as _patch_sdk __all__ = [ - "AzureDataLakeStorageRESTAPI", + "DataLakeClient", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/_azure_data_lake_storage_restapi.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/_client.py similarity index 65% rename from sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/_azure_data_lake_storage_restapi.py rename to sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/_client.py index ccbd94a2d0f6..e19b96a1b26a 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/_azure_data_lake_storage_restapi.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/_client.py @@ -2,55 +2,49 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional +from typing import Any, TYPE_CHECKING from typing_extensions import Self from azure.core import PipelineClient from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse -from . import models as _models -from ._configuration import AzureDataLakeStorageRESTAPIConfiguration +from ._configuration import DataLakeClientConfiguration from ._utils.serialization import Deserializer, Serializer from .operations import FileSystemOperations, PathOperations, ServiceOperations +if TYPE_CHECKING: + from azure.core.credentials import TokenCredential -class AzureDataLakeStorageRESTAPI: # pylint: disable=client-accepts-api-version-keyword - """Azure Data Lake Storage provides storage for Hadoop and other big data workloads. - :ivar service: ServiceOperations operations - :vartype service: azure.storage.filedatalake.operations.ServiceOperations +class DataLakeClient: # pylint: disable=client-accepts-api-version-keyword + """DataLakeClient. + :ivar file_system: FileSystemOperations operations :vartype file_system: azure.storage.filedatalake.operations.FileSystemOperations :ivar path: PathOperations operations :vartype path: azure.storage.filedatalake.operations.PathOperations + :ivar service: ServiceOperations operations + :vartype service: azure.storage.filedatalake.operations.ServiceOperations :param url: The URL of the service account, container, or blob that is the target of the desired operation. Required. :type url: str - :param version: Specifies the version of the operation to use for this request. Required. - :type version: str - :param base_url: Service URL. Required. Default value is "". - :type base_url: str - :param x_ms_lease_duration: The lease duration is required to acquire a lease, and specifies - the duration of the lease in seconds. The lease duration must be between 15 and 60 seconds or - -1 for infinite lease. Default value is None. - :type x_ms_lease_duration: int - :keyword resource: The value must be "filesystem" for all filesystem operations. Default value - is "filesystem". Note that overriding this default value may result in unsupported behavior. - :paramtype resource: str + :param credential: Credential used to authenticate requests to the service. Required. + :type credential: ~azure.core.credentials.TokenCredential + :keyword version: Specifies the version of the operation to use for this request. Known values + are "2026-06-06". Default value is "2026-06-06". Note that overriding this default value may + result in unsupported behavior. + :paramtype version: str """ - def __init__( # pylint: disable=missing-client-constructor-parameter-credential - self, url: str, version: str, base_url: str = "", x_ms_lease_duration: Optional[int] = None, **kwargs: Any - ) -> None: - self._config = AzureDataLakeStorageRESTAPIConfiguration( - url=url, version=version, x_ms_lease_duration=x_ms_lease_duration, **kwargs - ) + def __init__(self, url: str, credential: "TokenCredential", **kwargs: Any) -> None: + _endpoint = "{url}" + self._config = DataLakeClientConfiguration(url=url, credential=credential, **kwargs) _policies = kwargs.pop("policies", None) if _policies is None: @@ -69,23 +63,22 @@ def __init__( # pylint: disable=missing-client-constructor-parameter-credential policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, self._config.http_logging_policy, ] - self._client: PipelineClient = PipelineClient(base_url=base_url, policies=_policies, **kwargs) + self._client: PipelineClient = PipelineClient(base_url=_endpoint, 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 = Serializer() + self._deserialize = Deserializer() self._serialize.client_side_validation = False - self.service = ServiceOperations(self._client, self._config, self._serialize, self._deserialize) self.file_system = FileSystemOperations(self._client, self._config, self._serialize, self._deserialize) self.path = PathOperations(self._client, self._config, self._serialize, self._deserialize) + self.service = ServiceOperations(self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: + def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") - >>> response = client._send_request(request) + >>> response = client.send_request(request) For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request @@ -98,7 +91,11 @@ def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: """ request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) + path_format_arguments = { + "url": self._serialize.url("self._config.url", self._config.url, "str", skip_quote=True), + } + + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/_configuration.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/_configuration.py index a1a941bed54f..21e3f5892fbc 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/_configuration.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/_configuration.py @@ -2,19 +2,22 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Literal, Optional +from typing import Any, TYPE_CHECKING from azure.core.pipeline import policies -VERSION = "unknown" +from ._version import VERSION +if TYPE_CHECKING: + from azure.core.credentials import TokenCredential -class AzureDataLakeStorageRESTAPIConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for AzureDataLakeStorageRESTAPI. + +class DataLakeClientConfiguration: # pylint: disable=too-many-instance-attributes + """Configuration for DataLakeClient. Note that all parameters used to create this instance are saved as instance attributes. @@ -22,30 +25,27 @@ class AzureDataLakeStorageRESTAPIConfiguration: # pylint: disable=too-many-inst :param url: The URL of the service account, container, or blob that is the target of the desired operation. Required. :type url: str - :param version: Specifies the version of the operation to use for this request. Required. - :type version: str - :param x_ms_lease_duration: The lease duration is required to acquire a lease, and specifies - the duration of the lease in seconds. The lease duration must be between 15 and 60 seconds or - -1 for infinite lease. Default value is None. - :type x_ms_lease_duration: int - :keyword resource: The value must be "filesystem" for all filesystem operations. Default value - is "filesystem". Note that overriding this default value may result in unsupported behavior. - :paramtype resource: str + :param credential: Credential used to authenticate requests to the service. Required. + :type credential: ~azure.core.credentials.TokenCredential + :keyword version: Specifies the version of the operation to use for this request. Known values + are "2026-06-06". Default value is "2026-06-06". Note that overriding this default value may + result in unsupported behavior. + :paramtype version: str """ - def __init__(self, url: str, version: str, x_ms_lease_duration: Optional[int] = None, **kwargs: Any) -> None: - resource: Literal["filesystem"] = kwargs.pop("resource", "filesystem") + def __init__(self, url: str, credential: "TokenCredential", **kwargs: Any) -> None: + version: str = kwargs.pop("version", "2026-06-06") if url is None: raise ValueError("Parameter 'url' must not be None.") - if version is None: - raise ValueError("Parameter 'version' must not be None.") + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") self.url = url + self.credential = credential self.version = version - self.x_ms_lease_duration = x_ms_lease_duration - self.resource = resource - kwargs.setdefault("sdk_moniker", "azuredatalakestoragerestapi/{}".format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://storage.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "storage-file-datalake/{}".format(VERSION)) self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) @@ -59,3 +59,7 @@ def _configure(self, **kwargs: Any) -> None: self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.BearerTokenCredentialPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/_patch.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/_patch.py index f7dd32510333..2f296ab79969 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/_patch.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/_patch.py @@ -1,14 +1,108 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# 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. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -from typing import List +from typing import Any, Optional, TYPE_CHECKING -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level +from azure.core import PipelineClient +from azure.core.pipeline import Pipeline, PipelineRequest +from azure.core.pipeline.policies import SansIOHTTPPolicy + +from ._client import DataLakeClient as GeneratedDataLakeClient +from ._configuration import DataLakeClientConfiguration as GeneratedDataLakeClientConfiguration + +if TYPE_CHECKING: + from azure.core.credentials import TokenCredential + + +class RangeHeaderPolicy(SansIOHTTPPolicy): + """Policy that converts the 'Range' header to 'x-ms-range'.""" + + def on_request(self, request: PipelineRequest) -> None: + range_value = request.http_request.headers.pop("Range", None) + if range_value is not None: + request.http_request.headers["x-ms-range"] = range_value + + +class DataLakeClientConfiguration(GeneratedDataLakeClientConfiguration): + """Configuration for DataLakeClient that allows optional credentials. + + Overrides the generated configuration to allow None credentials + for anonymous access. + """ + + def __init__(self, url: str, credential: Optional["TokenCredential"] = None, **kwargs: Any) -> None: + if url is None: + raise ValueError("Parameter 'url' must not be None.") + version: str = kwargs.pop("version", "2026-06-06") + self.url = url + self.credential = credential + self.version = version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://storage.azure.com/.default"]) + from ._version import VERSION + + kwargs.setdefault("sdk_moniker", "storage-file-datalake/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) + self._configure(**kwargs) + + +class DataLakeClient(GeneratedDataLakeClient): + """Subclass of the generated DataLakeClient that allows optional credentials, + accepts a pre-built pipeline, and injects the RangeHeaderPolicy. + """ + + def __init__( + self, url: str, credential: Optional["TokenCredential"] = None, *, pipeline: Any = None, **kwargs: Any + ) -> None: + from azure.core.pipeline import policies + + from ._utils.serialization import Deserializer, Serializer + from .operations import FileSystemOperations, PathOperations, ServiceOperations + + _endpoint = "{url}" + self._config = DataLakeClientConfiguration(url=url, credential=credential, **kwargs) + + if pipeline is not None: + _wrapped_pipeline = Pipeline( + transport=pipeline._transport, + policies=[RangeHeaderPolicy()] + list(pipeline._impl_policies), + ) + self._client = PipelineClient(base_url=_endpoint, pipeline=_wrapped_pipeline) + else: + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + RangeHeaderPolicy(), + 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 = PipelineClient(base_url=_endpoint, policies=_policies, **kwargs) + + self._serialize = Serializer() + self._deserialize = Deserializer() + self._serialize.client_side_validation = False + self.service = ServiceOperations(self._client, self._config, self._serialize, self._deserialize) + self.file_system = FileSystemOperations(self._client, self._config, self._serialize, self._deserialize) + self.path = PathOperations(self._client, self._config, self._serialize, self._deserialize) + + +__all__: list[str] = ["DataLakeClient"] def patch_sdk(): diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/_utils/__init__.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/_utils/__init__.py index 0af9b28f6607..8026245c2abc 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/_utils/__init__.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/_utils/__init__.py @@ -1,6 +1,6 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/_utils/model_base.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/_utils/model_base.py new file mode 100644 index 000000000000..db24930fdca9 --- /dev/null +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/_utils/model_base.py @@ -0,0 +1,1441 @@ +# pylint: disable=line-too-long,useless-suppression,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) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=protected-access, broad-except + +import copy +import calendar +import decimal +import functools +import sys +import logging +import base64 +import re +import typing +import enum +import email.utils +from datetime import datetime, date, time, timedelta, timezone +from json import JSONEncoder +import xml.etree.ElementTree as ET +from collections.abc import MutableMapping +from typing_extensions import Self +import isodate +from azure.core.exceptions import DeserializationError +from azure.core import CaseInsensitiveEnumMeta +from azure.core.pipeline import PipelineResponse +from azure.core.serialization import _Null +from azure.core.rest import HttpResponse + +_LOGGER = logging.getLogger(__name__) + +__all__ = ["SdkJSONEncoder", "Model", "rest_field", "rest_discriminator"] + +TZ_UTC = timezone.utc +_T = typing.TypeVar("_T") +_NONE_TYPE = type(None) + + +def _timedelta_as_isostr(td: timedelta) -> str: + """Converts a datetime.timedelta object into an ISO 8601 formatted string, e.g. 'P4DT12H30M05S' + + Function adapted from the Tin Can Python project: https://github.com/RusticiSoftware/TinCanPython + + :param timedelta td: The timedelta to convert + :rtype: str + :return: ISO8601 version of this timedelta + """ + + # Split seconds to larger units + seconds = td.total_seconds() + minutes, seconds = divmod(seconds, 60) + hours, minutes = divmod(minutes, 60) + days, hours = divmod(hours, 24) + + days, hours, minutes = list(map(int, (days, hours, minutes))) + seconds = round(seconds, 6) + + # Build date + date_str = "" + if days: + date_str = "%sD" % days + + if hours or minutes or seconds: + # Build time + time_str = "T" + + # Hours + bigger_exists = date_str or hours + if bigger_exists: + time_str += "{:02}H".format(hours) + + # Minutes + bigger_exists = bigger_exists or minutes + if bigger_exists: + time_str += "{:02}M".format(minutes) + + # Seconds + try: + if seconds.is_integer(): + seconds_string = "{:02}".format(int(seconds)) + else: + # 9 chars long w/ leading 0, 6 digits after decimal + seconds_string = "%09.6f" % seconds + # Remove trailing zeros + seconds_string = seconds_string.rstrip("0") + except AttributeError: # int.is_integer() raises + seconds_string = "{:02}".format(seconds) + + time_str += "{}S".format(seconds_string) + else: + time_str = "" + + return "P" + date_str + time_str + + +def _serialize_bytes(o, format: typing.Optional[str] = None) -> str: + encoded = base64.b64encode(o).decode() + if format == "base64url": + return encoded.strip("=").replace("+", "-").replace("/", "_") + return encoded + + +def _serialize_datetime(o, format: typing.Optional[str] = None): + if hasattr(o, "year") and hasattr(o, "hour"): + if format == "rfc7231": + return email.utils.format_datetime(o, usegmt=True) + if format == "unix-timestamp": + return int(calendar.timegm(o.utctimetuple())) + + # astimezone() fails for naive times in Python 2.7, so make make sure o is aware (tzinfo is set) + if not o.tzinfo: + iso_formatted = o.replace(tzinfo=TZ_UTC).isoformat() + else: + iso_formatted = o.astimezone(TZ_UTC).isoformat() + # Replace the trailing "+00:00" UTC offset with "Z" (RFC 3339: https://www.ietf.org/rfc/rfc3339.txt) + return iso_formatted.replace("+00:00", "Z") + # Next try datetime.date or datetime.time + return o.isoformat() + + +def _is_readonly(p): + try: + return p._visibility == ["read"] + except AttributeError: + return False + + +class SdkJSONEncoder(JSONEncoder): + """A JSON encoder that's capable of serializing datetime objects and bytes.""" + + def __init__(self, *args, exclude_readonly: bool = False, format: typing.Optional[str] = None, **kwargs): + super().__init__(*args, **kwargs) + self.exclude_readonly = exclude_readonly + self.format = format + + def default(self, o): # pylint: disable=too-many-return-statements + if _is_model(o): + if self.exclude_readonly: + readonly_props = [p._rest_name for p in o._attr_to_rest_field.values() if _is_readonly(p)] + return {k: v for k, v in o.items() if k not in readonly_props} + return dict(o.items()) + try: + return super(SdkJSONEncoder, self).default(o) + except TypeError: + if isinstance(o, _Null): + return None + if isinstance(o, decimal.Decimal): + return float(o) + if isinstance(o, (bytes, bytearray)): + return _serialize_bytes(o, self.format) + try: + # First try datetime.datetime + return _serialize_datetime(o, self.format) + except AttributeError: + pass + # Last, try datetime.timedelta + try: + return _timedelta_as_isostr(o) + except AttributeError: + # This will be raised when it hits value.total_seconds in the method above + pass + return super(SdkJSONEncoder, self).default(o) + + +_VALID_DATE = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" + r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") +_VALID_RFC7231 = re.compile( + r"(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s\d{2}\s" + r"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{4}\s\d{2}:\d{2}:\d{2}\sGMT" +) + +_ARRAY_ENCODE_MAPPING = { + "pipeDelimited": "|", + "spaceDelimited": " ", + "commaDelimited": ",", + "newlineDelimited": "\n", +} + + +def _deserialize_array_encoded(delimit: str, attr): + if isinstance(attr, str): + if attr == "": + return [] + return attr.split(delimit) + return attr + + +def _deserialize_datetime(attr: typing.Union[str, datetime]) -> datetime: + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + attr = attr.upper() + match = _VALID_DATE.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split(".") + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + return date_obj # type: ignore[no-any-return] + + +def _deserialize_datetime_rfc7231(attr: typing.Union[str, datetime]) -> datetime: + """Deserialize RFC7231 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + match = _VALID_RFC7231.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + return email.utils.parsedate_to_datetime(attr) + + +def _deserialize_datetime_unix_timestamp(attr: typing.Union[float, datetime]) -> datetime: + """Deserialize unix timestamp into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + return datetime.fromtimestamp(attr, TZ_UTC) + + +def _deserialize_date(attr: typing.Union[str, date]) -> date: + """Deserialize ISO-8601 formatted string into Date object. + :param str attr: response string to be deserialized. + :rtype: date + :returns: The date object from that input + """ + # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. + if isinstance(attr, date): + return attr + return isodate.parse_date(attr, defaultmonth=None, defaultday=None) # type: ignore + + +def _deserialize_time(attr: typing.Union[str, time]) -> time: + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :rtype: datetime.time + :returns: The time object from that input + """ + if isinstance(attr, time): + return attr + return isodate.parse_time(attr) # type: ignore[no-any-return] + + +def _deserialize_bytes(attr): + if isinstance(attr, (bytes, bytearray)): + return attr + return bytes(base64.b64decode(attr)) + + +def _deserialize_bytes_base64(attr): + if isinstance(attr, (bytes, bytearray)): + return attr + padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore + attr = attr + padding # type: ignore + encoded = attr.replace("-", "+").replace("_", "/") + return bytes(base64.b64decode(encoded)) + + +def _deserialize_duration(attr): + if isinstance(attr, timedelta): + return attr + return isodate.parse_duration(attr) + + +def _deserialize_decimal(attr): + if isinstance(attr, decimal.Decimal): + return attr + return decimal.Decimal(str(attr)) + + +def _deserialize_int_as_str(attr): + if isinstance(attr, int): + return attr + return int(attr) + + +_DESERIALIZE_MAPPING = { + datetime: _deserialize_datetime, + date: _deserialize_date, + time: _deserialize_time, + bytes: _deserialize_bytes, + bytearray: _deserialize_bytes, + timedelta: _deserialize_duration, + typing.Any: lambda x: x, + decimal.Decimal: _deserialize_decimal, +} + +_DESERIALIZE_MAPPING_WITHFORMAT = { + "rfc3339": _deserialize_datetime, + "rfc7231": _deserialize_datetime_rfc7231, + "unix-timestamp": _deserialize_datetime_unix_timestamp, + "base64": _deserialize_bytes, + "base64url": _deserialize_bytes_base64, +} + + +def get_deserializer(annotation: typing.Any, rf: typing.Optional["_RestField"] = None): + if annotation is int and rf and rf._format == "str": + return _deserialize_int_as_str + if annotation is str and rf and rf._format in _ARRAY_ENCODE_MAPPING: + return functools.partial(_deserialize_array_encoded, _ARRAY_ENCODE_MAPPING[rf._format]) + if rf and rf._format: + return _DESERIALIZE_MAPPING_WITHFORMAT.get(rf._format) + return _DESERIALIZE_MAPPING.get(annotation) # pyright: ignore + + +def _get_type_alias_type(module_name: str, alias_name: str): + types = { + k: v + for k, v in sys.modules[module_name].__dict__.items() + if isinstance(v, typing._GenericAlias) # type: ignore + } + if alias_name not in types: + return alias_name + return types[alias_name] + + +def _get_model(module_name: str, model_name: str): + models = {k: v for k, v in sys.modules[module_name].__dict__.items() if isinstance(v, type)} + module_end = module_name.rsplit(".", 1)[0] + models.update({k: v for k, v in sys.modules[module_end].__dict__.items() if isinstance(v, type)}) + if isinstance(model_name, str): + model_name = model_name.split(".")[-1] + if model_name not in models: + return model_name + return models[model_name] + + +_UNSET = object() + + +class _MyMutableMapping(MutableMapping[str, typing.Any]): + def __init__(self, data: dict[str, typing.Any]) -> None: + self._data = data + + def __contains__(self, key: typing.Any) -> bool: + return key in self._data + + def __getitem__(self, key: str) -> typing.Any: + # If this key has been deserialized (for mutable types), we need to handle serialization + if hasattr(self, "_attr_to_rest_field"): + cache_attr = f"_deserialized_{key}" + if hasattr(self, cache_attr): + rf = _get_rest_field(getattr(self, "_attr_to_rest_field"), key) + if rf: + value = self._data.get(key) + if isinstance(value, (dict, list, set)): + # For mutable types, serialize and return + # But also update _data with serialized form and clear flag + # so mutations via this returned value affect _data + serialized = _serialize(value, rf._format) + # If serialized form is same type (no transformation needed), + # return _data directly so mutations work + if isinstance(serialized, type(value)) and serialized == value: + return self._data.get(key) + # Otherwise return serialized copy and clear flag + try: + object.__delattr__(self, cache_attr) + except AttributeError: + pass + # Store serialized form back + self._data[key] = serialized + return serialized + return self._data.__getitem__(key) + + def __setitem__(self, key: str, value: typing.Any) -> None: + # Clear any cached deserialized value when setting through dictionary access + cache_attr = f"_deserialized_{key}" + try: + object.__delattr__(self, cache_attr) + except AttributeError: + pass + self._data.__setitem__(key, value) + + def __delitem__(self, key: str) -> None: + self._data.__delitem__(key) + + def __iter__(self) -> typing.Iterator[typing.Any]: + return self._data.__iter__() + + def __len__(self) -> int: + return self._data.__len__() + + def __ne__(self, other: typing.Any) -> bool: + return not self.__eq__(other) + + def keys(self) -> typing.KeysView[str]: + """ + :returns: a set-like object providing a view on D's keys + :rtype: ~typing.KeysView + """ + return self._data.keys() + + def values(self) -> typing.ValuesView[typing.Any]: + """ + :returns: an object providing a view on D's values + :rtype: ~typing.ValuesView + """ + return self._data.values() + + def items(self) -> typing.ItemsView[str, typing.Any]: + """ + :returns: set-like object providing a view on D's items + :rtype: ~typing.ItemsView + """ + return self._data.items() + + def get(self, key: str, default: typing.Any = None) -> typing.Any: + """ + Get the value for key if key is in the dictionary, else default. + :param str key: The key to look up. + :param any default: The value to return if key is not in the dictionary. Defaults to None + :returns: D[k] if k in D, else d. + :rtype: any + """ + try: + return self[key] + except KeyError: + return default + + @typing.overload + def pop(self, key: str) -> typing.Any: ... # pylint: disable=arguments-differ + + @typing.overload + def pop(self, key: str, default: _T) -> _T: ... # pylint: disable=signature-differs + + @typing.overload + def pop(self, key: str, default: typing.Any) -> typing.Any: ... # pylint: disable=signature-differs + + def pop(self, key: str, default: typing.Any = _UNSET) -> typing.Any: + """ + Removes specified key and return the corresponding value. + :param str key: The key to pop. + :param any default: The value to return if key is not in the dictionary + :returns: The value corresponding to the key. + :rtype: any + :raises KeyError: If key is not found and default is not given. + """ + if default is _UNSET: + return self._data.pop(key) + return self._data.pop(key, default) + + def popitem(self) -> tuple[str, typing.Any]: + """ + Removes and returns some (key, value) pair + :returns: The (key, value) pair. + :rtype: tuple + :raises KeyError: if D is empty. + """ + return self._data.popitem() + + def clear(self) -> None: + """ + Remove all items from D. + """ + self._data.clear() + + def update(self, *args: typing.Any, **kwargs: typing.Any) -> None: # pylint: disable=arguments-differ + """ + Updates D from mapping/iterable E and F. + :param any args: Either a mapping object or an iterable of key-value pairs. + """ + self._data.update(*args, **kwargs) + + @typing.overload + def setdefault(self, key: str, default: None = None) -> None: ... + + @typing.overload + def setdefault(self, key: str, default: typing.Any) -> typing.Any: ... # pylint: disable=signature-differs + + def setdefault(self, key: str, default: typing.Any = _UNSET) -> typing.Any: + """ + Same as calling D.get(k, d), and setting D[k]=d if k not found + :param str key: The key to look up. + :param any default: The value to set if key is not in the dictionary + :returns: D[k] if k in D, else d. + :rtype: any + """ + if default is _UNSET: + return self._data.setdefault(key) + return self._data.setdefault(key, default) + + def __eq__(self, other: typing.Any) -> bool: + if isinstance(other, _MyMutableMapping): + return self._data == other._data + try: + other_model = self.__class__(other) + except Exception: + return False + return self._data == other_model._data + + def __repr__(self) -> str: + return str(self._data) + + +def _is_model(obj: typing.Any) -> bool: + return getattr(obj, "_is_model", False) + + +def _serialize(o, format: typing.Optional[str] = None): # pylint: disable=too-many-return-statements + if isinstance(o, list): + if format in _ARRAY_ENCODE_MAPPING and all(isinstance(x, str) for x in o): + return _ARRAY_ENCODE_MAPPING[format].join(o) + return [_serialize(x, format) for x in o] + if isinstance(o, dict): + return {k: _serialize(v, format) for k, v in o.items()} + if isinstance(o, set): + return {_serialize(x, format) for x in o} + if isinstance(o, tuple): + return tuple(_serialize(x, format) for x in o) + if isinstance(o, (bytes, bytearray)): + return _serialize_bytes(o, format) + if isinstance(o, decimal.Decimal): + return float(o) + if isinstance(o, enum.Enum): + return o.value + if isinstance(o, int): + if format == "str": + return str(o) + return o + try: + # First try datetime.datetime + return _serialize_datetime(o, format) + except AttributeError: + pass + # Last, try datetime.timedelta + try: + return _timedelta_as_isostr(o) + except AttributeError: + # This will be raised when it hits value.total_seconds in the method above + pass + return o + + +def _get_rest_field(attr_to_rest_field: dict[str, "_RestField"], rest_name: str) -> typing.Optional["_RestField"]: + try: + return next(rf for rf in attr_to_rest_field.values() if rf._rest_name == rest_name) + except StopIteration: + return None + + +def _create_value(rf: typing.Optional["_RestField"], value: typing.Any) -> typing.Any: + if not rf: + return _serialize(value, None) + if rf._is_multipart_file_input: + return value + if rf._is_model: + return _deserialize(rf._type, value) + if isinstance(value, ET.Element): + value = _deserialize(rf._type, value) + return _serialize(value, rf._format) + + +class Model(_MyMutableMapping): + _is_model = True + # label whether current class's _attr_to_rest_field has been calculated + # could not see _attr_to_rest_field directly because subclass inherits it from parent class + _calculated: set[str] = set() + + def __init__(self, *args: typing.Any, **kwargs: typing.Any) -> None: + class_name = self.__class__.__name__ + if len(args) > 1: + raise TypeError(f"{class_name}.__init__() takes 2 positional arguments but {len(args) + 1} were given") + dict_to_pass = { + rest_field._rest_name: rest_field._default + for rest_field in self._attr_to_rest_field.values() + if rest_field._default is not _UNSET + } + if args: + if isinstance(args[0], ET.Element): + dict_to_pass.update(self._init_from_xml(args[0])) + else: + dict_to_pass.update( + {k: _create_value(_get_rest_field(self._attr_to_rest_field, k), v) for k, v in args[0].items()} + ) + else: + non_attr_kwargs = [k for k in kwargs if k not in self._attr_to_rest_field] + if non_attr_kwargs: + # actual type errors only throw the first wrong keyword arg they see, so following that. + raise TypeError(f"{class_name}.__init__() got an unexpected keyword argument '{non_attr_kwargs[0]}'") + dict_to_pass.update( + { + self._attr_to_rest_field[k]._rest_name: _create_value(self._attr_to_rest_field[k], v) + for k, v in kwargs.items() + if v is not None + } + ) + super().__init__(dict_to_pass) + + def _init_from_xml(self, element: ET.Element) -> dict[str, typing.Any]: + """Deserialize an XML element into a dict mapping rest field names to values. + + :param ET.Element element: The XML element to deserialize from. + :returns: A dictionary of rest_name to deserialized value pairs. + :rtype: dict + """ + result: dict[str, typing.Any] = {} + model_meta = getattr(self, "_xml", {}) + existed_attr_keys: list[str] = [] + + for rf in self._attr_to_rest_field.values(): + prop_meta = getattr(rf, "_xml", {}) + xml_name = prop_meta.get("name", rf._rest_name) + xml_ns = _resolve_xml_ns(prop_meta, model_meta) + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + + # attribute + if prop_meta.get("attribute", False) and element.get(xml_name) is not None: + existed_attr_keys.append(xml_name) + result[rf._rest_name] = _deserialize(rf._type, element.get(xml_name)) + continue + + # unwrapped element is array + if prop_meta.get("unwrapped", False): + # unwrapped array could either use prop items meta/prop meta + _items_name = prop_meta.get("itemsName") + if _items_name: + xml_name = _items_name + _items_ns = prop_meta.get("itemsNs") + if _items_ns is not None: + xml_ns = _items_ns + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + items = element.findall(xml_name) # pyright: ignore + if len(items) > 0: + existed_attr_keys.append(xml_name) + result[rf._rest_name] = _deserialize(rf._type, items) + elif not rf._is_optional: + existed_attr_keys.append(xml_name) + result[rf._rest_name] = [] + continue + + # text element is primitive type + if prop_meta.get("text", False): + if element.text is not None: + result[rf._rest_name] = _deserialize(rf._type, element.text) + continue + + # wrapped element could be normal property or array, it should only have one element + item = element.find(xml_name) + if item is not None: + existed_attr_keys.append(xml_name) + result[rf._rest_name] = _deserialize(rf._type, item) + + # rest thing is additional properties + for e in element: + if e.tag not in existed_attr_keys: + result[e.tag] = _convert_element(e) + + return result + + def copy(self) -> "Model": + return Model(self.__dict__) + + def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: + if f"{cls.__module__}.{cls.__qualname__}" not in cls._calculated: + # we know the last nine classes in mro are going to be 'Model', '_MyMutableMapping', 'MutableMapping', + # 'Mapping', 'Collection', 'Sized', 'Iterable', 'Container' and 'object' + mros = cls.__mro__[:-9][::-1] # ignore parents, and reverse the mro order + attr_to_rest_field: dict[str, _RestField] = { # map attribute name to rest_field property + k: v for mro_class in mros for k, v in mro_class.__dict__.items() if k[0] != "_" and hasattr(v, "_type") + } + annotations = { + k: v + for mro_class in mros + if hasattr(mro_class, "__annotations__") + for k, v in mro_class.__annotations__.items() + } + for attr, rf in attr_to_rest_field.items(): + rf._module = cls.__module__ + if not rf._type: + rf._type = rf._get_deserialize_callable_from_annotation(annotations.get(attr, None)) + if not rf._rest_name_input: + rf._rest_name_input = attr + cls._attr_to_rest_field: dict[str, _RestField] = dict(attr_to_rest_field.items()) + cls._calculated.add(f"{cls.__module__}.{cls.__qualname__}") + + return super().__new__(cls) + + def __init_subclass__(cls, discriminator: typing.Optional[str] = None) -> None: + for base in cls.__bases__: + if hasattr(base, "__mapping__"): + base.__mapping__[discriminator or cls.__name__] = cls # type: ignore + + @classmethod + def _get_discriminator(cls, exist_discriminators) -> typing.Optional["_RestField"]: + for v in cls.__dict__.values(): + if isinstance(v, _RestField) and v._is_discriminator and v._rest_name not in exist_discriminators: + return v + return None + + @classmethod + def _deserialize(cls, data, exist_discriminators): + if not hasattr(cls, "__mapping__"): + return cls(data) + discriminator = cls._get_discriminator(exist_discriminators) + if discriminator is None: + return cls(data) + exist_discriminators.append(discriminator._rest_name) + if isinstance(data, ET.Element): + model_meta = getattr(cls, "_xml", {}) + prop_meta = getattr(discriminator, "_xml", {}) + xml_name = prop_meta.get("name", discriminator._rest_name) + xml_ns = _resolve_xml_ns(prop_meta, model_meta) + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + + if data.get(xml_name) is not None: + discriminator_value = data.get(xml_name) + else: + discriminator_value = data.find(xml_name).text # pyright: ignore + else: + discriminator_value = data.get(discriminator._rest_name) + mapped_cls = cls.__mapping__.get(discriminator_value, cls) # pyright: ignore # pylint: disable=no-member + return mapped_cls._deserialize(data, exist_discriminators) + + def as_dict(self, *, exclude_readonly: bool = False) -> dict[str, typing.Any]: + """Return a dict that can be turned into json using json.dump. + + :keyword bool exclude_readonly: Whether to remove the readonly properties. + :returns: A dict JSON compatible object + :rtype: dict + """ + + result = {} + readonly_props = [] + if exclude_readonly: + readonly_props = [p._rest_name for p in self._attr_to_rest_field.values() if _is_readonly(p)] + for k, v in self.items(): + if exclude_readonly and k in readonly_props: # pyright: ignore + continue + is_multipart_file_input = False + try: + is_multipart_file_input = next( + rf for rf in self._attr_to_rest_field.values() if rf._rest_name == k + )._is_multipart_file_input + except StopIteration: + pass + result[k] = v if is_multipart_file_input else Model._as_dict_value(v, exclude_readonly=exclude_readonly) + return result + + @staticmethod + def _as_dict_value(v: typing.Any, exclude_readonly: bool = False) -> typing.Any: + if v is None or isinstance(v, _Null): + return None + if isinstance(v, (list, tuple, set)): + return type(v)(Model._as_dict_value(x, exclude_readonly=exclude_readonly) for x in v) + if isinstance(v, dict): + return {dk: Model._as_dict_value(dv, exclude_readonly=exclude_readonly) for dk, dv in v.items()} + return v.as_dict(exclude_readonly=exclude_readonly) if hasattr(v, "as_dict") else v + + +def _deserialize_model(model_deserializer: typing.Optional[typing.Callable], obj): + if _is_model(obj): + return obj + return _deserialize(model_deserializer, obj) + + +def _deserialize_with_optional(if_obj_deserializer: typing.Optional[typing.Callable], obj): + if obj is None: + return obj + return _deserialize_with_callable(if_obj_deserializer, obj) + + +def _deserialize_with_union(deserializers, obj): + for deserializer in deserializers: + try: + return _deserialize(deserializer, obj) + except DeserializationError: + pass + raise DeserializationError() + + +def _deserialize_dict( + value_deserializer: typing.Optional[typing.Callable], + module: typing.Optional[str], + obj: dict[typing.Any, typing.Any], +): + if obj is None: + return obj + if isinstance(obj, ET.Element): + obj = {child.tag: child for child in obj} + return {k: _deserialize(value_deserializer, v, module) for k, v in obj.items()} + + +def _deserialize_multiple_sequence( + entry_deserializers: list[typing.Optional[typing.Callable]], + module: typing.Optional[str], + obj, +): + if obj is None: + return obj + return type(obj)(_deserialize(deserializer, entry, module) for entry, deserializer in zip(obj, entry_deserializers)) + + +def _is_array_encoded_deserializer(deserializer: functools.partial) -> bool: + return ( + isinstance(deserializer, functools.partial) + and isinstance(deserializer.args[0], functools.partial) + and deserializer.args[0].func == _deserialize_array_encoded # pylint: disable=comparison-with-callable + ) + + +def _deserialize_sequence( + deserializer: typing.Optional[typing.Callable], + module: typing.Optional[str], + obj, +): + if obj is None: + return obj + if isinstance(obj, ET.Element): + obj = list(obj) + + # encoded string may be deserialized to sequence + if isinstance(obj, str) and isinstance(deserializer, functools.partial): + # for list[str] + if _is_array_encoded_deserializer(deserializer): + return deserializer(obj) + + # for list[Union[...]] + if isinstance(deserializer.args[0], list): + for sub_deserializer in deserializer.args[0]: + if _is_array_encoded_deserializer(sub_deserializer): + return sub_deserializer(obj) + + return type(obj)(_deserialize(deserializer, entry, module) for entry in obj) + + +def _sorted_annotations(types: list[typing.Any]) -> list[typing.Any]: + return sorted( + types, + key=lambda x: hasattr(x, "__name__") and x.__name__.lower() in ("str", "float", "int", "bool"), + ) + + +def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-return-statements, too-many-statements, too-many-branches + annotation: typing.Any, + module: typing.Optional[str], + rf: typing.Optional["_RestField"] = None, +) -> typing.Optional[typing.Callable[[typing.Any], typing.Any]]: + if not annotation: + return None + + # is it a type alias? + if isinstance(annotation, str): + if module is not None: + annotation = _get_type_alias_type(module, annotation) + + # is it a forward ref / in quotes? + if isinstance(annotation, (str, typing.ForwardRef)): + try: + model_name = annotation.__forward_arg__ # type: ignore + except AttributeError: + model_name = annotation + if module is not None: + annotation = _get_model(module, model_name) # type: ignore + + try: + if module and _is_model(annotation): + if rf: + rf._is_model = True + + return functools.partial(_deserialize_model, annotation) # pyright: ignore + except Exception: + pass + + # is it a literal? + try: + if annotation.__origin__ is typing.Literal: # pyright: ignore + return None + except AttributeError: + pass + + # is it optional? + try: + if any(a is _NONE_TYPE for a in annotation.__args__): # pyright: ignore + if rf: + rf._is_optional = True + if len(annotation.__args__) <= 2: # pyright: ignore + if_obj_deserializer = _get_deserialize_callable_from_annotation( + next(a for a in annotation.__args__ if a is not _NONE_TYPE), module, rf # pyright: ignore + ) + + return functools.partial(_deserialize_with_optional, if_obj_deserializer) + # the type is Optional[Union[...]], we need to remove the None type from the Union + annotation_copy = copy.copy(annotation) + annotation_copy.__args__ = [a for a in annotation_copy.__args__ if a is not _NONE_TYPE] # pyright: ignore + return _get_deserialize_callable_from_annotation(annotation_copy, module, rf) + except AttributeError: + pass + + # is it union? + if getattr(annotation, "__origin__", None) is typing.Union: + # initial ordering is we make `string` the last deserialization option, because it is often them most generic + deserializers = [ + _get_deserialize_callable_from_annotation(arg, module, rf) + for arg in _sorted_annotations(annotation.__args__) # pyright: ignore + ] + + return functools.partial(_deserialize_with_union, deserializers) + + try: + annotation_name = ( + annotation.__name__ if hasattr(annotation, "__name__") else annotation._name # pyright: ignore + ) + if annotation_name.lower() == "dict": + value_deserializer = _get_deserialize_callable_from_annotation( + annotation.__args__[1], module, rf # pyright: ignore + ) + + return functools.partial( + _deserialize_dict, + value_deserializer, + module, + ) + except (AttributeError, IndexError): + pass + try: + annotation_name = ( + annotation.__name__ if hasattr(annotation, "__name__") else annotation._name # pyright: ignore + ) + if annotation_name.lower() in ["list", "set", "tuple", "sequence"]: + if len(annotation.__args__) > 1: # pyright: ignore + entry_deserializers = [ + _get_deserialize_callable_from_annotation(dt, module, rf) + for dt in annotation.__args__ # pyright: ignore + ] + return functools.partial(_deserialize_multiple_sequence, entry_deserializers, module) + deserializer = _get_deserialize_callable_from_annotation( + annotation.__args__[0], module, rf # pyright: ignore + ) + + return functools.partial(_deserialize_sequence, deserializer, module) + except (TypeError, IndexError, AttributeError, SyntaxError): + pass + + def _deserialize_default( + deserializer, + obj, + ): + if obj is None: + return obj + try: + return _deserialize_with_callable(deserializer, obj) + except Exception: + pass + return obj + + if get_deserializer(annotation, rf): + return functools.partial(_deserialize_default, get_deserializer(annotation, rf)) + + return functools.partial(_deserialize_default, annotation) + + +def _deserialize_with_callable( + deserializer: typing.Optional[typing.Callable[[typing.Any], typing.Any]], + value: typing.Any, +): # pylint: disable=too-many-return-statements + try: + if value is None or isinstance(value, _Null): + return None + if isinstance(value, ET.Element): + if deserializer is str: + return value.text or "" + if deserializer is int: + return int(value.text) if value.text else None + if deserializer is float: + return float(value.text) if value.text else None + if deserializer is bool: + return value.text == "true" if value.text else None + if deserializer and deserializer in _DESERIALIZE_MAPPING.values(): + return deserializer(value.text) if value.text else None + if deserializer and deserializer in _DESERIALIZE_MAPPING_WITHFORMAT.values(): + return deserializer(value.text) if value.text else None + if deserializer is None: + return value + if deserializer in [int, float, bool]: + return deserializer(value) + if isinstance(deserializer, CaseInsensitiveEnumMeta): + try: + return deserializer(value.text if isinstance(value, ET.Element) else value) + except ValueError: + # for unknown value, return raw value + return value.text if isinstance(value, ET.Element) else value + if isinstance(deserializer, type) and issubclass(deserializer, Model): + return deserializer._deserialize(value, []) + return typing.cast(typing.Callable[[typing.Any], typing.Any], deserializer)(value) + except Exception as e: + raise DeserializationError() from e + + +def _deserialize( + deserializer: typing.Any, + value: typing.Any, + module: typing.Optional[str] = None, + rf: typing.Optional["_RestField"] = None, + format: typing.Optional[str] = None, +) -> typing.Any: + if isinstance(value, PipelineResponse): + value = value.http_response.json() + if rf is None and format: + rf = _RestField(format=format) + if not isinstance(deserializer, functools.partial): + deserializer = _get_deserialize_callable_from_annotation(deserializer, module, rf) + return _deserialize_with_callable(deserializer, value) + + +def _failsafe_deserialize( + deserializer: typing.Any, + response: HttpResponse, + module: typing.Optional[str] = None, + rf: typing.Optional["_RestField"] = None, + format: typing.Optional[str] = None, +) -> typing.Any: + try: + return _deserialize(deserializer, response.json(), module, rf, format) + except Exception: # pylint: disable=broad-except + _LOGGER.warning( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + +def _failsafe_deserialize_xml( + deserializer: typing.Any, + response: HttpResponse, +) -> typing.Any: + try: + return _deserialize_xml(deserializer, response.text()) + except Exception: # pylint: disable=broad-except + _LOGGER.warning( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + +# pylint: disable=too-many-instance-attributes +class _RestField: + def __init__( + self, + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + is_discriminator: bool = False, + visibility: typing.Optional[list[str]] = None, + default: typing.Any = _UNSET, + format: typing.Optional[str] = None, + is_multipart_file_input: bool = False, + xml: typing.Optional[dict[str, typing.Any]] = None, + ): + self._type = type + self._rest_name_input = name + self._module: typing.Optional[str] = None + self._is_discriminator = is_discriminator + self._visibility = visibility + self._is_model = False + self._is_optional = False + self._default = default + self._format = format + self._is_multipart_file_input = is_multipart_file_input + self._xml = xml if xml is not None else {} + + @property + def _class_type(self) -> typing.Any: + result = getattr(self._type, "args", [None])[0] + # type may be wrapped by nested functools.partial so we need to check for that + if isinstance(result, functools.partial): + return getattr(result, "args", [None])[0] + return result + + @property + def _rest_name(self) -> str: + if self._rest_name_input is None: + raise ValueError("Rest name was never set") + return self._rest_name_input + + def __get__(self, obj: Model, type=None): # pylint: disable=redefined-builtin + # by this point, type and rest_name will have a value bc we default + # them in __new__ of the Model class + # Use _data.get() directly to avoid triggering __getitem__ which clears the cache + item = obj._data.get(self._rest_name) + if item is None: + return item + if self._is_model: + return item + + # For mutable types, we want mutations to directly affect _data + # Check if we've already deserialized this value + cache_attr = f"_deserialized_{self._rest_name}" + if hasattr(obj, cache_attr): + # Return the value from _data directly (it's been deserialized in place) + return obj._data.get(self._rest_name) + + deserialized = _deserialize(self._type, _serialize(item, self._format), rf=self) + + # For mutable types, store the deserialized value back in _data + # so mutations directly affect _data + if isinstance(deserialized, (dict, list, set)): + obj._data[self._rest_name] = deserialized + object.__setattr__(obj, cache_attr, True) # Mark as deserialized + return deserialized + + return deserialized + + def __set__(self, obj: Model, value) -> None: + # Clear the cached deserialized object when setting a new value + cache_attr = f"_deserialized_{self._rest_name}" + if hasattr(obj, cache_attr): + object.__delattr__(obj, cache_attr) + + if value is None: + # we want to wipe out entries if users set attr to None + try: + obj.__delitem__(self._rest_name) + except KeyError: + pass + return + if self._is_model: + if not _is_model(value): + value = _deserialize(self._type, value) + obj.__setitem__(self._rest_name, value) + return + obj.__setitem__(self._rest_name, _serialize(value, self._format)) + + def _get_deserialize_callable_from_annotation( + self, annotation: typing.Any + ) -> typing.Optional[typing.Callable[[typing.Any], typing.Any]]: + return _get_deserialize_callable_from_annotation(annotation, self._module, self) + + +def rest_field( + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + visibility: typing.Optional[list[str]] = None, + default: typing.Any = _UNSET, + format: typing.Optional[str] = None, + is_multipart_file_input: bool = False, + xml: typing.Optional[dict[str, typing.Any]] = None, +) -> typing.Any: + return _RestField( + name=name, + type=type, + visibility=visibility, + default=default, + format=format, + is_multipart_file_input=is_multipart_file_input, + xml=xml, + ) + + +def rest_discriminator( + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + visibility: typing.Optional[list[str]] = None, + xml: typing.Optional[dict[str, typing.Any]] = None, +) -> typing.Any: + return _RestField(name=name, type=type, is_discriminator=True, visibility=visibility, xml=xml) + + +def serialize_xml(model: Model, exclude_readonly: bool = False) -> str: + """Serialize a model to XML. + + :param Model model: The model to serialize. + :param bool exclude_readonly: Whether to exclude readonly properties. + :returns: The XML representation of the model. + :rtype: str + """ + return ET.tostring(_get_element(model, exclude_readonly), encoding="unicode") # type: ignore + + +def _get_xml_ns(meta: dict[str, typing.Any]) -> typing.Optional[str]: + """Return the XML namespace from a metadata dict, checking both 'ns' (old-style) and 'namespace' (DPG) keys. + + :param dict meta: The metadata dictionary to extract namespace from. + :returns: The namespace string if 'ns' or 'namespace' key is present, None otherwise. + :rtype: str or None + """ + ns = meta.get("ns") + if ns is None: + ns = meta.get("namespace") + return ns + + +def _resolve_xml_ns( + prop_meta: dict[str, typing.Any], model_meta: typing.Optional[dict[str, typing.Any]] = None +) -> typing.Optional[str]: + """Resolve XML namespace for a property, falling back to model namespace when appropriate. + + Checks the property metadata first; if no namespace is found and the model does not declare + an explicit prefix, falls back to the model-level namespace. + + :param dict prop_meta: The property metadata dictionary. + :param dict model_meta: The model metadata dictionary, used as fallback. + :returns: The resolved namespace string, or None. + :rtype: str or None + """ + ns = _get_xml_ns(prop_meta) + if ns is None and model_meta is not None and not model_meta.get("prefix"): + ns = _get_xml_ns(model_meta) + return ns + + +def _set_xml_attribute(element: ET.Element, name: str, value: typing.Any, prop_meta: dict[str, typing.Any]) -> None: + """Set an XML attribute on an element, handling namespace prefix registration. + + :param ET.Element element: The element to set the attribute on. + :param str name: The default attribute name (wire name). + :param any value: The attribute value. + :param dict prop_meta: The property metadata dictionary. + """ + xml_name = prop_meta.get("name", name) + _attr_ns = _get_xml_ns(prop_meta) + if _attr_ns: + _attr_prefix = prop_meta.get("prefix") + if _attr_prefix: + _safe_register_namespace(_attr_prefix, _attr_ns) + xml_name = "{" + _attr_ns + "}" + xml_name + element.set(xml_name, _get_primitive_type_value(value)) + + +def _get_element( + o: typing.Any, + exclude_readonly: bool = False, + parent_meta: typing.Optional[dict[str, typing.Any]] = None, + wrapped_element: typing.Optional[ET.Element] = None, +) -> typing.Union[ET.Element, list[ET.Element]]: + if _is_model(o): + model_meta = getattr(o, "_xml", {}) + + # if prop is a model, then use the prop element directly, else generate a wrapper of model + if wrapped_element is None: + # When serializing as an array item (parent_meta is set), check if the parent has an + # explicit itemsName. This ensures correct element names for unwrapped arrays (where + # the element tag is the property/items name, not the model type name). + _items_name = parent_meta.get("itemsName") if parent_meta is not None else None + element_name = _items_name if _items_name else (model_meta.get("name") or o.__class__.__name__) + _model_ns = _get_xml_ns(model_meta) + wrapped_element = _create_xml_element( + element_name, + model_meta.get("prefix"), + _model_ns, + ) + + readonly_props = [] + if exclude_readonly: + readonly_props = [p._rest_name for p in o._attr_to_rest_field.values() if _is_readonly(p)] + + for k, v in o.items(): + # do not serialize readonly properties + if exclude_readonly and k in readonly_props: + continue + + prop_rest_field = _get_rest_field(o._attr_to_rest_field, k) + if prop_rest_field: + prop_meta = getattr(prop_rest_field, "_xml").copy() + # use the wire name as xml name if no specific name is set + if prop_meta.get("name") is None: + prop_meta["name"] = k + else: + # additional properties will not have rest field, use the wire name as xml name + prop_meta = {"name": k} + + # Propagate model namespace to properties only for old-style "ns"-keyed models. + # DPG-generated models use the "namespace" key and explicitly declare namespace on + # each property that needs it, so propagation is intentionally skipped for them. + if prop_meta.get("ns") is None and model_meta.get("ns"): + prop_meta["ns"] = model_meta.get("ns") + prop_meta["prefix"] = model_meta.get("prefix") + + if prop_meta.get("unwrapped", False): + # unwrapped could only set on array + wrapped_element.extend(_get_element(v, exclude_readonly, prop_meta)) + elif prop_meta.get("text", False): + # text could only set on primitive type + wrapped_element.text = _get_primitive_type_value(v) + elif prop_meta.get("attribute", False): + _set_xml_attribute(wrapped_element, k, v, prop_meta) + else: + # other wrapped prop element + wrapped_element.append(_get_wrapped_element(v, exclude_readonly, prop_meta)) + return wrapped_element + if isinstance(o, list): + return [_get_element(x, exclude_readonly, parent_meta) for x in o] # type: ignore + if isinstance(o, dict): + result = [] + _dict_ns = _get_xml_ns(parent_meta) if parent_meta else None + for k, v in o.items(): + result.append( + _get_wrapped_element( + v, + exclude_readonly, + { + "name": k, + "ns": _dict_ns, + "prefix": parent_meta.get("prefix") if parent_meta else None, + }, + ) + ) + return result + + # primitive case need to create element based on parent_meta + if parent_meta: + _items_ns = parent_meta.get("itemsNs") + if _items_ns is None: + _items_ns = _get_xml_ns(parent_meta) + return _get_wrapped_element( + o, + exclude_readonly, + { + "name": parent_meta.get("itemsName", parent_meta.get("name")), + "prefix": parent_meta.get("itemsPrefix", parent_meta.get("prefix")), + "ns": _items_ns, + }, + ) + + raise ValueError("Could not serialize value into xml: " + o) + + +def _get_wrapped_element( + v: typing.Any, + exclude_readonly: bool, + meta: typing.Optional[dict[str, typing.Any]], +) -> ET.Element: + _meta_ns = _get_xml_ns(meta) if meta else None + wrapped_element = _create_xml_element( + meta.get("name") if meta else None, meta.get("prefix") if meta else None, _meta_ns + ) + if isinstance(v, (dict, list)): + wrapped_element.extend(_get_element(v, exclude_readonly, meta)) + elif _is_model(v): + _get_element(v, exclude_readonly, meta, wrapped_element) + else: + wrapped_element.text = _get_primitive_type_value(v) + return wrapped_element # type: ignore[no-any-return] + + +def _get_primitive_type_value(v) -> str: + if v is True: + return "true" + if v is False: + return "false" + if isinstance(v, _Null): + return "" + return str(v) + + +def _safe_register_namespace(prefix: str, ns: str) -> None: + """Register an XML namespace prefix, handling reserved prefix patterns. + + Some prefixes (e.g. 'ns2') match Python's reserved 'ns\\d+' pattern used for + auto-generated prefixes, causing register_namespace to raise ValueError. + Falls back to directly registering in the internal namespace map. + + :param str prefix: The namespace prefix to register. + :param str ns: The namespace URI. + """ + try: + ET.register_namespace(prefix, ns) + except ValueError: + _ns_map = getattr(ET, "_namespace_map", None) + if _ns_map is not None: + _ns_map[ns] = prefix + + +def _create_xml_element( + tag: typing.Any, prefix: typing.Optional[str] = None, ns: typing.Optional[str] = None +) -> ET.Element: + if prefix and ns: + _safe_register_namespace(prefix, ns) + if ns: + return ET.Element("{" + ns + "}" + tag) + return ET.Element(tag) + + +def _deserialize_xml( + deserializer: typing.Any, + value: str, +) -> typing.Any: + element = ET.fromstring(value) # nosec + return _deserialize(deserializer, element) + + +def _convert_element(e: ET.Element): + # dict case + if len(e.attrib) > 0 or len({child.tag for child in e}) > 1: + dict_result: dict[str, typing.Any] = {} + for child in e: + if dict_result.get(child.tag) is not None: + if isinstance(dict_result[child.tag], list): + dict_result[child.tag].append(_convert_element(child)) + else: + dict_result[child.tag] = [dict_result[child.tag], _convert_element(child)] + else: + dict_result[child.tag] = _convert_element(child) + dict_result.update(e.attrib) + return dict_result + # array case + if len(e) > 0: + array_result: list[typing.Any] = [] + for child in e: + array_result.append(_convert_element(child)) + return array_result + # primitive case + return e.text diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/_utils/serialization.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/_utils/serialization.py index 6da830e0cf4a..81ec1de5922b 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/_utils/serialization.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/_utils/serialization.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/_utils/utils.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/_utils/utils.py new file mode 100644 index 000000000000..cbaa624660e4 --- /dev/null +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/_utils/utils.py @@ -0,0 +1,40 @@ +# -------------------------------------------------------------------------- +# 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) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Optional + +from azure.core import MatchConditions + + +def quote_etag(etag: Optional[str]) -> Optional[str]: + if not etag or etag == "*": + return etag + if etag.startswith("W/"): + return etag + if etag.startswith('"') and etag.endswith('"'): + return etag + if etag.startswith("'") and etag.endswith("'"): + return etag + return '"' + etag + '"' + + +def prep_if_match(etag: Optional[str], match_condition: Optional[MatchConditions]) -> Optional[str]: + if match_condition == MatchConditions.IfNotModified: + if_match = quote_etag(etag) if etag else None + return if_match + if match_condition == MatchConditions.IfPresent: + return "*" + return None + + +def prep_if_none_match(etag: Optional[str], match_condition: Optional[MatchConditions]) -> Optional[str]: + if match_condition == MatchConditions.IfModified: + if_none_match = quote_etag(etag) if etag else None + return if_none_match + if match_condition == MatchConditions.IfMissing: + return "*" + return None diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/_version.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/_version.py new file mode 100644 index 000000000000..be71c81bd282 --- /dev/null +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/_version.py @@ -0,0 +1,9 @@ +# 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) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/aio/__init__.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/aio/__init__.py index 8a9f7149c0f5..2ce417833389 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/aio/__init__.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/aio/__init__.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- # pylint: disable=wrong-import-position @@ -12,7 +12,7 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import -from ._azure_data_lake_storage_restapi import AzureDataLakeStorageRESTAPI # type: ignore +from ._client import DataLakeClient # type: ignore try: from ._patch import __all__ as _patch_all @@ -22,7 +22,7 @@ from ._patch import patch_sdk as _patch_sdk __all__ = [ - "AzureDataLakeStorageRESTAPI", + "DataLakeClient", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/aio/_azure_data_lake_storage_restapi.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/aio/_client.py similarity index 68% rename from sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/aio/_azure_data_lake_storage_restapi.py rename to sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/aio/_client.py index b15761157c8b..6fd32ba93408 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/aio/_azure_data_lake_storage_restapi.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/aio/_client.py @@ -2,55 +2,49 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python 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 +from typing import Any, Awaitable, TYPE_CHECKING 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 .._utils.serialization import Deserializer, Serializer -from ._configuration import AzureDataLakeStorageRESTAPIConfiguration +from ._configuration import DataLakeClientConfiguration from .operations import FileSystemOperations, PathOperations, ServiceOperations +if TYPE_CHECKING: + from azure.core.credentials_async import AsyncTokenCredential -class AzureDataLakeStorageRESTAPI: # pylint: disable=client-accepts-api-version-keyword - """Azure Data Lake Storage provides storage for Hadoop and other big data workloads. - :ivar service: ServiceOperations operations - :vartype service: azure.storage.filedatalake.aio.operations.ServiceOperations +class DataLakeClient: # pylint: disable=client-accepts-api-version-keyword + """DataLakeClient. + :ivar file_system: FileSystemOperations operations :vartype file_system: azure.storage.filedatalake.aio.operations.FileSystemOperations :ivar path: PathOperations operations :vartype path: azure.storage.filedatalake.aio.operations.PathOperations + :ivar service: ServiceOperations operations + :vartype service: azure.storage.filedatalake.aio.operations.ServiceOperations :param url: The URL of the service account, container, or blob that is the target of the desired operation. Required. :type url: str - :param version: Specifies the version of the operation to use for this request. Required. - :type version: str - :param base_url: Service URL. Required. Default value is "". - :type base_url: str - :param x_ms_lease_duration: The lease duration is required to acquire a lease, and specifies - the duration of the lease in seconds. The lease duration must be between 15 and 60 seconds or - -1 for infinite lease. Default value is None. - :type x_ms_lease_duration: int - :keyword resource: The value must be "filesystem" for all filesystem operations. Default value - is "filesystem". Note that overriding this default value may result in unsupported behavior. - :paramtype resource: str + :param credential: Credential used to authenticate requests to the service. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :keyword version: Specifies the version of the operation to use for this request. Known values + are "2026-06-06". Default value is "2026-06-06". Note that overriding this default value may + result in unsupported behavior. + :paramtype version: str """ - def __init__( # pylint: disable=missing-client-constructor-parameter-credential - self, url: str, version: str, base_url: str = "", x_ms_lease_duration: Optional[int] = None, **kwargs: Any - ) -> None: - self._config = AzureDataLakeStorageRESTAPIConfiguration( - url=url, version=version, x_ms_lease_duration=x_ms_lease_duration, **kwargs - ) + def __init__(self, url: str, credential: "AsyncTokenCredential", **kwargs: Any) -> None: + _endpoint = "{url}" + self._config = DataLakeClientConfiguration(url=url, credential=credential, **kwargs) _policies = kwargs.pop("policies", None) if _policies is None: @@ -69,17 +63,16 @@ def __init__( # pylint: disable=missing-client-constructor-parameter-credential 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) + self._client: AsyncPipelineClient = AsyncPipelineClient(base_url=_endpoint, 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 = Serializer() + self._deserialize = Deserializer() self._serialize.client_side_validation = False - self.service = ServiceOperations(self._client, self._config, self._serialize, self._deserialize) self.file_system = FileSystemOperations(self._client, self._config, self._serialize, self._deserialize) self.path = PathOperations(self._client, self._config, self._serialize, self._deserialize) + self.service = ServiceOperations(self._client, self._config, self._serialize, self._deserialize) - def _send_request( + def send_request( self, request: HttpRequest, *, stream: bool = False, **kwargs: Any ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. @@ -87,7 +80,7 @@ def _send_request( >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") - >>> response = await client._send_request(request) + >>> response = await client.send_request(request) For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request @@ -100,7 +93,11 @@ def _send_request( """ request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) + path_format_arguments = { + "url": self._serialize.url("self._config.url", self._config.url, "str", skip_quote=True), + } + + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore async def close(self) -> None: diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/aio/_configuration.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/aio/_configuration.py index 944d6e735243..0168efeb5ba9 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/aio/_configuration.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/aio/_configuration.py @@ -2,19 +2,22 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Literal, Optional +from typing import Any, TYPE_CHECKING from azure.core.pipeline import policies -VERSION = "unknown" +from .._version import VERSION +if TYPE_CHECKING: + from azure.core.credentials_async import AsyncTokenCredential -class AzureDataLakeStorageRESTAPIConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for AzureDataLakeStorageRESTAPI. + +class DataLakeClientConfiguration: # pylint: disable=too-many-instance-attributes + """Configuration for DataLakeClient. Note that all parameters used to create this instance are saved as instance attributes. @@ -22,30 +25,27 @@ class AzureDataLakeStorageRESTAPIConfiguration: # pylint: disable=too-many-inst :param url: The URL of the service account, container, or blob that is the target of the desired operation. Required. :type url: str - :param version: Specifies the version of the operation to use for this request. Required. - :type version: str - :param x_ms_lease_duration: The lease duration is required to acquire a lease, and specifies - the duration of the lease in seconds. The lease duration must be between 15 and 60 seconds or - -1 for infinite lease. Default value is None. - :type x_ms_lease_duration: int - :keyword resource: The value must be "filesystem" for all filesystem operations. Default value - is "filesystem". Note that overriding this default value may result in unsupported behavior. - :paramtype resource: str + :param credential: Credential used to authenticate requests to the service. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :keyword version: Specifies the version of the operation to use for this request. Known values + are "2026-06-06". Default value is "2026-06-06". Note that overriding this default value may + result in unsupported behavior. + :paramtype version: str """ - def __init__(self, url: str, version: str, x_ms_lease_duration: Optional[int] = None, **kwargs: Any) -> None: - resource: Literal["filesystem"] = kwargs.pop("resource", "filesystem") + def __init__(self, url: str, credential: "AsyncTokenCredential", **kwargs: Any) -> None: + version: str = kwargs.pop("version", "2026-06-06") if url is None: raise ValueError("Parameter 'url' must not be None.") - if version is None: - raise ValueError("Parameter 'version' must not be None.") + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") self.url = url + self.credential = credential self.version = version - self.x_ms_lease_duration = x_ms_lease_duration - self.resource = resource - kwargs.setdefault("sdk_moniker", "azuredatalakestoragerestapi/{}".format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://storage.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "storage-file-datalake/{}".format(VERSION)) self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) @@ -59,3 +59,7 @@ def _configure(self, **kwargs: Any) -> None: 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") + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/aio/_patch.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/aio/_patch.py index f7dd32510333..2feffd5116f2 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/aio/_patch.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/aio/_patch.py @@ -1,14 +1,76 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# 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. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -from typing import List +from typing import Any, Optional, TYPE_CHECKING -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level +from azure.core import AsyncPipelineClient +from azure.core.pipeline import AsyncPipeline + +from ._client import DataLakeClient as GeneratedDataLakeClient +from .._patch import DataLakeClientConfiguration, RangeHeaderPolicy + +if TYPE_CHECKING: + from azure.core.credentials_async import AsyncTokenCredential + + +class DataLakeClient(GeneratedDataLakeClient): + """Async subclass of the generated DataLakeClient that allows optional credentials, + accepts a pre-built pipeline, and injects the RangeHeaderPolicy. + """ + + def __init__( + self, url: str, credential: Optional["AsyncTokenCredential"] = None, *, pipeline: Any = None, **kwargs: Any + ) -> None: + from azure.core.pipeline import policies + + from .._utils.serialization import Deserializer, Serializer + from .operations import FileSystemOperations, PathOperations, ServiceOperations + + _endpoint = "{url}" + self._config = DataLakeClientConfiguration(url=url, credential=credential, **kwargs) + + if pipeline is not None: + _wrapped_pipeline = AsyncPipeline( + transport=pipeline._transport, + policies=[RangeHeaderPolicy()] + list(pipeline._impl_policies), + ) + self._client = AsyncPipelineClient(base_url=_endpoint, pipeline=_wrapped_pipeline) + else: + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + RangeHeaderPolicy(), + 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(base_url=_endpoint, policies=_policies, **kwargs) + + self._serialize = Serializer() + self._deserialize = Deserializer() + self._serialize.client_side_validation = False + self.service = ServiceOperations(self._client, self._config, self._serialize, self._deserialize) + self.file_system = FileSystemOperations(self._client, self._config, self._serialize, self._deserialize) + self.path = PathOperations(self._client, self._config, self._serialize, self._deserialize) + + +__all__: list[str] = ["DataLakeClient"] def patch_sdk(): diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/aio/operations/__init__.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/aio/operations/__init__.py index 56a7ece347ab..5af3b3165fc0 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/aio/operations/__init__.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/aio/operations/__init__.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- # pylint: disable=wrong-import-position @@ -12,18 +12,18 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import -from ._service_operations import ServiceOperations # type: ignore -from ._file_system_operations import FileSystemOperations # type: ignore -from ._path_operations import PathOperations # type: ignore +from ._operations import FileSystemOperations # type: ignore +from ._operations import PathOperations # type: ignore +from ._operations import ServiceOperations # type: ignore from ._patch import __all__ as _patch_all from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ - "ServiceOperations", "FileSystemOperations", "PathOperations", + "ServiceOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/aio/operations/_file_system_operations.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/aio/operations/_file_system_operations.py deleted file mode 100644 index 88edb5316012..000000000000 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/aio/operations/_file_system_operations.py +++ /dev/null @@ -1,647 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from typing import Any, Callable, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._file_system_operations import ( - build_create_request, - build_delete_request, - build_get_properties_request, - build_list_blob_hierarchy_segment_request, - build_list_paths_request, - build_set_properties_request, -) -from .._configuration import AzureDataLakeStorageRESTAPIConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] - - -class FileSystemOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.storage.filedatalake.aio.AzureDataLakeStorageRESTAPI`'s - :attr:`file_system` 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: AzureDataLakeStorageRESTAPIConfiguration = ( - 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, - request_id_parameter: Optional[str] = None, - timeout: Optional[int] = None, - properties: Optional[str] = None, - **kwargs: Any - ) -> None: - """Create FileSystem. - - Create a FileSystem rooted at the specified location. If the FileSystem already exists, the - operation fails. This operation does not support conditional HTTP requests. - - :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 timeout: The timeout parameter is expressed in seconds. For more information, see - :code:`Setting - Timeouts for Blob Service Operations.`. Default value is None. - :type timeout: int - :param properties: Optional. User-defined properties to be stored with the filesystem, in the - format of a comma-separated list of name and value pairs "n1=v1, n2=v2, ...", where each value - is a base64 encoded string. Note that the string may only contain ASCII characters in the - ISO-8859-1 character set. If the filesystem exists, any properties not included in the list - will be removed. All properties are removed if the header is omitted. To merge new and - existing properties, first get all existing properties and the current E-Tag, then make a - conditional request with the E-Tag and include values for all properties. Default value is - None. - :type properties: 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 = kwargs.pop("params", {}) or {} - - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_create_request( - url=self._config.url, - version=self._config.version, - request_id_parameter=request_id_parameter, - timeout=timeout, - properties=properties, - resource=self._config.resource, - 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["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) - 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["x-ms-namespace-enabled"] = self._deserialize( - "str", response.headers.get("x-ms-namespace-enabled") - ) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @distributed_trace_async - async def set_properties( - self, - request_id_parameter: Optional[str] = None, - timeout: Optional[int] = None, - properties: Optional[str] = None, - modified_access_conditions: Optional[_models.ModifiedAccessConditions] = None, - **kwargs: Any - ) -> None: - """Set FileSystem Properties. - - Set properties for the FileSystem. This operation supports conditional HTTP requests. For - more information, see `Specifying Conditional Headers for Blob Service Operations - `_. - - :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 timeout: The timeout parameter is expressed in seconds. For more information, see - :code:`Setting - Timeouts for Blob Service Operations.`. Default value is None. - :type timeout: int - :param properties: Optional. User-defined properties to be stored with the filesystem, in the - format of a comma-separated list of name and value pairs "n1=v1, n2=v2, ...", where each value - is a base64 encoded string. Note that the string may only contain ASCII characters in the - ISO-8859-1 character set. If the filesystem exists, any properties not included in the list - will be removed. All properties are removed if the header is omitted. To merge new and - existing properties, first get all existing properties and the current E-Tag, then make a - conditional request with the E-Tag and include values for all properties. Default value is - None. - :type properties: str - :param modified_access_conditions: Parameter group. Default value is None. - :type modified_access_conditions: ~azure.storage.filedatalake.models.ModifiedAccessConditions - :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) - - _if_modified_since = None - _if_unmodified_since = None - if modified_access_conditions is not None: - _if_modified_since = modified_access_conditions.if_modified_since - _if_unmodified_since = modified_access_conditions.if_unmodified_since - - _request = build_set_properties_request( - url=self._config.url, - version=self._config.version, - request_id_parameter=request_id_parameter, - timeout=timeout, - properties=properties, - if_modified_since=_if_modified_since, - if_unmodified_since=_if_unmodified_since, - resource=self._config.resource, - 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["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) - 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")) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @distributed_trace_async - async def get_properties( - self, request_id_parameter: Optional[str] = None, timeout: Optional[int] = None, **kwargs: Any - ) -> None: - """Get FileSystem Properties. - - All system and user-defined filesystem properties are specified in the response headers. - - :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 timeout: The timeout parameter is expressed in seconds. For more information, see - :code:`Setting - Timeouts for Blob Service Operations.`. 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 = kwargs.pop("params", {}) or {} - - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_get_properties_request( - url=self._config.url, - version=self._config.version, - request_id_parameter=request_id_parameter, - timeout=timeout, - resource=self._config.resource, - 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["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) - 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["x-ms-properties"] = self._deserialize("str", response.headers.get("x-ms-properties")) - response_headers["x-ms-namespace-enabled"] = self._deserialize( - "str", response.headers.get("x-ms-namespace-enabled") - ) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @distributed_trace_async - async def delete( - self, - request_id_parameter: Optional[str] = None, - timeout: Optional[int] = None, - modified_access_conditions: Optional[_models.ModifiedAccessConditions] = None, - **kwargs: Any - ) -> None: - """Delete FileSystem. - - Marks the FileSystem for deletion. When a FileSystem is deleted, a FileSystem with the same - identifier cannot be created for at least 30 seconds. While the filesystem is being deleted, - attempts to create a filesystem with the same identifier will fail with status code 409 - (Conflict), with the service returning additional error information indicating that the - filesystem is being deleted. All other operations, including operations on any files or - directories within the filesystem, will fail with status code 404 (Not Found) while the - filesystem is being deleted. This operation supports conditional HTTP requests. For more - information, see `Specifying Conditional Headers for Blob Service Operations - `_. - - :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 timeout: The timeout parameter is expressed in seconds. For more information, see - :code:`Setting - Timeouts for Blob Service Operations.`. Default value is None. - :type timeout: int - :param modified_access_conditions: Parameter group. Default value is None. - :type modified_access_conditions: ~azure.storage.filedatalake.models.ModifiedAccessConditions - :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) - - _if_modified_since = None - _if_unmodified_since = None - if modified_access_conditions is not None: - _if_modified_since = modified_access_conditions.if_modified_since - _if_unmodified_since = modified_access_conditions.if_unmodified_since - - _request = build_delete_request( - url=self._config.url, - version=self._config.version, - request_id_parameter=request_id_parameter, - timeout=timeout, - if_modified_since=_if_modified_since, - if_unmodified_since=_if_unmodified_since, - resource=self._config.resource, - 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 list_paths( - self, - recursive: bool, - request_id_parameter: Optional[str] = None, - timeout: Optional[int] = None, - continuation: Optional[str] = None, - path: Optional[str] = None, - max_results: Optional[int] = None, - upn: Optional[bool] = None, - begin_from: Optional[str] = None, - **kwargs: Any - ) -> _models.PathList: - """List Paths. - - List FileSystem paths and their properties. - - :param recursive: Required. Required. - :type recursive: bool - :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 timeout: The timeout parameter is expressed in seconds. For more information, see - :code:`Setting - Timeouts for Blob Service Operations.`. Default value is None. - :type timeout: int - :param continuation: Optional. When deleting a directory, the number of paths that are deleted - with each invocation is limited. If the number of paths to be deleted exceeds this limit, a - continuation token is returned in this response header. When a continuation token is returned - in the response, it must be specified in a subsequent invocation of the delete operation to - continue deleting the directory. Default value is None. - :type continuation: str - :param path: Optional. Filters results to paths within the specified directory. An error - occurs if the directory does not exist. Default value is None. - :type path: str - :param max_results: An optional value that specifies the maximum number of items to return. If - omitted or greater than 5,000, the response will include up to 5,000 items. Default value is - None. - :type max_results: int - :param upn: Optional. Valid only when Hierarchical Namespace is enabled for the account. If - "true", the user identity values returned in the x-ms-owner, x-ms-group, and x-ms-acl response - headers will be transformed from Azure Active Directory Object IDs to User Principal Names. If - "false", the values will be returned as Azure Active Directory Object IDs. The default value is - false. Note that group and application Object IDs are not translated because they do not have - unique friendly names. Default value is None. - :type upn: bool - :param begin_from: Optional. A relative path within the specified directory where the listing - will start from. For example, a recursive listing under directory folder1/folder2 with - beginFrom as folder3/readmefile.txt will start listing from - folder1/folder2/folder3/readmefile.txt. Please note that, multiple entity levels are supported - for recursive listing. Non-recursive listing supports only one entity level. An error will - appear if multiple entity levels are specified for non-recursive listing. Default value is - None. - :type begin_from: str - :return: PathList or the result of cls(response) - :rtype: ~azure.storage.filedatalake.models.PathList - :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[_models.PathList] = kwargs.pop("cls", None) - - _request = build_list_paths_request( - url=self._config.url, - recursive=recursive, - version=self._config.version, - request_id_parameter=request_id_parameter, - timeout=timeout, - continuation=continuation, - path=path, - max_results=max_results, - upn=upn, - begin_from=begin_from, - resource=self._config.resource, - 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["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) - 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["x-ms-continuation"] = self._deserialize("str", response.headers.get("x-ms-continuation")) - - deserialized = self._deserialize("PathList", 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_blob_hierarchy_segment( - self, - prefix: Optional[str] = None, - delimiter: Optional[str] = None, - marker: Optional[str] = None, - max_results: Optional[int] = None, - include: Optional[list[Union[str, _models.ListBlobsIncludeItem]]] = None, - showonly: Literal["deleted"] = "deleted", - timeout: Optional[int] = None, - request_id_parameter: Optional[str] = None, - **kwargs: Any - ) -> _models.ListBlobsHierarchySegmentResponse: - """The List Blobs operation returns a list of the blobs under the specified container. - - :param prefix: Filters results to filesystems within the specified prefix. Default value is - None. - :type prefix: str - :param delimiter: When the request includes this parameter, the operation returns a BlobPrefix - element in the response body that acts as a placeholder for all blobs whose names begin with - the same substring up to the appearance of the delimiter character. The delimiter may be a - single character or a string. Default value is None. - :type delimiter: str - :param marker: A string value that identifies the portion of the list of containers to be - returned with the next listing operation. The operation returns the NextMarker value within the - response body if the listing operation did not return all containers remaining to be listed - with the current page. The NextMarker value can be used as the value for the marker parameter - in a subsequent call to request the next page of list items. The marker value is opaque to the - client. Default value is None. - :type marker: str - :param max_results: An optional value that specifies the maximum number of items to return. If - omitted or greater than 5,000, the response will include up to 5,000 items. Default value is - None. - :type max_results: 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.filedatalake.models.ListBlobsIncludeItem] - :param showonly: Include this parameter to specify one or more datasets to include in the - response. Known values are "deleted" and None. Default value is "deleted". - :type showonly: str - :param timeout: The timeout parameter is expressed in seconds. For more information, see - :code:`Setting - Timeouts for Blob Service Operations.`. 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: ListBlobsHierarchySegmentResponse or the result of cls(response) - :rtype: ~azure.storage.filedatalake.models.ListBlobsHierarchySegmentResponse - :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["container"] = kwargs.pop("restype", _params.pop("restype", "container")) - comp: Literal["list"] = kwargs.pop("comp", _params.pop("comp", "list")) - cls: ClsType[_models.ListBlobsHierarchySegmentResponse] = kwargs.pop("cls", None) - - _request = build_list_blob_hierarchy_segment_request( - url=self._config.url, - version=self._config.version, - prefix=prefix, - delimiter=delimiter, - marker=marker, - max_results=max_results, - include=include, - showonly=showonly, - timeout=timeout, - request_id_parameter=request_id_parameter, - restype=restype, - comp=comp, - 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-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")) - - deserialized = self._deserialize("ListBlobsHierarchySegmentResponse", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/aio/operations/_operations.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/aio/operations/_operations.py new file mode 100644 index 000000000000..a589bff0df3e --- /dev/null +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/aio/operations/_operations.py @@ -0,0 +1,2701 @@ +# pylint: disable=line-too-long,useless-suppression,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) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +import datetime +from typing import Any, AsyncIterator, Callable, Optional, TypeVar, Union + +from azure.core import AsyncPipelineClient, MatchConditions +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceModifiedError, + 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 ..._utils.model_base import _deserialize, _deserialize_xml, _failsafe_deserialize +from ..._utils.serialization import Deserializer, Serializer +from ...operations._operations import ( + build_file_system_create_request, + build_file_system_delete_request, + build_file_system_get_properties_request, + build_file_system_list_blob_hierarchy_segment_request, + build_file_system_list_paths_request, + build_file_system_set_properties_request, + build_path_append_data_request, + build_path_create_request, + build_path_delete_request, + build_path_flush_data_request, + build_path_get_properties_request, + build_path_lease_request, + build_path_read_request, + build_path_set_access_control_recursive_request, + build_path_set_access_control_request, + build_path_set_expiry_request, + build_path_undelete_request, + build_path_update_request, + build_service_list_file_systems_request, +) +from .._configuration import DataLakeClientConfiguration + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] + + +class FileSystemOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.storage.filedatalake.aio.DataLakeClient`'s + :attr:`file_system` attribute. + """ + + 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: DataLakeClientConfiguration = 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, + *, + resource: Union[str, _models.FileSystemResourceType], + properties: Optional[str] = None, + timeout: Optional[int] = None, + **kwargs: Any + ) -> None: + """Create a FileSystem rooted at the specified location. If the FileSystem already exists, the + operation fails. This operation does not support conditional HTTP requests. + + :keyword resource: The value must be "filesystem" for all filesystem operations. "filesystem" + Required. + :paramtype resource: str or ~azure.storage.filedatalake.models.FileSystemResourceType + :keyword properties: Optional. User-defined properties to be stored with the filesystem, in the + format of a comma-separated list of name and value pairs "n1=v1, n2=v2, ...", where each value + is a base64 encoded string. Note that the string may only contain ASCII characters in the + ISO-8859-1 character set. If the filesystem exists, any properties not included in the list + will be removed. All properties are removed if the header is omitted. To merge new and existing + properties, first get all existing properties and the current E-Tag, then make a conditional + request with the E-Tag and include values for all properties. Default value is None. + :paramtype properties: str + :keyword timeout: The timeout parameter is expressed in seconds. For more information, see Setting + Timeouts for Blob Service Operations.. Default value is None. + :paramtype timeout: int + :return: None + :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) + + _request = build_file_system_create_request( + resource=resource, + properties=properties, + timeout=timeout, + version=self._config.version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "url": self._serialize.url("self._config.url", self._config.url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.StorageError, + 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-namespace-enabled"] = self._deserialize( + "str", response.headers.get("x-ms-namespace-enabled") + ) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + 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") + ) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace_async + async def set_properties( + self, + *, + resource: Union[str, _models.FileSystemResourceType], + properties: Optional[str] = None, + if_modified_since: Optional[datetime.datetime] = None, + if_unmodified_since: Optional[datetime.datetime] = None, + timeout: Optional[int] = None, + **kwargs: Any + ) -> None: + """Set properties for the FileSystem. This operation supports conditional HTTP requests. For more + information, see `Specifying Conditional Headers for Blob Service Operations + `_. + + :keyword resource: The value must be "filesystem" for all filesystem operations. "filesystem" + Required. + :paramtype resource: str or ~azure.storage.filedatalake.models.FileSystemResourceType + :keyword properties: Optional. User-defined properties to be stored with the filesystem, in the + format of a comma-separated list of name and value pairs "n1=v1, n2=v2, ...", where each value + is a base64 encoded string. Note that the string may only contain ASCII characters in the + ISO-8859-1 character set. If the filesystem exists, any properties not included in the list + will be removed. All properties are removed if the header is omitted. To merge new and existing + properties, first get all existing properties and the current E-Tag, then make a conditional + request with the E-Tag and include values for all properties. Default value is None. + :paramtype properties: str + :keyword if_modified_since: Specify this header value to operate only on a blob if it has been + modified since the specified date/time. Default value is None. + :paramtype if_modified_since: ~datetime.datetime + :keyword if_unmodified_since: Specify this header value to operate only on a blob if it has not + been modified since the specified date/time. Default value is None. + :paramtype if_unmodified_since: ~datetime.datetime + :keyword timeout: The timeout parameter is expressed in seconds. For more information, see Setting + Timeouts for Blob Service Operations.. Default value is None. + :paramtype timeout: int + :return: None + :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) + + _request = build_file_system_set_properties_request( + resource=resource, + properties=properties, + if_modified_since=if_modified_since, + if_unmodified_since=if_unmodified_since, + timeout=timeout, + version=self._config.version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "url": self._serialize.url("self._config.url", self._config.url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.StorageError, + 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["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + 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") + ) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace_async + async def get_properties( + self, *, resource: Union[str, _models.FileSystemResourceType], timeout: Optional[int] = None, **kwargs: Any + ) -> bool: + """All system and user-defined filesystem properties are specified in the response headers. + + :keyword resource: The value must be "filesystem" for all filesystem operations. "filesystem" + Required. + :paramtype resource: str or ~azure.storage.filedatalake.models.FileSystemResourceType + :keyword timeout: The timeout parameter is expressed in seconds. For more information, see Setting + Timeouts for Blob Service Operations.. Default value is None. + :paramtype timeout: int + :return: bool + :rtype: bool + :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) + + _request = build_file_system_get_properties_request( + resource=resource, + timeout=timeout, + version=self._config.version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "url": self._serialize.url("self._config.url", self._config.url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.StorageError, + 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-properties"] = self._deserialize("str", response.headers.get("x-ms-properties")) + response_headers["x-ms-namespace-enabled"] = self._deserialize( + "str", response.headers.get("x-ms-namespace-enabled") + ) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + 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") + ) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + return 200 <= response.status_code <= 299 + + @distributed_trace_async + async def delete( + self, + *, + resource: Union[str, _models.FileSystemResourceType], + if_modified_since: Optional[datetime.datetime] = None, + if_unmodified_since: Optional[datetime.datetime] = None, + timeout: Optional[int] = None, + **kwargs: Any + ) -> None: + """Marks the FileSystem for deletion. When a FileSystem is deleted, a FileSystem with the same + identifier cannot be created for at least 30 seconds. While the filesystem is being deleted, + attempts to create a filesystem with the same identifier will fail with status code 409 + (Conflict), with the service returning additional error information indicating that the + filesystem is being deleted. All other operations, including operations on any files or + directories within the filesystem, will fail with status code 404 (Not Found) while the + filesystem is being deleted. This operation supports conditional HTTP requests. For more + information, see `Specifying Conditional Headers for Blob Service Operations + `_. + + :keyword resource: The value must be "filesystem" for all filesystem operations. "filesystem" + Required. + :paramtype resource: str or ~azure.storage.filedatalake.models.FileSystemResourceType + :keyword if_modified_since: Specify this header value to operate only on a blob if it has been + modified since the specified date/time. Default value is None. + :paramtype if_modified_since: ~datetime.datetime + :keyword if_unmodified_since: Specify this header value to operate only on a blob if it has not + been modified since the specified date/time. Default value is None. + :paramtype if_unmodified_since: ~datetime.datetime + :keyword timeout: The timeout parameter is expressed in seconds. For more information, see Setting + Timeouts for Blob Service Operations.. Default value is None. + :paramtype timeout: int + :return: None + :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) + + _request = build_file_system_delete_request( + resource=resource, + if_modified_since=if_modified_since, + if_unmodified_since=if_unmodified_since, + timeout=timeout, + version=self._config.version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "url": self._serialize.url("self._config.url", self._config.url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.StorageError, + response, + ) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + 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") + ) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace_async + async def list_paths( + self, + *, + recursive: bool, + continuation: Optional[str] = None, + path: Optional[str] = None, + max_results: Optional[int] = None, + upn: Optional[bool] = None, + begin_from: Optional[str] = None, + timeout: Optional[int] = None, + **kwargs: Any + ) -> _models.PathList: + """List FileSystem paths and their properties. + + :keyword recursive: Required. Required. + :paramtype recursive: bool + :keyword continuation: Optional. When deleting a directory, the number of paths that are + deleted with each invocation is limited. If the number of paths to be deleted exceeds this + limit, a continuation token is returned in this response header. When a continuation token is + returned in the response, it must be specified in a subsequent invocation of the delete + operation to continue deleting the directory. Default value is None. + :paramtype continuation: str + :keyword path: Optional. Filters results to paths within the specified directory. An error + occurs if the directory does not exist. Default value is None. + :paramtype path: str + :keyword max_results: An optional value that specifies the maximum number of items to return. + If omitted or greater than 5,000, the response will include up to 5,000 items. Default value is + None. + :paramtype max_results: int + :keyword upn: Optional. Valid only when Hierarchical Namespace is enabled for the account. If + "true", the user identity values returned in the x-ms-owner, x-ms-group, and x-ms-acl response + headers will be transformed from Azure Active Directory Object IDs to User Principal Names. If + "false", the values will be returned as Azure Active Directory Object IDs. The default value is + false. Note that group and application Object IDs are not translated because they do not have + unique friendly names. Default value is None. + :paramtype upn: bool + :keyword begin_from: Optional. A relative path within the specified directory where the listing + will start from. Default value is None. + :paramtype begin_from: str + :keyword timeout: The timeout parameter is expressed in seconds. For more information, see Setting + Timeouts for Blob Service Operations.. Default value is None. + :paramtype timeout: int + :return: PathList. The PathList is compatible with MutableMapping + :rtype: ~azure.storage.filedatalake._generated.models.PathList + :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[_models.PathList] = kwargs.pop("cls", None) + + _request = build_file_system_list_paths_request( + recursive=recursive, + continuation=continuation, + path=path, + max_results=max_results, + upn=upn, + begin_from=begin_from, + timeout=timeout, + version=self._config.version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "url": self._serialize.url("self._config.url", self._config.url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.StorageError, + 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-continuation"] = self._deserialize("str", response.headers.get("x-ms-continuation")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + 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["Content-Type"] = self._deserialize("str", response.headers.get("Content-Type")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PathList, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def list_blob_hierarchy_segment( + self, + *, + prefix: Optional[str] = None, + delimiter: Optional[str] = None, + marker: Optional[str] = None, + max_results: Optional[int] = None, + include: Optional[list[Union[str, _models.ListBlobsIncludeItem]]] = None, + showonly: Optional[Union[str, _models.ListBlobsShowOnly]] = None, + timeout: Optional[int] = None, + **kwargs: Any + ) -> _models.ListBlobsHierarchySegmentResponse: + """The List Blobs operation returns a list of the blobs under the specified container. + + :keyword prefix: Filters results to filesystems within the specified prefix. Default value is + None. + :paramtype prefix: str + :keyword delimiter: When the request includes this parameter, the operation returns a + BlobPrefix element in the response body that acts as a placeholder for all blobs whose names + begin with the same substring up to the appearance of the delimiter character. The delimiter + may be a single character or a string. Default value is None. + :paramtype delimiter: str + :keyword marker: A string value that identifies the portion of the list of containers to be + returned with the next listing operation. The operation returns the NextMarker value within the + response body if the listing operation did not return all containers remaining to be listed + with the current page. The NextMarker value can be used as the value for the marker parameter + in a subsequent call to request the next page of list items. The marker value is opaque to the + client. Default value is None. + :paramtype marker: str + :keyword max_results: An optional value that specifies the maximum number of items to return. + If omitted or greater than 5,000, the response will include up to 5,000 items. Default value is + None. + :paramtype max_results: int + :keyword include: Include this parameter to specify one or more datasets to include in the + response. Default value is None. + :paramtype include: list[str or ~azure.storage.filedatalake.models.ListBlobsIncludeItem] + :keyword showonly: Include this parameter to specify one or more datasets to include in the + response. "deleted" Default value is None. + :paramtype showonly: str or ~azure.storage.filedatalake.models.ListBlobsShowOnly + :keyword timeout: The timeout parameter is expressed in seconds. For more information, see Setting + Timeouts for Blob Service Operations.. Default value is None. + :paramtype timeout: int + :return: ListBlobsHierarchySegmentResponse. The ListBlobsHierarchySegmentResponse is compatible + with MutableMapping + :rtype: ~azure.storage.filedatalake._generated.models.ListBlobsHierarchySegmentResponse + :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[_models.ListBlobsHierarchySegmentResponse] = kwargs.pop("cls", None) + + _request = build_file_system_list_blob_hierarchy_segment_request( + prefix=prefix, + delimiter=delimiter, + marker=marker, + max_results=max_results, + include=include, + showonly=showonly, + timeout=timeout, + version=self._config.version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "url": self._serialize.url("self._config.url", self._config.url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.StorageError, + response, + ) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + 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["Content-Type"] = self._deserialize("str", response.headers.get("Content-Type")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize_xml(_models.ListBlobsHierarchySegmentResponse, response.text()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + +class PathOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.storage.filedatalake.aio.DataLakeClient`'s + :attr:`path` attribute. + """ + + 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: DataLakeClientConfiguration = 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( # pylint: disable=too-many-locals + self, + *, + resource: Optional[Union[str, _models.PathResourceType]] = None, + mode: Optional[Union[str, _models.PathRenameMode]] = None, + continuation: Optional[str] = None, + cache_control: Optional[str] = None, + content_encoding: Optional[str] = None, + content_language: Optional[str] = None, + content_disposition: Optional[str] = None, + content_type: Optional[str] = None, + rename_source: Optional[str] = None, + lease_id: Optional[str] = None, + source_lease_id: Optional[str] = None, + properties: Optional[str] = None, + permissions: Optional[str] = None, + umask: Optional[str] = None, + if_modified_since: Optional[datetime.datetime] = None, + if_unmodified_since: Optional[datetime.datetime] = None, + source_if_match: Optional[str] = None, + source_if_none_match: Optional[str] = None, + source_if_modified_since: Optional[datetime.datetime] = None, + source_if_unmodified_since: Optional[datetime.datetime] = None, + encryption_key: Optional[str] = None, + encryption_key_sha256: Optional[str] = None, + encryption_algorithm: Optional[Union[str, _models.EncryptionAlgorithmType]] = None, + owner: Optional[str] = None, + group: Optional[str] = None, + acl: Optional[str] = None, + proposed_lease_id: Optional[str] = None, + lease_duration: Optional[int] = None, + expiry_options: Optional[Union[str, _models.PathExpiryOptions]] = None, + expires_on: Optional[str] = None, + encryption_context: Optional[str] = None, + timeout: Optional[int] = None, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> None: + """Create or rename a file or directory. By default, the destination is overwritten and if the + destination already exists and has a lease the lease is broken. This operation supports + conditional HTTP requests. For more information, see `Specifying Conditional Headers for Blob + Service Operations + `_. + To fail if the destination already exists, use a conditional request with If-None-Match: "*". + + :keyword resource: Required only for Create File and Create Directory. The value must be "file" + or "directory". Known values are: "directory" and "file". Default value is None. + :paramtype resource: str or ~azure.storage.filedatalake.models.PathResourceType + :keyword mode: Optional. Valid only when namespace is enabled. This parameter determines the + behavior of the rename operation. The value must be "legacy" or "posix", and the default value + will be "posix". Known values are: "legacy" and "posix". Default value is None. + :paramtype mode: str or ~azure.storage.filedatalake.models.PathRenameMode + :keyword continuation: Optional. When deleting a directory, the number of paths that are + deleted with each invocation is limited. If the number of paths to be deleted exceeds this + limit, a continuation token is returned in this response header. When a continuation token is + returned in the response, it must be specified in a subsequent invocation of the delete + operation to continue deleting the directory. Default value is None. + :paramtype continuation: str + :keyword cache_control: Optional. Sets the blob's cache control. If specified, this property is + stored with the blob and returned with a read request. Default value is None. + :paramtype cache_control: str + :keyword content_encoding: Optional. Sets the blob's content encoding. If specified, this + property is stored with the blob and returned with a read request. Default value is None. + :paramtype content_encoding: str + :keyword content_language: Optional. Set the blob's content language. If specified, this + property is stored with the blob and returned with a read request. Default value is None. + :paramtype content_language: str + :keyword content_disposition: Optional. Sets the blob's Content-Disposition header. Default + value is None. + :paramtype content_disposition: str + :keyword content_type: Optional. Sets the blob's content type. If specified, this property is + stored with the blob and returned with a read request. Default value is None. + :paramtype content_type: str + :keyword rename_source: An optional file or directory to be renamed. The value must have the + following format: "/{filesystem}/{path}". If "x-ms-properties" is specified, the properties + will overwrite the existing properties; otherwise, the existing properties will be preserved. + This value must be a URL percent-encoded string. Note that the string may only contain ASCII + characters in the ISO-8859-1 character set. Default value is None. + :paramtype rename_source: str + :keyword lease_id: If specified, the operation only succeeds if the resource's lease is active + and matches this ID. Default value is None. + :paramtype lease_id: str + :keyword source_lease_id: A lease ID for the source path. If specified, the source path must + have an active lease and the lease ID must match. Default value is None. + :paramtype source_lease_id: str + :keyword properties: Optional. User-defined properties to be stored with the filesystem, in the + format of a comma-separated list of name and value pairs "n1=v1, n2=v2, ...", where each value + is a base64 encoded string. Note that the string may only contain ASCII characters in the + ISO-8859-1 character set. If the filesystem exists, any properties not included in the list + will be removed. All properties are removed if the header is omitted. To merge new and existing + properties, first get all existing properties and the current E-Tag, then make a conditional + request with the E-Tag and include values for all properties. Default value is None. + :paramtype properties: str + :keyword permissions: Optional and only valid if Hierarchical Namespace is enabled for the + account. Sets POSIX access permissions for the file owner, the file owning group, and others. + Each class may be granted read, write, or execute permission. The sticky bit is also supported. + Both symbolic (rwxrw-rw-) and 4-digit octal notation (e.g. 0766) are supported. Default value + is None. + :paramtype permissions: str + :keyword umask: Optional and only valid if Hierarchical Namespace is enabled for the account. + When creating a file or directory and the parent folder does not have a default ACL, the umask + restricts the permissions of the file or directory to be created. The resulting permission is + given by p bitwise and not u, where p is the permission and u is the umask. For example, if p + is 0777 and u is 0057, then the resulting permission is 0720. The default permission is 0777 + for a directory and 0666 for a file. The default umask is 0027. The umask must be specified in + 4-digit octal notation (e.g. 0766). Default value is None. + :paramtype umask: str + :keyword if_modified_since: Specify this header value to operate only on a blob if it has been + modified since the specified date/time. Default value is None. + :paramtype if_modified_since: ~datetime.datetime + :keyword if_unmodified_since: Specify this header value to operate only on a blob if it has not + been modified since the specified date/time. Default value is None. + :paramtype if_unmodified_since: ~datetime.datetime + :keyword source_if_match: Specify an ETag value to operate only on blobs with a matching value. + Default value is None. + :paramtype source_if_match: str + :keyword source_if_none_match: Specify an ETag value to operate only on blobs without a + matching value. Default value is None. + :paramtype source_if_none_match: str + :keyword source_if_modified_since: Specify this header value to operate only on a blob if it + has been modified since the specified date/time. Default value is None. + :paramtype source_if_modified_since: ~datetime.datetime + :keyword source_if_unmodified_since: Specify this header value to operate only on a blob if it + has not been modified since the specified date/time. Default value is None. + :paramtype source_if_unmodified_since: ~datetime.datetime + :keyword encryption_key: Optional. Specifies the encryption key to use to encrypt the data + provided in the request. If not specified, encryption is performed with the root account + encryption key. Default value is None. + :paramtype encryption_key: str + :keyword encryption_key_sha256: The SHA-256 hash of the provided encryption key. Must be + provided if the x-ms-encryption-key header is provided. Default value is None. + :paramtype encryption_key_sha256: str + :keyword encryption_algorithm: The algorithm used to produce the encryption key hash. + Currently, the only accepted value is "AES256". Must be provided if the x-ms-encryption-key + header is provided. "AES256" Default value is None. + :paramtype encryption_algorithm: str or + ~azure.storage.filedatalake.models.EncryptionAlgorithmType + :keyword owner: Optional. The owner of the blob or directory. Default value is None. + :paramtype owner: str + :keyword group: Optional. The owning group of the blob or directory. Default value is None. + :paramtype group: str + :keyword acl: Sets POSIX access control rights on files and directories. The value is a + comma-separated list of access control entries. Each access control entry (ACE) consists of a + scope, a type, a user or group identifier, and permissions in the format + "[scope:][type]:[id]:[permissions]". Default value is None. + :paramtype acl: str + :keyword proposed_lease_id: Proposed lease ID, in a GUID string format. Default value is None. + :paramtype proposed_lease_id: str + :keyword lease_duration: The lease duration is required to acquire a lease, and specifies the + duration of the lease in seconds. The lease duration must be between 15 and 60 seconds or -1 + for infinite lease. Default value is None. + :paramtype lease_duration: int + :keyword expiry_options: Required. Indicates mode of the expiry time. Known values are: + "NeverExpire", "RelativeToCreation", "RelativeToNow", and "Absolute". Default value is None. + :paramtype expiry_options: str or ~azure.storage.filedatalake.models.PathExpiryOptions + :keyword expires_on: The time to set the blob to expiry. Default value is None. + :paramtype expires_on: str + :keyword encryption_context: Specifies the encryption context to set on the file. Default value + is None. + :paramtype encryption_context: str + :keyword timeout: The timeout parameter is expressed in seconds. For more information, see Setting + Timeouts for Blob Service Operations.. Default value is None. + :paramtype timeout: int + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + 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) + + _request = build_path_create_request( + resource=resource, + mode=mode, + continuation=continuation, + cache_control=cache_control, + content_encoding=content_encoding, + content_language=content_language, + content_disposition=content_disposition, + content_type=content_type, + rename_source=rename_source, + lease_id=lease_id, + source_lease_id=source_lease_id, + properties=properties, + permissions=permissions, + umask=umask, + if_modified_since=if_modified_since, + if_unmodified_since=if_unmodified_since, + source_if_match=source_if_match, + source_if_none_match=source_if_none_match, + source_if_modified_since=source_if_modified_since, + source_if_unmodified_since=source_if_unmodified_since, + encryption_key=encryption_key, + encryption_key_sha256=encryption_key_sha256, + encryption_algorithm=encryption_algorithm, + owner=owner, + group=group, + acl=acl, + proposed_lease_id=proposed_lease_id, + lease_duration=lease_duration, + expiry_options=expiry_options, + expires_on=expires_on, + encryption_context=encryption_context, + timeout=timeout, + etag=etag, + match_condition=match_condition, + version=self._config.version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "url": self._serialize.url("self._config.url", self._config.url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.StorageError, + 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-continuation"] = self._deserialize("str", response.headers.get("x-ms-continuation")) + response_headers["Content-Length"] = self._deserialize("int", response.headers.get("Content-Length")) + response_headers["x-ms-request-server-encrypted"] = self._deserialize( + "bool", response.headers.get("x-ms-request-server-encrypted") + ) + response_headers["x-ms-encryption-key-sha256"] = self._deserialize( + "str", response.headers.get("x-ms-encryption-key-sha256") + ) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + 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") + ) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace_async + async def update( # pylint: disable=too-many-locals + self, + body: bytes, + *, + action: Union[str, _models.PathUpdateAction], + max_records: Optional[int] = None, + continuation: Optional[str] = None, + mode: Optional[Union[str, _models.PathSetAccessControlRecursiveMode]] = None, + force_flag: Optional[bool] = None, + position: Optional[int] = None, + retain_uncommitted_data: Optional[bool] = None, + close: Optional[bool] = None, + content_length: Optional[int] = None, + content_md5: Optional[bytes] = None, + lease_id: Optional[str] = None, + cache_control: Optional[str] = None, + content_disposition: Optional[str] = None, + content_encoding: Optional[str] = None, + content_language: Optional[str] = None, + properties: Optional[str] = None, + owner: Optional[str] = None, + group: Optional[str] = None, + permissions: Optional[str] = None, + acl: Optional[str] = None, + if_modified_since: Optional[datetime.datetime] = None, + if_unmodified_since: Optional[datetime.datetime] = None, + structured_body_type: Optional[str] = None, + structured_content_length: Optional[int] = None, + timeout: Optional[int] = None, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.SetAccessControlRecursiveResponse: + """Uploads data to be appended to a file, flushes (writes) previously uploaded data to a file, + sets properties for a file or directory, or sets access control for a file or directory. Data + can only be appended to a file. Concurrent writes to the same file using multiple clients are + not supported. This operation supports conditional HTTP requests. For more information, see + `Specifying Conditional Headers for Blob Service Operations + `_. + + :param body: Initial data. Required. + :type body: bytes + :keyword action: The action must be "append" to upload data to be appended to a file, "flush" + to flush previously uploaded data to a file, "setProperties" to set the properties of a file or + directory, "setAccessControl" to set the owner, group, permissions, or access control list for + a file or directory, or "setAccessControlRecursive" to set the access control list for a + directory recursively. Note that Hierarchical Namespace must be enabled for the account in + order to use access control. Also note that the Access Control List (ACL) includes permissions + for the owner, owning group, and others, so the x-ms-permissions and x-ms-acl request headers + are mutually exclusive. Known values are: "append", "flush", "setProperties", + "setAccessControl", and "setAccessControlRecursive". Required. + :paramtype action: str or ~azure.storage.filedatalake.models.PathUpdateAction + :keyword max_records: Optional. Valid for "SetAccessControlRecursive" operation. It specifies + the maximum number of files or directories on which the acl change will be applied. If omitted + or greater than 2,000, the request will process up to 2,000 items. Default value is None. + :paramtype max_records: int + :keyword continuation: Optional. The number of paths processed with each invocation is limited. + If the number of paths to be processed exceeds this limit, a continuation token is returned in + the response header x-ms-continuation. When a continuation token is returned in the response, + it must be percent-encoded and specified in a subsequent invocation of + setAccessControlRecursive operation. Default value is None. + :paramtype continuation: str + :keyword mode: Mode for set access control recursive. Known values are: "set", "modify", and + "remove". Default value is None. + :paramtype mode: str or ~azure.storage.filedatalake.models.PathSetAccessControlRecursiveMode + :keyword force_flag: Optional. Valid for "SetAccessControlRecursive" operation. If set to + false, the operation will terminate quickly on encountering user errors (4XX). If true, the + operation will ignore user errors and proceed with the operation on other sub-entities of the + directory. Continuation token will only be returned when forceFlag is true in case of user + errors. If not set the default value is false for this. Default value is None. + :paramtype force_flag: bool + :keyword position: This parameter allows the caller to upload data in parallel and control the + order in which it is appended to the file. It is required when uploading data to be appended to + the file and when flushing previously uploaded data to the file. The value must be the position + where the data is to be appended. Uploaded data is not immediately flushed, or written, to the + file. To flush, the previously uploaded data must be contiguous, the position parameter must be + specified and equal to the length of the file after all data has been written, and there must + not be a request entity body included with the request. Default value is None. + :paramtype position: int + :keyword retain_uncommitted_data: Valid only for flush operations. If "true", uncommitted data + is retained after the flush operation completes; otherwise, the uncommitted data is deleted + after the flush operation. The default is false. Data at offsets less than the specified + position are written to the file when flush succeeds, but this optional parameter allows data + after the flush position to be retained for a future flush operation. Default value is None. + :paramtype retain_uncommitted_data: bool + :keyword close: Azure Storage Events allow applications to receive notifications when files + change. When Azure Storage Events are enabled, a file changed event is raised. This event has a + property indicating whether this is the final change to distinguish the difference between an + intermediate flush to a file stream and the final close of a file stream. The close query + parameter is valid only when the action is "flush" and change notifications are enabled. If the + value of close is "true" and the flush operation completes successfully, the service raises a + file change notification with a property indicating that this is the final update (the file + stream has been closed). If "false" a change notification is raised indicating the file has + changed. The default is false. This query parameter is set to true by the Hadoop ABFS driver to + indicate that the file stream has been closed. Default value is None. + :paramtype close: bool + :keyword content_length: Required for "Append Data" and "Flush Data". Must be 0 for "Flush + Data". Must be the length of the request content in bytes for "Append Data". Default value is + None. + :paramtype content_length: int + :keyword content_md5: Specify the transactional md5 for the body, to be validated by the + service. Default value is None. + :paramtype content_md5: bytes + :keyword lease_id: If specified, the operation only succeeds if the resource's lease is active + and matches this ID. Default value is None. + :paramtype lease_id: str + :keyword cache_control: Optional. Sets the blob's cache control. If specified, this property is + stored with the blob and returned with a read request. Default value is None. + :paramtype cache_control: str + :keyword content_disposition: Optional. Sets the blob's Content-Disposition header. Default + value is None. + :paramtype content_disposition: str + :keyword content_encoding: Optional. Sets the blob's content encoding. If specified, this + property is stored with the blob and returned with a read request. Default value is None. + :paramtype content_encoding: str + :keyword content_language: Optional. Set the blob's content language. If specified, this + property is stored with the blob and returned with a read request. Default value is None. + :paramtype content_language: str + :keyword properties: Optional. User-defined properties to be stored with the filesystem, in the + format of a comma-separated list of name and value pairs "n1=v1, n2=v2, ...", where each value + is a base64 encoded string. Note that the string may only contain ASCII characters in the + ISO-8859-1 character set. If the filesystem exists, any properties not included in the list + will be removed. All properties are removed if the header is omitted. To merge new and existing + properties, first get all existing properties and the current E-Tag, then make a conditional + request with the E-Tag and include values for all properties. Default value is None. + :paramtype properties: str + :keyword owner: Optional. The owner of the blob or directory. Default value is None. + :paramtype owner: str + :keyword group: Optional. The owning group of the blob or directory. Default value is None. + :paramtype group: str + :keyword permissions: Optional and only valid if Hierarchical Namespace is enabled for the + account. Sets POSIX access permissions for the file owner, the file owning group, and others. + Each class may be granted read, write, or execute permission. The sticky bit is also supported. + Both symbolic (rwxrw-rw-) and 4-digit octal notation (e.g. 0766) are supported. Default value + is None. + :paramtype permissions: str + :keyword acl: Sets POSIX access control rights on files and directories. The value is a + comma-separated list of access control entries. Each access control entry (ACE) consists of a + scope, a type, a user or group identifier, and permissions in the format + "[scope:][type]:[id]:[permissions]". Default value is None. + :paramtype acl: str + :keyword if_modified_since: Specify this header value to operate only on a blob if it has been + modified since the specified date/time. Default value is None. + :paramtype if_modified_since: ~datetime.datetime + :keyword if_unmodified_since: Specify this header value to operate only on a blob if it has not + been modified since the specified date/time. Default value is None. + :paramtype if_unmodified_since: ~datetime.datetime + :keyword structured_body_type: Required if the request body is a structured message. Specifies + the message schema version and properties. Default value is None. + :paramtype structured_body_type: str + :keyword 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. + :paramtype structured_content_length: int + :keyword timeout: The timeout parameter is expressed in seconds. For more information, see Setting + Timeouts for Blob Service Operations.. Default value is None. + :paramtype timeout: int + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: SetAccessControlRecursiveResponse. The SetAccessControlRecursiveResponse is compatible + with MutableMapping + :rtype: ~azure.storage.filedatalake._generated.models.SetAccessControlRecursiveResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/octet-stream")) + cls: ClsType[_models.SetAccessControlRecursiveResponse] = kwargs.pop("cls", None) + + _content = body + + _request = build_path_update_request( + action=action, + max_records=max_records, + continuation=continuation, + mode=mode, + force_flag=force_flag, + position=position, + retain_uncommitted_data=retain_uncommitted_data, + close=close, + content_length=content_length, + content_md5=content_md5, + lease_id=lease_id, + cache_control=cache_control, + content_disposition=content_disposition, + content_encoding=content_encoding, + content_language=content_language, + properties=properties, + owner=owner, + group=group, + permissions=permissions, + acl=acl, + if_modified_since=if_modified_since, + if_unmodified_since=if_unmodified_since, + structured_body_type=structured_body_type, + structured_content_length=structured_content_length, + timeout=timeout, + etag=etag, + match_condition=match_condition, + content_type=content_type, + version=self._config.version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "url": self._serialize.url("self._config.url", self._config.url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.StorageError, + 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["Accept-Ranges"] = self._deserialize("str", response.headers.get("Accept-Ranges")) + 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-Encoding"] = self._deserialize("str", response.headers.get("Content-Encoding")) + response_headers["Content-Language"] = self._deserialize("str", response.headers.get("Content-Language")) + response_headers["Content-Length"] = self._deserialize("int", response.headers.get("Content-Length")) + response_headers["Content-Range"] = self._deserialize("str", response.headers.get("Content-Range")) + response_headers["Content-MD5"] = self._deserialize("bytearray", response.headers.get("Content-MD5")) + response_headers["x-ms-properties"] = self._deserialize("str", response.headers.get("x-ms-properties")) + response_headers["x-ms-continuation"] = self._deserialize("str", response.headers.get("x-ms-continuation")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + 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["Content-Type"] = self._deserialize("str", response.headers.get("Content-Type")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SetAccessControlRecursiveResponse, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def lease( + self, + *, + lease_action: Union[str, _models.PathLeaseAction], + lease_duration: Optional[int] = None, + lease_break_period: Optional[int] = None, + lease_id: Optional[str] = None, + proposed_lease_id: Optional[str] = None, + if_modified_since: Optional[datetime.datetime] = None, + if_unmodified_since: Optional[datetime.datetime] = None, + timeout: Optional[int] = None, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> None: + """Create and manage a lease to restrict write and delete access to the path. This operation + supports conditional HTTP requests. For more information, see `Specifying Conditional Headers + for Blob Service Operations + `_. + + :keyword lease_action: There are five lease actions: "acquire", "break", "change", "renew", and + "release". Use "acquire" and specify the "x-ms-proposed-lease-id" and "x-ms-lease-duration" to + acquire a new lease. Use "break" to break an existing lease. When a lease is broken, the lease + break period is allowed to elapse, during which time no lease operation except break and + release can be performed on the file. When a lease is successfully broken, the response + indicates the interval in seconds until a new lease can be acquired. Use "change" and specify + the current lease ID in "x-ms-lease-id" and the new lease ID in "x-ms-proposed-lease-id" to + change the lease ID of an active lease. Use "renew" and specify the "x-ms-lease-id" to renew an + existing lease. Use "release" and specify the "x-ms-lease-id" to release a lease. Known values + are: "acquire", "break", "change", "renew", and "release". Required. + :paramtype lease_action: str or ~azure.storage.filedatalake.models.PathLeaseAction + :keyword lease_duration: The lease duration is required to acquire a lease, and specifies the + duration of the lease in seconds. The lease duration must be between 15 and 60 seconds or -1 + for infinite lease. Default value is None. + :paramtype lease_duration: int + :keyword lease_break_period: The lease break period duration is optional to break a lease, and + specifies the break period of the lease in seconds. The lease break duration must be between 0 + and 60 seconds. Default value is None. + :paramtype lease_break_period: int + :keyword lease_id: If specified, the operation only succeeds if the resource's lease is active + and matches this ID. Default value is None. + :paramtype lease_id: str + :keyword proposed_lease_id: Proposed lease ID, in a GUID string format. Default value is None. + :paramtype proposed_lease_id: str + :keyword if_modified_since: Specify this header value to operate only on a blob if it has been + modified since the specified date/time. Default value is None. + :paramtype if_modified_since: ~datetime.datetime + :keyword if_unmodified_since: Specify this header value to operate only on a blob if it has not + been modified since the specified date/time. Default value is None. + :paramtype if_unmodified_since: ~datetime.datetime + :keyword timeout: The timeout parameter is expressed in seconds. For more information, see Setting + Timeouts for Blob Service Operations.. Default value is None. + :paramtype timeout: int + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + 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) + + _request = build_path_lease_request( + lease_action=lease_action, + lease_duration=lease_duration, + lease_break_period=lease_break_period, + lease_id=lease_id, + proposed_lease_id=proposed_lease_id, + if_modified_since=if_modified_since, + if_unmodified_since=if_unmodified_since, + timeout=timeout, + etag=etag, + match_condition=match_condition, + version=self._config.version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "url": self._serialize.url("self._config.url", self._config.url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.StorageError, + 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-lease-time"] = self._deserialize("str", response.headers.get("x-ms-lease-time")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + 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") + ) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace_async + async def read( + self, + *, + range: Optional[str] = None, + lease_id: Optional[str] = None, + range_get_content_md5: Optional[bool] = None, + if_modified_since: Optional[datetime.datetime] = None, + if_unmodified_since: Optional[datetime.datetime] = None, + encryption_key: Optional[str] = None, + encryption_key_sha256: Optional[str] = None, + encryption_algorithm: Optional[Union[str, _models.EncryptionAlgorithmType]] = None, + timeout: Optional[int] = None, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + """Read the contents of a file. For read operations, range requests are supported. This operation + supports conditional HTTP requests. For more information, see `Specifying Conditional Headers + for Blob Service Operations + `_. + + :keyword range: The HTTP Range request header specifies one or more byte ranges of the resource + to be retrieved. Default value is None. + :paramtype range: str + :keyword lease_id: If specified, the operation only succeeds if the resource's lease is active + and matches this ID. Default value is None. + :paramtype lease_id: str + :keyword range_get_content_md5: Optional. 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 4MB in size. Default value is None. + :paramtype range_get_content_md5: bool + :keyword if_modified_since: Specify this header value to operate only on a blob if it has been + modified since the specified date/time. Default value is None. + :paramtype if_modified_since: ~datetime.datetime + :keyword if_unmodified_since: Specify this header value to operate only on a blob if it has not + been modified since the specified date/time. Default value is None. + :paramtype if_unmodified_since: ~datetime.datetime + :keyword encryption_key: Optional. Specifies the encryption key to use to encrypt the data + provided in the request. If not specified, encryption is performed with the root account + encryption key. Default value is None. + :paramtype encryption_key: str + :keyword encryption_key_sha256: The SHA-256 hash of the provided encryption key. Must be + provided if the x-ms-encryption-key header is provided. Default value is None. + :paramtype encryption_key_sha256: str + :keyword encryption_algorithm: The algorithm used to produce the encryption key hash. + Currently, the only accepted value is "AES256". Must be provided if the x-ms-encryption-key + header is provided. "AES256" Default value is None. + :paramtype encryption_algorithm: str or + ~azure.storage.filedatalake.models.EncryptionAlgorithmType + :keyword timeout: The timeout parameter is expressed in seconds. For more information, see Setting + Timeouts for Blob Service Operations.. Default value is None. + :paramtype timeout: int + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: AsyncIterator[bytes] + :rtype: AsyncIterator[bytes] + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + 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) + + _request = build_path_read_request( + range=range, + lease_id=lease_id, + range_get_content_md5=range_get_content_md5, + if_modified_since=if_modified_since, + if_unmodified_since=if_unmodified_since, + encryption_key=encryption_key, + encryption_key_sha256=encryption_key_sha256, + encryption_algorithm=encryption_algorithm, + timeout=timeout, + etag=etag, + match_condition=match_condition, + version=self._config.version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "url": self._serialize.url("self._config.url", self._config.url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.StorageError, + response, + ) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["Accept-Ranges"] = self._deserialize("str", response.headers.get("Accept-Ranges")) + 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-Encoding"] = self._deserialize("str", response.headers.get("Content-Encoding")) + response_headers["Content-Language"] = self._deserialize("str", response.headers.get("Content-Language")) + response_headers["Content-Length"] = self._deserialize("int", response.headers.get("Content-Length")) + response_headers["Content-Range"] = self._deserialize("str", response.headers.get("Content-Range")) + response_headers["Content-MD5"] = self._deserialize("bytearray", response.headers.get("Content-MD5")) + 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-resource-type"] = self._deserialize("str", response.headers.get("x-ms-resource-type")) + response_headers["x-ms-properties"] = self._deserialize("str", response.headers.get("x-ms-properties")) + 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-request-server-encrypted"] = self._deserialize( + "bool", response.headers.get("x-ms-request-server-encrypted") + ) + response_headers["x-ms-encryption-key-sha256"] = self._deserialize( + "str", response.headers.get("x-ms-encryption-key-sha256") + ) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + 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["Content-Type"] = self._deserialize("str", response.headers.get("Content-Type")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_properties( + self, + *, + action: Optional[Union[str, _models.PathGetPropertiesAction]] = None, + upn: Optional[bool] = None, + lease_id: Optional[str] = None, + if_modified_since: Optional[datetime.datetime] = None, + if_unmodified_since: Optional[datetime.datetime] = None, + timeout: Optional[int] = None, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> bool: + """Get Properties returns all system and user defined properties for a path. Get Status returns + all system defined properties for a path. Get Access Control List returns the access control + list for a path. This operation supports conditional HTTP requests. For more information, see + `Specifying Conditional Headers for Blob Service Operations + `_. + + :keyword action: Optional. If the value is "getStatus" only the system defined properties for + the path are returned. If the value is "getAccessControl" the access control list is returned + in the response headers (Hierarchical Namespace must be enabled for the account), otherwise the + properties are returned. Known values are: "getAccessControl" and "getStatus". Default value is + None. + :paramtype action: str or ~azure.storage.filedatalake.models.PathGetPropertiesAction + :keyword upn: Optional. Valid only when Hierarchical Namespace is enabled for the account. If + "true", the user identity values returned in the x-ms-owner, x-ms-group, and x-ms-acl response + headers will be transformed from Azure Active Directory Object IDs to User Principal Names. If + "false", the values will be returned as Azure Active Directory Object IDs. The default value is + false. Note that group and application Object IDs are not translated because they do not have + unique friendly names. Default value is None. + :paramtype upn: bool + :keyword lease_id: If specified, the operation only succeeds if the resource's lease is active + and matches this ID. Default value is None. + :paramtype lease_id: str + :keyword if_modified_since: Specify this header value to operate only on a blob if it has been + modified since the specified date/time. Default value is None. + :paramtype if_modified_since: ~datetime.datetime + :keyword if_unmodified_since: Specify this header value to operate only on a blob if it has not + been modified since the specified date/time. Default value is None. + :paramtype if_unmodified_since: ~datetime.datetime + :keyword timeout: The timeout parameter is expressed in seconds. For more information, see Setting + Timeouts for Blob Service Operations.. Default value is None. + :paramtype timeout: int + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + 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) + + _request = build_path_get_properties_request( + action=action, + upn=upn, + lease_id=lease_id, + if_modified_since=if_modified_since, + if_unmodified_since=if_unmodified_since, + timeout=timeout, + etag=etag, + match_condition=match_condition, + version=self._config.version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "url": self._serialize.url("self._config.url", self._config.url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.StorageError, + response, + ) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["Accept-Ranges"] = self._deserialize("str", response.headers.get("Accept-Ranges")) + 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-Encoding"] = self._deserialize("str", response.headers.get("Content-Encoding")) + response_headers["Content-Language"] = self._deserialize("str", response.headers.get("Content-Language")) + response_headers["Content-Length"] = self._deserialize("int", response.headers.get("Content-Length")) + response_headers["Content-Range"] = self._deserialize("str", response.headers.get("Content-Range")) + response_headers["Content-Type"] = self._deserialize("str", response.headers.get("Content-Type")) + response_headers["Content-MD5"] = self._deserialize("bytearray", response.headers.get("Content-MD5")) + 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-resource-type"] = self._deserialize("str", response.headers.get("x-ms-resource-type")) + response_headers["x-ms-properties"] = self._deserialize("str", response.headers.get("x-ms-properties")) + 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-permissions"] = self._deserialize("str", response.headers.get("x-ms-permissions")) + response_headers["x-ms-acl"] = self._deserialize("str", response.headers.get("x-ms-acl")) + 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-server-encrypted"] = self._deserialize( + "bool", response.headers.get("x-ms-server-encrypted") + ) + response_headers["x-ms-encryption-key-sha256"] = self._deserialize( + "str", response.headers.get("x-ms-encryption-key-sha256") + ) + response_headers["x-ms-encryption-context"] = self._deserialize( + "str", response.headers.get("x-ms-encryption-context") + ) + response_headers["x-ms-encryption-scope"] = self._deserialize( + "str", response.headers.get("x-ms-encryption-scope") + ) + response_headers["x-ms-creation-time"] = self._deserialize( + "rfc-1123", response.headers.get("x-ms-creation-time") + ) + response_headers["x-ms-expiry-time"] = self._deserialize("rfc-1123", response.headers.get("x-ms-expiry-time")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + 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") + ) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + return 200 <= response.status_code <= 299 + + @distributed_trace_async + async def delete( + self, + *, + recursive: Optional[bool] = None, + continuation: Optional[str] = None, + lease_id: Optional[str] = None, + if_modified_since: Optional[datetime.datetime] = None, + if_unmodified_since: Optional[datetime.datetime] = None, + paginated: Optional[bool] = None, + timeout: Optional[int] = None, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> None: + """Delete the file or directory. This operation supports conditional HTTP requests. For more + information, see `Specifying Conditional Headers for Blob Service Operations + `_. + + :keyword recursive: Required. Default value is None. + :paramtype recursive: bool + :keyword continuation: Optional. When deleting a directory, the number of paths that are + deleted with each invocation is limited. If the number of paths to be deleted exceeds this + limit, a continuation token is returned in this response header. When a continuation token is + returned in the response, it must be specified in a subsequent invocation of the delete + operation to continue deleting the directory. Default value is None. + :paramtype continuation: str + :keyword lease_id: If specified, the operation only succeeds if the resource's lease is active + and matches this ID. Default value is None. + :paramtype lease_id: str + :keyword if_modified_since: Specify this header value to operate only on a blob if it has been + modified since the specified date/time. Default value is None. + :paramtype if_modified_since: ~datetime.datetime + :keyword if_unmodified_since: Specify this header value to operate only on a blob if it has not + been modified since the specified date/time. Default value is None. + :paramtype if_unmodified_since: ~datetime.datetime + :keyword paginated: If true, paginated behavior will be seen. Pagination is for the recursive + ACL checks as a POSIX requirement in the server and Delete in an atomic operation once the ACL + checks are completed. If false or missing, normal default behavior will kick in, which may + timeout in case of very large directories due to recursive ACL checks. This new parameter is + introduced for backward compatibility. Default value is None. + :paramtype paginated: bool + :keyword timeout: The timeout parameter is expressed in seconds. For more information, see Setting + Timeouts for Blob Service Operations.. Default value is None. + :paramtype timeout: int + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + 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) + + _request = build_path_delete_request( + recursive=recursive, + continuation=continuation, + lease_id=lease_id, + if_modified_since=if_modified_since, + if_unmodified_since=if_unmodified_since, + paginated=paginated, + timeout=timeout, + etag=etag, + match_condition=match_condition, + version=self._config.version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "url": self._serialize.url("self._config.url", self._config.url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.StorageError, + response, + ) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["x-ms-continuation"] = self._deserialize("str", response.headers.get("x-ms-continuation")) + response_headers["x-ms-deletion-id"] = self._deserialize("str", response.headers.get("x-ms-deletion-id")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + 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") + ) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace_async + async def set_access_control( + self, + *, + lease_id: Optional[str] = None, + owner: Optional[str] = None, + group: Optional[str] = None, + permissions: Optional[str] = None, + acl: Optional[str] = None, + if_modified_since: Optional[datetime.datetime] = None, + if_unmodified_since: Optional[datetime.datetime] = None, + timeout: Optional[int] = None, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> None: + """Set the owner, group, permissions, or access control list for a path. + + :keyword lease_id: If specified, the operation only succeeds if the resource's lease is active + and matches this ID. Default value is None. + :paramtype lease_id: str + :keyword owner: Optional. The owner of the blob or directory. Default value is None. + :paramtype owner: str + :keyword group: Optional. The owning group of the blob or directory. Default value is None. + :paramtype group: str + :keyword permissions: Optional and only valid if Hierarchical Namespace is enabled for the + account. Sets POSIX access permissions for the file owner, the file owning group, and others. + Each class may be granted read, write, or execute permission. The sticky bit is also supported. + Both symbolic (rwxrw-rw-) and 4-digit octal notation (e.g. 0766) are supported. Default value + is None. + :paramtype permissions: str + :keyword acl: Sets POSIX access control rights on files and directories. The value is a + comma-separated list of access control entries. Each access control entry (ACE) consists of a + scope, a type, a user or group identifier, and permissions in the format + "[scope:][type]:[id]:[permissions]". Default value is None. + :paramtype acl: str + :keyword if_modified_since: Specify this header value to operate only on a blob if it has been + modified since the specified date/time. Default value is None. + :paramtype if_modified_since: ~datetime.datetime + :keyword if_unmodified_since: Specify this header value to operate only on a blob if it has not + been modified since the specified date/time. Default value is None. + :paramtype if_unmodified_since: ~datetime.datetime + :keyword timeout: The timeout parameter is expressed in seconds. For more information, see Setting + Timeouts for Blob Service Operations.. Default value is None. + :paramtype timeout: int + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + 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) + + _request = build_path_set_access_control_request( + lease_id=lease_id, + owner=owner, + group=group, + permissions=permissions, + acl=acl, + if_modified_since=if_modified_since, + if_unmodified_since=if_unmodified_since, + timeout=timeout, + etag=etag, + match_condition=match_condition, + version=self._config.version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "url": self._serialize.url("self._config.url", self._config.url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.StorageError, + 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["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + 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") + ) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace_async + async def set_access_control_recursive( + self, + *, + mode: Union[str, _models.PathSetAccessControlRecursiveMode], + continuation: Optional[str] = None, + force_flag: Optional[bool] = None, + max_records: Optional[int] = None, + acl: Optional[str] = None, + timeout: Optional[int] = None, + **kwargs: Any + ) -> _models.SetAccessControlRecursiveResponse: + """Set the access control list for a path and sub-paths. + + :keyword mode: Mode "set" sets POSIX access control rights on files and directories, "modify" + modifies one or more POSIX access control rights that pre-exist on files and directories, + "remove" removes one or more POSIX access control rights that were present earlier on files and + directories. Known values are: "set", "modify", and "remove". Required. + :paramtype mode: str or ~azure.storage.filedatalake.models.PathSetAccessControlRecursiveMode + :keyword continuation: Optional. When deleting a directory, the number of paths that are + deleted with each invocation is limited. If the number of paths to be deleted exceeds this + limit, a continuation token is returned in this response header. When a continuation token is + returned in the response, it must be specified in a subsequent invocation of the delete + operation to continue deleting the directory. Default value is None. + :paramtype continuation: str + :keyword force_flag: Optional. Valid for "SetAccessControlRecursive" operation. If set to + false, the operation will terminate quickly on encountering user errors (4XX). If true, the + operation will ignore user errors and proceed with the operation on other sub-entities of the + directory. Continuation token will only be returned when forceFlag is true in case of user + errors. If not set the default value is false for this. Default value is None. + :paramtype force_flag: bool + :keyword max_records: Optional. It specifies the maximum number of files or directories on + which the acl change will be applied. If omitted or greater than 2,000, the request will + process up to 2,000 items. Default value is None. + :paramtype max_records: int + :keyword acl: Sets POSIX access control rights on files and directories. The value is a + comma-separated list of access control entries. Each access control entry (ACE) consists of a + scope, a type, a user or group identifier, and permissions in the format + "[scope:][type]:[id]:[permissions]". Default value is None. + :paramtype acl: str + :keyword timeout: The timeout parameter is expressed in seconds. For more information, see Setting + Timeouts for Blob Service Operations.. Default value is None. + :paramtype timeout: int + :return: SetAccessControlRecursiveResponse. The SetAccessControlRecursiveResponse is compatible + with MutableMapping + :rtype: ~azure.storage.filedatalake._generated.models.SetAccessControlRecursiveResponse + :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[_models.SetAccessControlRecursiveResponse] = kwargs.pop("cls", None) + + _request = build_path_set_access_control_recursive_request( + mode=mode, + continuation=continuation, + force_flag=force_flag, + max_records=max_records, + acl=acl, + timeout=timeout, + version=self._config.version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "url": self._serialize.url("self._config.url", self._config.url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.StorageError, + response, + ) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["x-ms-continuation"] = self._deserialize("str", response.headers.get("x-ms-continuation")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + 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["Content-Type"] = self._deserialize("str", response.headers.get("Content-Type")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SetAccessControlRecursiveResponse, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def flush_data( # pylint: disable=too-many-locals + self, + *, + position: Optional[int] = None, + retain_uncommitted_data: Optional[bool] = None, + close: Optional[bool] = None, + content_length: Optional[int] = None, + content_md5: Optional[bytes] = None, + lease_id: Optional[str] = None, + lease_action: Optional[Union[str, _models.LeaseAction]] = None, + lease_duration: Optional[int] = None, + proposed_lease_id: Optional[str] = None, + cache_control: Optional[str] = None, + content_type: Optional[str] = None, + content_disposition: Optional[str] = None, + content_encoding: Optional[str] = None, + content_language: Optional[str] = None, + if_modified_since: Optional[datetime.datetime] = None, + if_unmodified_since: Optional[datetime.datetime] = None, + encryption_key: Optional[str] = None, + encryption_key_sha256: Optional[str] = None, + encryption_algorithm: Optional[Union[str, _models.EncryptionAlgorithmType]] = None, + timeout: Optional[int] = None, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> None: + """Set the owner, group, permissions, or access control list for a path. + + :keyword position: This parameter allows the caller to upload data in parallel and control the + order in which it is appended to the file. It is required when uploading data to be appended to + the file and when flushing previously uploaded data to the file. The value must be the position + where the data is to be appended. Uploaded data is not immediately flushed, or written, to the + file. To flush, the previously uploaded data must be contiguous, the position parameter must be + specified and equal to the length of the file after all data has been written, and there must + not be a request entity body included with the request. Default value is None. + :paramtype position: int + :keyword retain_uncommitted_data: Valid only for flush operations. If "true", uncommitted data + is retained after the flush operation completes; otherwise, the uncommitted data is deleted + after the flush operation. The default is false. Data at offsets less than the specified + position are written to the file when flush succeeds, but this optional parameter allows data + after the flush position to be retained for a future flush operation. Default value is None. + :paramtype retain_uncommitted_data: bool + :keyword close: Azure Storage Events allow applications to receive notifications when files + change. When Azure Storage Events are enabled, a file changed event is raised. This event has a + property indicating whether this is the final change to distinguish the difference between an + intermediate flush to a file stream and the final close of a file stream. The close query + parameter is valid only when the action is "flush" and change notifications are enabled. If the + value of close is "true" and the flush operation completes successfully, the service raises a + file change notification with a property indicating that this is the final update (the file + stream has been closed). If "false" a change notification is raised indicating the file has + changed. The default is false. This query parameter is set to true by the Hadoop ABFS driver to + indicate that the file stream has been closed. Default value is None. + :paramtype close: bool + :keyword content_length: Required for "Append Data" and "Flush Data". Must be 0 for "Flush + Data". Must be the length of the request content in bytes for "Append Data". Default value is + None. + :paramtype content_length: int + :keyword content_md5: Specify the transactional md5 for the body, to be validated by the + service. Default value is None. + :paramtype content_md5: bytes + :keyword lease_id: If specified, the operation only succeeds if the resource's lease is active + and matches this ID. Default value is None. + :paramtype lease_id: str + :keyword lease_action: Optional. If "acquire" it will acquire the lease. If "auto-renew" it + will renew the lease. If "release" it will release the lease only on flush. If + "acquire-release" it will acquire & complete the operation & release the lease once operation + is done. Known values are: "acquire", "auto-renew", "release", and "acquire-release". Default + value is None. + :paramtype lease_action: str or ~azure.storage.filedatalake.models.LeaseAction + :keyword lease_duration: The lease duration is required to acquire a lease, and specifies the + duration of the lease in seconds. The lease duration must be between 15 and 60 seconds or -1 + for infinite lease. Default value is None. + :paramtype lease_duration: int + :keyword proposed_lease_id: Proposed lease ID, in a GUID string format. Default value is None. + :paramtype proposed_lease_id: str + :keyword cache_control: Optional. Sets the blob's cache control. If specified, this property is + stored with the blob and returned with a read request. Default value is None. + :paramtype cache_control: str + :keyword content_type: Optional. Sets the blob's content type. If specified, this property is + stored with the blob and returned with a read request. Default value is None. + :paramtype content_type: str + :keyword content_disposition: Optional. Sets the blob's Content-Disposition header. Default + value is None. + :paramtype content_disposition: str + :keyword content_encoding: Optional. Sets the blob's content encoding. If specified, this + property is stored with the blob and returned with a read request. Default value is None. + :paramtype content_encoding: str + :keyword content_language: Optional. Set the blob's content language. If specified, this + property is stored with the blob and returned with a read request. Default value is None. + :paramtype content_language: str + :keyword if_modified_since: Specify this header value to operate only on a blob if it has been + modified since the specified date/time. Default value is None. + :paramtype if_modified_since: ~datetime.datetime + :keyword if_unmodified_since: Specify this header value to operate only on a blob if it has not + been modified since the specified date/time. Default value is None. + :paramtype if_unmodified_since: ~datetime.datetime + :keyword encryption_key: Optional. Specifies the encryption key to use to encrypt the data + provided in the request. If not specified, encryption is performed with the root account + encryption key. Default value is None. + :paramtype encryption_key: str + :keyword encryption_key_sha256: The SHA-256 hash of the provided encryption key. Must be + provided if the x-ms-encryption-key header is provided. Default value is None. + :paramtype encryption_key_sha256: str + :keyword encryption_algorithm: The algorithm used to produce the encryption key hash. + Currently, the only accepted value is "AES256". Must be provided if the x-ms-encryption-key + header is provided. "AES256" Default value is None. + :paramtype encryption_algorithm: str or + ~azure.storage.filedatalake.models.EncryptionAlgorithmType + :keyword timeout: The timeout parameter is expressed in seconds. For more information, see Setting + Timeouts for Blob Service Operations.. Default value is None. + :paramtype timeout: int + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + 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) + + _request = build_path_flush_data_request( + position=position, + retain_uncommitted_data=retain_uncommitted_data, + close=close, + content_length=content_length, + content_md5=content_md5, + lease_id=lease_id, + lease_action=lease_action, + lease_duration=lease_duration, + proposed_lease_id=proposed_lease_id, + cache_control=cache_control, + content_type=content_type, + content_disposition=content_disposition, + content_encoding=content_encoding, + content_language=content_language, + if_modified_since=if_modified_since, + if_unmodified_since=if_unmodified_since, + encryption_key=encryption_key, + encryption_key_sha256=encryption_key_sha256, + encryption_algorithm=encryption_algorithm, + timeout=timeout, + etag=etag, + match_condition=match_condition, + version=self._config.version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "url": self._serialize.url("self._config.url", self._config.url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.StorageError, + 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-Length"] = self._deserialize("int", response.headers.get("Content-Length")) + response_headers["x-ms-request-server-encrypted"] = self._deserialize( + "bool", response.headers.get("x-ms-request-server-encrypted") + ) + response_headers["x-ms-encryption-key-sha256"] = self._deserialize( + "str", response.headers.get("x-ms-encryption-key-sha256") + ) + response_headers["x-ms-lease-renewed"] = self._deserialize("bool", response.headers.get("x-ms-lease-renewed")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + 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") + ) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace_async + async def append_data( # pylint: disable=too-many-locals + self, + body: bytes, + *, + position: Optional[int] = None, + content_length: Optional[int] = None, + transactional_content_hash: Optional[bytes] = None, + transactional_content_crc64: Optional[bytes] = None, + lease_id: Optional[str] = None, + lease_action: Optional[Union[str, _models.LeaseAction]] = None, + lease_duration: Optional[int] = None, + proposed_lease_id: Optional[str] = None, + encryption_key: Optional[str] = None, + encryption_key_sha256: Optional[str] = None, + encryption_algorithm: Optional[Union[str, _models.EncryptionAlgorithmType]] = None, + flush: Optional[bool] = None, + structured_body_type: Optional[str] = None, + structured_content_length: Optional[int] = None, + timeout: Optional[int] = None, + **kwargs: Any + ) -> None: + """Append data to the file. + + :param body: Initial data. Required. + :type body: bytes + :keyword position: This parameter allows the caller to upload data in parallel and control the + order in which it is appended to the file. It is required when uploading data to be appended to + the file and when flushing previously uploaded data to the file. The value must be the position + where the data is to be appended. Uploaded data is not immediately flushed, or written, to the + file. To flush, the previously uploaded data must be contiguous, the position parameter must be + specified and equal to the length of the file after all data has been written, and there must + not be a request entity body included with the request. Default value is None. + :paramtype position: int + :keyword content_length: Required for "Append Data" and "Flush Data". Must be 0 for "Flush + Data". Must be the length of the request content in bytes for "Append Data". Default value is + None. + :paramtype content_length: int + :keyword transactional_content_hash: Specify the transactional md5 for the body, to be + validated by the service. Default value is None. + :paramtype transactional_content_hash: bytes + :keyword transactional_content_crc64: Specify the transactional crc64 for the body, to be + validated by the service. Default value is None. + :paramtype transactional_content_crc64: bytes + :keyword lease_id: If specified, the operation only succeeds if the resource's lease is active + and matches this ID. Default value is None. + :paramtype lease_id: str + :keyword lease_action: Optional. If "acquire" it will acquire the lease. If "auto-renew" it + will renew the lease. If "release" it will release the lease only on flush. If + "acquire-release" it will acquire & complete the operation & release the lease once operation + is done. Known values are: "acquire", "auto-renew", "release", and "acquire-release". Default + value is None. + :paramtype lease_action: str or ~azure.storage.filedatalake.models.LeaseAction + :keyword lease_duration: The lease duration is required to acquire a lease, and specifies the + duration of the lease in seconds. The lease duration must be between 15 and 60 seconds or -1 + for infinite lease. Default value is None. + :paramtype lease_duration: int + :keyword proposed_lease_id: Proposed lease ID, in a GUID string format. Default value is None. + :paramtype proposed_lease_id: str + :keyword encryption_key: Optional. Specifies the encryption key to use to encrypt the data + provided in the request. If not specified, encryption is performed with the root account + encryption key. Default value is None. + :paramtype encryption_key: str + :keyword encryption_key_sha256: The SHA-256 hash of the provided encryption key. Must be + provided if the x-ms-encryption-key header is provided. Default value is None. + :paramtype encryption_key_sha256: str + :keyword encryption_algorithm: The algorithm used to produce the encryption key hash. + Currently, the only accepted value is "AES256". Must be provided if the x-ms-encryption-key + header is provided. "AES256" Default value is None. + :paramtype encryption_algorithm: str or + ~azure.storage.filedatalake.models.EncryptionAlgorithmType + :keyword flush: If file should be flushed after the append. Default value is None. + :paramtype flush: bool + :keyword structured_body_type: Required if the request body is a structured message. Specifies + the message schema version and properties. Default value is None. + :paramtype structured_body_type: str + :keyword 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. + :paramtype structured_content_length: int + :keyword timeout: The timeout parameter is expressed in seconds. For more information, see Setting + Timeouts for Blob Service Operations.. Default value is None. + :paramtype timeout: int + :return: None + :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 {} + + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/octet-stream")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _content = body + + _request = build_path_append_data_request( + position=position, + content_length=content_length, + transactional_content_hash=transactional_content_hash, + transactional_content_crc64=transactional_content_crc64, + lease_id=lease_id, + lease_action=lease_action, + lease_duration=lease_duration, + proposed_lease_id=proposed_lease_id, + encryption_key=encryption_key, + encryption_key_sha256=encryption_key_sha256, + encryption_algorithm=encryption_algorithm, + flush=flush, + structured_body_type=structured_body_type, + structured_content_length=structured_content_length, + timeout=timeout, + content_type=content_type, + version=self._config.version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "url": self._serialize.url("self._config.url", self._config.url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.StorageError, + response, + ) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["Content-MD5"] = self._deserialize("bytearray", response.headers.get("Content-MD5")) + response_headers["x-ms-content-crc64"] = self._deserialize( + "bytearray", response.headers.get("x-ms-content-crc64") + ) + response_headers["x-ms-request-server-encrypted"] = self._deserialize( + "bool", response.headers.get("x-ms-request-server-encrypted") + ) + response_headers["x-ms-encryption-key-sha256"] = self._deserialize( + "str", response.headers.get("x-ms-encryption-key-sha256") + ) + response_headers["x-ms-lease-renewed"] = self._deserialize("bool", response.headers.get("x-ms-lease-renewed")) + response_headers["x-ms-structured-body"] = self._deserialize( + "str", response.headers.get("x-ms-structured-body") + ) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + 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") + ) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace_async + async def set_expiry( + self, + *, + expiry_options: Union[str, _models.PathExpiryOptions], + expires_on: Optional[str] = None, + timeout: Optional[int] = None, + **kwargs: Any + ) -> None: + """Sets the time a blob will expire and be deleted. + + :keyword expiry_options: Required. Indicates mode of the expiry time. Known values are: + "NeverExpire", "RelativeToCreation", "RelativeToNow", and "Absolute". Required. + :paramtype expiry_options: str or ~azure.storage.filedatalake.models.PathExpiryOptions + :keyword expires_on: The time to set the blob to expiry. Default value is None. + :paramtype expires_on: str + :keyword timeout: The timeout parameter is expressed in seconds. For more information, see Setting + Timeouts for Blob Service Operations.. Default value is None. + :paramtype timeout: int + :return: None + :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) + + _request = build_path_set_expiry_request( + expiry_options=expiry_options, + expires_on=expires_on, + timeout=timeout, + version=self._config.version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "url": self._serialize.url("self._config.url", self._config.url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.StorageError, + 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["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + 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") + ) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace_async + async def undelete( + self, *, undelete_source: Optional[str] = None, timeout: Optional[int] = None, **kwargs: Any + ) -> None: + """Undelete a path that was previously soft deleted. + + :keyword undelete_source: Only for hierarchical namespace enabled accounts. Optional. The path + of the soft deleted blob to undelete. Default value is None. + :paramtype undelete_source: str + :keyword timeout: The timeout parameter is expressed in seconds. For more information, see Setting + Timeouts for Blob Service Operations.. Default value is None. + :paramtype timeout: int + :return: None + :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) + + _request = build_path_undelete_request( + undelete_source=undelete_source, + timeout=timeout, + version=self._config.version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "url": self._serialize.url("self._config.url", self._config.url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.StorageError, + response, + ) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["x-ms-resource-type"] = self._deserialize("str", response.headers.get("x-ms-resource-type")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + 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") + ) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + +class ServiceOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.storage.filedatalake.aio.DataLakeClient`'s + :attr:`service` attribute. + """ + + 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: DataLakeClientConfiguration = 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 list_file_systems( + self, + *, + resource: Union[str, _models.AccountResourceType], + prefix: Optional[str] = None, + continuation: Optional[str] = None, + max_results: Optional[int] = None, + timeout: Optional[int] = None, + **kwargs: Any + ) -> _models.FileSystemList: + """List filesystems and their properties in given account. + + :keyword resource: The value must be "account" for all account operations. "account" Required. + :paramtype resource: str or ~azure.storage.filedatalake.models.AccountResourceType + :keyword prefix: Filters results to filesystems within the specified prefix. Default value is + None. + :paramtype prefix: str + :keyword continuation: Optional. When deleting a directory, the number of paths that are + deleted with each invocation is limited. If the number of paths to be deleted exceeds this + limit, a continuation token is returned in this response header. When a continuation token is + returned in the response, it must be specified in a subsequent invocation of the delete + operation to continue deleting the directory. Default value is None. + :paramtype continuation: str + :keyword max_results: An optional value that specifies the maximum number of items to return. + If omitted or greater than 5,000, the response will include up to 5,000 items. Default value is + None. + :paramtype max_results: int + :keyword timeout: The timeout parameter is expressed in seconds. For more information, see Setting + Timeouts for Blob Service Operations.. Default value is None. + :paramtype timeout: int + :return: FileSystemList. The FileSystemList is compatible with MutableMapping + :rtype: ~azure.storage.filedatalake._generated.models.FileSystemList + :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[_models.FileSystemList] = kwargs.pop("cls", None) + + _request = build_service_list_file_systems_request( + resource=resource, + prefix=prefix, + continuation=continuation, + max_results=max_results, + timeout=timeout, + version=self._config.version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "url": self._serialize.url("self._config.url", self._config.url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.StorageError, + response, + ) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["x-ms-continuation"] = self._deserialize("str", response.headers.get("x-ms-continuation")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + 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["Content-Type"] = self._deserialize("str", response.headers.get("Content-Type")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.FileSystemList, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/aio/operations/_patch.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/aio/operations/_patch.py index f7dd32510333..71a40df69f9b 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/aio/operations/_patch.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/aio/operations/_patch.py @@ -1,14 +1,14 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# 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. +# -------------------------------------------------------------------------- """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 +__all__: list[str] = [] def patch_sdk(): diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/aio/operations/_path_operations.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/aio/operations/_path_operations.py deleted file mode 100644 index 79f220bed0bd..000000000000 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/aio/operations/_path_operations.py +++ /dev/null @@ -1,2004 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,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 collections.abc import MutableMapping -from typing import Any, AsyncIterator, Callable, 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 ..._utils.serialization import Deserializer, Serializer -from ...operations._path_operations import ( - build_append_data_request, - build_create_request, - build_delete_request, - build_flush_data_request, - build_get_properties_request, - build_lease_request, - build_read_request, - build_set_access_control_recursive_request, - build_set_access_control_request, - build_set_expiry_request, - build_undelete_request, - build_update_request, -) -from .._configuration import AzureDataLakeStorageRESTAPIConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] - - -class PathOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.storage.filedatalake.aio.AzureDataLakeStorageRESTAPI`'s - :attr:`path` 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: AzureDataLakeStorageRESTAPIConfiguration = ( - 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( # pylint: disable=too-many-locals - self, - request_id_parameter: Optional[str] = None, - timeout: Optional[int] = None, - resource: Optional[Union[str, _models.PathResourceType]] = None, - continuation: Optional[str] = None, - mode: Optional[Union[str, _models.PathRenameMode]] = None, - rename_source: Optional[str] = None, - source_lease_id: Optional[str] = None, - properties: Optional[str] = None, - permissions: Optional[str] = None, - umask: Optional[str] = None, - owner: Optional[str] = None, - group: Optional[str] = None, - acl: Optional[str] = None, - proposed_lease_id: Optional[str] = None, - lease_duration: Optional[int] = None, - expiry_options: Optional[Union[str, _models.PathExpiryOptions]] = None, - expires_on: Optional[str] = None, - encryption_context: Optional[str] = None, - path_http_headers: Optional[_models.PathHTTPHeaders] = None, - lease_access_conditions: Optional[_models.LeaseAccessConditions] = None, - modified_access_conditions: Optional[_models.ModifiedAccessConditions] = None, - source_modified_access_conditions: Optional[_models.SourceModifiedAccessConditions] = None, - cpk_info: Optional[_models.CpkInfo] = None, - **kwargs: Any - ) -> None: - """Create File | Create Directory | Rename File | Rename Directory. - - Create or rename a file or directory. By default, the destination is overwritten and if the - destination already exists and has a lease the lease is broken. This operation supports - conditional HTTP requests. For more information, see `Specifying Conditional Headers for Blob - Service Operations - `_. - To fail if the destination already exists, use a conditional request with If-None-Match: "*". - - :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 timeout: The timeout parameter is expressed in seconds. For more information, see - :code:`Setting - Timeouts for Blob Service Operations.`. Default value is None. - :type timeout: int - :param resource: Required only for Create File and Create Directory. The value must be "file" - or "directory". Known values are: "directory" and "file". Default value is None. - :type resource: str or ~azure.storage.filedatalake.models.PathResourceType - :param continuation: Optional. When deleting a directory, the number of paths that are deleted - with each invocation is limited. If the number of paths to be deleted exceeds this limit, a - continuation token is returned in this response header. When a continuation token is returned - in the response, it must be specified in a subsequent invocation of the delete operation to - continue deleting the directory. Default value is None. - :type continuation: str - :param mode: Optional. Valid only when namespace is enabled. This parameter determines the - behavior of the rename operation. The value must be "legacy" or "posix", and the default value - will be "posix". Known values are: "legacy" and "posix". Default value is None. - :type mode: str or ~azure.storage.filedatalake.models.PathRenameMode - :param rename_source: An optional file or directory to be renamed. The value must have the - following format: "/{filesystem}/{path}". If "x-ms-properties" is specified, the properties - will overwrite the existing properties; otherwise, the existing properties will be preserved. - This value must be a URL percent-encoded string. Note that the string may only contain ASCII - characters in the ISO-8859-1 character set. Default value is None. - :type rename_source: str - :param source_lease_id: A lease ID for the source path. If specified, the source path must have - an active lease and the lease ID must match. Default value is None. - :type source_lease_id: str - :param properties: Optional. User-defined properties to be stored with the filesystem, in the - format of a comma-separated list of name and value pairs "n1=v1, n2=v2, ...", where each value - is a base64 encoded string. Note that the string may only contain ASCII characters in the - ISO-8859-1 character set. If the filesystem exists, any properties not included in the list - will be removed. All properties are removed if the header is omitted. To merge new and - existing properties, first get all existing properties and the current E-Tag, then make a - conditional request with the E-Tag and include values for all properties. Default value is - None. - :type properties: str - :param permissions: Optional and only valid if Hierarchical Namespace is enabled for the - account. Sets POSIX access permissions for the file owner, the file owning group, and others. - Each class may be granted read, write, or execute permission. The sticky bit is also - supported. Both symbolic (rwxrw-rw-) and 4-digit octal notation (e.g. 0766) are supported. - Default value is None. - :type permissions: str - :param umask: Optional and only valid if Hierarchical Namespace is enabled for the account. - When creating a file or directory and the parent folder does not have a default ACL, the umask - restricts the permissions of the file or directory to be created. The resulting permission is - given by p bitwise and not u, where p is the permission and u is the umask. For example, if p - is 0777 and u is 0057, then the resulting permission is 0720. The default permission is 0777 - for a directory and 0666 for a file. The default umask is 0027. The umask must be specified - in 4-digit octal notation (e.g. 0766). Default value is None. - :type umask: str - :param owner: Optional. The owner of the blob or directory. Default value is None. - :type owner: str - :param group: Optional. The owning group of the blob or directory. Default value is None. - :type group: str - :param acl: Sets POSIX access control rights on files and directories. The value is a - comma-separated list of access control entries. Each access control entry (ACE) consists of a - scope, a type, a user or group identifier, and permissions in the format - "[scope:][type]:[id]:[permissions]". Default value is None. - :type acl: str - :param proposed_lease_id: Proposed lease ID, in a GUID string format. The Blob 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 lease_duration: The lease duration is required to acquire a lease, and specifies the - duration of the lease in seconds. The lease duration must be between 15 and 60 seconds or -1 - for infinite lease. Default value is None. - :type lease_duration: int - :param expiry_options: Required. Indicates mode of the expiry time. Known values are: - "NeverExpire", "RelativeToCreation", "RelativeToNow", and "Absolute". Default value is None. - :type expiry_options: str or ~azure.storage.filedatalake.models.PathExpiryOptions - :param expires_on: The time to set the blob to expiry. Default value is None. - :type expires_on: str - :param encryption_context: Specifies the encryption context to set on the file. Default value - is None. - :type encryption_context: str - :param path_http_headers: Parameter group. Default value is None. - :type path_http_headers: ~azure.storage.filedatalake.models.PathHTTPHeaders - :param lease_access_conditions: Parameter group. Default value is None. - :type lease_access_conditions: ~azure.storage.filedatalake.models.LeaseAccessConditions - :param modified_access_conditions: Parameter group. Default value is None. - :type modified_access_conditions: ~azure.storage.filedatalake.models.ModifiedAccessConditions - :param source_modified_access_conditions: Parameter group. Default value is None. - :type source_modified_access_conditions: - ~azure.storage.filedatalake.models.SourceModifiedAccessConditions - :param cpk_info: Parameter group. Default value is None. - :type cpk_info: ~azure.storage.filedatalake.models.CpkInfo - :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) - - _cache_control = None - _content_encoding = None - _content_language = None - _content_disposition = None - _content_type_parameter = None - _lease_id = None - _if_match = None - _if_none_match = None - _if_modified_since = None - _if_unmodified_since = None - _source_if_match = None - _source_if_none_match = None - _source_if_modified_since = None - _source_if_unmodified_since = None - _encryption_key = None - _encryption_key_sha256 = None - _encryption_algorithm = None - if path_http_headers is not None: - _cache_control = path_http_headers.cache_control - _content_disposition = path_http_headers.content_disposition - _content_encoding = path_http_headers.content_encoding - _content_language = path_http_headers.content_language - _content_type_parameter = path_http_headers.content_type - if lease_access_conditions is not None: - _lease_id = lease_access_conditions.lease_id - if modified_access_conditions is not None: - _if_match = modified_access_conditions.if_match - _if_modified_since = modified_access_conditions.if_modified_since - _if_none_match = modified_access_conditions.if_none_match - _if_unmodified_since = modified_access_conditions.if_unmodified_since - if source_modified_access_conditions is not None: - _source_if_match = source_modified_access_conditions.source_if_match - _source_if_modified_since = source_modified_access_conditions.source_if_modified_since - _source_if_none_match = source_modified_access_conditions.source_if_none_match - _source_if_unmodified_since = source_modified_access_conditions.source_if_unmodified_since - if cpk_info is not None: - _encryption_algorithm = cpk_info.encryption_algorithm - _encryption_key = cpk_info.encryption_key - _encryption_key_sha256 = cpk_info.encryption_key_sha256 - - _request = build_create_request( - url=self._config.url, - version=self._config.version, - request_id_parameter=request_id_parameter, - timeout=timeout, - resource=resource, - continuation=continuation, - mode=mode, - cache_control=_cache_control, - content_encoding=_content_encoding, - content_language=_content_language, - content_disposition=_content_disposition, - content_type_parameter=_content_type_parameter, - rename_source=rename_source, - lease_id=_lease_id, - source_lease_id=source_lease_id, - properties=properties, - permissions=permissions, - umask=umask, - if_match=_if_match, - if_none_match=_if_none_match, - if_modified_since=_if_modified_since, - if_unmodified_since=_if_unmodified_since, - source_if_match=_source_if_match, - source_if_none_match=_source_if_none_match, - source_if_modified_since=_source_if_modified_since, - source_if_unmodified_since=_source_if_unmodified_since, - encryption_key=_encryption_key, - encryption_key_sha256=_encryption_key_sha256, - encryption_algorithm=_encryption_algorithm, # type: ignore - owner=owner, - group=group, - acl=acl, - proposed_lease_id=proposed_lease_id, - lease_duration=lease_duration, - expiry_options=expiry_options, - expires_on=expires_on, - encryption_context=encryption_context, - 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["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) - 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["x-ms-continuation"] = self._deserialize("str", response.headers.get("x-ms-continuation")) - response_headers["Content-Length"] = self._deserialize("int", response.headers.get("Content-Length")) - response_headers["x-ms-request-server-encrypted"] = self._deserialize( - "bool", response.headers.get("x-ms-request-server-encrypted") - ) - response_headers["x-ms-encryption-key-sha256"] = self._deserialize( - "str", response.headers.get("x-ms-encryption-key-sha256") - ) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @distributed_trace_async - async def update( # pylint: disable=too-many-locals - self, - action: Union[str, _models.PathUpdateAction], - mode: Union[str, _models.PathSetAccessControlRecursiveMode], - body: IO[bytes], - request_id_parameter: Optional[str] = None, - timeout: Optional[int] = None, - max_records: Optional[int] = None, - continuation: Optional[str] = None, - force_flag: Optional[bool] = None, - position: Optional[int] = None, - retain_uncommitted_data: Optional[bool] = None, - close: Optional[bool] = None, - content_length: Optional[int] = None, - properties: Optional[str] = None, - owner: Optional[str] = None, - group: Optional[str] = None, - permissions: Optional[str] = None, - acl: Optional[str] = None, - structured_body_type: Optional[str] = None, - structured_content_length: Optional[int] = None, - path_http_headers: Optional[_models.PathHTTPHeaders] = None, - lease_access_conditions: Optional[_models.LeaseAccessConditions] = None, - modified_access_conditions: Optional[_models.ModifiedAccessConditions] = None, - **kwargs: Any - ) -> Optional[_models.SetAccessControlRecursiveResponse]: - """Append Data | Flush Data | Set Properties | Set Access Control. - - Uploads data to be appended to a file, flushes (writes) previously uploaded data to a file, - sets properties for a file or directory, or sets access control for a file or directory. Data - can only be appended to a file. Concurrent writes to the same file using multiple clients are - not supported. This operation supports conditional HTTP requests. For more information, see - `Specifying Conditional Headers for Blob Service Operations - `_. - - :param action: The action must be "append" to upload data to be appended to a file, "flush" to - flush previously uploaded data to a file, "setProperties" to set the properties of a file or - directory, "setAccessControl" to set the owner, group, permissions, or access control list for - a file or directory, or "setAccessControlRecursive" to set the access control list for a - directory recursively. Note that Hierarchical Namespace must be enabled for the account in - order to use access control. Also note that the Access Control List (ACL) includes permissions - for the owner, owning group, and others, so the x-ms-permissions and x-ms-acl request headers - are mutually exclusive. Known values are: "append", "flush", "setProperties", - "setAccessControl", and "setAccessControlRecursive". Required. - :type action: str or ~azure.storage.filedatalake.models.PathUpdateAction - :param mode: Mode "set" sets POSIX access control rights on files and directories, "modify" - modifies one or more POSIX access control rights that pre-exist on files and directories, - "remove" removes one or more POSIX access control rights that were present earlier on files - and directories. Known values are: "set", "modify", and "remove". Required. - :type mode: str or ~azure.storage.filedatalake.models.PathSetAccessControlRecursiveMode - :param body: Initial data. Required. - :type body: IO[bytes] - :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 timeout: The timeout parameter is expressed in seconds. For more information, see - :code:`Setting - Timeouts for Blob Service Operations.`. Default value is None. - :type timeout: int - :param max_records: Optional. Valid for "SetAccessControlRecursive" operation. It specifies the - maximum number of files or directories on which the acl change will be applied. If omitted or - greater than 2,000, the request will process up to 2,000 items. Default value is None. - :type max_records: int - :param continuation: Optional. The number of paths processed with each invocation is limited. - If the number of paths to be processed exceeds this limit, a continuation token is returned in - the response header x-ms-continuation. When a continuation token is returned in the response, - it must be percent-encoded and specified in a subsequent invocation of - setAccessControlRecursive operation. Default value is None. - :type continuation: str - :param force_flag: Optional. Valid for "SetAccessControlRecursive" operation. If set to false, - the operation will terminate quickly on encountering user errors (4XX). If true, the operation - will ignore user errors and proceed with the operation on other sub-entities of the directory. - Continuation token will only be returned when forceFlag is true in case of user errors. If not - set the default value is false for this. Default value is None. - :type force_flag: bool - :param position: This parameter allows the caller to upload data in parallel and control the - order in which it is appended to the file. It is required when uploading data to be appended - to the file and when flushing previously uploaded data to the file. The value must be the - position where the data is to be appended. Uploaded data is not immediately flushed, or - written, to the file. To flush, the previously uploaded data must be contiguous, the position - parameter must be specified and equal to the length of the file after all data has been - written, and there must not be a request entity body included with the request. Default value - is None. - :type position: int - :param retain_uncommitted_data: Valid only for flush operations. If "true", uncommitted data - is retained after the flush operation completes; otherwise, the uncommitted data is deleted - after the flush operation. The default is false. Data at offsets less than the specified - position are written to the file when flush succeeds, but this optional parameter allows data - after the flush position to be retained for a future flush operation. Default value is None. - :type retain_uncommitted_data: bool - :param close: Azure Storage Events allow applications to receive notifications when files - change. When Azure Storage Events are enabled, a file changed event is raised. This event has a - property indicating whether this is the final change to distinguish the difference between an - intermediate flush to a file stream and the final close of a file stream. The close query - parameter is valid only when the action is "flush" and change notifications are enabled. If the - value of close is "true" and the flush operation completes successfully, the service raises a - file change notification with a property indicating that this is the final update (the file - stream has been closed). If "false" a change notification is raised indicating the file has - changed. The default is false. This query parameter is set to true by the Hadoop ABFS driver to - indicate that the file stream has been closed.". Default value is None. - :type close: bool - :param content_length: Required for "Append Data" and "Flush Data". Must be 0 for "Flush - Data". Must be the length of the request content in bytes for "Append Data". Default value is - None. - :type content_length: int - :param properties: Optional. User-defined properties to be stored with the filesystem, in the - format of a comma-separated list of name and value pairs "n1=v1, n2=v2, ...", where each value - is a base64 encoded string. Note that the string may only contain ASCII characters in the - ISO-8859-1 character set. If the filesystem exists, any properties not included in the list - will be removed. All properties are removed if the header is omitted. To merge new and - existing properties, first get all existing properties and the current E-Tag, then make a - conditional request with the E-Tag and include values for all properties. Default value is - None. - :type properties: str - :param owner: Optional. The owner of the blob or directory. Default value is None. - :type owner: str - :param group: Optional. The owning group of the blob or directory. Default value is None. - :type group: str - :param permissions: Optional and only valid if Hierarchical Namespace is enabled for the - account. Sets POSIX access permissions for the file owner, the file owning group, and others. - Each class may be granted read, write, or execute permission. The sticky bit is also - supported. Both symbolic (rwxrw-rw-) and 4-digit octal notation (e.g. 0766) are supported. - Default value is None. - :type permissions: str - :param acl: Sets POSIX access control rights on files and directories. The value is a - comma-separated list of access control entries. Each access control entry (ACE) consists of a - scope, a type, a user or group identifier, and permissions in the format - "[scope:][type]:[id]:[permissions]". Default value is None. - :type acl: str - :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 path_http_headers: Parameter group. Default value is None. - :type path_http_headers: ~azure.storage.filedatalake.models.PathHTTPHeaders - :param lease_access_conditions: Parameter group. Default value is None. - :type lease_access_conditions: ~azure.storage.filedatalake.models.LeaseAccessConditions - :param modified_access_conditions: Parameter group. Default value is None. - :type modified_access_conditions: ~azure.storage.filedatalake.models.ModifiedAccessConditions - :return: SetAccessControlRecursiveResponse or None or the result of cls(response) - :rtype: ~azure.storage.filedatalake.models.SetAccessControlRecursiveResponse or 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 {} - - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/octet-stream")) - cls: ClsType[Optional[_models.SetAccessControlRecursiveResponse]] = kwargs.pop("cls", None) - - _content_md5 = None - _lease_id = None - _cache_control = None - _content_type_parameter = None - _content_disposition = None - _content_encoding = None - _content_language = None - _if_match = None - _if_none_match = None - _if_modified_since = None - _if_unmodified_since = None - if path_http_headers is not None: - _cache_control = path_http_headers.cache_control - _content_disposition = path_http_headers.content_disposition - _content_encoding = path_http_headers.content_encoding - _content_language = path_http_headers.content_language - _content_md5 = path_http_headers.content_md5 - _content_type_parameter = path_http_headers.content_type - if lease_access_conditions is not None: - _lease_id = lease_access_conditions.lease_id - if modified_access_conditions is not None: - _if_match = modified_access_conditions.if_match - _if_modified_since = modified_access_conditions.if_modified_since - _if_none_match = modified_access_conditions.if_none_match - _if_unmodified_since = modified_access_conditions.if_unmodified_since - _content = body - - _request = build_update_request( - url=self._config.url, - action=action, - mode=mode, - version=self._config.version, - request_id_parameter=request_id_parameter, - timeout=timeout, - max_records=max_records, - continuation=continuation, - force_flag=force_flag, - position=position, - retain_uncommitted_data=retain_uncommitted_data, - close=close, - content_length=content_length, - content_md5=_content_md5, - lease_id=_lease_id, - cache_control=_cache_control, - content_type_parameter=_content_type_parameter, - content_disposition=_content_disposition, - content_encoding=_content_encoding, - content_language=_content_language, - properties=properties, - owner=owner, - group=group, - permissions=permissions, - acl=acl, - if_match=_if_match, - if_none_match=_if_none_match, - if_modified_since=_if_modified_since, - if_unmodified_since=_if_unmodified_since, - structured_body_type=structured_body_type, - structured_content_length=structured_content_length, - content_type=content_type, - 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, 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) - - deserialized = None - response_headers = {} - if response.status_code == 200: - response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) - 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["Accept-Ranges"] = self._deserialize("str", response.headers.get("Accept-Ranges")) - 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-Encoding"] = self._deserialize("str", response.headers.get("Content-Encoding")) - response_headers["Content-Language"] = self._deserialize("str", response.headers.get("Content-Language")) - response_headers["Content-Length"] = self._deserialize("int", response.headers.get("Content-Length")) - response_headers["Content-Range"] = self._deserialize("str", response.headers.get("Content-Range")) - response_headers["Content-Type"] = self._deserialize("str", response.headers.get("Content-Type")) - response_headers["Content-MD5"] = self._deserialize("str", response.headers.get("Content-MD5")) - response_headers["x-ms-properties"] = self._deserialize("str", response.headers.get("x-ms-properties")) - response_headers["x-ms-continuation"] = self._deserialize("str", response.headers.get("x-ms-continuation")) - 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("SetAccessControlRecursiveResponse", pipeline_response.http_response) - - if response.status_code == 202: - response_headers["Content-MD5"] = self._deserialize("str", response.headers.get("Content-MD5")) - response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) - 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["x-ms-structured-body"] = self._deserialize( - "str", response.headers.get("x-ms-structured-body") - ) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def lease( - self, - x_ms_lease_action: Union[str, _models.PathLeaseAction], - request_id_parameter: Optional[str] = None, - timeout: Optional[int] = None, - x_ms_lease_break_period: Optional[int] = None, - proposed_lease_id: Optional[str] = None, - lease_access_conditions: Optional[_models.LeaseAccessConditions] = None, - modified_access_conditions: Optional[_models.ModifiedAccessConditions] = None, - **kwargs: Any - ) -> None: - """Lease Path. - - Create and manage a lease to restrict write and delete access to the path. This operation - supports conditional HTTP requests. For more information, see `Specifying Conditional Headers - for Blob Service Operations - `_. - - :param x_ms_lease_action: There are five lease actions: "acquire", "break", "change", "renew", - and "release". Use "acquire" and specify the "x-ms-proposed-lease-id" and "x-ms-lease-duration" - to acquire a new lease. Use "break" to break an existing lease. When a lease is broken, the - lease break period is allowed to elapse, during which time no lease operation except break and - release can be performed on the file. When a lease is successfully broken, the response - indicates the interval in seconds until a new lease can be acquired. Use "change" and specify - the current lease ID in "x-ms-lease-id" and the new lease ID in "x-ms-proposed-lease-id" to - change the lease ID of an active lease. Use "renew" and specify the "x-ms-lease-id" to renew an - existing lease. Use "release" and specify the "x-ms-lease-id" to release a lease. Known values - are: "acquire", "break", "change", "renew", and "release". Required. - :type x_ms_lease_action: str or ~azure.storage.filedatalake.models.PathLeaseAction - :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 timeout: The timeout parameter is expressed in seconds. For more information, see - :code:`Setting - Timeouts for Blob Service Operations.`. Default value is None. - :type timeout: int - :param x_ms_lease_break_period: The lease break period duration is optional to break a lease, - and specifies the break period of the lease in seconds. The lease break duration must be - between 0 and 60 seconds. Default value is None. - :type x_ms_lease_break_period: int - :param proposed_lease_id: Proposed lease ID, in a GUID string format. The Blob 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 lease_access_conditions: Parameter group. Default value is None. - :type lease_access_conditions: ~azure.storage.filedatalake.models.LeaseAccessConditions - :param modified_access_conditions: Parameter group. Default value is None. - :type modified_access_conditions: ~azure.storage.filedatalake.models.ModifiedAccessConditions - :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_match = None - _if_none_match = None - _if_modified_since = None - _if_unmodified_since = None - if lease_access_conditions is not None: - _lease_id = lease_access_conditions.lease_id - if modified_access_conditions is not None: - _if_match = modified_access_conditions.if_match - _if_modified_since = modified_access_conditions.if_modified_since - _if_none_match = modified_access_conditions.if_none_match - _if_unmodified_since = modified_access_conditions.if_unmodified_since - - _request = build_lease_request( - url=self._config.url, - x_ms_lease_action=x_ms_lease_action, - version=self._config.version, - request_id_parameter=request_id_parameter, - timeout=timeout, - x_ms_lease_break_period=x_ms_lease_break_period, - lease_id=_lease_id, - proposed_lease_id=proposed_lease_id, - if_match=_if_match, - if_none_match=_if_none_match, - if_modified_since=_if_modified_since, - if_unmodified_since=_if_unmodified_since, - x_ms_lease_duration=self._config.x_ms_lease_duration, - 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, 201, 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 = {} - if response.status_code == 200: - response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) - 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["x-ms-lease-id"] = self._deserialize("str", response.headers.get("x-ms-lease-id")) - - if response.status_code == 201: - response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) - 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["x-ms-lease-id"] = self._deserialize("str", response.headers.get("x-ms-lease-id")) - - if response.status_code == 202: - 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["x-ms-lease-time"] = self._deserialize("str", response.headers.get("x-ms-lease-time")) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @distributed_trace_async - async def read( - self, - request_id_parameter: Optional[str] = None, - timeout: Optional[int] = None, - range: Optional[str] = None, - x_ms_range_get_content_md5: Optional[bool] = None, - lease_access_conditions: Optional[_models.LeaseAccessConditions] = None, - modified_access_conditions: Optional[_models.ModifiedAccessConditions] = None, - cpk_info: Optional[_models.CpkInfo] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - """Read File. - - Read the contents of a file. For read operations, range requests are supported. This operation - supports conditional HTTP requests. For more information, see `Specifying Conditional Headers - for Blob Service Operations - `_. - - :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 timeout: The timeout parameter is expressed in seconds. For more information, see - :code:`Setting - Timeouts for Blob Service Operations.`. Default value is None. - :type timeout: int - :param range: The HTTP Range request header specifies one or more byte ranges of the resource - to be retrieved. Default value is None. - :type range: str - :param x_ms_range_get_content_md5: Optional. 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 4MB in size. If this header is specified without the Range - header, the service returns status code 400 (Bad Request). If this header is set to true when - the range exceeds 4 MB in size, the service returns status code 400 (Bad Request). Default - value is None. - :type x_ms_range_get_content_md5: bool - :param lease_access_conditions: Parameter group. Default value is None. - :type lease_access_conditions: ~azure.storage.filedatalake.models.LeaseAccessConditions - :param modified_access_conditions: Parameter group. Default value is None. - :type modified_access_conditions: ~azure.storage.filedatalake.models.ModifiedAccessConditions - :param cpk_info: Parameter group. Default value is None. - :type cpk_info: ~azure.storage.filedatalake.models.CpkInfo - :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_match = None - _if_none_match = None - _if_modified_since = None - _if_unmodified_since = None - _encryption_key = None - _encryption_key_sha256 = None - _encryption_algorithm = None - if lease_access_conditions is not None: - _lease_id = lease_access_conditions.lease_id - if modified_access_conditions is not None: - _if_match = modified_access_conditions.if_match - _if_modified_since = modified_access_conditions.if_modified_since - _if_none_match = modified_access_conditions.if_none_match - _if_unmodified_since = modified_access_conditions.if_unmodified_since - if cpk_info is not None: - _encryption_algorithm = cpk_info.encryption_algorithm - _encryption_key = cpk_info.encryption_key - _encryption_key_sha256 = cpk_info.encryption_key_sha256 - - _request = build_read_request( - url=self._config.url, - version=self._config.version, - request_id_parameter=request_id_parameter, - timeout=timeout, - range=range, - lease_id=_lease_id, - x_ms_range_get_content_md5=x_ms_range_get_content_md5, - if_match=_if_match, - if_none_match=_if_none_match, - if_modified_since=_if_modified_since, - if_unmodified_since=_if_unmodified_since, - encryption_key=_encryption_key, - encryption_key_sha256=_encryption_key_sha256, - encryption_algorithm=_encryption_algorithm, # type: ignore - 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 = {} - if response.status_code == 200: - response_headers["Accept-Ranges"] = self._deserialize("str", response.headers.get("Accept-Ranges")) - 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-Encoding"] = self._deserialize("str", response.headers.get("Content-Encoding")) - response_headers["Content-Language"] = self._deserialize("str", response.headers.get("Content-Language")) - response_headers["Content-Length"] = self._deserialize("int", response.headers.get("Content-Length")) - response_headers["Content-Range"] = self._deserialize("str", response.headers.get("Content-Range")) - response_headers["Content-Type"] = self._deserialize("str", response.headers.get("Content-Type")) - response_headers["Content-MD5"] = self._deserialize("str", response.headers.get("Content-MD5")) - response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) - 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["x-ms-resource-type"] = self._deserialize( - "str", response.headers.get("x-ms-resource-type") - ) - response_headers["x-ms-properties"] = self._deserialize("str", response.headers.get("x-ms-properties")) - 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-request-server-encrypted"] = self._deserialize( - "bool", response.headers.get("x-ms-request-server-encrypted") - ) - response_headers["x-ms-encryption-key-sha256"] = self._deserialize( - "str", response.headers.get("x-ms-encryption-key-sha256") - ) - - if response.status_code == 206: - response_headers["Accept-Ranges"] = self._deserialize("str", response.headers.get("Accept-Ranges")) - 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-Encoding"] = self._deserialize("str", response.headers.get("Content-Encoding")) - response_headers["Content-Language"] = self._deserialize("str", response.headers.get("Content-Language")) - response_headers["Content-Length"] = self._deserialize("int", response.headers.get("Content-Length")) - response_headers["Content-Range"] = self._deserialize("str", response.headers.get("Content-Range")) - response_headers["Content-Type"] = self._deserialize("str", response.headers.get("Content-Type")) - response_headers["Content-MD5"] = self._deserialize("str", response.headers.get("Content-MD5")) - response_headers["x-ms-content-md5"] = self._deserialize("str", response.headers.get("x-ms-content-md5")) - response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) - 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["x-ms-resource-type"] = self._deserialize( - "str", response.headers.get("x-ms-resource-type") - ) - response_headers["x-ms-properties"] = self._deserialize("str", response.headers.get("x-ms-properties")) - 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-request-server-encrypted"] = self._deserialize( - "bool", response.headers.get("x-ms-request-server-encrypted") - ) - response_headers["x-ms-encryption-key-sha256"] = self._deserialize( - "str", response.headers.get("x-ms-encryption-key-sha256") - ) - - 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, - request_id_parameter: Optional[str] = None, - timeout: Optional[int] = None, - action: Optional[Union[str, _models.PathGetPropertiesAction]] = None, - upn: Optional[bool] = None, - lease_access_conditions: Optional[_models.LeaseAccessConditions] = None, - modified_access_conditions: Optional[_models.ModifiedAccessConditions] = None, - **kwargs: Any - ) -> None: - """Get Properties | Get Status | Get Access Control List. - - Get Properties returns all system and user defined properties for a path. Get Status returns - all system defined properties for a path. Get Access Control List returns the access control - list for a path. This operation supports conditional HTTP requests. For more information, see - `Specifying Conditional Headers for Blob Service Operations - `_. - - :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 timeout: The timeout parameter is expressed in seconds. For more information, see - :code:`Setting - Timeouts for Blob Service Operations.`. Default value is None. - :type timeout: int - :param action: Optional. If the value is "getStatus" only the system defined properties for the - path are returned. If the value is "getAccessControl" the access control list is returned in - the response headers (Hierarchical Namespace must be enabled for the account), otherwise the - properties are returned. Known values are: "getAccessControl" and "getStatus". Default value is - None. - :type action: str or ~azure.storage.filedatalake.models.PathGetPropertiesAction - :param upn: Optional. Valid only when Hierarchical Namespace is enabled for the account. If - "true", the user identity values returned in the x-ms-owner, x-ms-group, and x-ms-acl response - headers will be transformed from Azure Active Directory Object IDs to User Principal Names. If - "false", the values will be returned as Azure Active Directory Object IDs. The default value is - false. Note that group and application Object IDs are not translated because they do not have - unique friendly names. Default value is None. - :type upn: bool - :param lease_access_conditions: Parameter group. Default value is None. - :type lease_access_conditions: ~azure.storage.filedatalake.models.LeaseAccessConditions - :param modified_access_conditions: Parameter group. Default value is None. - :type modified_access_conditions: ~azure.storage.filedatalake.models.ModifiedAccessConditions - :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_match = None - _if_none_match = None - _if_modified_since = None - _if_unmodified_since = None - if lease_access_conditions is not None: - _lease_id = lease_access_conditions.lease_id - if modified_access_conditions is not None: - _if_match = modified_access_conditions.if_match - _if_modified_since = modified_access_conditions.if_modified_since - _if_none_match = modified_access_conditions.if_none_match - _if_unmodified_since = modified_access_conditions.if_unmodified_since - - _request = build_get_properties_request( - url=self._config.url, - version=self._config.version, - request_id_parameter=request_id_parameter, - timeout=timeout, - action=action, - upn=upn, - lease_id=_lease_id, - if_match=_if_match, - if_none_match=_if_none_match, - if_modified_since=_if_modified_since, - if_unmodified_since=_if_unmodified_since, - 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["Accept-Ranges"] = self._deserialize("str", response.headers.get("Accept-Ranges")) - 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-Encoding"] = self._deserialize("str", response.headers.get("Content-Encoding")) - response_headers["Content-Language"] = self._deserialize("str", response.headers.get("Content-Language")) - response_headers["Content-Length"] = self._deserialize("int", response.headers.get("Content-Length")) - response_headers["Content-Range"] = self._deserialize("str", response.headers.get("Content-Range")) - response_headers["Content-Type"] = self._deserialize("str", response.headers.get("Content-Type")) - response_headers["Content-MD5"] = self._deserialize("str", response.headers.get("Content-MD5")) - response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) - 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["x-ms-resource-type"] = self._deserialize("str", response.headers.get("x-ms-resource-type")) - response_headers["x-ms-properties"] = self._deserialize("str", response.headers.get("x-ms-properties")) - 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-permissions"] = self._deserialize("str", response.headers.get("x-ms-permissions")) - response_headers["x-ms-acl"] = self._deserialize("str", response.headers.get("x-ms-acl")) - 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-server-encrypted"] = self._deserialize( - "bool", response.headers.get("x-ms-server-encrypted") - ) - response_headers["x-ms-encryption-key-sha256"] = self._deserialize( - "str", response.headers.get("x-ms-encryption-key-sha256") - ) - response_headers["x-ms-encryption-context"] = self._deserialize( - "str", response.headers.get("x-ms-encryption-context") - ) - response_headers["x-ms-encryption-scope"] = self._deserialize( - "str", response.headers.get("x-ms-encryption-scope") - ) - response_headers["x-ms-creation-time"] = self._deserialize( - "rfc-1123", response.headers.get("x-ms-creation-time") - ) - response_headers["x-ms-expiry-time"] = self._deserialize("rfc-1123", response.headers.get("x-ms-expiry-time")) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @distributed_trace_async - async def delete( - self, - request_id_parameter: Optional[str] = None, - timeout: Optional[int] = None, - recursive: Optional[bool] = None, - continuation: Optional[str] = None, - paginated: Optional[bool] = None, - lease_access_conditions: Optional[_models.LeaseAccessConditions] = None, - modified_access_conditions: Optional[_models.ModifiedAccessConditions] = None, - **kwargs: Any - ) -> None: - """Delete File | Delete Directory. - - Delete the file or directory. This operation supports conditional HTTP requests. For more - information, see `Specifying Conditional Headers for Blob Service Operations - `_. - - :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 timeout: The timeout parameter is expressed in seconds. For more information, see - :code:`Setting - Timeouts for Blob Service Operations.`. Default value is None. - :type timeout: int - :param recursive: Required. Default value is None. - :type recursive: bool - :param continuation: Optional. When deleting a directory, the number of paths that are deleted - with each invocation is limited. If the number of paths to be deleted exceeds this limit, a - continuation token is returned in this response header. When a continuation token is returned - in the response, it must be specified in a subsequent invocation of the delete operation to - continue deleting the directory. Default value is None. - :type continuation: str - :param paginated: If true, paginated behavior will be seen. Pagination is for the recursive ACL - checks as a POSIX requirement in the server and Delete in an atomic operation once the ACL - checks are completed. If false or missing, normal default behavior will kick in, which may - timeout in case of very large directories due to recursive ACL checks. This new parameter is - introduced for backward compatibility. Default value is None. - :type paginated: bool - :param lease_access_conditions: Parameter group. Default value is None. - :type lease_access_conditions: ~azure.storage.filedatalake.models.LeaseAccessConditions - :param modified_access_conditions: Parameter group. Default value is None. - :type modified_access_conditions: ~azure.storage.filedatalake.models.ModifiedAccessConditions - :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_match = None - _if_none_match = None - _if_modified_since = None - _if_unmodified_since = None - if lease_access_conditions is not None: - _lease_id = lease_access_conditions.lease_id - if modified_access_conditions is not None: - _if_match = modified_access_conditions.if_match - _if_modified_since = modified_access_conditions.if_modified_since - _if_none_match = modified_access_conditions.if_none_match - _if_unmodified_since = modified_access_conditions.if_unmodified_since - - _request = build_delete_request( - url=self._config.url, - version=self._config.version, - request_id_parameter=request_id_parameter, - timeout=timeout, - recursive=recursive, - continuation=continuation, - lease_id=_lease_id, - if_match=_if_match, - if_none_match=_if_none_match, - if_modified_since=_if_modified_since, - if_unmodified_since=_if_unmodified_since, - paginated=paginated, - 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, 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 = {} - if response.status_code == 200: - response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) - 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["x-ms-continuation"] = self._deserialize("str", response.headers.get("x-ms-continuation")) - response_headers["x-ms-deletion-id"] = self._deserialize("str", response.headers.get("x-ms-deletion-id")) - - if response.status_code == 202: - response_headers["Date"] = self._deserialize("str", response.headers.get("Date")) - 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["x-ms-continuation"] = self._deserialize("str", response.headers.get("x-ms-continuation")) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @distributed_trace_async - async def set_access_control( - self, - timeout: Optional[int] = None, - owner: Optional[str] = None, - group: Optional[str] = None, - permissions: Optional[str] = None, - acl: Optional[str] = None, - request_id_parameter: Optional[str] = None, - lease_access_conditions: Optional[_models.LeaseAccessConditions] = None, - modified_access_conditions: Optional[_models.ModifiedAccessConditions] = None, - **kwargs: Any - ) -> None: - """Set the owner, group, permissions, or access control list for a path. - - :param timeout: The timeout parameter is expressed in seconds. For more information, see - :code:`Setting - Timeouts for Blob Service Operations.`. Default value is None. - :type timeout: int - :param owner: Optional. The owner of the blob or directory. Default value is None. - :type owner: str - :param group: Optional. The owning group of the blob or directory. Default value is None. - :type group: str - :param permissions: Optional and only valid if Hierarchical Namespace is enabled for the - account. Sets POSIX access permissions for the file owner, the file owning group, and others. - Each class may be granted read, write, or execute permission. The sticky bit is also - supported. Both symbolic (rwxrw-rw-) and 4-digit octal notation (e.g. 0766) are supported. - Default value is None. - :type permissions: str - :param acl: Sets POSIX access control rights on files and directories. The value is a - comma-separated list of access control entries. Each access control entry (ACE) consists of a - scope, a type, a user or group identifier, and permissions in the format - "[scope:][type]:[id]:[permissions]". Default value is None. - :type acl: 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 lease_access_conditions: Parameter group. Default value is None. - :type lease_access_conditions: ~azure.storage.filedatalake.models.LeaseAccessConditions - :param modified_access_conditions: Parameter group. Default value is None. - :type modified_access_conditions: ~azure.storage.filedatalake.models.ModifiedAccessConditions - :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 {}) - - action: Literal["setAccessControl"] = kwargs.pop("action", _params.pop("action", "setAccessControl")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _lease_id = None - _if_match = None - _if_none_match = None - _if_modified_since = None - _if_unmodified_since = None - if lease_access_conditions is not None: - _lease_id = lease_access_conditions.lease_id - if modified_access_conditions is not None: - _if_match = modified_access_conditions.if_match - _if_modified_since = modified_access_conditions.if_modified_since - _if_none_match = modified_access_conditions.if_none_match - _if_unmodified_since = modified_access_conditions.if_unmodified_since - - _request = build_set_access_control_request( - url=self._config.url, - version=self._config.version, - timeout=timeout, - lease_id=_lease_id, - owner=owner, - group=group, - permissions=permissions, - acl=acl, - if_match=_if_match, - if_none_match=_if_none_match, - if_modified_since=_if_modified_since, - if_unmodified_since=_if_unmodified_since, - request_id_parameter=request_id_parameter, - action=action, - 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["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) - 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")) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @distributed_trace_async - async def set_access_control_recursive( - self, - mode: Union[str, _models.PathSetAccessControlRecursiveMode], - timeout: Optional[int] = None, - continuation: Optional[str] = None, - force_flag: Optional[bool] = None, - max_records: Optional[int] = None, - acl: Optional[str] = None, - request_id_parameter: Optional[str] = None, - **kwargs: Any - ) -> _models.SetAccessControlRecursiveResponse: - """Set the access control list for a path and sub-paths. - - :param mode: Mode "set" sets POSIX access control rights on files and directories, "modify" - modifies one or more POSIX access control rights that pre-exist on files and directories, - "remove" removes one or more POSIX access control rights that were present earlier on files - and directories. Known values are: "set", "modify", and "remove". Required. - :type mode: str or ~azure.storage.filedatalake.models.PathSetAccessControlRecursiveMode - :param timeout: The timeout parameter is expressed in seconds. For more information, see - :code:`Setting - Timeouts for Blob Service Operations.`. Default value is None. - :type timeout: int - :param continuation: Optional. When deleting a directory, the number of paths that are deleted - with each invocation is limited. If the number of paths to be deleted exceeds this limit, a - continuation token is returned in this response header. When a continuation token is returned - in the response, it must be specified in a subsequent invocation of the delete operation to - continue deleting the directory. Default value is None. - :type continuation: str - :param force_flag: Optional. Valid for "SetAccessControlRecursive" operation. If set to false, - the operation will terminate quickly on encountering user errors (4XX). If true, the operation - will ignore user errors and proceed with the operation on other sub-entities of the directory. - Continuation token will only be returned when forceFlag is true in case of user errors. If not - set the default value is false for this. Default value is None. - :type force_flag: bool - :param max_records: Optional. It specifies the maximum number of files or directories on which - the acl change will be applied. If omitted or greater than 2,000, the request will process up - to 2,000 items. Default value is None. - :type max_records: int - :param acl: Sets POSIX access control rights on files and directories. The value is a - comma-separated list of access control entries. Each access control entry (ACE) consists of a - scope, a type, a user or group identifier, and permissions in the format - "[scope:][type]:[id]:[permissions]". Default value is None. - :type acl: 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: SetAccessControlRecursiveResponse or the result of cls(response) - :rtype: ~azure.storage.filedatalake.models.SetAccessControlRecursiveResponse - :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 {}) - - action: Literal["setAccessControlRecursive"] = kwargs.pop( - "action", _params.pop("action", "setAccessControlRecursive") - ) - cls: ClsType[_models.SetAccessControlRecursiveResponse] = kwargs.pop("cls", None) - - _request = build_set_access_control_recursive_request( - url=self._config.url, - mode=mode, - version=self._config.version, - timeout=timeout, - continuation=continuation, - force_flag=force_flag, - max_records=max_records, - acl=acl, - request_id_parameter=request_id_parameter, - action=action, - 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["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) - response_headers["x-ms-client-request-id"] = self._deserialize( - "str", response.headers.get("x-ms-client-request-id") - ) - response_headers["x-ms-continuation"] = self._deserialize("str", response.headers.get("x-ms-continuation")) - 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("SetAccessControlRecursiveResponse", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def flush_data( # pylint: disable=too-many-locals - self, - timeout: Optional[int] = None, - position: Optional[int] = None, - retain_uncommitted_data: Optional[bool] = None, - close: Optional[bool] = None, - content_length: Optional[int] = None, - lease_action: Optional[Union[str, _models.LeaseAction]] = None, - lease_duration: Optional[int] = None, - proposed_lease_id: Optional[str] = None, - request_id_parameter: Optional[str] = None, - path_http_headers: Optional[_models.PathHTTPHeaders] = None, - lease_access_conditions: Optional[_models.LeaseAccessConditions] = None, - modified_access_conditions: Optional[_models.ModifiedAccessConditions] = None, - cpk_info: Optional[_models.CpkInfo] = None, - **kwargs: Any - ) -> None: - """Set the owner, group, permissions, or access control list for a path. - - :param timeout: The timeout parameter is expressed in seconds. For more information, see - :code:`Setting - Timeouts for Blob Service Operations.`. Default value is None. - :type timeout: int - :param position: This parameter allows the caller to upload data in parallel and control the - order in which it is appended to the file. It is required when uploading data to be appended - to the file and when flushing previously uploaded data to the file. The value must be the - position where the data is to be appended. Uploaded data is not immediately flushed, or - written, to the file. To flush, the previously uploaded data must be contiguous, the position - parameter must be specified and equal to the length of the file after all data has been - written, and there must not be a request entity body included with the request. Default value - is None. - :type position: int - :param retain_uncommitted_data: Valid only for flush operations. If "true", uncommitted data - is retained after the flush operation completes; otherwise, the uncommitted data is deleted - after the flush operation. The default is false. Data at offsets less than the specified - position are written to the file when flush succeeds, but this optional parameter allows data - after the flush position to be retained for a future flush operation. Default value is None. - :type retain_uncommitted_data: bool - :param close: Azure Storage Events allow applications to receive notifications when files - change. When Azure Storage Events are enabled, a file changed event is raised. This event has a - property indicating whether this is the final change to distinguish the difference between an - intermediate flush to a file stream and the final close of a file stream. The close query - parameter is valid only when the action is "flush" and change notifications are enabled. If the - value of close is "true" and the flush operation completes successfully, the service raises a - file change notification with a property indicating that this is the final update (the file - stream has been closed). If "false" a change notification is raised indicating the file has - changed. The default is false. This query parameter is set to true by the Hadoop ABFS driver to - indicate that the file stream has been closed.". Default value is None. - :type close: bool - :param content_length: Required for "Append Data" and "Flush Data". Must be 0 for "Flush - Data". Must be the length of the request content in bytes for "Append Data". Default value is - None. - :type content_length: int - :param lease_action: Optional. If "acquire" it will acquire the lease. If "auto-renew" it will - renew the lease. If "release" it will release the lease only on flush. If "acquire-release" it - will acquire & complete the operation & release the lease once operation is done. Known values - are: "acquire", "auto-renew", "release", and "acquire-release". Default value is None. - :type lease_action: str or ~azure.storage.filedatalake.models.LeaseAction - :param lease_duration: The lease duration is required to acquire a lease, and specifies the - duration of the lease in seconds. The lease duration must be between 15 and 60 seconds or -1 - for infinite lease. Default value is None. - :type lease_duration: int - :param proposed_lease_id: Proposed lease ID, in a GUID string format. The Blob 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 - :param path_http_headers: Parameter group. Default value is None. - :type path_http_headers: ~azure.storage.filedatalake.models.PathHTTPHeaders - :param lease_access_conditions: Parameter group. Default value is None. - :type lease_access_conditions: ~azure.storage.filedatalake.models.LeaseAccessConditions - :param modified_access_conditions: Parameter group. Default value is None. - :type modified_access_conditions: ~azure.storage.filedatalake.models.ModifiedAccessConditions - :param cpk_info: Parameter group. Default value is None. - :type cpk_info: ~azure.storage.filedatalake.models.CpkInfo - :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 {}) - - action: Literal["flush"] = kwargs.pop("action", _params.pop("action", "flush")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _content_md5 = None - _lease_id = None - _cache_control = None - _content_type_parameter = None - _content_disposition = None - _content_encoding = None - _content_language = None - _if_match = None - _if_none_match = None - _if_modified_since = None - _if_unmodified_since = None - _encryption_key = None - _encryption_key_sha256 = None - _encryption_algorithm = None - if path_http_headers is not None: - _cache_control = path_http_headers.cache_control - _content_disposition = path_http_headers.content_disposition - _content_encoding = path_http_headers.content_encoding - _content_language = path_http_headers.content_language - _content_md5 = path_http_headers.content_md5 - _content_type_parameter = path_http_headers.content_type - if lease_access_conditions is not None: - _lease_id = lease_access_conditions.lease_id - if modified_access_conditions is not None: - _if_match = modified_access_conditions.if_match - _if_modified_since = modified_access_conditions.if_modified_since - _if_none_match = modified_access_conditions.if_none_match - _if_unmodified_since = modified_access_conditions.if_unmodified_since - if cpk_info is not None: - _encryption_algorithm = cpk_info.encryption_algorithm - _encryption_key = cpk_info.encryption_key - _encryption_key_sha256 = cpk_info.encryption_key_sha256 - - _request = build_flush_data_request( - url=self._config.url, - version=self._config.version, - timeout=timeout, - position=position, - retain_uncommitted_data=retain_uncommitted_data, - close=close, - content_length=content_length, - content_md5=_content_md5, - lease_id=_lease_id, - lease_action=lease_action, - lease_duration=lease_duration, - proposed_lease_id=proposed_lease_id, - cache_control=_cache_control, - content_type_parameter=_content_type_parameter, - content_disposition=_content_disposition, - content_encoding=_content_encoding, - content_language=_content_language, - if_match=_if_match, - if_none_match=_if_none_match, - if_modified_since=_if_modified_since, - if_unmodified_since=_if_unmodified_since, - request_id_parameter=request_id_parameter, - encryption_key=_encryption_key, - encryption_key_sha256=_encryption_key_sha256, - encryption_algorithm=_encryption_algorithm, # type: ignore - action=action, - 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["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) - 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-Length"] = self._deserialize("int", response.headers.get("Content-Length")) - 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["x-ms-request-server-encrypted"] = self._deserialize( - "bool", response.headers.get("x-ms-request-server-encrypted") - ) - response_headers["x-ms-encryption-key-sha256"] = self._deserialize( - "str", response.headers.get("x-ms-encryption-key-sha256") - ) - response_headers["x-ms-lease-renewed"] = self._deserialize("bool", response.headers.get("x-ms-lease-renewed")) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @distributed_trace_async - async def append_data( # pylint: disable=too-many-locals - self, - body: IO[bytes], - position: Optional[int] = None, - timeout: Optional[int] = None, - content_length: Optional[int] = None, - transactional_content_crc64: Optional[bytes] = None, - lease_action: Optional[Union[str, _models.LeaseAction]] = None, - lease_duration: Optional[int] = None, - proposed_lease_id: Optional[str] = None, - request_id_parameter: Optional[str] = None, - flush: Optional[bool] = None, - structured_body_type: Optional[str] = None, - structured_content_length: Optional[int] = None, - path_http_headers: Optional[_models.PathHTTPHeaders] = None, - lease_access_conditions: Optional[_models.LeaseAccessConditions] = None, - cpk_info: Optional[_models.CpkInfo] = None, - **kwargs: Any - ) -> None: - """Append data to the file. - - :param body: Initial data. Required. - :type body: IO[bytes] - :param position: This parameter allows the caller to upload data in parallel and control the - order in which it is appended to the file. It is required when uploading data to be appended - to the file and when flushing previously uploaded data to the file. The value must be the - position where the data is to be appended. Uploaded data is not immediately flushed, or - written, to the file. To flush, the previously uploaded data must be contiguous, the position - parameter must be specified and equal to the length of the file after all data has been - written, and there must not be a request entity body included with the request. Default value - is None. - :type position: int - :param timeout: The timeout parameter is expressed in seconds. For more information, see - :code:`Setting - Timeouts for Blob Service Operations.`. Default value is None. - :type timeout: int - :param content_length: Required for "Append Data" and "Flush Data". Must be 0 for "Flush - Data". Must be the length of the request content in bytes for "Append Data". Default value is - None. - :type content_length: int - :param transactional_content_crc64: Specify the transactional crc64 for the body, to be - validated by the service. Default value is None. - :type transactional_content_crc64: bytes - :param lease_action: Optional. If "acquire" it will acquire the lease. If "auto-renew" it will - renew the lease. If "release" it will release the lease only on flush. If "acquire-release" it - will acquire & complete the operation & release the lease once operation is done. Known values - are: "acquire", "auto-renew", "release", and "acquire-release". Default value is None. - :type lease_action: str or ~azure.storage.filedatalake.models.LeaseAction - :param lease_duration: The lease duration is required to acquire a lease, and specifies the - duration of the lease in seconds. The lease duration must be between 15 and 60 seconds or -1 - for infinite lease. Default value is None. - :type lease_duration: int - :param proposed_lease_id: Proposed lease ID, in a GUID string format. The Blob 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 - :param flush: If file should be flushed after the append. Default value is None. - :type flush: bool - :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 path_http_headers: Parameter group. Default value is None. - :type path_http_headers: ~azure.storage.filedatalake.models.PathHTTPHeaders - :param lease_access_conditions: Parameter group. Default value is None. - :type lease_access_conditions: ~azure.storage.filedatalake.models.LeaseAccessConditions - :param cpk_info: Parameter group. Default value is None. - :type cpk_info: ~azure.storage.filedatalake.models.CpkInfo - :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 {}) - - action: Literal["append"] = kwargs.pop("action", _params.pop("action", "append")) - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _transactional_content_hash = None - _lease_id = None - _encryption_key = None - _encryption_key_sha256 = None - _encryption_algorithm = None - if path_http_headers is not None: - _transactional_content_hash = path_http_headers.transactional_content_hash - if lease_access_conditions is not None: - _lease_id = lease_access_conditions.lease_id - if cpk_info is not None: - _encryption_algorithm = cpk_info.encryption_algorithm - _encryption_key = cpk_info.encryption_key - _encryption_key_sha256 = cpk_info.encryption_key_sha256 - _content = body - - _request = build_append_data_request( - url=self._config.url, - version=self._config.version, - position=position, - timeout=timeout, - content_length=content_length, - transactional_content_hash=_transactional_content_hash, - transactional_content_crc64=transactional_content_crc64, - lease_id=_lease_id, - lease_action=lease_action, - lease_duration=lease_duration, - proposed_lease_id=proposed_lease_id, - request_id_parameter=request_id_parameter, - encryption_key=_encryption_key, - encryption_key_sha256=_encryption_key_sha256, - encryption_algorithm=_encryption_algorithm, # type: ignore - flush=flush, - structured_body_type=structured_body_type, - structured_content_length=structured_content_length, - action=action, - content_type=content_type, - 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["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) - 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["ETag"] = self._deserialize("str", response.headers.get("ETag")) - response_headers["Content-MD5"] = self._deserialize("bytearray", response.headers.get("Content-MD5")) - response_headers["x-ms-content-crc64"] = self._deserialize( - "bytearray", response.headers.get("x-ms-content-crc64") - ) - response_headers["x-ms-request-server-encrypted"] = self._deserialize( - "bool", response.headers.get("x-ms-request-server-encrypted") - ) - response_headers["x-ms-encryption-key-sha256"] = self._deserialize( - "str", response.headers.get("x-ms-encryption-key-sha256") - ) - response_headers["x-ms-lease-renewed"] = self._deserialize("bool", response.headers.get("x-ms-lease-renewed")) - 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 set_expiry( - self, - expiry_options: Union[str, _models.PathExpiryOptions], - timeout: Optional[int] = None, - request_id_parameter: Optional[str] = None, - expires_on: Optional[str] = None, - **kwargs: Any - ) -> None: - """Sets the time a blob will expire and be deleted. - - :param expiry_options: Required. Indicates mode of the expiry time. Known values are: - "NeverExpire", "RelativeToCreation", "RelativeToNow", and "Absolute". Required. - :type expiry_options: str or ~azure.storage.filedatalake.models.PathExpiryOptions - :param timeout: The timeout parameter is expressed in seconds. For more information, see - :code:`Setting - Timeouts for Blob Service Operations.`. 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 expires_on: The time to set the blob to expiry. Default value is None. - :type expires_on: 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["expiry"] = kwargs.pop("comp", _params.pop("comp", "expiry")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_set_expiry_request( - url=self._config.url, - expiry_options=expiry_options, - version=self._config.version, - timeout=timeout, - request_id_parameter=request_id_parameter, - expires_on=expires_on, - comp=comp, - 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 undelete( - self, - timeout: Optional[int] = None, - undelete_source: Optional[str] = None, - request_id_parameter: Optional[str] = None, - **kwargs: Any - ) -> None: - """Undelete a path that was previously soft deleted. - - :param timeout: The timeout parameter is expressed in seconds. For more information, see - :code:`Setting - Timeouts for Blob Service Operations.`. Default value is None. - :type timeout: int - :param undelete_source: Only for hierarchical namespace enabled accounts. Optional. The path of - the soft deleted blob to undelete. Default value is None. - :type undelete_source: 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 {}) - - comp: Literal["undelete"] = kwargs.pop("comp", _params.pop("comp", "undelete")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_undelete_request( - url=self._config.url, - version=self._config.version, - timeout=timeout, - undelete_source=undelete_source, - request_id_parameter=request_id_parameter, - comp=comp, - 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-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-resource-type"] = self._deserialize("str", response.headers.get("x-ms-resource-type")) - 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 diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/aio/operations/_service_operations.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/aio/operations/_service_operations.py deleted file mode 100644 index 1f97459e2812..000000000000 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/aio/operations/_service_operations.py +++ /dev/null @@ -1,160 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from typing import Any, Callable, Literal, Optional, TypeVar - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -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 import distributed_trace -from azure.core.utils import case_insensitive_dict - -from ... import models as _models -from ..._utils.serialization import Deserializer, Serializer -from ...operations._service_operations import build_list_file_systems_request -from .._configuration import AzureDataLakeStorageRESTAPIConfiguration - -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.filedatalake.aio.AzureDataLakeStorageRESTAPI`'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: AzureDataLakeStorageRESTAPIConfiguration = ( - 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 - def list_file_systems( - self, - prefix: Optional[str] = None, - continuation: Optional[str] = None, - max_results: Optional[int] = None, - request_id_parameter: Optional[str] = None, - timeout: Optional[int] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.FileSystem"]: - """List FileSystems. - - List filesystems and their properties in given account. - - :param prefix: Filters results to filesystems within the specified prefix. Default value is - None. - :type prefix: str - :param continuation: Optional. When deleting a directory, the number of paths that are deleted - with each invocation is limited. If the number of paths to be deleted exceeds this limit, a - continuation token is returned in this response header. When a continuation token is returned - in the response, it must be specified in a subsequent invocation of the delete operation to - continue deleting the directory. Default value is None. - :type continuation: str - :param max_results: An optional value that specifies the maximum number of items to return. If - omitted or greater than 5,000, the response will include up to 5,000 items. Default value is - None. - :type max_results: 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 timeout: The timeout parameter is expressed in seconds. For more information, see - :code:`Setting - Timeouts for Blob Service Operations.`. Default value is None. - :type timeout: int - :return: An iterator like instance of either FileSystem or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.storage.filedatalake.models.FileSystem] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - resource: Literal["account"] = kwargs.pop("resource", _params.pop("resource", "account")) - cls: ClsType[_models.FileSystemList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_file_systems_request( - url=self._config.url, - version=self._config.version, - prefix=prefix, - continuation=continuation, - max_results=max_results, - request_id_parameter=request_id_parameter, - timeout=timeout, - resource=resource, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("FileSystemList", pipeline_response) - list_of_elem = deserialized.filesystems - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _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) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/models/__init__.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/models/__init__.py index ca1ce1ca0e03..d3f5f19040ed 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/models/__init__.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/models/__init__.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- # pylint: disable=wrong-import-position @@ -13,30 +13,29 @@ from ._patch import * # pylint: disable=unused-wildcard-import -from ._models_py3 import ( # type: ignore +from ._models import ( # type: ignore AclFailedEntry, BlobHierarchyListSegment, BlobItemInternal, BlobPrefix, BlobPropertiesInternal, - CpkInfo, - FileSystem, + FileSystemItem, FileSystemList, - LeaseAccessConditions, ListBlobsHierarchySegmentResponse, - ModifiedAccessConditions, Path, - PathHTTPHeaders, PathList, SetAccessControlRecursiveResponse, - SourceModifiedAccessConditions, StorageError, - StorageErrorError, + StorageErrorBody, ) -from ._azure_data_lake_storage_restapi_enums import ( # type: ignore +from ._enums import ( # type: ignore + AccountResourceType, + EncryptionAlgorithmType, + FileSystemResourceType, LeaseAction, ListBlobsIncludeItem, + ListBlobsShowOnly, PathExpiryOptions, PathGetPropertiesAction, PathLeaseAction, @@ -55,21 +54,20 @@ "BlobItemInternal", "BlobPrefix", "BlobPropertiesInternal", - "CpkInfo", - "FileSystem", + "FileSystemItem", "FileSystemList", - "LeaseAccessConditions", "ListBlobsHierarchySegmentResponse", - "ModifiedAccessConditions", "Path", - "PathHTTPHeaders", "PathList", "SetAccessControlRecursiveResponse", - "SourceModifiedAccessConditions", "StorageError", - "StorageErrorError", + "StorageErrorBody", + "AccountResourceType", + "EncryptionAlgorithmType", + "FileSystemResourceType", "LeaseAction", "ListBlobsIncludeItem", + "ListBlobsShowOnly", "PathExpiryOptions", "PathGetPropertiesAction", "PathLeaseAction", diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/models/_azure_data_lake_storage_restapi_enums.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/models/_azure_data_lake_storage_restapi_enums.py deleted file mode 100644 index f9fe6b949142..000000000000 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/models/_azure_data_lake_storage_restapi_enums.py +++ /dev/null @@ -1,89 +0,0 @@ -# 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 enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class LeaseAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """LeaseAction.""" - - ACQUIRE = "acquire" - AUTO_RENEW = "auto-renew" - RELEASE = "release" - ACQUIRE_RELEASE = "acquire-release" - - -class ListBlobsIncludeItem(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """ListBlobsIncludeItem.""" - - COPY = "copy" - DELETED = "deleted" - METADATA = "metadata" - SNAPSHOTS = "snapshots" - UNCOMMITTEDBLOBS = "uncommittedblobs" - VERSIONS = "versions" - TAGS = "tags" - - -class PathExpiryOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """PathExpiryOptions.""" - - NEVER_EXPIRE = "NeverExpire" - RELATIVE_TO_CREATION = "RelativeToCreation" - RELATIVE_TO_NOW = "RelativeToNow" - ABSOLUTE = "Absolute" - - -class PathGetPropertiesAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """PathGetPropertiesAction.""" - - GET_ACCESS_CONTROL = "getAccessControl" - GET_STATUS = "getStatus" - - -class PathLeaseAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """PathLeaseAction.""" - - ACQUIRE = "acquire" - BREAK = "break" - CHANGE = "change" - RENEW = "renew" - RELEASE = "release" - - -class PathRenameMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """PathRenameMode.""" - - LEGACY = "legacy" - POSIX = "posix" - - -class PathResourceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """PathResourceType.""" - - DIRECTORY = "directory" - FILE = "file" - - -class PathSetAccessControlRecursiveMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """PathSetAccessControlRecursiveMode.""" - - SET = "set" - MODIFY = "modify" - REMOVE = "remove" - - -class PathUpdateAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """PathUpdateAction.""" - - APPEND = "append" - FLUSH = "flush" - SET_PROPERTIES = "setProperties" - SET_ACCESS_CONTROL = "setAccessControl" - SET_ACCESS_CONTROL_RECURSIVE = "setAccessControlRecursive" diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/models/_enums.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/models/_enums.py new file mode 100644 index 000000000000..2f75d59f3524 --- /dev/null +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/models/_enums.py @@ -0,0 +1,151 @@ +# 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) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from enum import Enum +from azure.core import CaseInsensitiveEnumMeta + + +class AccountResourceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The value must be "account" for all account operations.""" + + ACCOUNT = "account" + """The account resource type.""" + + +class EncryptionAlgorithmType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The encryption algorithm type.""" + + AES256 = "AES256" + """The AES256 encryption algorithm.""" + + +class FileSystemResourceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The value must be "filesystem" for all filesystem operations.""" + + FILESYSTEM = "filesystem" + """The filesystem resource type.""" + + +class LeaseAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The lease action for append and flush operations.""" + + ACQUIRE = "acquire" + """Acquire a lease.""" + AUTO_RENEW = "auto-renew" + """Auto-renew the lease.""" + RELEASE = "release" + """Release the lease only on flush.""" + ACQUIRE_RELEASE = "acquire-release" + """Acquire, complete the operation, and release the lease.""" + + +class ListBlobsIncludeItem(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Include this parameter to specify one or more datasets to include in the response.""" + + COPY = "copy" + """Include copy information.""" + DELETED = "deleted" + """Include deleted blobs.""" + METADATA = "metadata" + """Include metadata.""" + SNAPSHOTS = "snapshots" + """Include snapshots.""" + UNCOMMITTEDBLOBS = "uncommittedblobs" + """Include uncommitted blobs.""" + VERSIONS = "versions" + """Include versions.""" + TAGS = "tags" + """Include tags.""" + + +class ListBlobsShowOnly(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The show only filter for list blobs.""" + + DELETED = "deleted" + """Show only deleted blobs.""" + + +class PathExpiryOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The path expiry options.""" + + NEVER_EXPIRE = "NeverExpire" + """Never expire.""" + RELATIVE_TO_CREATION = "RelativeToCreation" + """Relative to creation time.""" + RELATIVE_TO_NOW = "RelativeToNow" + """Relative to now.""" + ABSOLUTE = "Absolute" + """Absolute time.""" + + +class PathGetPropertiesAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The action for Path_GetProperties.""" + + GET_ACCESS_CONTROL = "getAccessControl" + """Get access control list.""" + GET_STATUS = "getStatus" + """Get status.""" + + +class PathLeaseAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The lease action for Path_Lease.""" + + ACQUIRE = "acquire" + """Acquire a new lease.""" + BREAK = "break" + """Break an existing lease.""" + CHANGE = "change" + """Change the lease ID of an active lease.""" + RENEW = "renew" + """Renew an existing lease.""" + RELEASE = "release" + """Release a lease.""" + + +class PathRenameMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The rename mode. The value must be "legacy" or "posix".""" + + LEGACY = "legacy" + """Legacy rename mode.""" + POSIX = "posix" + """POSIX rename mode.""" + + +class PathResourceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Required only for Create File and Create Directory. The value must be "file" or "directory".""" + + DIRECTORY = "directory" + """A directory resource type.""" + FILE = "file" + """A file resource type.""" + + +class PathSetAccessControlRecursiveMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The mode for recursive access control operations.""" + + SET = "set" + """Set POSIX access control rights.""" + MODIFY = "modify" + """Modify POSIX access control rights.""" + REMOVE = "remove" + """Remove POSIX access control rights.""" + + +class PathUpdateAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The action to perform on the path during update.""" + + APPEND = "append" + """Append data to the file.""" + FLUSH = "flush" + """Flush previously uploaded data to a file.""" + SET_PROPERTIES = "setProperties" + """Set the properties of a file or directory.""" + SET_ACCESS_CONTROL = "setAccessControl" + """Set the access control for a file or directory.""" + SET_ACCESS_CONTROL_RECURSIVE = "setAccessControlRecursive" + """Set the access control list for a directory recursively.""" diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/models/_models.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/models/_models.py new file mode 100644 index 000000000000..245d7a3a60fd --- /dev/null +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/models/_models.py @@ -0,0 +1,925 @@ +# 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) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=useless-super-delegation + +import datetime +from typing import Any, Mapping, Optional, TYPE_CHECKING, overload + +from .._utils.model_base import Model as _Model, rest_field + +if TYPE_CHECKING: + from .. import models as _models + + +class AclFailedEntry(_Model): + """An ACL failed entry. + + :ivar name: The name of the entry. + :vartype name: str + :ivar type: The type of the entry. + :vartype type: str + :ivar error_message: The error message. + :vartype error_message: str + """ + + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The name of the entry.""" + type: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The type of the entry.""" + error_message: Optional[str] = rest_field( + name="errorMessage", visibility=["read", "create", "update", "delete", "query"] + ) + """The error message.""" + + @overload + def __init__( + self, + *, + name: Optional[str] = None, + type: Optional[str] = None, + error_message: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class BlobHierarchyListSegment(_Model): + """A segment of blob hierarchy items. + + :ivar blob_prefixes: The blob prefixes. + :vartype blob_prefixes: ~azure.storage.filedatalake._generated.models.BlobPrefix + :ivar blob_items: The blob items. Required. + :vartype blob_items: ~azure.storage.filedatalake._generated.models.BlobItemInternal + """ + + blob_prefixes: Optional[list["_models.BlobPrefix"]] = rest_field( + name="blobPrefixes", + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "itemsName": "BlobPrefix", "name": "BlobPrefix", "text": False, "unwrapped": True}, + ) + """The blob prefixes.""" + blob_items: list["_models.BlobItemInternal"] = rest_field( + name="blobItems", + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "itemsName": "Blob", "name": "Blob", "text": False, "unwrapped": True}, + ) + """The blob items. Required.""" + + _xml = {"attribute": False, "name": "Blobs", "text": False, "unwrapped": False} + + @overload + def __init__( + self, + *, + blob_items: list["_models.BlobItemInternal"], + blob_prefixes: Optional[list["_models.BlobPrefix"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class BlobItemInternal(_Model): + """An Azure Storage blob. + + :ivar name: The blob name. Required. + :vartype name: str + :ivar deleted: Whether the blob is deleted. Required. + :vartype deleted: bool + :ivar snapshot: The snapshot. Required. + :vartype snapshot: str + :ivar version_id: The version ID. + :vartype version_id: str + :ivar is_current_version: Whether this is the current version. + :vartype is_current_version: bool + :ivar properties: The blob properties. Required. + :vartype properties: ~azure.storage.filedatalake._generated.models.BlobPropertiesInternal + :ivar deletion_id: The deletion ID. + :vartype deletion_id: str + """ + + name: str = rest_field( + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "Name", "text": False, "unwrapped": False}, + ) + """The blob name. Required.""" + deleted: bool = rest_field( + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "Deleted", "text": False, "unwrapped": False}, + ) + """Whether the blob is deleted. Required.""" + snapshot: str = rest_field( + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "Snapshot", "text": False, "unwrapped": False}, + ) + """The snapshot. Required.""" + version_id: Optional[str] = rest_field( + name="versionId", + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "VersionId", "text": False, "unwrapped": False}, + ) + """The version ID.""" + is_current_version: Optional[bool] = rest_field( + name="isCurrentVersion", + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "IsCurrentVersion", "text": False, "unwrapped": False}, + ) + """Whether this is the current version.""" + properties: "_models.BlobPropertiesInternal" = rest_field( + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "Properties", "text": False, "unwrapped": False}, + ) + """The blob properties. Required.""" + deletion_id: Optional[str] = rest_field( + name="deletionId", + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "DeletionId", "text": False, "unwrapped": False}, + ) + """The deletion ID.""" + + _xml = {"attribute": False, "name": "Blob", "text": False, "unwrapped": False} + + @overload + def __init__( + self, + *, + name: str, + deleted: bool, + snapshot: str, + properties: "_models.BlobPropertiesInternal", + version_id: Optional[str] = None, + is_current_version: Optional[bool] = None, + deletion_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class BlobPrefix(_Model): + """A blob prefix. + + :ivar name: The prefix name. Required. + :vartype name: str + """ + + name: str = rest_field( + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "Name", "text": False, "unwrapped": False}, + ) + """The prefix name. Required.""" + + _xml = {"attribute": False, "name": "BlobPrefix", "text": False, "unwrapped": False} + + @overload + def __init__( + self, + *, + name: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class BlobPropertiesInternal(_Model): + """Properties of a blob. + + :ivar creation_time: The creation time. + :vartype creation_time: ~datetime.datetime + :ivar last_modified: The last modified time. Required. + :vartype last_modified: ~datetime.datetime + :ivar etag: The entity tag. Required. + :vartype etag: str + :ivar content_length: Size in bytes. + :vartype content_length: int + :ivar content_type: The content type. + :vartype content_type: str + :ivar content_encoding: The content encoding. + :vartype content_encoding: str + :ivar content_language: The content language. + :vartype content_language: str + :ivar content_md5: The content MD5 hash. + :vartype content_md5: bytes + :ivar content_disposition: The content disposition. + :vartype content_disposition: str + :ivar cache_control: The cache control. + :vartype cache_control: str + :ivar blob_sequence_number: The blob sequence number. + :vartype blob_sequence_number: int + :ivar copy_id: The copy ID. + :vartype copy_id: str + :ivar copy_source: The copy source. + :vartype copy_source: str + :ivar copy_progress: The copy progress. + :vartype copy_progress: str + :ivar copy_completion_time: The copy completion time. + :vartype copy_completion_time: ~datetime.datetime + :ivar copy_status_description: The copy status description. + :vartype copy_status_description: str + :ivar server_encrypted: Whether the server is encrypted. + :vartype server_encrypted: bool + :ivar incremental_copy: Whether it is an incremental copy. + :vartype incremental_copy: bool + :ivar destination_snapshot: The destination snapshot. + :vartype destination_snapshot: str + :ivar deleted_time: The deleted time. + :vartype deleted_time: ~datetime.datetime + :ivar remaining_retention_days: The remaining retention days. + :vartype remaining_retention_days: int + :ivar access_tier_inferred: Whether the access tier is inferred. + :vartype access_tier_inferred: bool + :ivar customer_provided_key_sha256: The customer-provided key SHA256 hash. + :vartype customer_provided_key_sha256: str + :ivar encryption_scope: The name of the encryption scope under which the blob is encrypted. + :vartype encryption_scope: str + :ivar access_tier_change_time: The access tier change time. + :vartype access_tier_change_time: ~datetime.datetime + :ivar tag_count: The tag count. + :vartype tag_count: int + :ivar expires_on: The expiry time. + :vartype expires_on: ~datetime.datetime + :ivar is_sealed: Whether the blob is sealed. + :vartype is_sealed: bool + :ivar last_accessed_on: The last accessed time. + :vartype last_accessed_on: ~datetime.datetime + :ivar delete_time: The delete time. + :vartype delete_time: ~datetime.datetime + """ + + creation_time: Optional[datetime.datetime] = rest_field( + name="creationTime", + visibility=["read", "create", "update", "delete", "query"], + format="rfc7231", + xml={"attribute": False, "name": "Creation-Time", "text": False, "unwrapped": False}, + ) + """The creation time.""" + last_modified: datetime.datetime = rest_field( + name="lastModified", + visibility=["read", "create", "update", "delete", "query"], + format="rfc7231", + xml={"attribute": False, "name": "Last-Modified", "text": False, "unwrapped": False}, + ) + """The last modified time. Required.""" + etag: str = rest_field( + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "Etag", "text": False, "unwrapped": False}, + ) + """The entity tag. Required.""" + content_length: Optional[int] = rest_field( + name="contentLength", + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "Content-Length", "text": False, "unwrapped": False}, + ) + """Size in bytes.""" + content_type: Optional[str] = rest_field( + name="contentType", + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "Content-Type", "text": False, "unwrapped": False}, + ) + """The content type.""" + content_encoding: Optional[str] = rest_field( + name="contentEncoding", + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "Content-Encoding", "text": False, "unwrapped": False}, + ) + """The content encoding.""" + content_language: Optional[str] = rest_field( + name="contentLanguage", + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "Content-Language", "text": False, "unwrapped": False}, + ) + """The content language.""" + content_md5: Optional[bytes] = rest_field( + name="contentMd5", + visibility=["read", "create", "update", "delete", "query"], + format="base64", + xml={"attribute": False, "name": "Content-MD5", "text": False, "unwrapped": False}, + ) + """The content MD5 hash.""" + content_disposition: Optional[str] = rest_field( + name="contentDisposition", + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "Content-Disposition", "text": False, "unwrapped": False}, + ) + """The content disposition.""" + cache_control: Optional[str] = rest_field( + name="cacheControl", + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "Cache-Control", "text": False, "unwrapped": False}, + ) + """The cache control.""" + blob_sequence_number: Optional[int] = rest_field( + name="blobSequenceNumber", + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "x-ms-blob-sequence-number", "text": False, "unwrapped": False}, + ) + """The blob sequence number.""" + copy_id: Optional[str] = rest_field( + name="copyId", + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "CopyId", "text": False, "unwrapped": False}, + ) + """The copy ID.""" + copy_source: Optional[str] = rest_field( + name="copySource", + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "CopySource", "text": False, "unwrapped": False}, + ) + """The copy source.""" + copy_progress: Optional[str] = rest_field( + name="copyProgress", + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "CopyProgress", "text": False, "unwrapped": False}, + ) + """The copy progress.""" + copy_completion_time: Optional[datetime.datetime] = rest_field( + name="copyCompletionTime", + visibility=["read", "create", "update", "delete", "query"], + format="rfc7231", + xml={"attribute": False, "name": "CopyCompletionTime", "text": False, "unwrapped": False}, + ) + """The copy completion time.""" + copy_status_description: Optional[str] = rest_field( + name="copyStatusDescription", + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "CopyStatusDescription", "text": False, "unwrapped": False}, + ) + """The copy status description.""" + server_encrypted: Optional[bool] = rest_field( + name="serverEncrypted", + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "ServerEncrypted", "text": False, "unwrapped": False}, + ) + """Whether the server is encrypted.""" + incremental_copy: Optional[bool] = rest_field( + name="incrementalCopy", + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "IncrementalCopy", "text": False, "unwrapped": False}, + ) + """Whether it is an incremental copy.""" + destination_snapshot: Optional[str] = rest_field( + name="destinationSnapshot", + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "DestinationSnapshot", "text": False, "unwrapped": False}, + ) + """The destination snapshot.""" + deleted_time: Optional[datetime.datetime] = rest_field( + name="deletedTime", + visibility=["read", "create", "update", "delete", "query"], + format="rfc7231", + xml={"attribute": False, "name": "DeletedTime", "text": False, "unwrapped": False}, + ) + """The deleted time.""" + remaining_retention_days: Optional[int] = rest_field( + name="remainingRetentionDays", + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "RemainingRetentionDays", "text": False, "unwrapped": False}, + ) + """The remaining retention days.""" + access_tier_inferred: Optional[bool] = rest_field( + name="accessTierInferred", + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "AccessTierInferred", "text": False, "unwrapped": False}, + ) + """Whether the access tier is inferred.""" + customer_provided_key_sha256: Optional[str] = rest_field( + name="customerProvidedKeySha256", + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "CustomerProvidedKeySha256", "text": False, "unwrapped": False}, + ) + """The customer-provided key SHA256 hash.""" + encryption_scope: Optional[str] = rest_field( + name="encryptionScope", + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "EncryptionScope", "text": False, "unwrapped": False}, + ) + """The name of the encryption scope under which the blob is encrypted.""" + access_tier_change_time: Optional[datetime.datetime] = rest_field( + name="accessTierChangeTime", + visibility=["read", "create", "update", "delete", "query"], + format="rfc7231", + xml={"attribute": False, "name": "AccessTierChangeTime", "text": False, "unwrapped": False}, + ) + """The access tier change time.""" + tag_count: Optional[int] = rest_field( + name="tagCount", + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "TagCount", "text": False, "unwrapped": False}, + ) + """The tag count.""" + expires_on: Optional[datetime.datetime] = rest_field( + name="expiresOn", + visibility=["read", "create", "update", "delete", "query"], + format="rfc7231", + xml={"attribute": False, "name": "Expiry-Time", "text": False, "unwrapped": False}, + ) + """The expiry time.""" + is_sealed: Optional[bool] = rest_field( + name="isSealed", + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "Sealed", "text": False, "unwrapped": False}, + ) + """Whether the blob is sealed.""" + last_accessed_on: Optional[datetime.datetime] = rest_field( + name="lastAccessedOn", + visibility=["read", "create", "update", "delete", "query"], + format="rfc7231", + xml={"attribute": False, "name": "LastAccessTime", "text": False, "unwrapped": False}, + ) + """The last accessed time.""" + delete_time: Optional[datetime.datetime] = rest_field( + name="deleteTime", + visibility=["read", "create", "update", "delete", "query"], + format="rfc7231", + xml={"attribute": False, "name": "DeleteTime", "text": False, "unwrapped": False}, + ) + """The delete time.""" + + _xml = {"attribute": False, "name": "Properties", "text": False, "unwrapped": False} + + @overload + def __init__( # pylint: disable=too-many-locals + self, + *, + last_modified: datetime.datetime, + etag: str, + creation_time: Optional[datetime.datetime] = None, + content_length: Optional[int] = None, + content_type: Optional[str] = None, + content_encoding: Optional[str] = None, + content_language: Optional[str] = None, + content_md5: Optional[bytes] = None, + content_disposition: Optional[str] = None, + cache_control: Optional[str] = None, + blob_sequence_number: Optional[int] = None, + copy_id: Optional[str] = None, + copy_source: Optional[str] = None, + copy_progress: Optional[str] = None, + copy_completion_time: Optional[datetime.datetime] = None, + copy_status_description: Optional[str] = None, + server_encrypted: Optional[bool] = None, + incremental_copy: Optional[bool] = None, + destination_snapshot: Optional[str] = None, + deleted_time: Optional[datetime.datetime] = None, + remaining_retention_days: Optional[int] = None, + access_tier_inferred: Optional[bool] = None, + customer_provided_key_sha256: Optional[str] = None, + encryption_scope: Optional[str] = None, + access_tier_change_time: Optional[datetime.datetime] = None, + tag_count: Optional[int] = None, + expires_on: Optional[datetime.datetime] = None, + is_sealed: Optional[bool] = None, + last_accessed_on: Optional[datetime.datetime] = None, + delete_time: Optional[datetime.datetime] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class FileSystemItem(_Model): + """Represents a filesystem. + + :ivar name: The filesystem name. + :vartype name: str + :ivar last_modified: The last modified time. + :vartype last_modified: str + :ivar etag: The entity tag. + :vartype etag: str + """ + + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The filesystem name.""" + last_modified: Optional[str] = rest_field( + name="lastModified", visibility=["read", "create", "update", "delete", "query"] + ) + """The last modified time.""" + etag: Optional[str] = rest_field(name="eTag", visibility=["read", "create", "update", "delete", "query"]) + """The entity tag.""" + + @overload + def __init__( + self, + *, + name: Optional[str] = None, + last_modified: Optional[str] = None, + etag: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class FileSystemList(_Model): + """A list of filesystems. + + :ivar filesystems: The list of filesystems. + :vartype filesystems: list[~azure.storage.filedatalake._generated.models.FileSystemItem] + """ + + filesystems: Optional[list["_models.FileSystemItem"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The list of filesystems.""" + + @overload + def __init__( + self, + *, + filesystems: Optional[list["_models.FileSystemItem"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ListBlobsHierarchySegmentResponse(_Model): + """An enumeration of blobs. + + :ivar service_endpoint: The service endpoint. Required. + :vartype service_endpoint: str + :ivar container_name: The container name. Required. + :vartype container_name: str + :ivar prefix: The prefix filter. + :vartype prefix: str + :ivar marker: The marker for pagination. + :vartype marker: str + :ivar max_results: The maximum number of results. + :vartype max_results: int + :ivar delimiter: The delimiter used for hierarchy. + :vartype delimiter: str + :ivar segment: The blob segment. Required. + :vartype segment: ~azure.storage.filedatalake._generated.models.BlobHierarchyListSegment + :ivar next_marker: The next marker for pagination. + :vartype next_marker: str + """ + + service_endpoint: str = rest_field( + name="serviceEndpoint", + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": True, "name": "ServiceEndpoint", "text": False, "unwrapped": False}, + ) + """The service endpoint. Required.""" + container_name: str = rest_field( + name="containerName", + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": True, "name": "ContainerName", "text": False, "unwrapped": False}, + ) + """The container name. Required.""" + prefix: Optional[str] = rest_field( + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "Prefix", "text": False, "unwrapped": False}, + ) + """The prefix filter.""" + marker: Optional[str] = rest_field( + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "Marker", "text": False, "unwrapped": False}, + ) + """The marker for pagination.""" + max_results: Optional[int] = rest_field( + name="maxResults", + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "MaxResults", "text": False, "unwrapped": False}, + ) + """The maximum number of results.""" + delimiter: Optional[str] = rest_field( + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "Delimiter", "text": False, "unwrapped": False}, + ) + """The delimiter used for hierarchy.""" + segment: "_models.BlobHierarchyListSegment" = rest_field( + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "Blobs", "text": False, "unwrapped": False}, + ) + """The blob segment. Required.""" + next_marker: Optional[str] = rest_field( + name="nextMarker", + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "NextMarker", "text": False, "unwrapped": False}, + ) + """The next marker for pagination.""" + + _xml = {"attribute": False, "name": "EnumerationResults", "text": False, "unwrapped": False} + + @overload + def __init__( + self, + *, + service_endpoint: str, + container_name: str, + segment: "_models.BlobHierarchyListSegment", + prefix: Optional[str] = None, + marker: Optional[str] = None, + max_results: Optional[int] = None, + delimiter: Optional[str] = None, + next_marker: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Path(_Model): + """Represents a path in a filesystem. + + :ivar name: The path name. + :vartype name: str + :ivar is_directory: Whether the path is a directory. + :vartype is_directory: bool + :ivar last_modified: The last modified time. + :vartype last_modified: str + :ivar etag: The entity tag. + :vartype etag: str + :ivar content_length: The content length. + :vartype content_length: int + :ivar owner: The owner of the path. + :vartype owner: str + :ivar group: The owning group of the path. + :vartype group: str + :ivar permissions: The POSIX access permissions. + :vartype permissions: str + :ivar encryption_scope: The name of the encryption scope under which the blob is encrypted. + :vartype encryption_scope: str + :ivar creation_time: The creation time. + :vartype creation_time: str + :ivar expiry_time: The expiry time. + :vartype expiry_time: str + :ivar encryption_context: The encryption context. + :vartype encryption_context: str + """ + + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The path name.""" + is_directory: Optional[bool] = rest_field( + name="isDirectory", visibility=["read", "create", "update", "delete", "query"] + ) + """Whether the path is a directory.""" + last_modified: Optional[str] = rest_field( + name="lastModified", visibility=["read", "create", "update", "delete", "query"] + ) + """The last modified time.""" + etag: Optional[str] = rest_field(name="eTag", visibility=["read", "create", "update", "delete", "query"]) + """The entity tag.""" + content_length: Optional[int] = rest_field( + name="contentLength", visibility=["read", "create", "update", "delete", "query"] + ) + """The content length.""" + owner: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The owner of the path.""" + group: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The owning group of the path.""" + permissions: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The POSIX access permissions.""" + encryption_scope: Optional[str] = rest_field( + name="EncryptionScope", visibility=["read", "create", "update", "delete", "query"] + ) + """The name of the encryption scope under which the blob is encrypted.""" + creation_time: Optional[str] = rest_field( + name="creationTime", visibility=["read", "create", "update", "delete", "query"] + ) + """The creation time.""" + expiry_time: Optional[str] = rest_field( + name="expiryTime", visibility=["read", "create", "update", "delete", "query"] + ) + """The expiry time.""" + encryption_context: Optional[str] = rest_field( + name="EncryptionContext", visibility=["read", "create", "update", "delete", "query"] + ) + """The encryption context.""" + + @overload + def __init__( + self, + *, + name: Optional[str] = None, + is_directory: Optional[bool] = None, + last_modified: Optional[str] = None, + etag: Optional[str] = None, + content_length: Optional[int] = None, + owner: Optional[str] = None, + group: Optional[str] = None, + permissions: Optional[str] = None, + encryption_scope: Optional[str] = None, + creation_time: Optional[str] = None, + expiry_time: Optional[str] = None, + encryption_context: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PathList(_Model): + """A list of paths. + + :ivar paths: The list of paths. + :vartype paths: list[~azure.storage.filedatalake._generated.models.Path] + """ + + paths: Optional[list["_models.Path"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The list of paths.""" + + @overload + def __init__( + self, + *, + paths: Optional[list["_models.Path"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SetAccessControlRecursiveResponse(_Model): + """The response for set access control recursive operations. + + :ivar directories_successful: The number of directories successfully processed. + :vartype directories_successful: int + :ivar files_successful: The number of files successfully processed. + :vartype files_successful: int + :ivar failure_count: The number of failures. + :vartype failure_count: int + :ivar failed_entries: The list of failed entries. + :vartype failed_entries: list[~azure.storage.filedatalake._generated.models.AclFailedEntry] + """ + + directories_successful: Optional[int] = rest_field( + name="directoriesSuccessful", visibility=["read", "create", "update", "delete", "query"] + ) + """The number of directories successfully processed.""" + files_successful: Optional[int] = rest_field( + name="filesSuccessful", visibility=["read", "create", "update", "delete", "query"] + ) + """The number of files successfully processed.""" + failure_count: Optional[int] = rest_field( + name="failureCount", visibility=["read", "create", "update", "delete", "query"] + ) + """The number of failures.""" + failed_entries: Optional[list["_models.AclFailedEntry"]] = rest_field( + name="failedEntries", visibility=["read", "create", "update", "delete", "query"] + ) + """The list of failed entries.""" + + @overload + def __init__( + self, + *, + directories_successful: Optional[int] = None, + files_successful: Optional[int] = None, + failure_count: Optional[int] = None, + failed_entries: Optional[list["_models.AclFailedEntry"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class StorageError(_Model): + """The storage error response. + + :ivar error: The service error response object. + :vartype error: ~azure.storage.filedatalake._generated.models.StorageErrorBody + """ + + error: Optional["_models.StorageErrorBody"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The service error response object.""" + + @overload + def __init__( + self, + *, + error: Optional["_models.StorageErrorBody"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class StorageErrorBody(_Model): + """The service error response body. + + :ivar code: The service error code. + :vartype code: str + :ivar message: The service error message. + :vartype message: str + """ + + code: Optional[str] = rest_field( + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "Code", "text": False, "unwrapped": False}, + ) + """The service error code.""" + message: Optional[str] = rest_field( + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "Message", "text": False, "unwrapped": False}, + ) + """The service error message.""" + + @overload + def __init__( + self, + *, + code: Optional[str] = None, + message: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/models/_models_py3.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/models/_models_py3.py deleted file mode 100644 index e9422fbe63d7..000000000000 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/models/_models_py3.py +++ /dev/null @@ -1,1041 +0,0 @@ -# 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 datetime -from typing import Any, Literal, Optional, TYPE_CHECKING - -from .._utils import serialization as _serialization - -if TYPE_CHECKING: - from .. import models as _models - - -class AclFailedEntry(_serialization.Model): - """AclFailedEntry. - - :ivar name: - :vartype name: str - :ivar type: - :vartype type: str - :ivar error_message: - :vartype error_message: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "error_message": {"key": "errorMessage", "type": "str"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - type: Optional[str] = None, - error_message: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: - :paramtype name: str - :keyword type: - :paramtype type: str - :keyword error_message: - :paramtype error_message: str - """ - super().__init__(**kwargs) - self.name = name - self.type = type - self.error_message = error_message - - -class BlobHierarchyListSegment(_serialization.Model): - """BlobHierarchyListSegment. - - All required parameters must be populated in order to send to server. - - :ivar blob_prefixes: - :vartype blob_prefixes: list[~azure.storage.filedatalake.models.BlobPrefix] - :ivar blob_items: Required. - :vartype blob_items: list[~azure.storage.filedatalake.models.BlobItemInternal] - """ - - _validation = { - "blob_items": {"required": True}, - } - - _attribute_map = { - "blob_prefixes": {"key": "BlobPrefixes", "type": "[BlobPrefix]"}, - "blob_items": {"key": "BlobItems", "type": "[BlobItemInternal]", "xml": {"itemsName": "Blob"}}, - } - _xml_map = {"name": "Blobs"} - - def __init__( - self, - *, - blob_items: list["_models.BlobItemInternal"], - blob_prefixes: Optional[list["_models.BlobPrefix"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword blob_prefixes: - :paramtype blob_prefixes: list[~azure.storage.filedatalake.models.BlobPrefix] - :keyword blob_items: Required. - :paramtype blob_items: list[~azure.storage.filedatalake.models.BlobItemInternal] - """ - super().__init__(**kwargs) - self.blob_prefixes = blob_prefixes - self.blob_items = blob_items - - -class BlobItemInternal(_serialization.Model): - """An Azure Storage blob. - - All required parameters must be populated in order to send to server. - - :ivar name: Required. - :vartype name: str - :ivar deleted: Required. - :vartype deleted: bool - :ivar snapshot: Required. - :vartype snapshot: str - :ivar version_id: - :vartype version_id: str - :ivar is_current_version: - :vartype is_current_version: bool - :ivar properties: Properties of a blob. Required. - :vartype properties: ~azure.storage.filedatalake.models.BlobPropertiesInternal - :ivar deletion_id: - :vartype deletion_id: str - """ - - _validation = { - "name": {"required": True}, - "deleted": {"required": True}, - "snapshot": {"required": True}, - "properties": {"required": True}, - } - - _attribute_map = { - "name": {"key": "Name", "type": "str"}, - "deleted": {"key": "Deleted", "type": "bool"}, - "snapshot": {"key": "Snapshot", "type": "str"}, - "version_id": {"key": "VersionId", "type": "str"}, - "is_current_version": {"key": "IsCurrentVersion", "type": "bool"}, - "properties": {"key": "Properties", "type": "BlobPropertiesInternal"}, - "deletion_id": {"key": "DeletionId", "type": "str"}, - } - _xml_map = {"name": "Blob"} - - def __init__( - self, - *, - name: str, - deleted: bool, - snapshot: str, - properties: "_models.BlobPropertiesInternal", - version_id: Optional[str] = None, - is_current_version: Optional[bool] = None, - deletion_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: Required. - :paramtype name: str - :keyword deleted: Required. - :paramtype deleted: bool - :keyword snapshot: Required. - :paramtype snapshot: str - :keyword version_id: - :paramtype version_id: str - :keyword is_current_version: - :paramtype is_current_version: bool - :keyword properties: Properties of a blob. Required. - :paramtype properties: ~azure.storage.filedatalake.models.BlobPropertiesInternal - :keyword deletion_id: - :paramtype deletion_id: str - """ - super().__init__(**kwargs) - self.name = name - self.deleted = deleted - self.snapshot = snapshot - self.version_id = version_id - self.is_current_version = is_current_version - self.properties = properties - self.deletion_id = deletion_id - - -class BlobPrefix(_serialization.Model): - """BlobPrefix. - - All required parameters must be populated in order to send to server. - - :ivar name: Required. - :vartype name: str - """ - - _validation = { - "name": {"required": True}, - } - - _attribute_map = { - "name": {"key": "Name", "type": "str"}, - } - - def __init__(self, *, name: str, **kwargs: Any) -> None: - """ - :keyword name: Required. - :paramtype name: str - """ - super().__init__(**kwargs) - self.name = name - - -class BlobPropertiesInternal(_serialization.Model): - """Properties of a blob. - - All required parameters must be populated in order to send to server. - - :ivar creation_time: - :vartype creation_time: ~datetime.datetime - :ivar last_modified: Required. - :vartype last_modified: ~datetime.datetime - :ivar etag: Required. - :vartype etag: str - :ivar content_length: Size in bytes. - :vartype content_length: int - :ivar content_type: - :vartype content_type: str - :ivar content_encoding: - :vartype content_encoding: str - :ivar content_language: - :vartype content_language: str - :ivar content_md5: - :vartype content_md5: bytes - :ivar content_disposition: - :vartype content_disposition: str - :ivar cache_control: - :vartype cache_control: str - :ivar blob_sequence_number: - :vartype blob_sequence_number: int - :ivar copy_id: - :vartype copy_id: str - :ivar copy_source: - :vartype copy_source: str - :ivar copy_progress: - :vartype copy_progress: str - :ivar copy_completion_time: - :vartype copy_completion_time: ~datetime.datetime - :ivar copy_status_description: - :vartype copy_status_description: str - :ivar server_encrypted: - :vartype server_encrypted: bool - :ivar incremental_copy: - :vartype incremental_copy: bool - :ivar destination_snapshot: - :vartype destination_snapshot: str - :ivar deleted_time: - :vartype deleted_time: ~datetime.datetime - :ivar remaining_retention_days: - :vartype remaining_retention_days: int - :ivar access_tier_inferred: - :vartype access_tier_inferred: bool - :ivar customer_provided_key_sha256: - :vartype customer_provided_key_sha256: str - :ivar encryption_scope: The name of the encryption scope under which the blob is encrypted. - :vartype encryption_scope: str - :ivar access_tier_change_time: - :vartype access_tier_change_time: ~datetime.datetime - :ivar tag_count: - :vartype tag_count: int - :ivar expires_on: - :vartype expires_on: ~datetime.datetime - :ivar is_sealed: - :vartype is_sealed: bool - :ivar last_accessed_on: - :vartype last_accessed_on: ~datetime.datetime - :ivar delete_time: - :vartype delete_time: ~datetime.datetime - """ - - _validation = { - "last_modified": {"required": True}, - "etag": {"required": True}, - } - - _attribute_map = { - "creation_time": {"key": "Creation-Time", "type": "rfc-1123"}, - "last_modified": {"key": "Last-Modified", "type": "rfc-1123"}, - "etag": {"key": "Etag", "type": "str"}, - "content_length": {"key": "Content-Length", "type": "int"}, - "content_type": {"key": "Content-Type", "type": "str"}, - "content_encoding": {"key": "Content-Encoding", "type": "str"}, - "content_language": {"key": "Content-Language", "type": "str"}, - "content_md5": {"key": "Content-MD5", "type": "bytearray"}, - "content_disposition": {"key": "Content-Disposition", "type": "str"}, - "cache_control": {"key": "Cache-Control", "type": "str"}, - "blob_sequence_number": {"key": "x-ms-blob-sequence-number", "type": "int"}, - "copy_id": {"key": "CopyId", "type": "str"}, - "copy_source": {"key": "CopySource", "type": "str"}, - "copy_progress": {"key": "CopyProgress", "type": "str"}, - "copy_completion_time": {"key": "CopyCompletionTime", "type": "rfc-1123"}, - "copy_status_description": {"key": "CopyStatusDescription", "type": "str"}, - "server_encrypted": {"key": "ServerEncrypted", "type": "bool"}, - "incremental_copy": {"key": "IncrementalCopy", "type": "bool"}, - "destination_snapshot": {"key": "DestinationSnapshot", "type": "str"}, - "deleted_time": {"key": "DeletedTime", "type": "rfc-1123"}, - "remaining_retention_days": {"key": "RemainingRetentionDays", "type": "int"}, - "access_tier_inferred": {"key": "AccessTierInferred", "type": "bool"}, - "customer_provided_key_sha256": {"key": "CustomerProvidedKeySha256", "type": "str"}, - "encryption_scope": {"key": "EncryptionScope", "type": "str"}, - "access_tier_change_time": {"key": "AccessTierChangeTime", "type": "rfc-1123"}, - "tag_count": {"key": "TagCount", "type": "int"}, - "expires_on": {"key": "Expiry-Time", "type": "rfc-1123"}, - "is_sealed": {"key": "Sealed", "type": "bool"}, - "last_accessed_on": {"key": "LastAccessTime", "type": "rfc-1123"}, - "delete_time": {"key": "DeleteTime", "type": "rfc-1123"}, - } - _xml_map = {"name": "Properties"} - - def __init__( # pylint: disable=too-many-locals - self, - *, - last_modified: datetime.datetime, - etag: str, - creation_time: Optional[datetime.datetime] = None, - content_length: Optional[int] = None, - content_type: Optional[str] = None, - content_encoding: Optional[str] = None, - content_language: Optional[str] = None, - content_md5: Optional[bytes] = None, - content_disposition: Optional[str] = None, - cache_control: Optional[str] = None, - blob_sequence_number: Optional[int] = None, - copy_id: Optional[str] = None, - copy_source: Optional[str] = None, - copy_progress: Optional[str] = None, - copy_completion_time: Optional[datetime.datetime] = None, - copy_status_description: Optional[str] = None, - server_encrypted: Optional[bool] = None, - incremental_copy: Optional[bool] = None, - destination_snapshot: Optional[str] = None, - deleted_time: Optional[datetime.datetime] = None, - remaining_retention_days: Optional[int] = None, - access_tier_inferred: Optional[bool] = None, - customer_provided_key_sha256: Optional[str] = None, - encryption_scope: Optional[str] = None, - access_tier_change_time: Optional[datetime.datetime] = None, - tag_count: Optional[int] = None, - expires_on: Optional[datetime.datetime] = None, - is_sealed: Optional[bool] = None, - last_accessed_on: Optional[datetime.datetime] = None, - delete_time: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword creation_time: - :paramtype creation_time: ~datetime.datetime - :keyword last_modified: Required. - :paramtype last_modified: ~datetime.datetime - :keyword etag: Required. - :paramtype etag: str - :keyword content_length: Size in bytes. - :paramtype content_length: int - :keyword content_type: - :paramtype content_type: str - :keyword content_encoding: - :paramtype content_encoding: str - :keyword content_language: - :paramtype content_language: str - :keyword content_md5: - :paramtype content_md5: bytes - :keyword content_disposition: - :paramtype content_disposition: str - :keyword cache_control: - :paramtype cache_control: str - :keyword blob_sequence_number: - :paramtype blob_sequence_number: int - :keyword copy_id: - :paramtype copy_id: str - :keyword copy_source: - :paramtype copy_source: str - :keyword copy_progress: - :paramtype copy_progress: str - :keyword copy_completion_time: - :paramtype copy_completion_time: ~datetime.datetime - :keyword copy_status_description: - :paramtype copy_status_description: str - :keyword server_encrypted: - :paramtype server_encrypted: bool - :keyword incremental_copy: - :paramtype incremental_copy: bool - :keyword destination_snapshot: - :paramtype destination_snapshot: str - :keyword deleted_time: - :paramtype deleted_time: ~datetime.datetime - :keyword remaining_retention_days: - :paramtype remaining_retention_days: int - :keyword access_tier_inferred: - :paramtype access_tier_inferred: bool - :keyword customer_provided_key_sha256: - :paramtype customer_provided_key_sha256: str - :keyword encryption_scope: The name of the encryption scope under which the blob is encrypted. - :paramtype encryption_scope: str - :keyword access_tier_change_time: - :paramtype access_tier_change_time: ~datetime.datetime - :keyword tag_count: - :paramtype tag_count: int - :keyword expires_on: - :paramtype expires_on: ~datetime.datetime - :keyword is_sealed: - :paramtype is_sealed: bool - :keyword last_accessed_on: - :paramtype last_accessed_on: ~datetime.datetime - :keyword delete_time: - :paramtype delete_time: ~datetime.datetime - """ - super().__init__(**kwargs) - self.creation_time = creation_time - self.last_modified = last_modified - self.etag = etag - self.content_length = content_length - self.content_type = content_type - self.content_encoding = content_encoding - self.content_language = content_language - self.content_md5 = content_md5 - self.content_disposition = content_disposition - self.cache_control = cache_control - self.blob_sequence_number = blob_sequence_number - self.copy_id = copy_id - self.copy_source = copy_source - self.copy_progress = copy_progress - self.copy_completion_time = copy_completion_time - self.copy_status_description = copy_status_description - self.server_encrypted = server_encrypted - self.incremental_copy = incremental_copy - self.destination_snapshot = destination_snapshot - self.deleted_time = deleted_time - self.remaining_retention_days = remaining_retention_days - self.access_tier_inferred = access_tier_inferred - self.customer_provided_key_sha256 = customer_provided_key_sha256 - self.encryption_scope = encryption_scope - self.access_tier_change_time = access_tier_change_time - self.tag_count = tag_count - self.expires_on = expires_on - self.is_sealed = is_sealed - self.last_accessed_on = last_accessed_on - self.delete_time = delete_time - - -class CpkInfo(_serialization.Model): - """Parameter group. - - :ivar encryption_key: Optional. Specifies the encryption key to use to encrypt the data - provided in the request. If not specified, encryption is performed with the root account - encryption key. For more information, see Encryption at Rest for Azure Storage Services. - :vartype encryption_key: str - :ivar encryption_key_sha256: The SHA-256 hash of the provided encryption key. Must be provided - if the x-ms-encryption-key header is provided. - :vartype encryption_key_sha256: str - :ivar encryption_algorithm: The algorithm used to produce the encryption key hash. Currently, - the only accepted value is "AES256". Must be provided if the x-ms-encryption-key header is - provided. Default value is "AES256". - :vartype encryption_algorithm: str - """ - - _attribute_map = { - "encryption_key": {"key": "encryptionKey", "type": "str"}, - "encryption_key_sha256": {"key": "encryptionKeySha256", "type": "str"}, - "encryption_algorithm": {"key": "encryptionAlgorithm", "type": "str"}, - } - - def __init__( - self, - *, - encryption_key: Optional[str] = None, - encryption_key_sha256: Optional[str] = None, - encryption_algorithm: Optional[Literal["AES256"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword encryption_key: Optional. Specifies the encryption key to use to encrypt the data - provided in the request. If not specified, encryption is performed with the root account - encryption key. For more information, see Encryption at Rest for Azure Storage Services. - :paramtype encryption_key: str - :keyword encryption_key_sha256: The SHA-256 hash of the provided encryption key. Must be - provided if the x-ms-encryption-key header is provided. - :paramtype encryption_key_sha256: str - :keyword encryption_algorithm: The algorithm used to produce the encryption key hash. - Currently, the only accepted value is "AES256". Must be provided if the x-ms-encryption-key - header is provided. Default value is "AES256". - :paramtype encryption_algorithm: str - """ - super().__init__(**kwargs) - self.encryption_key = encryption_key - self.encryption_key_sha256 = encryption_key_sha256 - self.encryption_algorithm = encryption_algorithm - - -class FileSystem(_serialization.Model): - """FileSystem. - - :ivar name: - :vartype name: str - :ivar last_modified: - :vartype last_modified: str - :ivar e_tag: - :vartype e_tag: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "last_modified": {"key": "lastModified", "type": "str"}, - "e_tag": {"key": "eTag", "type": "str"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - last_modified: Optional[str] = None, - e_tag: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: - :paramtype name: str - :keyword last_modified: - :paramtype last_modified: str - :keyword e_tag: - :paramtype e_tag: str - """ - super().__init__(**kwargs) - self.name = name - self.last_modified = last_modified - self.e_tag = e_tag - - -class FileSystemList(_serialization.Model): - """FileSystemList. - - :ivar filesystems: - :vartype filesystems: list[~azure.storage.filedatalake.models.FileSystem] - """ - - _attribute_map = { - "filesystems": {"key": "filesystems", "type": "[FileSystem]"}, - } - - def __init__(self, *, filesystems: Optional[list["_models.FileSystem"]] = None, **kwargs: Any) -> None: - """ - :keyword filesystems: - :paramtype filesystems: list[~azure.storage.filedatalake.models.FileSystem] - """ - super().__init__(**kwargs) - self.filesystems = filesystems - - -class LeaseAccessConditions(_serialization.Model): - """Parameter group. - - :ivar lease_id: If specified, the operation only succeeds if the resource's lease is active and - matches this ID. - :vartype lease_id: str - """ - - _attribute_map = { - "lease_id": {"key": "leaseId", "type": "str"}, - } - - def __init__(self, *, lease_id: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword lease_id: If specified, the operation only succeeds if the resource's lease is active - and matches this ID. - :paramtype lease_id: str - """ - super().__init__(**kwargs) - self.lease_id = lease_id - - -class ListBlobsHierarchySegmentResponse(_serialization.Model): - """An enumeration of blobs. - - All required parameters must be populated in order to send to server. - - :ivar service_endpoint: Required. - :vartype service_endpoint: str - :ivar container_name: Required. - :vartype container_name: str - :ivar prefix: - :vartype prefix: str - :ivar marker: - :vartype marker: str - :ivar max_results: - :vartype max_results: int - :ivar delimiter: - :vartype delimiter: str - :ivar segment: Required. - :vartype segment: ~azure.storage.filedatalake.models.BlobHierarchyListSegment - :ivar next_marker: - :vartype next_marker: str - """ - - _validation = { - "service_endpoint": {"required": True}, - "container_name": {"required": True}, - "segment": {"required": True}, - } - - _attribute_map = { - "service_endpoint": {"key": "ServiceEndpoint", "type": "str", "xml": {"attr": True}}, - "container_name": {"key": "ContainerName", "type": "str", "xml": {"attr": True}}, - "prefix": {"key": "Prefix", "type": "str"}, - "marker": {"key": "Marker", "type": "str"}, - "max_results": {"key": "MaxResults", "type": "int"}, - "delimiter": {"key": "Delimiter", "type": "str"}, - "segment": {"key": "Segment", "type": "BlobHierarchyListSegment"}, - "next_marker": {"key": "NextMarker", "type": "str"}, - } - _xml_map = {"name": "EnumerationResults"} - - def __init__( - self, - *, - service_endpoint: str, - container_name: str, - segment: "_models.BlobHierarchyListSegment", - prefix: Optional[str] = None, - marker: Optional[str] = None, - max_results: Optional[int] = None, - delimiter: Optional[str] = None, - next_marker: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword service_endpoint: Required. - :paramtype service_endpoint: str - :keyword container_name: Required. - :paramtype container_name: str - :keyword prefix: - :paramtype prefix: str - :keyword marker: - :paramtype marker: str - :keyword max_results: - :paramtype max_results: int - :keyword delimiter: - :paramtype delimiter: str - :keyword segment: Required. - :paramtype segment: ~azure.storage.filedatalake.models.BlobHierarchyListSegment - :keyword next_marker: - :paramtype next_marker: str - """ - super().__init__(**kwargs) - self.service_endpoint = service_endpoint - self.container_name = container_name - self.prefix = prefix - self.marker = marker - self.max_results = max_results - self.delimiter = delimiter - self.segment = segment - self.next_marker = next_marker - - -class ModifiedAccessConditions(_serialization.Model): - """Parameter group. - - :ivar if_modified_since: Specify this header value to operate only on a blob if it has been - modified since the specified date/time. - :vartype if_modified_since: ~datetime.datetime - :ivar if_unmodified_since: Specify this header value to operate only on a blob if it has not - been modified since the specified date/time. - :vartype if_unmodified_since: ~datetime.datetime - :ivar if_match: Specify an ETag value to operate only on blobs with a matching value. - :vartype if_match: str - :ivar if_none_match: Specify an ETag value to operate only on blobs without a matching value. - :vartype if_none_match: str - """ - - _attribute_map = { - "if_modified_since": {"key": "ifModifiedSince", "type": "rfc-1123"}, - "if_unmodified_since": {"key": "ifUnmodifiedSince", "type": "rfc-1123"}, - "if_match": {"key": "ifMatch", "type": "str"}, - "if_none_match": {"key": "ifNoneMatch", "type": "str"}, - } - - def __init__( - self, - *, - if_modified_since: Optional[datetime.datetime] = None, - if_unmodified_since: Optional[datetime.datetime] = None, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword if_modified_since: Specify this header value to operate only on a blob if it has been - modified since the specified date/time. - :paramtype if_modified_since: ~datetime.datetime - :keyword if_unmodified_since: Specify this header value to operate only on a blob if it has not - been modified since the specified date/time. - :paramtype if_unmodified_since: ~datetime.datetime - :keyword if_match: Specify an ETag value to operate only on blobs with a matching value. - :paramtype if_match: str - :keyword if_none_match: Specify an ETag value to operate only on blobs without a matching - value. - :paramtype if_none_match: str - """ - super().__init__(**kwargs) - self.if_modified_since = if_modified_since - self.if_unmodified_since = if_unmodified_since - self.if_match = if_match - self.if_none_match = if_none_match - - -class Path(_serialization.Model): - """Path. - - :ivar name: - :vartype name: str - :ivar is_directory: - :vartype is_directory: bool - :ivar last_modified: - :vartype last_modified: str - :ivar e_tag: - :vartype e_tag: str - :ivar content_length: - :vartype content_length: int - :ivar owner: - :vartype owner: str - :ivar group: - :vartype group: str - :ivar permissions: - :vartype permissions: str - :ivar encryption_scope: The name of the encryption scope under which the blob is encrypted. - :vartype encryption_scope: str - :ivar creation_time: - :vartype creation_time: str - :ivar expiry_time: - :vartype expiry_time: str - :ivar encryption_context: - :vartype encryption_context: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "is_directory": {"key": "isDirectory", "type": "bool"}, - "last_modified": {"key": "lastModified", "type": "str"}, - "e_tag": {"key": "eTag", "type": "str"}, - "content_length": {"key": "contentLength", "type": "int"}, - "owner": {"key": "owner", "type": "str"}, - "group": {"key": "group", "type": "str"}, - "permissions": {"key": "permissions", "type": "str"}, - "encryption_scope": {"key": "EncryptionScope", "type": "str"}, - "creation_time": {"key": "creationTime", "type": "str"}, - "expiry_time": {"key": "expiryTime", "type": "str"}, - "encryption_context": {"key": "EncryptionContext", "type": "str"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - is_directory: bool = False, - last_modified: Optional[str] = None, - e_tag: Optional[str] = None, - content_length: Optional[int] = None, - owner: Optional[str] = None, - group: Optional[str] = None, - permissions: Optional[str] = None, - encryption_scope: Optional[str] = None, - creation_time: Optional[str] = None, - expiry_time: Optional[str] = None, - encryption_context: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: - :paramtype name: str - :keyword is_directory: - :paramtype is_directory: bool - :keyword last_modified: - :paramtype last_modified: str - :keyword e_tag: - :paramtype e_tag: str - :keyword content_length: - :paramtype content_length: int - :keyword owner: - :paramtype owner: str - :keyword group: - :paramtype group: str - :keyword permissions: - :paramtype permissions: str - :keyword encryption_scope: The name of the encryption scope under which the blob is encrypted. - :paramtype encryption_scope: str - :keyword creation_time: - :paramtype creation_time: str - :keyword expiry_time: - :paramtype expiry_time: str - :keyword encryption_context: - :paramtype encryption_context: str - """ - super().__init__(**kwargs) - self.name = name - self.is_directory = is_directory - self.last_modified = last_modified - self.e_tag = e_tag - self.content_length = content_length - self.owner = owner - self.group = group - self.permissions = permissions - self.encryption_scope = encryption_scope - self.creation_time = creation_time - self.expiry_time = expiry_time - self.encryption_context = encryption_context - - -class PathHTTPHeaders(_serialization.Model): - """Parameter group. - - :ivar cache_control: Optional. Sets the blob's cache control. If specified, this property is - stored with the blob and returned with a read request. - :vartype cache_control: str - :ivar content_encoding: Optional. Sets the blob's content encoding. If specified, this property - is stored with the blob and returned with a read request. - :vartype content_encoding: str - :ivar content_language: Optional. Set the blob's content language. If specified, this property - is stored with the blob and returned with a read request. - :vartype content_language: str - :ivar content_disposition: Optional. Sets the blob's Content-Disposition header. - :vartype content_disposition: str - :ivar content_type: Optional. Sets the blob's content type. If specified, this property is - stored with the blob and returned with a read request. - :vartype content_type: str - :ivar content_md5: Specify the transactional md5 for the body, to be validated by the service. - :vartype content_md5: bytes - :ivar transactional_content_hash: Specify the transactional md5 for the body, to be validated - by the service. - :vartype transactional_content_hash: bytes - """ - - _attribute_map = { - "cache_control": {"key": "cacheControl", "type": "str"}, - "content_encoding": {"key": "contentEncoding", "type": "str"}, - "content_language": {"key": "contentLanguage", "type": "str"}, - "content_disposition": {"key": "contentDisposition", "type": "str"}, - "content_type": {"key": "contentType", "type": "str"}, - "content_md5": {"key": "contentMD5", "type": "bytearray"}, - "transactional_content_hash": {"key": "transactionalContentHash", "type": "bytearray"}, - } - - def __init__( - self, - *, - cache_control: Optional[str] = None, - content_encoding: Optional[str] = None, - content_language: Optional[str] = None, - content_disposition: Optional[str] = None, - content_type: Optional[str] = None, - content_md5: Optional[bytes] = None, - transactional_content_hash: Optional[bytes] = None, - **kwargs: Any - ) -> None: - """ - :keyword cache_control: Optional. Sets the blob's cache control. If specified, this property is - stored with the blob and returned with a read request. - :paramtype cache_control: str - :keyword content_encoding: Optional. Sets the blob's content encoding. If specified, this - property is stored with the blob and returned with a read request. - :paramtype content_encoding: str - :keyword content_language: Optional. Set the blob's content language. If specified, this - property is stored with the blob and returned with a read request. - :paramtype content_language: str - :keyword content_disposition: Optional. Sets the blob's Content-Disposition header. - :paramtype content_disposition: str - :keyword content_type: Optional. Sets the blob's content type. If specified, this property is - stored with the blob and returned with a read request. - :paramtype content_type: str - :keyword content_md5: Specify the transactional md5 for the body, to be validated by the - service. - :paramtype content_md5: bytes - :keyword transactional_content_hash: Specify the transactional md5 for the body, to be - validated by the service. - :paramtype transactional_content_hash: bytes - """ - super().__init__(**kwargs) - self.cache_control = cache_control - self.content_encoding = content_encoding - self.content_language = content_language - self.content_disposition = content_disposition - self.content_type = content_type - self.content_md5 = content_md5 - self.transactional_content_hash = transactional_content_hash - - -class PathList(_serialization.Model): - """PathList. - - :ivar paths: - :vartype paths: list[~azure.storage.filedatalake.models.Path] - """ - - _attribute_map = { - "paths": {"key": "paths", "type": "[Path]"}, - } - - def __init__(self, *, paths: Optional[list["_models.Path"]] = None, **kwargs: Any) -> None: - """ - :keyword paths: - :paramtype paths: list[~azure.storage.filedatalake.models.Path] - """ - super().__init__(**kwargs) - self.paths = paths - - -class SetAccessControlRecursiveResponse(_serialization.Model): - """SetAccessControlRecursiveResponse. - - :ivar directories_successful: - :vartype directories_successful: int - :ivar files_successful: - :vartype files_successful: int - :ivar failure_count: - :vartype failure_count: int - :ivar failed_entries: - :vartype failed_entries: list[~azure.storage.filedatalake.models.AclFailedEntry] - """ - - _attribute_map = { - "directories_successful": {"key": "directoriesSuccessful", "type": "int"}, - "files_successful": {"key": "filesSuccessful", "type": "int"}, - "failure_count": {"key": "failureCount", "type": "int"}, - "failed_entries": {"key": "failedEntries", "type": "[AclFailedEntry]"}, - } - - def __init__( - self, - *, - directories_successful: Optional[int] = None, - files_successful: Optional[int] = None, - failure_count: Optional[int] = None, - failed_entries: Optional[list["_models.AclFailedEntry"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword directories_successful: - :paramtype directories_successful: int - :keyword files_successful: - :paramtype files_successful: int - :keyword failure_count: - :paramtype failure_count: int - :keyword failed_entries: - :paramtype failed_entries: list[~azure.storage.filedatalake.models.AclFailedEntry] - """ - super().__init__(**kwargs) - self.directories_successful = directories_successful - self.files_successful = files_successful - self.failure_count = failure_count - self.failed_entries = failed_entries - - -class SourceModifiedAccessConditions(_serialization.Model): - """Parameter group. - - :ivar source_if_match: Specify an ETag value to operate only on blobs with a matching value. - :vartype source_if_match: str - :ivar source_if_none_match: Specify an ETag value to operate only on blobs without a matching - value. - :vartype source_if_none_match: str - :ivar source_if_modified_since: Specify this header value to operate only on a blob if it has - been modified since the specified date/time. - :vartype source_if_modified_since: ~datetime.datetime - :ivar source_if_unmodified_since: Specify this header value to operate only on a blob if it has - not been modified since the specified date/time. - :vartype source_if_unmodified_since: ~datetime.datetime - """ - - _attribute_map = { - "source_if_match": {"key": "sourceIfMatch", "type": "str"}, - "source_if_none_match": {"key": "sourceIfNoneMatch", "type": "str"}, - "source_if_modified_since": {"key": "sourceIfModifiedSince", "type": "rfc-1123"}, - "source_if_unmodified_since": {"key": "sourceIfUnmodifiedSince", "type": "rfc-1123"}, - } - - def __init__( - self, - *, - source_if_match: Optional[str] = None, - source_if_none_match: Optional[str] = None, - source_if_modified_since: Optional[datetime.datetime] = None, - source_if_unmodified_since: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword source_if_match: Specify an ETag value to operate only on blobs with a matching value. - :paramtype source_if_match: str - :keyword source_if_none_match: Specify an ETag value to operate only on blobs without a - matching value. - :paramtype source_if_none_match: str - :keyword source_if_modified_since: Specify this header value to operate only on a blob if it - has been modified since the specified date/time. - :paramtype source_if_modified_since: ~datetime.datetime - :keyword source_if_unmodified_since: Specify this header value to operate only on a blob if it - has not been modified since the specified date/time. - :paramtype source_if_unmodified_since: ~datetime.datetime - """ - super().__init__(**kwargs) - self.source_if_match = source_if_match - self.source_if_none_match = source_if_none_match - self.source_if_modified_since = source_if_modified_since - self.source_if_unmodified_since = source_if_unmodified_since - - -class StorageError(_serialization.Model): - """StorageError. - - :ivar error: The service error response object. - :vartype error: ~azure.storage.filedatalake.models.StorageErrorError - """ - - _attribute_map = { - "error": {"key": "error", "type": "StorageErrorError"}, - } - - def __init__(self, *, error: Optional["_models.StorageErrorError"] = None, **kwargs: Any) -> None: - """ - :keyword error: The service error response object. - :paramtype error: ~azure.storage.filedatalake.models.StorageErrorError - """ - super().__init__(**kwargs) - self.error = error - - -class StorageErrorError(_serialization.Model): - """The service error response object. - - :ivar code: The service error code. - :vartype code: str - :ivar message: The service error message. - :vartype message: str - """ - - _attribute_map = { - "code": {"key": "Code", "type": "str"}, - "message": {"key": "Message", "type": "str"}, - } - - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword code: The service error code. - :paramtype code: str - :keyword message: The service error message. - :paramtype message: str - """ - super().__init__(**kwargs) - self.code = code - self.message = message diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/models/_patch.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/models/_patch.py index f7dd32510333..a32caa2ceb1b 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/models/_patch.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/models/_patch.py @@ -6,7 +6,112 @@ Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -from typing import List +import sys +from typing import Any, Callable, Dict, List, Optional + +from .._utils.serialization import JSON, Model + +if sys.version_info >= (3, 11): + from typing import Self +else: + from typing_extensions import Self + + +# These public models inherited (transitively) from the autorest msrest model, +# which exposed ``serialize``, ``deserialize``, ``from_dict``, ``as_dict``, +# ``is_xml_model``, and ``enable_additional_properties_sending``. After the +# migration the generated models use a different base class. The public classes mix this in to expose +# exactly the historical methods, each delegating to ``Model``. +class _BackCompatMixin: + _validation = {} + + def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: + """Serialize this model to a dictionary. + + :param bool keep_readonly: If you want to serialize the readonly attributes. + :returns: A dict JSON compatible object. + :rtype: JSON + """ + return Model.serialize(self, keep_readonly=keep_readonly, **kwargs) # type: ignore[arg-type] + + def as_dict(self, keep_readonly: bool = True, **kwargs: Any) -> JSON: + """Return a dict that can be serialized using json.dump. + + :param bool keep_readonly: If you want to serialize the readonly attributes. + :returns: A dict JSON compatible object. + :rtype: JSON + """ + return Model.as_dict(self, keep_readonly=keep_readonly, **kwargs) # type: ignore[arg-type] + + @classmethod + def deserialize(cls, data: Any, content_type: Optional[str] = None) -> Self: + """Deserialize this model from a dictionary. + + :param data: A str using RestAPI structure. JSON by default. + :type data: str + :param str content_type: JSON by default, set application/xml if XML. + :returns: An instance of this model. + :rtype: Self + """ + # ``Model.deserialize`` is a classmethod already bound to ``Model``; reach + # through ``__func__`` so it runs with this subclass as ``cls``. + return Model.deserialize.__func__(cls, data, content_type=content_type) + + @classmethod + def from_dict( + cls, + data: Any, + key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, + content_type: Optional[str] = None, + ) -> Self: + """Parse a dict using a given key extractor and return a model. + + :param dict data: A dict using RestAPI structure. + :param key_extractors: A key extractor function. + :type key_extractors: callable or None + :param str content_type: JSON by default, set application/xml if XML. + :returns: An instance of this model. + :rtype: Self + """ + return Model.from_dict.__func__(cls, data, key_extractors=key_extractors, content_type=content_type) + + @classmethod + def enable_additional_properties_sending(cls) -> None: + """Add ``additional_properties`` to the attribute map so they are sent to the service. + + :returns: None + :rtype: None + """ + return Model.enable_additional_properties_sending.__func__(cls) + + @classmethod + def is_xml_model(cls) -> bool: + """Whether this model is serialized as XML. + + :returns: True if this model is serialized as XML, otherwise False. + :rtype: bool + """ + return Model.is_xml_model.__func__(cls) + + @classmethod + def _infer_class_models(cls) -> Dict[str, type]: + # Internal helper used by serialize/as_dict/deserialize/from_dict. + return Model._infer_class_models.__func__(cls) + + @classmethod + def _create_xml_node(cls) -> Any: + # Internal helper used during XML (de)serialization. + return Model._create_xml_node.__func__(cls) + + def __eq__(self, other: Any) -> bool: + return Model.__eq__(self, other) # type: ignore[arg-type] + + def __ne__(self, other: Any) -> bool: + return Model.__ne__(self, other) # type: ignore[arg-type] + + def __str__(self) -> str: + return Model.__str__(self) # type: ignore[arg-type] + __all__: List[str] = [] # Add all objects you want publicly available to users at this package level diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/operations/__init__.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/operations/__init__.py index 56a7ece347ab..5af3b3165fc0 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/operations/__init__.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/operations/__init__.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- # pylint: disable=wrong-import-position @@ -12,18 +12,18 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import -from ._service_operations import ServiceOperations # type: ignore -from ._file_system_operations import FileSystemOperations # type: ignore -from ._path_operations import PathOperations # type: ignore +from ._operations import FileSystemOperations # type: ignore +from ._operations import PathOperations # type: ignore +from ._operations import ServiceOperations # type: ignore from ._patch import __all__ as _patch_all from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ - "ServiceOperations", "FileSystemOperations", "PathOperations", + "ServiceOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/operations/_file_system_operations.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/operations/_file_system_operations.py deleted file mode 100644 index abc58c7a7ba4..000000000000 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/operations/_file_system_operations.py +++ /dev/null @@ -1,909 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -import datetime -from typing import Any, Callable, Literal, Optional, TypeVar, Union - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict - -from .. import models as _models -from .._configuration import AzureDataLakeStorageRESTAPIConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_create_request( - url: str, - *, - version: str, - request_id_parameter: Optional[str] = None, - timeout: Optional[int] = None, - properties: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - resource: Literal["filesystem"] = kwargs.pop("resource", _params.pop("resource", "filesystem")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "{url}") - path_format_arguments = { - "url": _SERIALIZER.url("url", url, "str", skip_quote=True), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["resource"] = _SERIALIZER.query("resource", resource, "str") - if timeout is not None: - _params["timeout"] = _SERIALIZER.query("timeout", timeout, "int", minimum=0) - - # Construct headers - if request_id_parameter is not None: - _headers["x-ms-client-request-id"] = _SERIALIZER.header("request_id_parameter", request_id_parameter, "str") - _headers["x-ms-version"] = _SERIALIZER.header("version", version, "str") - if properties is not None: - _headers["x-ms-properties"] = _SERIALIZER.header("properties", properties, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_set_properties_request( - url: str, - *, - version: str, - request_id_parameter: Optional[str] = None, - timeout: Optional[int] = None, - properties: Optional[str] = None, - if_modified_since: Optional[datetime.datetime] = None, - if_unmodified_since: Optional[datetime.datetime] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - resource: Literal["filesystem"] = kwargs.pop("resource", _params.pop("resource", "filesystem")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "{url}") - path_format_arguments = { - "url": _SERIALIZER.url("url", url, "str", skip_quote=True), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["resource"] = _SERIALIZER.query("resource", resource, "str") - if timeout is not None: - _params["timeout"] = _SERIALIZER.query("timeout", timeout, "int", minimum=0) - - # Construct headers - if request_id_parameter is not None: - _headers["x-ms-client-request-id"] = _SERIALIZER.header("request_id_parameter", request_id_parameter, "str") - _headers["x-ms-version"] = _SERIALIZER.header("version", version, "str") - if properties is not None: - _headers["x-ms-properties"] = _SERIALIZER.header("properties", properties, "str") - if if_modified_since is not None: - _headers["If-Modified-Since"] = _SERIALIZER.header("if_modified_since", if_modified_since, "rfc-1123") - if if_unmodified_since is not None: - _headers["If-Unmodified-Since"] = _SERIALIZER.header("if_unmodified_since", if_unmodified_since, "rfc-1123") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_properties_request( - url: str, *, version: str, request_id_parameter: Optional[str] = None, timeout: Optional[int] = None, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - resource: Literal["filesystem"] = kwargs.pop("resource", _params.pop("resource", "filesystem")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "{url}") - path_format_arguments = { - "url": _SERIALIZER.url("url", url, "str", skip_quote=True), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["resource"] = _SERIALIZER.query("resource", resource, "str") - if timeout is not None: - _params["timeout"] = _SERIALIZER.query("timeout", timeout, "int", minimum=0) - - # Construct headers - if request_id_parameter is not None: - _headers["x-ms-client-request-id"] = _SERIALIZER.header("request_id_parameter", request_id_parameter, "str") - _headers["x-ms-version"] = _SERIALIZER.header("version", version, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - url: str, - *, - version: str, - request_id_parameter: Optional[str] = None, - timeout: Optional[int] = None, - if_modified_since: Optional[datetime.datetime] = None, - if_unmodified_since: Optional[datetime.datetime] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - resource: Literal["filesystem"] = kwargs.pop("resource", _params.pop("resource", "filesystem")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "{url}") - path_format_arguments = { - "url": _SERIALIZER.url("url", url, "str", skip_quote=True), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["resource"] = _SERIALIZER.query("resource", resource, "str") - if timeout is not None: - _params["timeout"] = _SERIALIZER.query("timeout", timeout, "int", minimum=0) - - # Construct headers - if request_id_parameter is not None: - _headers["x-ms-client-request-id"] = _SERIALIZER.header("request_id_parameter", request_id_parameter, "str") - _headers["x-ms-version"] = _SERIALIZER.header("version", version, "str") - if if_modified_since is not None: - _headers["If-Modified-Since"] = _SERIALIZER.header("if_modified_since", if_modified_since, "rfc-1123") - if if_unmodified_since is not None: - _headers["If-Unmodified-Since"] = _SERIALIZER.header("if_unmodified_since", if_unmodified_since, "rfc-1123") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_paths_request( - url: str, - *, - recursive: bool, - version: str, - request_id_parameter: Optional[str] = None, - timeout: Optional[int] = None, - continuation: Optional[str] = None, - path: Optional[str] = None, - max_results: Optional[int] = None, - upn: Optional[bool] = None, - begin_from: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - resource: Literal["filesystem"] = kwargs.pop("resource", _params.pop("resource", "filesystem")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "{url}") - path_format_arguments = { - "url": _SERIALIZER.url("url", url, "str", skip_quote=True), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["resource"] = _SERIALIZER.query("resource", resource, "str") - if timeout is not None: - _params["timeout"] = _SERIALIZER.query("timeout", timeout, "int", minimum=0) - if continuation is not None: - _params["continuation"] = _SERIALIZER.query("continuation", continuation, "str") - if path is not None: - _params["directory"] = _SERIALIZER.query("path", path, "str") - _params["recursive"] = _SERIALIZER.query("recursive", recursive, "bool") - if max_results is not None: - _params["maxResults"] = _SERIALIZER.query("max_results", max_results, "int", minimum=1) - if upn is not None: - _params["upn"] = _SERIALIZER.query("upn", upn, "bool") - if begin_from is not None: - _params["beginFrom"] = _SERIALIZER.query("begin_from", begin_from, "str") - - # Construct headers - if request_id_parameter is not None: - _headers["x-ms-client-request-id"] = _SERIALIZER.header("request_id_parameter", request_id_parameter, "str") - _headers["x-ms-version"] = _SERIALIZER.header("version", version, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_blob_hierarchy_segment_request( # pylint: disable=name-too-long - url: str, - *, - version: str, - prefix: Optional[str] = None, - delimiter: Optional[str] = None, - marker: Optional[str] = None, - max_results: Optional[int] = None, - include: Optional[list[Union[str, _models.ListBlobsIncludeItem]]] = None, - showonly: Literal["deleted"] = "deleted", - timeout: Optional[int] = None, - request_id_parameter: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - restype: Literal["container"] = kwargs.pop("restype", _params.pop("restype", "container")) - comp: Literal["list"] = kwargs.pop("comp", _params.pop("comp", "list")) - accept = _headers.pop("Accept", "application/xml") - - # Construct URL - _url = kwargs.pop("template_url", "{url}") - path_format_arguments = { - "url": _SERIALIZER.url("url", url, "str", skip_quote=True), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["restype"] = _SERIALIZER.query("restype", restype, "str") - _params["comp"] = _SERIALIZER.query("comp", comp, "str") - if prefix is not None: - _params["prefix"] = _SERIALIZER.query("prefix", prefix, "str") - if delimiter is not None: - _params["delimiter"] = _SERIALIZER.query("delimiter", delimiter, "str") - if marker is not None: - _params["marker"] = _SERIALIZER.query("marker", marker, "str") - if max_results is not None: - _params["maxResults"] = _SERIALIZER.query("max_results", max_results, "int", minimum=1) - if include is not None: - _params["include"] = _SERIALIZER.query("include", include, "[str]", div=",") - if showonly is not None: - _params["showonly"] = _SERIALIZER.query("showonly", showonly, "str") - if timeout is not None: - _params["timeout"] = _SERIALIZER.query("timeout", timeout, "int", minimum=0) - - # Construct headers - _headers["x-ms-version"] = _SERIALIZER.header("version", version, "str") - if request_id_parameter is not None: - _headers["x-ms-client-request-id"] = _SERIALIZER.header("request_id_parameter", request_id_parameter, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class FileSystemOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.storage.filedatalake.AzureDataLakeStorageRESTAPI`'s - :attr:`file_system` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AzureDataLakeStorageRESTAPIConfiguration = ( - 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 - def create( # pylint: disable=inconsistent-return-statements - self, - request_id_parameter: Optional[str] = None, - timeout: Optional[int] = None, - properties: Optional[str] = None, - **kwargs: Any - ) -> None: - """Create FileSystem. - - Create a FileSystem rooted at the specified location. If the FileSystem already exists, the - operation fails. This operation does not support conditional HTTP requests. - - :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 timeout: The timeout parameter is expressed in seconds. For more information, see - :code:`Setting - Timeouts for Blob Service Operations.`. Default value is None. - :type timeout: int - :param properties: Optional. User-defined properties to be stored with the filesystem, in the - format of a comma-separated list of name and value pairs "n1=v1, n2=v2, ...", where each value - is a base64 encoded string. Note that the string may only contain ASCII characters in the - ISO-8859-1 character set. If the filesystem exists, any properties not included in the list - will be removed. All properties are removed if the header is omitted. To merge new and - existing properties, first get all existing properties and the current E-Tag, then make a - conditional request with the E-Tag and include values for all properties. Default value is - None. - :type properties: 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 = kwargs.pop("params", {}) or {} - - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_create_request( - url=self._config.url, - version=self._config.version, - request_id_parameter=request_id_parameter, - timeout=timeout, - properties=properties, - resource=self._config.resource, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = 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["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) - 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["x-ms-namespace-enabled"] = self._deserialize( - "str", response.headers.get("x-ms-namespace-enabled") - ) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @distributed_trace - def set_properties( # pylint: disable=inconsistent-return-statements - self, - request_id_parameter: Optional[str] = None, - timeout: Optional[int] = None, - properties: Optional[str] = None, - modified_access_conditions: Optional[_models.ModifiedAccessConditions] = None, - **kwargs: Any - ) -> None: - """Set FileSystem Properties. - - Set properties for the FileSystem. This operation supports conditional HTTP requests. For - more information, see `Specifying Conditional Headers for Blob Service Operations - `_. - - :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 timeout: The timeout parameter is expressed in seconds. For more information, see - :code:`Setting - Timeouts for Blob Service Operations.`. Default value is None. - :type timeout: int - :param properties: Optional. User-defined properties to be stored with the filesystem, in the - format of a comma-separated list of name and value pairs "n1=v1, n2=v2, ...", where each value - is a base64 encoded string. Note that the string may only contain ASCII characters in the - ISO-8859-1 character set. If the filesystem exists, any properties not included in the list - will be removed. All properties are removed if the header is omitted. To merge new and - existing properties, first get all existing properties and the current E-Tag, then make a - conditional request with the E-Tag and include values for all properties. Default value is - None. - :type properties: str - :param modified_access_conditions: Parameter group. Default value is None. - :type modified_access_conditions: ~azure.storage.filedatalake.models.ModifiedAccessConditions - :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) - - _if_modified_since = None - _if_unmodified_since = None - if modified_access_conditions is not None: - _if_modified_since = modified_access_conditions.if_modified_since - _if_unmodified_since = modified_access_conditions.if_unmodified_since - - _request = build_set_properties_request( - url=self._config.url, - version=self._config.version, - request_id_parameter=request_id_parameter, - timeout=timeout, - properties=properties, - if_modified_since=_if_modified_since, - if_unmodified_since=_if_unmodified_since, - resource=self._config.resource, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = 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["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) - 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")) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @distributed_trace - def get_properties( # pylint: disable=inconsistent-return-statements - self, request_id_parameter: Optional[str] = None, timeout: Optional[int] = None, **kwargs: Any - ) -> None: - """Get FileSystem Properties. - - All system and user-defined filesystem properties are specified in the response headers. - - :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 timeout: The timeout parameter is expressed in seconds. For more information, see - :code:`Setting - Timeouts for Blob Service Operations.`. 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 = kwargs.pop("params", {}) or {} - - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_get_properties_request( - url=self._config.url, - version=self._config.version, - request_id_parameter=request_id_parameter, - timeout=timeout, - resource=self._config.resource, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = 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["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) - 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["x-ms-properties"] = self._deserialize("str", response.headers.get("x-ms-properties")) - response_headers["x-ms-namespace-enabled"] = self._deserialize( - "str", response.headers.get("x-ms-namespace-enabled") - ) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, - request_id_parameter: Optional[str] = None, - timeout: Optional[int] = None, - modified_access_conditions: Optional[_models.ModifiedAccessConditions] = None, - **kwargs: Any - ) -> None: - """Delete FileSystem. - - Marks the FileSystem for deletion. When a FileSystem is deleted, a FileSystem with the same - identifier cannot be created for at least 30 seconds. While the filesystem is being deleted, - attempts to create a filesystem with the same identifier will fail with status code 409 - (Conflict), with the service returning additional error information indicating that the - filesystem is being deleted. All other operations, including operations on any files or - directories within the filesystem, will fail with status code 404 (Not Found) while the - filesystem is being deleted. This operation supports conditional HTTP requests. For more - information, see `Specifying Conditional Headers for Blob Service Operations - `_. - - :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 timeout: The timeout parameter is expressed in seconds. For more information, see - :code:`Setting - Timeouts for Blob Service Operations.`. Default value is None. - :type timeout: int - :param modified_access_conditions: Parameter group. Default value is None. - :type modified_access_conditions: ~azure.storage.filedatalake.models.ModifiedAccessConditions - :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) - - _if_modified_since = None - _if_unmodified_since = None - if modified_access_conditions is not None: - _if_modified_since = modified_access_conditions.if_modified_since - _if_unmodified_since = modified_access_conditions.if_unmodified_since - - _request = build_delete_request( - url=self._config.url, - version=self._config.version, - request_id_parameter=request_id_parameter, - timeout=timeout, - if_modified_since=_if_modified_since, - if_unmodified_since=_if_unmodified_since, - resource=self._config.resource, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = 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 - def list_paths( - self, - recursive: bool, - request_id_parameter: Optional[str] = None, - timeout: Optional[int] = None, - continuation: Optional[str] = None, - path: Optional[str] = None, - max_results: Optional[int] = None, - upn: Optional[bool] = None, - begin_from: Optional[str] = None, - **kwargs: Any - ) -> _models.PathList: - """List Paths. - - List FileSystem paths and their properties. - - :param recursive: Required. Required. - :type recursive: bool - :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 timeout: The timeout parameter is expressed in seconds. For more information, see - :code:`Setting - Timeouts for Blob Service Operations.`. Default value is None. - :type timeout: int - :param continuation: Optional. When deleting a directory, the number of paths that are deleted - with each invocation is limited. If the number of paths to be deleted exceeds this limit, a - continuation token is returned in this response header. When a continuation token is returned - in the response, it must be specified in a subsequent invocation of the delete operation to - continue deleting the directory. Default value is None. - :type continuation: str - :param path: Optional. Filters results to paths within the specified directory. An error - occurs if the directory does not exist. Default value is None. - :type path: str - :param max_results: An optional value that specifies the maximum number of items to return. If - omitted or greater than 5,000, the response will include up to 5,000 items. Default value is - None. - :type max_results: int - :param upn: Optional. Valid only when Hierarchical Namespace is enabled for the account. If - "true", the user identity values returned in the x-ms-owner, x-ms-group, and x-ms-acl response - headers will be transformed from Azure Active Directory Object IDs to User Principal Names. If - "false", the values will be returned as Azure Active Directory Object IDs. The default value is - false. Note that group and application Object IDs are not translated because they do not have - unique friendly names. Default value is None. - :type upn: bool - :param begin_from: Optional. A relative path within the specified directory where the listing - will start from. For example, a recursive listing under directory folder1/folder2 with - beginFrom as folder3/readmefile.txt will start listing from - folder1/folder2/folder3/readmefile.txt. Please note that, multiple entity levels are supported - for recursive listing. Non-recursive listing supports only one entity level. An error will - appear if multiple entity levels are specified for non-recursive listing. Default value is - None. - :type begin_from: str - :return: PathList or the result of cls(response) - :rtype: ~azure.storage.filedatalake.models.PathList - :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[_models.PathList] = kwargs.pop("cls", None) - - _request = build_list_paths_request( - url=self._config.url, - recursive=recursive, - version=self._config.version, - request_id_parameter=request_id_parameter, - timeout=timeout, - continuation=continuation, - path=path, - max_results=max_results, - upn=upn, - begin_from=begin_from, - resource=self._config.resource, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = 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["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) - 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["x-ms-continuation"] = self._deserialize("str", response.headers.get("x-ms-continuation")) - - deserialized = self._deserialize("PathList", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_blob_hierarchy_segment( - self, - prefix: Optional[str] = None, - delimiter: Optional[str] = None, - marker: Optional[str] = None, - max_results: Optional[int] = None, - include: Optional[list[Union[str, _models.ListBlobsIncludeItem]]] = None, - showonly: Literal["deleted"] = "deleted", - timeout: Optional[int] = None, - request_id_parameter: Optional[str] = None, - **kwargs: Any - ) -> _models.ListBlobsHierarchySegmentResponse: - """The List Blobs operation returns a list of the blobs under the specified container. - - :param prefix: Filters results to filesystems within the specified prefix. Default value is - None. - :type prefix: str - :param delimiter: When the request includes this parameter, the operation returns a BlobPrefix - element in the response body that acts as a placeholder for all blobs whose names begin with - the same substring up to the appearance of the delimiter character. The delimiter may be a - single character or a string. Default value is None. - :type delimiter: str - :param marker: A string value that identifies the portion of the list of containers to be - returned with the next listing operation. The operation returns the NextMarker value within the - response body if the listing operation did not return all containers remaining to be listed - with the current page. The NextMarker value can be used as the value for the marker parameter - in a subsequent call to request the next page of list items. The marker value is opaque to the - client. Default value is None. - :type marker: str - :param max_results: An optional value that specifies the maximum number of items to return. If - omitted or greater than 5,000, the response will include up to 5,000 items. Default value is - None. - :type max_results: 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.filedatalake.models.ListBlobsIncludeItem] - :param showonly: Include this parameter to specify one or more datasets to include in the - response. Known values are "deleted" and None. Default value is "deleted". - :type showonly: str - :param timeout: The timeout parameter is expressed in seconds. For more information, see - :code:`Setting - Timeouts for Blob Service Operations.`. 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: ListBlobsHierarchySegmentResponse or the result of cls(response) - :rtype: ~azure.storage.filedatalake.models.ListBlobsHierarchySegmentResponse - :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["container"] = kwargs.pop("restype", _params.pop("restype", "container")) - comp: Literal["list"] = kwargs.pop("comp", _params.pop("comp", "list")) - cls: ClsType[_models.ListBlobsHierarchySegmentResponse] = kwargs.pop("cls", None) - - _request = build_list_blob_hierarchy_segment_request( - url=self._config.url, - version=self._config.version, - prefix=prefix, - delimiter=delimiter, - marker=marker, - max_results=max_results, - include=include, - showonly=showonly, - timeout=timeout, - request_id_parameter=request_id_parameter, - restype=restype, - comp=comp, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = 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-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")) - - deserialized = self._deserialize("ListBlobsHierarchySegmentResponse", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/operations/_operations.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/operations/_operations.py new file mode 100644 index 000000000000..6f2c56f58208 --- /dev/null +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/operations/_operations.py @@ -0,0 +1,3659 @@ +# pylint: disable=line-too-long,useless-suppression,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) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +import datetime +from typing import Any, Callable, Iterator, Optional, TypeVar, Union + +from azure.core import MatchConditions, PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceModifiedError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict + +from .. import models as _models +from .._configuration import DataLakeClientConfiguration +from .._utils.model_base import _deserialize, _deserialize_xml, _failsafe_deserialize +from .._utils.serialization import Deserializer, Serializer +from .._utils.utils import prep_if_match, prep_if_none_match + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_file_system_create_request( + *, + resource: Union[str, _models.FileSystemResourceType], + properties: Optional[str] = None, + timeout: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + version: str = kwargs.pop("version", _headers.pop("x-ms-version", "2026-06-06")) + # Construct URL + _url = "" + + # Construct parameters + _params["resource"] = _SERIALIZER.query("resource", resource, "str") + if timeout is not None: + _params["timeout"] = _SERIALIZER.query("timeout", timeout, "int") + + # Construct headers + _headers["x-ms-version"] = _SERIALIZER.header("version", version, "str") + if properties is not None: + _headers["x-ms-properties"] = _SERIALIZER.header("properties", properties, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_file_system_set_properties_request( + *, + resource: Union[str, _models.FileSystemResourceType], + properties: Optional[str] = None, + if_modified_since: Optional[datetime.datetime] = None, + if_unmodified_since: Optional[datetime.datetime] = None, + timeout: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + version: str = kwargs.pop("version", _headers.pop("x-ms-version", "2026-06-06")) + # Construct URL + _url = "" + + # Construct parameters + _params["resource"] = _SERIALIZER.query("resource", resource, "str") + if timeout is not None: + _params["timeout"] = _SERIALIZER.query("timeout", timeout, "int") + + # Construct headers + _headers["x-ms-version"] = _SERIALIZER.header("version", version, "str") + if properties is not None: + _headers["x-ms-properties"] = _SERIALIZER.header("properties", properties, "str") + if if_modified_since is not None: + _headers["If-Modified-Since"] = _SERIALIZER.header("if_modified_since", if_modified_since, "rfc-1123") + if if_unmodified_since is not None: + _headers["If-Unmodified-Since"] = _SERIALIZER.header("if_unmodified_since", if_unmodified_since, "rfc-1123") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_file_system_get_properties_request( + *, resource: Union[str, _models.FileSystemResourceType], timeout: Optional[int] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + version: str = kwargs.pop("version", _headers.pop("x-ms-version", "2026-06-06")) + # Construct URL + _url = "" + + # Construct parameters + _params["resource"] = _SERIALIZER.query("resource", resource, "str") + if timeout is not None: + _params["timeout"] = _SERIALIZER.query("timeout", timeout, "int") + + # Construct headers + _headers["x-ms-version"] = _SERIALIZER.header("version", version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_file_system_delete_request( + *, + resource: Union[str, _models.FileSystemResourceType], + if_modified_since: Optional[datetime.datetime] = None, + if_unmodified_since: Optional[datetime.datetime] = None, + timeout: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + version: str = kwargs.pop("version", _headers.pop("x-ms-version", "2026-06-06")) + # Construct URL + _url = "" + + # Construct parameters + _params["resource"] = _SERIALIZER.query("resource", resource, "str") + if timeout is not None: + _params["timeout"] = _SERIALIZER.query("timeout", timeout, "int") + + # Construct headers + _headers["x-ms-version"] = _SERIALIZER.header("version", version, "str") + if if_modified_since is not None: + _headers["If-Modified-Since"] = _SERIALIZER.header("if_modified_since", if_modified_since, "rfc-1123") + if if_unmodified_since is not None: + _headers["If-Unmodified-Since"] = _SERIALIZER.header("if_unmodified_since", if_unmodified_since, "rfc-1123") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_file_system_list_paths_request( + *, + recursive: bool, + continuation: Optional[str] = None, + path: Optional[str] = None, + max_results: Optional[int] = None, + upn: Optional[bool] = None, + begin_from: Optional[str] = None, + timeout: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + version: str = kwargs.pop("version", _headers.pop("x-ms-version", "2026-06-06")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "?resource=filesystem" + + # Construct parameters + if continuation is not None: + _params["continuation"] = _SERIALIZER.query("continuation", continuation, "str") + if path is not None: + _params["directory"] = _SERIALIZER.query("path", path, "str") + _params["recursive"] = _SERIALIZER.query("recursive", recursive, "bool") + if max_results is not None: + _params["maxResults"] = _SERIALIZER.query("max_results", max_results, "int") + if upn is not None: + _params["upn"] = _SERIALIZER.query("upn", upn, "bool") + if begin_from is not None: + _params["beginFrom"] = _SERIALIZER.query("begin_from", begin_from, "str") + if timeout is not None: + _params["timeout"] = _SERIALIZER.query("timeout", timeout, "int") + + # Construct headers + _headers["x-ms-version"] = _SERIALIZER.header("version", version, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_file_system_list_blob_hierarchy_segment_request( # pylint: disable=name-too-long + *, + prefix: Optional[str] = None, + delimiter: Optional[str] = None, + marker: Optional[str] = None, + max_results: Optional[int] = None, + include: Optional[list[Union[str, _models.ListBlobsIncludeItem]]] = None, + showonly: Optional[Union[str, _models.ListBlobsShowOnly]] = None, + timeout: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + version: str = kwargs.pop("version", _headers.pop("x-ms-version", "2026-06-06")) + accept = _headers.pop("Accept", "application/xml") + + # Construct URL + _url = "?restype=container&comp=list" + + # Construct parameters + if prefix is not None: + _params["prefix"] = _SERIALIZER.query("prefix", prefix, "str") + if delimiter is not None: + _params["delimiter"] = _SERIALIZER.query("delimiter", delimiter, "str") + if marker is not None: + _params["marker"] = _SERIALIZER.query("marker", marker, "str") + if max_results is not None: + _params["maxResults"] = _SERIALIZER.query("max_results", max_results, "int") + if include is not None: + _params["include"] = _SERIALIZER.query("include", include, "[str]", div=",") + if showonly is not None: + _params["showonly"] = _SERIALIZER.query("showonly", showonly, "str") + if timeout is not None: + _params["timeout"] = _SERIALIZER.query("timeout", timeout, "int") + + # Construct headers + _headers["x-ms-version"] = _SERIALIZER.header("version", version, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_path_create_request( # pylint: disable=too-many-locals,too-many-statements,too-many-branches + *, + resource: Optional[Union[str, _models.PathResourceType]] = None, + mode: Optional[Union[str, _models.PathRenameMode]] = None, + continuation: Optional[str] = None, + cache_control: Optional[str] = None, + content_encoding: Optional[str] = None, + content_language: Optional[str] = None, + content_disposition: Optional[str] = None, + content_type: Optional[str] = None, + rename_source: Optional[str] = None, + lease_id: Optional[str] = None, + source_lease_id: Optional[str] = None, + properties: Optional[str] = None, + permissions: Optional[str] = None, + umask: Optional[str] = None, + if_modified_since: Optional[datetime.datetime] = None, + if_unmodified_since: Optional[datetime.datetime] = None, + source_if_match: Optional[str] = None, + source_if_none_match: Optional[str] = None, + source_if_modified_since: Optional[datetime.datetime] = None, + source_if_unmodified_since: Optional[datetime.datetime] = None, + encryption_key: Optional[str] = None, + encryption_key_sha256: Optional[str] = None, + encryption_algorithm: Optional[Union[str, _models.EncryptionAlgorithmType]] = None, + owner: Optional[str] = None, + group: Optional[str] = None, + acl: Optional[str] = None, + proposed_lease_id: Optional[str] = None, + lease_duration: Optional[int] = None, + expiry_options: Optional[Union[str, _models.PathExpiryOptions]] = None, + expires_on: Optional[str] = None, + encryption_context: Optional[str] = None, + timeout: Optional[int] = None, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + version: str = kwargs.pop("version", _headers.pop("x-ms-version", "2026-06-06")) + # Construct URL + _url = "" + + # Construct parameters + if resource is not None: + _params["resource"] = _SERIALIZER.query("resource", resource, "str") + if mode is not None: + _params["mode"] = _SERIALIZER.query("mode", mode, "str") + if continuation is not None: + _params["continuation"] = _SERIALIZER.query("continuation", continuation, "str") + if timeout is not None: + _params["timeout"] = _SERIALIZER.query("timeout", timeout, "int") + + # Construct headers + _headers["x-ms-version"] = _SERIALIZER.header("version", version, "str") + if cache_control is not None: + _headers["x-ms-cache-control"] = _SERIALIZER.header("cache_control", cache_control, "str") + if content_encoding is not None: + _headers["x-ms-content-encoding"] = _SERIALIZER.header("content_encoding", content_encoding, "str") + if content_language is not None: + _headers["x-ms-content-language"] = _SERIALIZER.header("content_language", content_language, "str") + if content_disposition is not None: + _headers["x-ms-content-disposition"] = _SERIALIZER.header("content_disposition", content_disposition, "str") + if content_type is not None: + _headers["x-ms-content-type"] = _SERIALIZER.header("content_type", content_type, "str") + if rename_source is not None: + _headers["x-ms-rename-source"] = _SERIALIZER.header("rename_source", rename_source, "str") + if lease_id is not None: + _headers["x-ms-lease-id"] = _SERIALIZER.header("lease_id", lease_id, "str") + if source_lease_id is not None: + _headers["x-ms-source-lease-id"] = _SERIALIZER.header("source_lease_id", source_lease_id, "str") + if properties is not None: + _headers["x-ms-properties"] = _SERIALIZER.header("properties", properties, "str") + if permissions is not None: + _headers["x-ms-permissions"] = _SERIALIZER.header("permissions", permissions, "str") + if umask is not None: + _headers["x-ms-umask"] = _SERIALIZER.header("umask", umask, "str") + if if_modified_since is not None: + _headers["If-Modified-Since"] = _SERIALIZER.header("if_modified_since", if_modified_since, "rfc-1123") + if if_unmodified_since is not None: + _headers["If-Unmodified-Since"] = _SERIALIZER.header("if_unmodified_since", if_unmodified_since, "rfc-1123") + if source_if_match is not None: + _headers["x-ms-source-if-match"] = _SERIALIZER.header("source_if_match", source_if_match, "str") + if source_if_none_match is not None: + _headers["x-ms-source-if-none-match"] = _SERIALIZER.header("source_if_none_match", source_if_none_match, "str") + if source_if_modified_since is not None: + _headers["x-ms-source-if-modified-since"] = _SERIALIZER.header( + "source_if_modified_since", source_if_modified_since, "rfc-1123" + ) + if source_if_unmodified_since is not None: + _headers["x-ms-source-if-unmodified-since"] = _SERIALIZER.header( + "source_if_unmodified_since", source_if_unmodified_since, "rfc-1123" + ) + if encryption_key is not None: + _headers["x-ms-encryption-key"] = _SERIALIZER.header("encryption_key", encryption_key, "str") + if encryption_key_sha256 is not None: + _headers["x-ms-encryption-key-sha256"] = _SERIALIZER.header( + "encryption_key_sha256", encryption_key_sha256, "str" + ) + if encryption_algorithm is not None: + _headers["x-ms-encryption-algorithm"] = _SERIALIZER.header("encryption_algorithm", encryption_algorithm, "str") + if owner is not None: + _headers["x-ms-owner"] = _SERIALIZER.header("owner", owner, "str") + if group is not None: + _headers["x-ms-group"] = _SERIALIZER.header("group", group, "str") + if acl is not None: + _headers["x-ms-acl"] = _SERIALIZER.header("acl", acl, "str") + if proposed_lease_id is not None: + _headers["x-ms-proposed-lease-id"] = _SERIALIZER.header("proposed_lease_id", proposed_lease_id, "str") + if lease_duration is not None: + _headers["x-ms-lease-duration"] = _SERIALIZER.header("lease_duration", lease_duration, "int") + if expiry_options is not None: + _headers["x-ms-expiry-option"] = _SERIALIZER.header("expiry_options", expiry_options, "str") + if expires_on is not None: + _headers["x-ms-expiry-time"] = _SERIALIZER.header("expires_on", expires_on, "str") + if encryption_context is not None: + _headers["x-ms-encryption-context"] = _SERIALIZER.header("encryption_context", encryption_context, "str") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_path_update_request( # pylint: disable=too-many-locals,too-many-statements,too-many-branches + *, + action: Union[str, _models.PathUpdateAction], + max_records: Optional[int] = None, + continuation: Optional[str] = None, + mode: Optional[Union[str, _models.PathSetAccessControlRecursiveMode]] = None, + force_flag: Optional[bool] = None, + position: Optional[int] = None, + retain_uncommitted_data: Optional[bool] = None, + close: Optional[bool] = None, + content_length: Optional[int] = None, + content_md5: Optional[bytes] = None, + lease_id: Optional[str] = None, + cache_control: Optional[str] = None, + content_disposition: Optional[str] = None, + content_encoding: Optional[str] = None, + content_language: Optional[str] = None, + properties: Optional[str] = None, + owner: Optional[str] = None, + group: Optional[str] = None, + permissions: Optional[str] = None, + acl: Optional[str] = None, + if_modified_since: Optional[datetime.datetime] = None, + if_unmodified_since: Optional[datetime.datetime] = None, + structured_body_type: Optional[str] = None, + structured_content_length: Optional[int] = None, + timeout: Optional[int] = None, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: str = kwargs.pop("content_type") + version: str = kwargs.pop("version", _headers.pop("x-ms-version", "2026-06-06")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "" + + # Construct parameters + _params["action"] = _SERIALIZER.query("action", action, "str") + if max_records is not None: + _params["maxRecords"] = _SERIALIZER.query("max_records", max_records, "int") + if continuation is not None: + _params["continuation"] = _SERIALIZER.query("continuation", continuation, "str") + if mode is not None: + _params["mode"] = _SERIALIZER.query("mode", mode, "str") + if force_flag is not None: + _params["forceFlag"] = _SERIALIZER.query("force_flag", force_flag, "bool") + if position is not None: + _params["position"] = _SERIALIZER.query("position", position, "int") + if retain_uncommitted_data is not None: + _params["retainUncommittedData"] = _SERIALIZER.query("retain_uncommitted_data", retain_uncommitted_data, "bool") + if close is not None: + _params["close"] = _SERIALIZER.query("close", close, "bool") + if timeout is not None: + _params["timeout"] = _SERIALIZER.query("timeout", timeout, "int") + + # Construct headers + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["x-ms-version"] = _SERIALIZER.header("version", version, "str") + if content_length is not None: + _headers["Content-Length"] = _SERIALIZER.header("content_length", content_length, "int") + if content_md5 is not None: + _headers["x-ms-content-md5"] = _SERIALIZER.header("content_md5", content_md5, "bytearray") + if lease_id is not None: + _headers["x-ms-lease-id"] = _SERIALIZER.header("lease_id", lease_id, "str") + if cache_control is not None: + _headers["x-ms-cache-control"] = _SERIALIZER.header("cache_control", cache_control, "str") + if content_disposition is not None: + _headers["x-ms-content-disposition"] = _SERIALIZER.header("content_disposition", content_disposition, "str") + if content_encoding is not None: + _headers["x-ms-content-encoding"] = _SERIALIZER.header("content_encoding", content_encoding, "str") + if content_language is not None: + _headers["x-ms-content-language"] = _SERIALIZER.header("content_language", content_language, "str") + if properties is not None: + _headers["x-ms-properties"] = _SERIALIZER.header("properties", properties, "str") + if owner is not None: + _headers["x-ms-owner"] = _SERIALIZER.header("owner", owner, "str") + if group is not None: + _headers["x-ms-group"] = _SERIALIZER.header("group", group, "str") + if permissions is not None: + _headers["x-ms-permissions"] = _SERIALIZER.header("permissions", permissions, "str") + if acl is not None: + _headers["x-ms-acl"] = _SERIALIZER.header("acl", acl, "str") + if if_modified_since is not None: + _headers["If-Modified-Since"] = _SERIALIZER.header("if_modified_since", if_modified_since, "rfc-1123") + if if_unmodified_since is not None: + _headers["If-Unmodified-Since"] = _SERIALIZER.header("if_unmodified_since", if_unmodified_since, "rfc-1123") + if structured_body_type is not None: + _headers["x-ms-structured-body"] = _SERIALIZER.header("structured_body_type", structured_body_type, "str") + if structured_content_length is not None: + _headers["x-ms-structured-content-length"] = _SERIALIZER.header( + "structured_content_length", structured_content_length, "int" + ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_path_lease_request( + *, + lease_action: Union[str, _models.PathLeaseAction], + lease_duration: Optional[int] = None, + lease_break_period: Optional[int] = None, + lease_id: Optional[str] = None, + proposed_lease_id: Optional[str] = None, + if_modified_since: Optional[datetime.datetime] = None, + if_unmodified_since: Optional[datetime.datetime] = None, + timeout: Optional[int] = None, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + version: str = kwargs.pop("version", _headers.pop("x-ms-version", "2026-06-06")) + # Construct URL + _url = "" + + # Construct parameters + if timeout is not None: + _params["timeout"] = _SERIALIZER.query("timeout", timeout, "int") + + # Construct headers + _headers["x-ms-version"] = _SERIALIZER.header("version", version, "str") + _headers["x-ms-lease-action"] = _SERIALIZER.header("lease_action", lease_action, "str") + if lease_duration is not None: + _headers["x-ms-lease-duration"] = _SERIALIZER.header("lease_duration", lease_duration, "int") + if lease_break_period is not None: + _headers["x-ms-lease-break-period"] = _SERIALIZER.header("lease_break_period", lease_break_period, "int") + if lease_id is not None: + _headers["x-ms-lease-id"] = _SERIALIZER.header("lease_id", lease_id, "str") + if proposed_lease_id is not None: + _headers["x-ms-proposed-lease-id"] = _SERIALIZER.header("proposed_lease_id", proposed_lease_id, "str") + if if_modified_since is not None: + _headers["If-Modified-Since"] = _SERIALIZER.header("if_modified_since", if_modified_since, "rfc-1123") + if if_unmodified_since is not None: + _headers["If-Unmodified-Since"] = _SERIALIZER.header("if_unmodified_since", if_unmodified_since, "rfc-1123") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_path_read_request( + *, + range: Optional[str] = None, + lease_id: Optional[str] = None, + range_get_content_md5: Optional[bool] = None, + if_modified_since: Optional[datetime.datetime] = None, + if_unmodified_since: Optional[datetime.datetime] = None, + encryption_key: Optional[str] = None, + encryption_key_sha256: Optional[str] = None, + encryption_algorithm: Optional[Union[str, _models.EncryptionAlgorithmType]] = None, + timeout: Optional[int] = None, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + version: str = kwargs.pop("version", _headers.pop("x-ms-version", "2026-06-06")) + accept = _headers.pop("Accept", "application/octet-stream") + + # Construct URL + _url = "" + + # Construct parameters + if timeout is not None: + _params["timeout"] = _SERIALIZER.query("timeout", timeout, "int") + + # Construct headers + _headers["x-ms-version"] = _SERIALIZER.header("version", version, "str") + if range is not None: + _headers["Range"] = _SERIALIZER.header("range", range, "str") + if lease_id is not None: + _headers["x-ms-lease-id"] = _SERIALIZER.header("lease_id", lease_id, "str") + if range_get_content_md5 is not None: + _headers["x-ms-range-get-content-md5"] = _SERIALIZER.header( + "range_get_content_md5", range_get_content_md5, "bool" + ) + if if_modified_since is not None: + _headers["If-Modified-Since"] = _SERIALIZER.header("if_modified_since", if_modified_since, "rfc-1123") + if if_unmodified_since is not None: + _headers["If-Unmodified-Since"] = _SERIALIZER.header("if_unmodified_since", if_unmodified_since, "rfc-1123") + if encryption_key is not None: + _headers["x-ms-encryption-key"] = _SERIALIZER.header("encryption_key", encryption_key, "str") + if encryption_key_sha256 is not None: + _headers["x-ms-encryption-key-sha256"] = _SERIALIZER.header( + "encryption_key_sha256", encryption_key_sha256, "str" + ) + if encryption_algorithm is not None: + _headers["x-ms-encryption-algorithm"] = _SERIALIZER.header("encryption_algorithm", encryption_algorithm, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_path_get_properties_request( + *, + action: Optional[Union[str, _models.PathGetPropertiesAction]] = None, + upn: Optional[bool] = None, + lease_id: Optional[str] = None, + if_modified_since: Optional[datetime.datetime] = None, + if_unmodified_since: Optional[datetime.datetime] = None, + timeout: Optional[int] = None, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + version: str = kwargs.pop("version", _headers.pop("x-ms-version", "2026-06-06")) + # Construct URL + _url = "" + + # Construct parameters + if action is not None: + _params["action"] = _SERIALIZER.query("action", action, "str") + if upn is not None: + _params["upn"] = _SERIALIZER.query("upn", upn, "bool") + if timeout is not None: + _params["timeout"] = _SERIALIZER.query("timeout", timeout, "int") + + # Construct headers + _headers["x-ms-version"] = _SERIALIZER.header("version", version, "str") + if lease_id is not None: + _headers["x-ms-lease-id"] = _SERIALIZER.header("lease_id", lease_id, "str") + if if_modified_since is not None: + _headers["If-Modified-Since"] = _SERIALIZER.header("if_modified_since", if_modified_since, "rfc-1123") + if if_unmodified_since is not None: + _headers["If-Unmodified-Since"] = _SERIALIZER.header("if_unmodified_since", if_unmodified_since, "rfc-1123") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_path_delete_request( + *, + recursive: Optional[bool] = None, + continuation: Optional[str] = None, + lease_id: Optional[str] = None, + if_modified_since: Optional[datetime.datetime] = None, + if_unmodified_since: Optional[datetime.datetime] = None, + paginated: Optional[bool] = None, + timeout: Optional[int] = None, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + version: str = kwargs.pop("version", _headers.pop("x-ms-version", "2026-06-06")) + # Construct URL + _url = "" + + # Construct parameters + if recursive is not None: + _params["recursive"] = _SERIALIZER.query("recursive", recursive, "bool") + if continuation is not None: + _params["continuation"] = _SERIALIZER.query("continuation", continuation, "str") + if paginated is not None: + _params["paginated"] = _SERIALIZER.query("paginated", paginated, "bool") + if timeout is not None: + _params["timeout"] = _SERIALIZER.query("timeout", timeout, "int") + + # Construct headers + _headers["x-ms-version"] = _SERIALIZER.header("version", version, "str") + if lease_id is not None: + _headers["x-ms-lease-id"] = _SERIALIZER.header("lease_id", lease_id, "str") + if if_modified_since is not None: + _headers["If-Modified-Since"] = _SERIALIZER.header("if_modified_since", if_modified_since, "rfc-1123") + if if_unmodified_since is not None: + _headers["If-Unmodified-Since"] = _SERIALIZER.header("if_unmodified_since", if_unmodified_since, "rfc-1123") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_path_set_access_control_request( + *, + lease_id: Optional[str] = None, + owner: Optional[str] = None, + group: Optional[str] = None, + permissions: Optional[str] = None, + acl: Optional[str] = None, + if_modified_since: Optional[datetime.datetime] = None, + if_unmodified_since: Optional[datetime.datetime] = None, + timeout: Optional[int] = None, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + version: str = kwargs.pop("version", _headers.pop("x-ms-version", "2026-06-06")) + # Construct URL + _url = "?action=setAccessControl" + + # Construct parameters + if timeout is not None: + _params["timeout"] = _SERIALIZER.query("timeout", timeout, "int") + + # Construct headers + _headers["x-ms-version"] = _SERIALIZER.header("version", version, "str") + if lease_id is not None: + _headers["x-ms-lease-id"] = _SERIALIZER.header("lease_id", lease_id, "str") + if owner is not None: + _headers["x-ms-owner"] = _SERIALIZER.header("owner", owner, "str") + if group is not None: + _headers["x-ms-group"] = _SERIALIZER.header("group", group, "str") + if permissions is not None: + _headers["x-ms-permissions"] = _SERIALIZER.header("permissions", permissions, "str") + if acl is not None: + _headers["x-ms-acl"] = _SERIALIZER.header("acl", acl, "str") + if if_modified_since is not None: + _headers["If-Modified-Since"] = _SERIALIZER.header("if_modified_since", if_modified_since, "rfc-1123") + if if_unmodified_since is not None: + _headers["If-Unmodified-Since"] = _SERIALIZER.header("if_unmodified_since", if_unmodified_since, "rfc-1123") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_path_set_access_control_recursive_request( # pylint: disable=name-too-long + *, + mode: Union[str, _models.PathSetAccessControlRecursiveMode], + continuation: Optional[str] = None, + force_flag: Optional[bool] = None, + max_records: Optional[int] = None, + acl: Optional[str] = None, + timeout: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + version: str = kwargs.pop("version", _headers.pop("x-ms-version", "2026-06-06")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "?action=setAccessControlRecursive" + + # Construct parameters + _params["mode"] = _SERIALIZER.query("mode", mode, "str") + if continuation is not None: + _params["continuation"] = _SERIALIZER.query("continuation", continuation, "str") + if force_flag is not None: + _params["forceFlag"] = _SERIALIZER.query("force_flag", force_flag, "bool") + if max_records is not None: + _params["maxRecords"] = _SERIALIZER.query("max_records", max_records, "int") + if timeout is not None: + _params["timeout"] = _SERIALIZER.query("timeout", timeout, "int") + + # Construct headers + _headers["x-ms-version"] = _SERIALIZER.header("version", version, "str") + if acl is not None: + _headers["x-ms-acl"] = _SERIALIZER.header("acl", acl, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_path_flush_data_request( # pylint: disable=too-many-locals + *, + position: Optional[int] = None, + retain_uncommitted_data: Optional[bool] = None, + close: Optional[bool] = None, + content_length: Optional[int] = None, + content_md5: Optional[bytes] = None, + lease_id: Optional[str] = None, + lease_action: Optional[Union[str, _models.LeaseAction]] = None, + lease_duration: Optional[int] = None, + proposed_lease_id: Optional[str] = None, + cache_control: Optional[str] = None, + content_type: Optional[str] = None, + content_disposition: Optional[str] = None, + content_encoding: Optional[str] = None, + content_language: Optional[str] = None, + if_modified_since: Optional[datetime.datetime] = None, + if_unmodified_since: Optional[datetime.datetime] = None, + encryption_key: Optional[str] = None, + encryption_key_sha256: Optional[str] = None, + encryption_algorithm: Optional[Union[str, _models.EncryptionAlgorithmType]] = None, + timeout: Optional[int] = None, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + version: str = kwargs.pop("version", _headers.pop("x-ms-version", "2026-06-06")) + # Construct URL + _url = "?action=flush" + + # Construct parameters + if position is not None: + _params["position"] = _SERIALIZER.query("position", position, "int") + if retain_uncommitted_data is not None: + _params["retainUncommittedData"] = _SERIALIZER.query("retain_uncommitted_data", retain_uncommitted_data, "bool") + if close is not None: + _params["close"] = _SERIALIZER.query("close", close, "bool") + if timeout is not None: + _params["timeout"] = _SERIALIZER.query("timeout", timeout, "int") + + # Construct headers + _headers["x-ms-version"] = _SERIALIZER.header("version", version, "str") + if content_length is not None: + _headers["Content-Length"] = _SERIALIZER.header("content_length", content_length, "int") + if content_md5 is not None: + _headers["x-ms-content-md5"] = _SERIALIZER.header("content_md5", content_md5, "bytearray") + if lease_id is not None: + _headers["x-ms-lease-id"] = _SERIALIZER.header("lease_id", lease_id, "str") + if lease_action is not None: + _headers["x-ms-lease-action"] = _SERIALIZER.header("lease_action", lease_action, "str") + if lease_duration is not None: + _headers["x-ms-lease-duration"] = _SERIALIZER.header("lease_duration", lease_duration, "int") + if proposed_lease_id is not None: + _headers["x-ms-proposed-lease-id"] = _SERIALIZER.header("proposed_lease_id", proposed_lease_id, "str") + if cache_control is not None: + _headers["x-ms-cache-control"] = _SERIALIZER.header("cache_control", cache_control, "str") + if content_type is not None: + _headers["x-ms-content-type"] = _SERIALIZER.header("content_type", content_type, "str") + if content_disposition is not None: + _headers["x-ms-content-disposition"] = _SERIALIZER.header("content_disposition", content_disposition, "str") + if content_encoding is not None: + _headers["x-ms-content-encoding"] = _SERIALIZER.header("content_encoding", content_encoding, "str") + if content_language is not None: + _headers["x-ms-content-language"] = _SERIALIZER.header("content_language", content_language, "str") + if if_modified_since is not None: + _headers["If-Modified-Since"] = _SERIALIZER.header("if_modified_since", if_modified_since, "rfc-1123") + if if_unmodified_since is not None: + _headers["If-Unmodified-Since"] = _SERIALIZER.header("if_unmodified_since", if_unmodified_since, "rfc-1123") + if encryption_key is not None: + _headers["x-ms-encryption-key"] = _SERIALIZER.header("encryption_key", encryption_key, "str") + if encryption_key_sha256 is not None: + _headers["x-ms-encryption-key-sha256"] = _SERIALIZER.header( + "encryption_key_sha256", encryption_key_sha256, "str" + ) + if encryption_algorithm is not None: + _headers["x-ms-encryption-algorithm"] = _SERIALIZER.header("encryption_algorithm", encryption_algorithm, "str") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_path_append_data_request( + *, + position: Optional[int] = None, + content_length: Optional[int] = None, + transactional_content_hash: Optional[bytes] = None, + transactional_content_crc64: Optional[bytes] = None, + lease_id: Optional[str] = None, + lease_action: Optional[Union[str, _models.LeaseAction]] = None, + lease_duration: Optional[int] = None, + proposed_lease_id: Optional[str] = None, + encryption_key: Optional[str] = None, + encryption_key_sha256: Optional[str] = None, + encryption_algorithm: Optional[Union[str, _models.EncryptionAlgorithmType]] = None, + flush: Optional[bool] = None, + structured_body_type: Optional[str] = None, + structured_content_length: Optional[int] = None, + timeout: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: str = kwargs.pop("content_type") + version: str = kwargs.pop("version", _headers.pop("x-ms-version", "2026-06-06")) + # Construct URL + _url = "?action=append" + + # Construct parameters + if position is not None: + _params["position"] = _SERIALIZER.query("position", position, "int") + if flush is not None: + _params["flush"] = _SERIALIZER.query("flush", flush, "bool") + if timeout is not None: + _params["timeout"] = _SERIALIZER.query("timeout", timeout, "int") + + # Construct headers + _headers["x-ms-version"] = _SERIALIZER.header("version", version, "str") + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + if content_length is not None: + _headers["Content-Length"] = _SERIALIZER.header("content_length", content_length, "int") + if transactional_content_hash is not None: + _headers["Content-MD5"] = _SERIALIZER.header( + "transactional_content_hash", transactional_content_hash, "bytearray" + ) + if transactional_content_crc64 is not None: + _headers["x-ms-content-crc64"] = _SERIALIZER.header( + "transactional_content_crc64", transactional_content_crc64, "bytearray" + ) + if lease_id is not None: + _headers["x-ms-lease-id"] = _SERIALIZER.header("lease_id", lease_id, "str") + if lease_action is not None: + _headers["x-ms-lease-action"] = _SERIALIZER.header("lease_action", lease_action, "str") + if lease_duration is not None: + _headers["x-ms-lease-duration"] = _SERIALIZER.header("lease_duration", lease_duration, "int") + if proposed_lease_id is not None: + _headers["x-ms-proposed-lease-id"] = _SERIALIZER.header("proposed_lease_id", proposed_lease_id, "str") + if encryption_key is not None: + _headers["x-ms-encryption-key"] = _SERIALIZER.header("encryption_key", encryption_key, "str") + if encryption_key_sha256 is not None: + _headers["x-ms-encryption-key-sha256"] = _SERIALIZER.header( + "encryption_key_sha256", encryption_key_sha256, "str" + ) + if encryption_algorithm is not None: + _headers["x-ms-encryption-algorithm"] = _SERIALIZER.header("encryption_algorithm", encryption_algorithm, "str") + if structured_body_type is not None: + _headers["x-ms-structured-body"] = _SERIALIZER.header("structured_body_type", structured_body_type, "str") + if structured_content_length is not None: + _headers["x-ms-structured-content-length"] = _SERIALIZER.header( + "structured_content_length", structured_content_length, "int" + ) + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_path_set_expiry_request( + *, + expiry_options: Union[str, _models.PathExpiryOptions], + expires_on: Optional[str] = None, + timeout: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + version: str = kwargs.pop("version", _headers.pop("x-ms-version", "2026-06-06")) + # Construct URL + _url = "?comp=expiry" + + # Construct parameters + if timeout is not None: + _params["timeout"] = _SERIALIZER.query("timeout", timeout, "int") + + # Construct headers + _headers["x-ms-version"] = _SERIALIZER.header("version", version, "str") + _headers["x-ms-expiry-option"] = _SERIALIZER.header("expiry_options", expiry_options, "str") + if expires_on is not None: + _headers["x-ms-expiry-time"] = _SERIALIZER.header("expires_on", expires_on, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_path_undelete_request( + *, undelete_source: Optional[str] = None, timeout: Optional[int] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + version: str = kwargs.pop("version", _headers.pop("x-ms-version", "2026-06-06")) + # Construct URL + _url = "?comp=undelete" + + # Construct parameters + if timeout is not None: + _params["timeout"] = _SERIALIZER.query("timeout", timeout, "int") + + # Construct headers + _headers["x-ms-version"] = _SERIALIZER.header("version", version, "str") + if undelete_source is not None: + _headers["x-ms-undelete-source"] = _SERIALIZER.header("undelete_source", undelete_source, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_service_list_file_systems_request( + *, + resource: Union[str, _models.AccountResourceType], + prefix: Optional[str] = None, + continuation: Optional[str] = None, + max_results: Optional[int] = None, + timeout: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + version: str = kwargs.pop("version", _headers.pop("x-ms-version", "2026-06-06")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "" + + # Construct parameters + _params["resource"] = _SERIALIZER.query("resource", resource, "str") + if prefix is not None: + _params["prefix"] = _SERIALIZER.query("prefix", prefix, "str") + if continuation is not None: + _params["continuation"] = _SERIALIZER.query("continuation", continuation, "str") + if max_results is not None: + _params["maxResults"] = _SERIALIZER.query("max_results", max_results, "int") + if timeout is not None: + _params["timeout"] = _SERIALIZER.query("timeout", timeout, "int") + + # Construct headers + _headers["x-ms-version"] = _SERIALIZER.header("version", version, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class FileSystemOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.storage.filedatalake.DataLakeClient`'s + :attr:`file_system` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: DataLakeClientConfiguration = 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 + def create( # pylint: disable=inconsistent-return-statements + self, + *, + resource: Union[str, _models.FileSystemResourceType], + properties: Optional[str] = None, + timeout: Optional[int] = None, + **kwargs: Any + ) -> None: + """Create a FileSystem rooted at the specified location. If the FileSystem already exists, the + operation fails. This operation does not support conditional HTTP requests. + + :keyword resource: The value must be "filesystem" for all filesystem operations. "filesystem" + Required. + :paramtype resource: str or ~azure.storage.filedatalake.models.FileSystemResourceType + :keyword properties: Optional. User-defined properties to be stored with the filesystem, in the + format of a comma-separated list of name and value pairs "n1=v1, n2=v2, ...", where each value + is a base64 encoded string. Note that the string may only contain ASCII characters in the + ISO-8859-1 character set. If the filesystem exists, any properties not included in the list + will be removed. All properties are removed if the header is omitted. To merge new and existing + properties, first get all existing properties and the current E-Tag, then make a conditional + request with the E-Tag and include values for all properties. Default value is None. + :paramtype properties: str + :keyword timeout: The timeout parameter is expressed in seconds. For more information, see Setting + Timeouts for Blob Service Operations.. Default value is None. + :paramtype timeout: int + :return: None + :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) + + _request = build_file_system_create_request( + resource=resource, + properties=properties, + timeout=timeout, + version=self._config.version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "url": self._serialize.url("self._config.url", self._config.url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = 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 = _failsafe_deserialize( + _models.StorageError, + 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-namespace-enabled"] = self._deserialize( + "str", response.headers.get("x-ms-namespace-enabled") + ) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + 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") + ) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace + def set_properties( # pylint: disable=inconsistent-return-statements + self, + *, + resource: Union[str, _models.FileSystemResourceType], + properties: Optional[str] = None, + if_modified_since: Optional[datetime.datetime] = None, + if_unmodified_since: Optional[datetime.datetime] = None, + timeout: Optional[int] = None, + **kwargs: Any + ) -> None: + """Set properties for the FileSystem. This operation supports conditional HTTP requests. For more + information, see `Specifying Conditional Headers for Blob Service Operations + `_. + + :keyword resource: The value must be "filesystem" for all filesystem operations. "filesystem" + Required. + :paramtype resource: str or ~azure.storage.filedatalake.models.FileSystemResourceType + :keyword properties: Optional. User-defined properties to be stored with the filesystem, in the + format of a comma-separated list of name and value pairs "n1=v1, n2=v2, ...", where each value + is a base64 encoded string. Note that the string may only contain ASCII characters in the + ISO-8859-1 character set. If the filesystem exists, any properties not included in the list + will be removed. All properties are removed if the header is omitted. To merge new and existing + properties, first get all existing properties and the current E-Tag, then make a conditional + request with the E-Tag and include values for all properties. Default value is None. + :paramtype properties: str + :keyword if_modified_since: Specify this header value to operate only on a blob if it has been + modified since the specified date/time. Default value is None. + :paramtype if_modified_since: ~datetime.datetime + :keyword if_unmodified_since: Specify this header value to operate only on a blob if it has not + been modified since the specified date/time. Default value is None. + :paramtype if_unmodified_since: ~datetime.datetime + :keyword timeout: The timeout parameter is expressed in seconds. For more information, see Setting + Timeouts for Blob Service Operations.. Default value is None. + :paramtype timeout: int + :return: None + :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) + + _request = build_file_system_set_properties_request( + resource=resource, + properties=properties, + if_modified_since=if_modified_since, + if_unmodified_since=if_unmodified_since, + timeout=timeout, + version=self._config.version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "url": self._serialize.url("self._config.url", self._config.url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = 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 = _failsafe_deserialize( + _models.StorageError, + 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["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + 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") + ) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace + def get_properties( + self, *, resource: Union[str, _models.FileSystemResourceType], timeout: Optional[int] = None, **kwargs: Any + ) -> bool: + """All system and user-defined filesystem properties are specified in the response headers. + + :keyword resource: The value must be "filesystem" for all filesystem operations. "filesystem" + Required. + :paramtype resource: str or ~azure.storage.filedatalake.models.FileSystemResourceType + :keyword timeout: The timeout parameter is expressed in seconds. For more information, see Setting + Timeouts for Blob Service Operations.. Default value is None. + :paramtype timeout: int + :return: bool + :rtype: bool + :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) + + _request = build_file_system_get_properties_request( + resource=resource, + timeout=timeout, + version=self._config.version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "url": self._serialize.url("self._config.url", self._config.url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = 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 = _failsafe_deserialize( + _models.StorageError, + 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-properties"] = self._deserialize("str", response.headers.get("x-ms-properties")) + response_headers["x-ms-namespace-enabled"] = self._deserialize( + "str", response.headers.get("x-ms-namespace-enabled") + ) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + 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") + ) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + return 200 <= response.status_code <= 299 + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + *, + resource: Union[str, _models.FileSystemResourceType], + if_modified_since: Optional[datetime.datetime] = None, + if_unmodified_since: Optional[datetime.datetime] = None, + timeout: Optional[int] = None, + **kwargs: Any + ) -> None: + """Marks the FileSystem for deletion. When a FileSystem is deleted, a FileSystem with the same + identifier cannot be created for at least 30 seconds. While the filesystem is being deleted, + attempts to create a filesystem with the same identifier will fail with status code 409 + (Conflict), with the service returning additional error information indicating that the + filesystem is being deleted. All other operations, including operations on any files or + directories within the filesystem, will fail with status code 404 (Not Found) while the + filesystem is being deleted. This operation supports conditional HTTP requests. For more + information, see `Specifying Conditional Headers for Blob Service Operations + `_. + + :keyword resource: The value must be "filesystem" for all filesystem operations. "filesystem" + Required. + :paramtype resource: str or ~azure.storage.filedatalake.models.FileSystemResourceType + :keyword if_modified_since: Specify this header value to operate only on a blob if it has been + modified since the specified date/time. Default value is None. + :paramtype if_modified_since: ~datetime.datetime + :keyword if_unmodified_since: Specify this header value to operate only on a blob if it has not + been modified since the specified date/time. Default value is None. + :paramtype if_unmodified_since: ~datetime.datetime + :keyword timeout: The timeout parameter is expressed in seconds. For more information, see Setting + Timeouts for Blob Service Operations.. Default value is None. + :paramtype timeout: int + :return: None + :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) + + _request = build_file_system_delete_request( + resource=resource, + if_modified_since=if_modified_since, + if_unmodified_since=if_unmodified_since, + timeout=timeout, + version=self._config.version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "url": self._serialize.url("self._config.url", self._config.url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = 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 = _failsafe_deserialize( + _models.StorageError, + response, + ) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + 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") + ) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace + def list_paths( + self, + *, + recursive: bool, + continuation: Optional[str] = None, + path: Optional[str] = None, + max_results: Optional[int] = None, + upn: Optional[bool] = None, + begin_from: Optional[str] = None, + timeout: Optional[int] = None, + **kwargs: Any + ) -> _models.PathList: + """List FileSystem paths and their properties. + + :keyword recursive: Required. Required. + :paramtype recursive: bool + :keyword continuation: Optional. When deleting a directory, the number of paths that are + deleted with each invocation is limited. If the number of paths to be deleted exceeds this + limit, a continuation token is returned in this response header. When a continuation token is + returned in the response, it must be specified in a subsequent invocation of the delete + operation to continue deleting the directory. Default value is None. + :paramtype continuation: str + :keyword path: Optional. Filters results to paths within the specified directory. An error + occurs if the directory does not exist. Default value is None. + :paramtype path: str + :keyword max_results: An optional value that specifies the maximum number of items to return. + If omitted or greater than 5,000, the response will include up to 5,000 items. Default value is + None. + :paramtype max_results: int + :keyword upn: Optional. Valid only when Hierarchical Namespace is enabled for the account. If + "true", the user identity values returned in the x-ms-owner, x-ms-group, and x-ms-acl response + headers will be transformed from Azure Active Directory Object IDs to User Principal Names. If + "false", the values will be returned as Azure Active Directory Object IDs. The default value is + false. Note that group and application Object IDs are not translated because they do not have + unique friendly names. Default value is None. + :paramtype upn: bool + :keyword begin_from: Optional. A relative path within the specified directory where the listing + will start from. Default value is None. + :paramtype begin_from: str + :keyword timeout: The timeout parameter is expressed in seconds. For more information, see Setting + Timeouts for Blob Service Operations.. Default value is None. + :paramtype timeout: int + :return: PathList. The PathList is compatible with MutableMapping + :rtype: ~azure.storage.filedatalake._generated.models.PathList + :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[_models.PathList] = kwargs.pop("cls", None) + + _request = build_file_system_list_paths_request( + recursive=recursive, + continuation=continuation, + path=path, + max_results=max_results, + upn=upn, + begin_from=begin_from, + timeout=timeout, + version=self._config.version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "url": self._serialize.url("self._config.url", self._config.url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + 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 = _failsafe_deserialize( + _models.StorageError, + 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-continuation"] = self._deserialize("str", response.headers.get("x-ms-continuation")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + 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["Content-Type"] = self._deserialize("str", response.headers.get("Content-Type")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PathList, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_blob_hierarchy_segment( + self, + *, + prefix: Optional[str] = None, + delimiter: Optional[str] = None, + marker: Optional[str] = None, + max_results: Optional[int] = None, + include: Optional[list[Union[str, _models.ListBlobsIncludeItem]]] = None, + showonly: Optional[Union[str, _models.ListBlobsShowOnly]] = None, + timeout: Optional[int] = None, + **kwargs: Any + ) -> _models.ListBlobsHierarchySegmentResponse: + """The List Blobs operation returns a list of the blobs under the specified container. + + :keyword prefix: Filters results to filesystems within the specified prefix. Default value is + None. + :paramtype prefix: str + :keyword delimiter: When the request includes this parameter, the operation returns a + BlobPrefix element in the response body that acts as a placeholder for all blobs whose names + begin with the same substring up to the appearance of the delimiter character. The delimiter + may be a single character or a string. Default value is None. + :paramtype delimiter: str + :keyword marker: A string value that identifies the portion of the list of containers to be + returned with the next listing operation. The operation returns the NextMarker value within the + response body if the listing operation did not return all containers remaining to be listed + with the current page. The NextMarker value can be used as the value for the marker parameter + in a subsequent call to request the next page of list items. The marker value is opaque to the + client. Default value is None. + :paramtype marker: str + :keyword max_results: An optional value that specifies the maximum number of items to return. + If omitted or greater than 5,000, the response will include up to 5,000 items. Default value is + None. + :paramtype max_results: int + :keyword include: Include this parameter to specify one or more datasets to include in the + response. Default value is None. + :paramtype include: list[str or ~azure.storage.filedatalake.models.ListBlobsIncludeItem] + :keyword showonly: Include this parameter to specify one or more datasets to include in the + response. "deleted" Default value is None. + :paramtype showonly: str or ~azure.storage.filedatalake.models.ListBlobsShowOnly + :keyword timeout: The timeout parameter is expressed in seconds. For more information, see Setting + Timeouts for Blob Service Operations.. Default value is None. + :paramtype timeout: int + :return: ListBlobsHierarchySegmentResponse. The ListBlobsHierarchySegmentResponse is compatible + with MutableMapping + :rtype: ~azure.storage.filedatalake._generated.models.ListBlobsHierarchySegmentResponse + :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[_models.ListBlobsHierarchySegmentResponse] = kwargs.pop("cls", None) + + _request = build_file_system_list_blob_hierarchy_segment_request( + prefix=prefix, + delimiter=delimiter, + marker=marker, + max_results=max_results, + include=include, + showonly=showonly, + timeout=timeout, + version=self._config.version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "url": self._serialize.url("self._config.url", self._config.url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + 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 = _failsafe_deserialize( + _models.StorageError, + response, + ) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + 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["Content-Type"] = self._deserialize("str", response.headers.get("Content-Type")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize_xml(_models.ListBlobsHierarchySegmentResponse, response.text()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + +class PathOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.storage.filedatalake.DataLakeClient`'s + :attr:`path` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: DataLakeClientConfiguration = 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 + def create( # pylint: disable=inconsistent-return-statements,too-many-locals + self, + *, + resource: Optional[Union[str, _models.PathResourceType]] = None, + mode: Optional[Union[str, _models.PathRenameMode]] = None, + continuation: Optional[str] = None, + cache_control: Optional[str] = None, + content_encoding: Optional[str] = None, + content_language: Optional[str] = None, + content_disposition: Optional[str] = None, + content_type: Optional[str] = None, + rename_source: Optional[str] = None, + lease_id: Optional[str] = None, + source_lease_id: Optional[str] = None, + properties: Optional[str] = None, + permissions: Optional[str] = None, + umask: Optional[str] = None, + if_modified_since: Optional[datetime.datetime] = None, + if_unmodified_since: Optional[datetime.datetime] = None, + source_if_match: Optional[str] = None, + source_if_none_match: Optional[str] = None, + source_if_modified_since: Optional[datetime.datetime] = None, + source_if_unmodified_since: Optional[datetime.datetime] = None, + encryption_key: Optional[str] = None, + encryption_key_sha256: Optional[str] = None, + encryption_algorithm: Optional[Union[str, _models.EncryptionAlgorithmType]] = None, + owner: Optional[str] = None, + group: Optional[str] = None, + acl: Optional[str] = None, + proposed_lease_id: Optional[str] = None, + lease_duration: Optional[int] = None, + expiry_options: Optional[Union[str, _models.PathExpiryOptions]] = None, + expires_on: Optional[str] = None, + encryption_context: Optional[str] = None, + timeout: Optional[int] = None, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> None: + """Create or rename a file or directory. By default, the destination is overwritten and if the + destination already exists and has a lease the lease is broken. This operation supports + conditional HTTP requests. For more information, see `Specifying Conditional Headers for Blob + Service Operations + `_. + To fail if the destination already exists, use a conditional request with If-None-Match: "*". + + :keyword resource: Required only for Create File and Create Directory. The value must be "file" + or "directory". Known values are: "directory" and "file". Default value is None. + :paramtype resource: str or ~azure.storage.filedatalake.models.PathResourceType + :keyword mode: Optional. Valid only when namespace is enabled. This parameter determines the + behavior of the rename operation. The value must be "legacy" or "posix", and the default value + will be "posix". Known values are: "legacy" and "posix". Default value is None. + :paramtype mode: str or ~azure.storage.filedatalake.models.PathRenameMode + :keyword continuation: Optional. When deleting a directory, the number of paths that are + deleted with each invocation is limited. If the number of paths to be deleted exceeds this + limit, a continuation token is returned in this response header. When a continuation token is + returned in the response, it must be specified in a subsequent invocation of the delete + operation to continue deleting the directory. Default value is None. + :paramtype continuation: str + :keyword cache_control: Optional. Sets the blob's cache control. If specified, this property is + stored with the blob and returned with a read request. Default value is None. + :paramtype cache_control: str + :keyword content_encoding: Optional. Sets the blob's content encoding. If specified, this + property is stored with the blob and returned with a read request. Default value is None. + :paramtype content_encoding: str + :keyword content_language: Optional. Set the blob's content language. If specified, this + property is stored with the blob and returned with a read request. Default value is None. + :paramtype content_language: str + :keyword content_disposition: Optional. Sets the blob's Content-Disposition header. Default + value is None. + :paramtype content_disposition: str + :keyword content_type: Optional. Sets the blob's content type. If specified, this property is + stored with the blob and returned with a read request. Default value is None. + :paramtype content_type: str + :keyword rename_source: An optional file or directory to be renamed. The value must have the + following format: "/{filesystem}/{path}". If "x-ms-properties" is specified, the properties + will overwrite the existing properties; otherwise, the existing properties will be preserved. + This value must be a URL percent-encoded string. Note that the string may only contain ASCII + characters in the ISO-8859-1 character set. Default value is None. + :paramtype rename_source: str + :keyword lease_id: If specified, the operation only succeeds if the resource's lease is active + and matches this ID. Default value is None. + :paramtype lease_id: str + :keyword source_lease_id: A lease ID for the source path. If specified, the source path must + have an active lease and the lease ID must match. Default value is None. + :paramtype source_lease_id: str + :keyword properties: Optional. User-defined properties to be stored with the filesystem, in the + format of a comma-separated list of name and value pairs "n1=v1, n2=v2, ...", where each value + is a base64 encoded string. Note that the string may only contain ASCII characters in the + ISO-8859-1 character set. If the filesystem exists, any properties not included in the list + will be removed. All properties are removed if the header is omitted. To merge new and existing + properties, first get all existing properties and the current E-Tag, then make a conditional + request with the E-Tag and include values for all properties. Default value is None. + :paramtype properties: str + :keyword permissions: Optional and only valid if Hierarchical Namespace is enabled for the + account. Sets POSIX access permissions for the file owner, the file owning group, and others. + Each class may be granted read, write, or execute permission. The sticky bit is also supported. + Both symbolic (rwxrw-rw-) and 4-digit octal notation (e.g. 0766) are supported. Default value + is None. + :paramtype permissions: str + :keyword umask: Optional and only valid if Hierarchical Namespace is enabled for the account. + When creating a file or directory and the parent folder does not have a default ACL, the umask + restricts the permissions of the file or directory to be created. The resulting permission is + given by p bitwise and not u, where p is the permission and u is the umask. For example, if p + is 0777 and u is 0057, then the resulting permission is 0720. The default permission is 0777 + for a directory and 0666 for a file. The default umask is 0027. The umask must be specified in + 4-digit octal notation (e.g. 0766). Default value is None. + :paramtype umask: str + :keyword if_modified_since: Specify this header value to operate only on a blob if it has been + modified since the specified date/time. Default value is None. + :paramtype if_modified_since: ~datetime.datetime + :keyword if_unmodified_since: Specify this header value to operate only on a blob if it has not + been modified since the specified date/time. Default value is None. + :paramtype if_unmodified_since: ~datetime.datetime + :keyword source_if_match: Specify an ETag value to operate only on blobs with a matching value. + Default value is None. + :paramtype source_if_match: str + :keyword source_if_none_match: Specify an ETag value to operate only on blobs without a + matching value. Default value is None. + :paramtype source_if_none_match: str + :keyword source_if_modified_since: Specify this header value to operate only on a blob if it + has been modified since the specified date/time. Default value is None. + :paramtype source_if_modified_since: ~datetime.datetime + :keyword source_if_unmodified_since: Specify this header value to operate only on a blob if it + has not been modified since the specified date/time. Default value is None. + :paramtype source_if_unmodified_since: ~datetime.datetime + :keyword encryption_key: Optional. Specifies the encryption key to use to encrypt the data + provided in the request. If not specified, encryption is performed with the root account + encryption key. Default value is None. + :paramtype encryption_key: str + :keyword encryption_key_sha256: The SHA-256 hash of the provided encryption key. Must be + provided if the x-ms-encryption-key header is provided. Default value is None. + :paramtype encryption_key_sha256: str + :keyword encryption_algorithm: The algorithm used to produce the encryption key hash. + Currently, the only accepted value is "AES256". Must be provided if the x-ms-encryption-key + header is provided. "AES256" Default value is None. + :paramtype encryption_algorithm: str or + ~azure.storage.filedatalake.models.EncryptionAlgorithmType + :keyword owner: Optional. The owner of the blob or directory. Default value is None. + :paramtype owner: str + :keyword group: Optional. The owning group of the blob or directory. Default value is None. + :paramtype group: str + :keyword acl: Sets POSIX access control rights on files and directories. The value is a + comma-separated list of access control entries. Each access control entry (ACE) consists of a + scope, a type, a user or group identifier, and permissions in the format + "[scope:][type]:[id]:[permissions]". Default value is None. + :paramtype acl: str + :keyword proposed_lease_id: Proposed lease ID, in a GUID string format. Default value is None. + :paramtype proposed_lease_id: str + :keyword lease_duration: The lease duration is required to acquire a lease, and specifies the + duration of the lease in seconds. The lease duration must be between 15 and 60 seconds or -1 + for infinite lease. Default value is None. + :paramtype lease_duration: int + :keyword expiry_options: Required. Indicates mode of the expiry time. Known values are: + "NeverExpire", "RelativeToCreation", "RelativeToNow", and "Absolute". Default value is None. + :paramtype expiry_options: str or ~azure.storage.filedatalake.models.PathExpiryOptions + :keyword expires_on: The time to set the blob to expiry. Default value is None. + :paramtype expires_on: str + :keyword encryption_context: Specifies the encryption context to set on the file. Default value + is None. + :paramtype encryption_context: str + :keyword timeout: The timeout parameter is expressed in seconds. For more information, see Setting + Timeouts for Blob Service Operations.. Default value is None. + :paramtype timeout: int + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + 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) + + _request = build_path_create_request( + resource=resource, + mode=mode, + continuation=continuation, + cache_control=cache_control, + content_encoding=content_encoding, + content_language=content_language, + content_disposition=content_disposition, + content_type=content_type, + rename_source=rename_source, + lease_id=lease_id, + source_lease_id=source_lease_id, + properties=properties, + permissions=permissions, + umask=umask, + if_modified_since=if_modified_since, + if_unmodified_since=if_unmodified_since, + source_if_match=source_if_match, + source_if_none_match=source_if_none_match, + source_if_modified_since=source_if_modified_since, + source_if_unmodified_since=source_if_unmodified_since, + encryption_key=encryption_key, + encryption_key_sha256=encryption_key_sha256, + encryption_algorithm=encryption_algorithm, + owner=owner, + group=group, + acl=acl, + proposed_lease_id=proposed_lease_id, + lease_duration=lease_duration, + expiry_options=expiry_options, + expires_on=expires_on, + encryption_context=encryption_context, + timeout=timeout, + etag=etag, + match_condition=match_condition, + version=self._config.version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "url": self._serialize.url("self._config.url", self._config.url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = 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 = _failsafe_deserialize( + _models.StorageError, + 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-continuation"] = self._deserialize("str", response.headers.get("x-ms-continuation")) + response_headers["Content-Length"] = self._deserialize("int", response.headers.get("Content-Length")) + response_headers["x-ms-request-server-encrypted"] = self._deserialize( + "bool", response.headers.get("x-ms-request-server-encrypted") + ) + response_headers["x-ms-encryption-key-sha256"] = self._deserialize( + "str", response.headers.get("x-ms-encryption-key-sha256") + ) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + 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") + ) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace + def update( # pylint: disable=too-many-locals + self, + body: bytes, + *, + action: Union[str, _models.PathUpdateAction], + max_records: Optional[int] = None, + continuation: Optional[str] = None, + mode: Optional[Union[str, _models.PathSetAccessControlRecursiveMode]] = None, + force_flag: Optional[bool] = None, + position: Optional[int] = None, + retain_uncommitted_data: Optional[bool] = None, + close: Optional[bool] = None, + content_length: Optional[int] = None, + content_md5: Optional[bytes] = None, + lease_id: Optional[str] = None, + cache_control: Optional[str] = None, + content_disposition: Optional[str] = None, + content_encoding: Optional[str] = None, + content_language: Optional[str] = None, + properties: Optional[str] = None, + owner: Optional[str] = None, + group: Optional[str] = None, + permissions: Optional[str] = None, + acl: Optional[str] = None, + if_modified_since: Optional[datetime.datetime] = None, + if_unmodified_since: Optional[datetime.datetime] = None, + structured_body_type: Optional[str] = None, + structured_content_length: Optional[int] = None, + timeout: Optional[int] = None, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.SetAccessControlRecursiveResponse: + """Uploads data to be appended to a file, flushes (writes) previously uploaded data to a file, + sets properties for a file or directory, or sets access control for a file or directory. Data + can only be appended to a file. Concurrent writes to the same file using multiple clients are + not supported. This operation supports conditional HTTP requests. For more information, see + `Specifying Conditional Headers for Blob Service Operations + `_. + + :param body: Initial data. Required. + :type body: bytes + :keyword action: The action must be "append" to upload data to be appended to a file, "flush" + to flush previously uploaded data to a file, "setProperties" to set the properties of a file or + directory, "setAccessControl" to set the owner, group, permissions, or access control list for + a file or directory, or "setAccessControlRecursive" to set the access control list for a + directory recursively. Note that Hierarchical Namespace must be enabled for the account in + order to use access control. Also note that the Access Control List (ACL) includes permissions + for the owner, owning group, and others, so the x-ms-permissions and x-ms-acl request headers + are mutually exclusive. Known values are: "append", "flush", "setProperties", + "setAccessControl", and "setAccessControlRecursive". Required. + :paramtype action: str or ~azure.storage.filedatalake.models.PathUpdateAction + :keyword max_records: Optional. Valid for "SetAccessControlRecursive" operation. It specifies + the maximum number of files or directories on which the acl change will be applied. If omitted + or greater than 2,000, the request will process up to 2,000 items. Default value is None. + :paramtype max_records: int + :keyword continuation: Optional. The number of paths processed with each invocation is limited. + If the number of paths to be processed exceeds this limit, a continuation token is returned in + the response header x-ms-continuation. When a continuation token is returned in the response, + it must be percent-encoded and specified in a subsequent invocation of + setAccessControlRecursive operation. Default value is None. + :paramtype continuation: str + :keyword mode: Mode for set access control recursive. Known values are: "set", "modify", and + "remove". Default value is None. + :paramtype mode: str or ~azure.storage.filedatalake.models.PathSetAccessControlRecursiveMode + :keyword force_flag: Optional. Valid for "SetAccessControlRecursive" operation. If set to + false, the operation will terminate quickly on encountering user errors (4XX). If true, the + operation will ignore user errors and proceed with the operation on other sub-entities of the + directory. Continuation token will only be returned when forceFlag is true in case of user + errors. If not set the default value is false for this. Default value is None. + :paramtype force_flag: bool + :keyword position: This parameter allows the caller to upload data in parallel and control the + order in which it is appended to the file. It is required when uploading data to be appended to + the file and when flushing previously uploaded data to the file. The value must be the position + where the data is to be appended. Uploaded data is not immediately flushed, or written, to the + file. To flush, the previously uploaded data must be contiguous, the position parameter must be + specified and equal to the length of the file after all data has been written, and there must + not be a request entity body included with the request. Default value is None. + :paramtype position: int + :keyword retain_uncommitted_data: Valid only for flush operations. If "true", uncommitted data + is retained after the flush operation completes; otherwise, the uncommitted data is deleted + after the flush operation. The default is false. Data at offsets less than the specified + position are written to the file when flush succeeds, but this optional parameter allows data + after the flush position to be retained for a future flush operation. Default value is None. + :paramtype retain_uncommitted_data: bool + :keyword close: Azure Storage Events allow applications to receive notifications when files + change. When Azure Storage Events are enabled, a file changed event is raised. This event has a + property indicating whether this is the final change to distinguish the difference between an + intermediate flush to a file stream and the final close of a file stream. The close query + parameter is valid only when the action is "flush" and change notifications are enabled. If the + value of close is "true" and the flush operation completes successfully, the service raises a + file change notification with a property indicating that this is the final update (the file + stream has been closed). If "false" a change notification is raised indicating the file has + changed. The default is false. This query parameter is set to true by the Hadoop ABFS driver to + indicate that the file stream has been closed. Default value is None. + :paramtype close: bool + :keyword content_length: Required for "Append Data" and "Flush Data". Must be 0 for "Flush + Data". Must be the length of the request content in bytes for "Append Data". Default value is + None. + :paramtype content_length: int + :keyword content_md5: Specify the transactional md5 for the body, to be validated by the + service. Default value is None. + :paramtype content_md5: bytes + :keyword lease_id: If specified, the operation only succeeds if the resource's lease is active + and matches this ID. Default value is None. + :paramtype lease_id: str + :keyword cache_control: Optional. Sets the blob's cache control. If specified, this property is + stored with the blob and returned with a read request. Default value is None. + :paramtype cache_control: str + :keyword content_disposition: Optional. Sets the blob's Content-Disposition header. Default + value is None. + :paramtype content_disposition: str + :keyword content_encoding: Optional. Sets the blob's content encoding. If specified, this + property is stored with the blob and returned with a read request. Default value is None. + :paramtype content_encoding: str + :keyword content_language: Optional. Set the blob's content language. If specified, this + property is stored with the blob and returned with a read request. Default value is None. + :paramtype content_language: str + :keyword properties: Optional. User-defined properties to be stored with the filesystem, in the + format of a comma-separated list of name and value pairs "n1=v1, n2=v2, ...", where each value + is a base64 encoded string. Note that the string may only contain ASCII characters in the + ISO-8859-1 character set. If the filesystem exists, any properties not included in the list + will be removed. All properties are removed if the header is omitted. To merge new and existing + properties, first get all existing properties and the current E-Tag, then make a conditional + request with the E-Tag and include values for all properties. Default value is None. + :paramtype properties: str + :keyword owner: Optional. The owner of the blob or directory. Default value is None. + :paramtype owner: str + :keyword group: Optional. The owning group of the blob or directory. Default value is None. + :paramtype group: str + :keyword permissions: Optional and only valid if Hierarchical Namespace is enabled for the + account. Sets POSIX access permissions for the file owner, the file owning group, and others. + Each class may be granted read, write, or execute permission. The sticky bit is also supported. + Both symbolic (rwxrw-rw-) and 4-digit octal notation (e.g. 0766) are supported. Default value + is None. + :paramtype permissions: str + :keyword acl: Sets POSIX access control rights on files and directories. The value is a + comma-separated list of access control entries. Each access control entry (ACE) consists of a + scope, a type, a user or group identifier, and permissions in the format + "[scope:][type]:[id]:[permissions]". Default value is None. + :paramtype acl: str + :keyword if_modified_since: Specify this header value to operate only on a blob if it has been + modified since the specified date/time. Default value is None. + :paramtype if_modified_since: ~datetime.datetime + :keyword if_unmodified_since: Specify this header value to operate only on a blob if it has not + been modified since the specified date/time. Default value is None. + :paramtype if_unmodified_since: ~datetime.datetime + :keyword structured_body_type: Required if the request body is a structured message. Specifies + the message schema version and properties. Default value is None. + :paramtype structured_body_type: str + :keyword 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. + :paramtype structured_content_length: int + :keyword timeout: The timeout parameter is expressed in seconds. For more information, see Setting + Timeouts for Blob Service Operations.. Default value is None. + :paramtype timeout: int + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: SetAccessControlRecursiveResponse. The SetAccessControlRecursiveResponse is compatible + with MutableMapping + :rtype: ~azure.storage.filedatalake._generated.models.SetAccessControlRecursiveResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/octet-stream")) + cls: ClsType[_models.SetAccessControlRecursiveResponse] = kwargs.pop("cls", None) + + _content = body + + _request = build_path_update_request( + action=action, + max_records=max_records, + continuation=continuation, + mode=mode, + force_flag=force_flag, + position=position, + retain_uncommitted_data=retain_uncommitted_data, + close=close, + content_length=content_length, + content_md5=content_md5, + lease_id=lease_id, + cache_control=cache_control, + content_disposition=content_disposition, + content_encoding=content_encoding, + content_language=content_language, + properties=properties, + owner=owner, + group=group, + permissions=permissions, + acl=acl, + if_modified_since=if_modified_since, + if_unmodified_since=if_unmodified_since, + structured_body_type=structured_body_type, + structured_content_length=structured_content_length, + timeout=timeout, + etag=etag, + match_condition=match_condition, + content_type=content_type, + version=self._config.version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "url": self._serialize.url("self._config.url", self._config.url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + 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 = _failsafe_deserialize( + _models.StorageError, + 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["Accept-Ranges"] = self._deserialize("str", response.headers.get("Accept-Ranges")) + 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-Encoding"] = self._deserialize("str", response.headers.get("Content-Encoding")) + response_headers["Content-Language"] = self._deserialize("str", response.headers.get("Content-Language")) + response_headers["Content-Length"] = self._deserialize("int", response.headers.get("Content-Length")) + response_headers["Content-Range"] = self._deserialize("str", response.headers.get("Content-Range")) + response_headers["Content-MD5"] = self._deserialize("bytearray", response.headers.get("Content-MD5")) + response_headers["x-ms-properties"] = self._deserialize("str", response.headers.get("x-ms-properties")) + response_headers["x-ms-continuation"] = self._deserialize("str", response.headers.get("x-ms-continuation")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + 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["Content-Type"] = self._deserialize("str", response.headers.get("Content-Type")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SetAccessControlRecursiveResponse, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def lease( # pylint: disable=inconsistent-return-statements + self, + *, + lease_action: Union[str, _models.PathLeaseAction], + lease_duration: Optional[int] = None, + lease_break_period: Optional[int] = None, + lease_id: Optional[str] = None, + proposed_lease_id: Optional[str] = None, + if_modified_since: Optional[datetime.datetime] = None, + if_unmodified_since: Optional[datetime.datetime] = None, + timeout: Optional[int] = None, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> None: + """Create and manage a lease to restrict write and delete access to the path. This operation + supports conditional HTTP requests. For more information, see `Specifying Conditional Headers + for Blob Service Operations + `_. + + :keyword lease_action: There are five lease actions: "acquire", "break", "change", "renew", and + "release". Use "acquire" and specify the "x-ms-proposed-lease-id" and "x-ms-lease-duration" to + acquire a new lease. Use "break" to break an existing lease. When a lease is broken, the lease + break period is allowed to elapse, during which time no lease operation except break and + release can be performed on the file. When a lease is successfully broken, the response + indicates the interval in seconds until a new lease can be acquired. Use "change" and specify + the current lease ID in "x-ms-lease-id" and the new lease ID in "x-ms-proposed-lease-id" to + change the lease ID of an active lease. Use "renew" and specify the "x-ms-lease-id" to renew an + existing lease. Use "release" and specify the "x-ms-lease-id" to release a lease. Known values + are: "acquire", "break", "change", "renew", and "release". Required. + :paramtype lease_action: str or ~azure.storage.filedatalake.models.PathLeaseAction + :keyword lease_duration: The lease duration is required to acquire a lease, and specifies the + duration of the lease in seconds. The lease duration must be between 15 and 60 seconds or -1 + for infinite lease. Default value is None. + :paramtype lease_duration: int + :keyword lease_break_period: The lease break period duration is optional to break a lease, and + specifies the break period of the lease in seconds. The lease break duration must be between 0 + and 60 seconds. Default value is None. + :paramtype lease_break_period: int + :keyword lease_id: If specified, the operation only succeeds if the resource's lease is active + and matches this ID. Default value is None. + :paramtype lease_id: str + :keyword proposed_lease_id: Proposed lease ID, in a GUID string format. Default value is None. + :paramtype proposed_lease_id: str + :keyword if_modified_since: Specify this header value to operate only on a blob if it has been + modified since the specified date/time. Default value is None. + :paramtype if_modified_since: ~datetime.datetime + :keyword if_unmodified_since: Specify this header value to operate only on a blob if it has not + been modified since the specified date/time. Default value is None. + :paramtype if_unmodified_since: ~datetime.datetime + :keyword timeout: The timeout parameter is expressed in seconds. For more information, see Setting + Timeouts for Blob Service Operations.. Default value is None. + :paramtype timeout: int + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + 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) + + _request = build_path_lease_request( + lease_action=lease_action, + lease_duration=lease_duration, + lease_break_period=lease_break_period, + lease_id=lease_id, + proposed_lease_id=proposed_lease_id, + if_modified_since=if_modified_since, + if_unmodified_since=if_unmodified_since, + timeout=timeout, + etag=etag, + match_condition=match_condition, + version=self._config.version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "url": self._serialize.url("self._config.url", self._config.url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = 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 = _failsafe_deserialize( + _models.StorageError, + 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-lease-time"] = self._deserialize("str", response.headers.get("x-ms-lease-time")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + 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") + ) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace + def read( + self, + *, + range: Optional[str] = None, + lease_id: Optional[str] = None, + range_get_content_md5: Optional[bool] = None, + if_modified_since: Optional[datetime.datetime] = None, + if_unmodified_since: Optional[datetime.datetime] = None, + encryption_key: Optional[str] = None, + encryption_key_sha256: Optional[str] = None, + encryption_algorithm: Optional[Union[str, _models.EncryptionAlgorithmType]] = None, + timeout: Optional[int] = None, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> Iterator[bytes]: + """Read the contents of a file. For read operations, range requests are supported. This operation + supports conditional HTTP requests. For more information, see `Specifying Conditional Headers + for Blob Service Operations + `_. + + :keyword range: The HTTP Range request header specifies one or more byte ranges of the resource + to be retrieved. Default value is None. + :paramtype range: str + :keyword lease_id: If specified, the operation only succeeds if the resource's lease is active + and matches this ID. Default value is None. + :paramtype lease_id: str + :keyword range_get_content_md5: Optional. 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 4MB in size. Default value is None. + :paramtype range_get_content_md5: bool + :keyword if_modified_since: Specify this header value to operate only on a blob if it has been + modified since the specified date/time. Default value is None. + :paramtype if_modified_since: ~datetime.datetime + :keyword if_unmodified_since: Specify this header value to operate only on a blob if it has not + been modified since the specified date/time. Default value is None. + :paramtype if_unmodified_since: ~datetime.datetime + :keyword encryption_key: Optional. Specifies the encryption key to use to encrypt the data + provided in the request. If not specified, encryption is performed with the root account + encryption key. Default value is None. + :paramtype encryption_key: str + :keyword encryption_key_sha256: The SHA-256 hash of the provided encryption key. Must be + provided if the x-ms-encryption-key header is provided. Default value is None. + :paramtype encryption_key_sha256: str + :keyword encryption_algorithm: The algorithm used to produce the encryption key hash. + Currently, the only accepted value is "AES256". Must be provided if the x-ms-encryption-key + header is provided. "AES256" Default value is None. + :paramtype encryption_algorithm: str or + ~azure.storage.filedatalake.models.EncryptionAlgorithmType + :keyword timeout: The timeout parameter is expressed in seconds. For more information, see Setting + Timeouts for Blob Service Operations.. Default value is None. + :paramtype timeout: int + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: Iterator[bytes] + :rtype: Iterator[bytes] + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_path_read_request( + range=range, + lease_id=lease_id, + range_get_content_md5=range_get_content_md5, + if_modified_since=if_modified_since, + if_unmodified_since=if_unmodified_since, + encryption_key=encryption_key, + encryption_key_sha256=encryption_key_sha256, + encryption_algorithm=encryption_algorithm, + timeout=timeout, + etag=etag, + match_condition=match_condition, + version=self._config.version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "url": self._serialize.url("self._config.url", self._config.url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", True) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + 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 = _failsafe_deserialize( + _models.StorageError, + response, + ) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["Accept-Ranges"] = self._deserialize("str", response.headers.get("Accept-Ranges")) + 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-Encoding"] = self._deserialize("str", response.headers.get("Content-Encoding")) + response_headers["Content-Language"] = self._deserialize("str", response.headers.get("Content-Language")) + response_headers["Content-Length"] = self._deserialize("int", response.headers.get("Content-Length")) + response_headers["Content-Range"] = self._deserialize("str", response.headers.get("Content-Range")) + response_headers["Content-MD5"] = self._deserialize("bytearray", response.headers.get("Content-MD5")) + 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-resource-type"] = self._deserialize("str", response.headers.get("x-ms-resource-type")) + response_headers["x-ms-properties"] = self._deserialize("str", response.headers.get("x-ms-properties")) + 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-request-server-encrypted"] = self._deserialize( + "bool", response.headers.get("x-ms-request-server-encrypted") + ) + response_headers["x-ms-encryption-key-sha256"] = self._deserialize( + "str", response.headers.get("x-ms-encryption-key-sha256") + ) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + 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["Content-Type"] = self._deserialize("str", response.headers.get("Content-Type")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_properties( + self, + *, + action: Optional[Union[str, _models.PathGetPropertiesAction]] = None, + upn: Optional[bool] = None, + lease_id: Optional[str] = None, + if_modified_since: Optional[datetime.datetime] = None, + if_unmodified_since: Optional[datetime.datetime] = None, + timeout: Optional[int] = None, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> bool: + """Get Properties returns all system and user defined properties for a path. Get Status returns + all system defined properties for a path. Get Access Control List returns the access control + list for a path. This operation supports conditional HTTP requests. For more information, see + `Specifying Conditional Headers for Blob Service Operations + `_. + + :keyword action: Optional. If the value is "getStatus" only the system defined properties for + the path are returned. If the value is "getAccessControl" the access control list is returned + in the response headers (Hierarchical Namespace must be enabled for the account), otherwise the + properties are returned. Known values are: "getAccessControl" and "getStatus". Default value is + None. + :paramtype action: str or ~azure.storage.filedatalake.models.PathGetPropertiesAction + :keyword upn: Optional. Valid only when Hierarchical Namespace is enabled for the account. If + "true", the user identity values returned in the x-ms-owner, x-ms-group, and x-ms-acl response + headers will be transformed from Azure Active Directory Object IDs to User Principal Names. If + "false", the values will be returned as Azure Active Directory Object IDs. The default value is + false. Note that group and application Object IDs are not translated because they do not have + unique friendly names. Default value is None. + :paramtype upn: bool + :keyword lease_id: If specified, the operation only succeeds if the resource's lease is active + and matches this ID. Default value is None. + :paramtype lease_id: str + :keyword if_modified_since: Specify this header value to operate only on a blob if it has been + modified since the specified date/time. Default value is None. + :paramtype if_modified_since: ~datetime.datetime + :keyword if_unmodified_since: Specify this header value to operate only on a blob if it has not + been modified since the specified date/time. Default value is None. + :paramtype if_unmodified_since: ~datetime.datetime + :keyword timeout: The timeout parameter is expressed in seconds. For more information, see Setting + Timeouts for Blob Service Operations.. Default value is None. + :paramtype timeout: int + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + 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) + + _request = build_path_get_properties_request( + action=action, + upn=upn, + lease_id=lease_id, + if_modified_since=if_modified_since, + if_unmodified_since=if_unmodified_since, + timeout=timeout, + etag=etag, + match_condition=match_condition, + version=self._config.version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "url": self._serialize.url("self._config.url", self._config.url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = 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 = _failsafe_deserialize( + _models.StorageError, + response, + ) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["Accept-Ranges"] = self._deserialize("str", response.headers.get("Accept-Ranges")) + 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-Encoding"] = self._deserialize("str", response.headers.get("Content-Encoding")) + response_headers["Content-Language"] = self._deserialize("str", response.headers.get("Content-Language")) + response_headers["Content-Length"] = self._deserialize("int", response.headers.get("Content-Length")) + response_headers["Content-Range"] = self._deserialize("str", response.headers.get("Content-Range")) + response_headers["Content-Type"] = self._deserialize("str", response.headers.get("Content-Type")) + response_headers["Content-MD5"] = self._deserialize("bytearray", response.headers.get("Content-MD5")) + 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-resource-type"] = self._deserialize("str", response.headers.get("x-ms-resource-type")) + response_headers["x-ms-properties"] = self._deserialize("str", response.headers.get("x-ms-properties")) + 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-permissions"] = self._deserialize("str", response.headers.get("x-ms-permissions")) + response_headers["x-ms-acl"] = self._deserialize("str", response.headers.get("x-ms-acl")) + 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-server-encrypted"] = self._deserialize( + "bool", response.headers.get("x-ms-server-encrypted") + ) + response_headers["x-ms-encryption-key-sha256"] = self._deserialize( + "str", response.headers.get("x-ms-encryption-key-sha256") + ) + response_headers["x-ms-encryption-context"] = self._deserialize( + "str", response.headers.get("x-ms-encryption-context") + ) + response_headers["x-ms-encryption-scope"] = self._deserialize( + "str", response.headers.get("x-ms-encryption-scope") + ) + response_headers["x-ms-creation-time"] = self._deserialize( + "rfc-1123", response.headers.get("x-ms-creation-time") + ) + response_headers["x-ms-expiry-time"] = self._deserialize("rfc-1123", response.headers.get("x-ms-expiry-time")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + 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") + ) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + return 200 <= response.status_code <= 299 + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + *, + recursive: Optional[bool] = None, + continuation: Optional[str] = None, + lease_id: Optional[str] = None, + if_modified_since: Optional[datetime.datetime] = None, + if_unmodified_since: Optional[datetime.datetime] = None, + paginated: Optional[bool] = None, + timeout: Optional[int] = None, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> None: + """Delete the file or directory. This operation supports conditional HTTP requests. For more + information, see `Specifying Conditional Headers for Blob Service Operations + `_. + + :keyword recursive: Required. Default value is None. + :paramtype recursive: bool + :keyword continuation: Optional. When deleting a directory, the number of paths that are + deleted with each invocation is limited. If the number of paths to be deleted exceeds this + limit, a continuation token is returned in this response header. When a continuation token is + returned in the response, it must be specified in a subsequent invocation of the delete + operation to continue deleting the directory. Default value is None. + :paramtype continuation: str + :keyword lease_id: If specified, the operation only succeeds if the resource's lease is active + and matches this ID. Default value is None. + :paramtype lease_id: str + :keyword if_modified_since: Specify this header value to operate only on a blob if it has been + modified since the specified date/time. Default value is None. + :paramtype if_modified_since: ~datetime.datetime + :keyword if_unmodified_since: Specify this header value to operate only on a blob if it has not + been modified since the specified date/time. Default value is None. + :paramtype if_unmodified_since: ~datetime.datetime + :keyword paginated: If true, paginated behavior will be seen. Pagination is for the recursive + ACL checks as a POSIX requirement in the server and Delete in an atomic operation once the ACL + checks are completed. If false or missing, normal default behavior will kick in, which may + timeout in case of very large directories due to recursive ACL checks. This new parameter is + introduced for backward compatibility. Default value is None. + :paramtype paginated: bool + :keyword timeout: The timeout parameter is expressed in seconds. For more information, see Setting + Timeouts for Blob Service Operations.. Default value is None. + :paramtype timeout: int + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + 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) + + _request = build_path_delete_request( + recursive=recursive, + continuation=continuation, + lease_id=lease_id, + if_modified_since=if_modified_since, + if_unmodified_since=if_unmodified_since, + paginated=paginated, + timeout=timeout, + etag=etag, + match_condition=match_condition, + version=self._config.version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "url": self._serialize.url("self._config.url", self._config.url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = 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 = _failsafe_deserialize( + _models.StorageError, + response, + ) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["x-ms-continuation"] = self._deserialize("str", response.headers.get("x-ms-continuation")) + response_headers["x-ms-deletion-id"] = self._deserialize("str", response.headers.get("x-ms-deletion-id")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + 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") + ) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace + def set_access_control( # pylint: disable=inconsistent-return-statements + self, + *, + lease_id: Optional[str] = None, + owner: Optional[str] = None, + group: Optional[str] = None, + permissions: Optional[str] = None, + acl: Optional[str] = None, + if_modified_since: Optional[datetime.datetime] = None, + if_unmodified_since: Optional[datetime.datetime] = None, + timeout: Optional[int] = None, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> None: + """Set the owner, group, permissions, or access control list for a path. + + :keyword lease_id: If specified, the operation only succeeds if the resource's lease is active + and matches this ID. Default value is None. + :paramtype lease_id: str + :keyword owner: Optional. The owner of the blob or directory. Default value is None. + :paramtype owner: str + :keyword group: Optional. The owning group of the blob or directory. Default value is None. + :paramtype group: str + :keyword permissions: Optional and only valid if Hierarchical Namespace is enabled for the + account. Sets POSIX access permissions for the file owner, the file owning group, and others. + Each class may be granted read, write, or execute permission. The sticky bit is also supported. + Both symbolic (rwxrw-rw-) and 4-digit octal notation (e.g. 0766) are supported. Default value + is None. + :paramtype permissions: str + :keyword acl: Sets POSIX access control rights on files and directories. The value is a + comma-separated list of access control entries. Each access control entry (ACE) consists of a + scope, a type, a user or group identifier, and permissions in the format + "[scope:][type]:[id]:[permissions]". Default value is None. + :paramtype acl: str + :keyword if_modified_since: Specify this header value to operate only on a blob if it has been + modified since the specified date/time. Default value is None. + :paramtype if_modified_since: ~datetime.datetime + :keyword if_unmodified_since: Specify this header value to operate only on a blob if it has not + been modified since the specified date/time. Default value is None. + :paramtype if_unmodified_since: ~datetime.datetime + :keyword timeout: The timeout parameter is expressed in seconds. For more information, see Setting + Timeouts for Blob Service Operations.. Default value is None. + :paramtype timeout: int + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + 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) + + _request = build_path_set_access_control_request( + lease_id=lease_id, + owner=owner, + group=group, + permissions=permissions, + acl=acl, + if_modified_since=if_modified_since, + if_unmodified_since=if_unmodified_since, + timeout=timeout, + etag=etag, + match_condition=match_condition, + version=self._config.version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "url": self._serialize.url("self._config.url", self._config.url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = 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 = _failsafe_deserialize( + _models.StorageError, + 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["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + 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") + ) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace + def set_access_control_recursive( + self, + *, + mode: Union[str, _models.PathSetAccessControlRecursiveMode], + continuation: Optional[str] = None, + force_flag: Optional[bool] = None, + max_records: Optional[int] = None, + acl: Optional[str] = None, + timeout: Optional[int] = None, + **kwargs: Any + ) -> _models.SetAccessControlRecursiveResponse: + """Set the access control list for a path and sub-paths. + + :keyword mode: Mode "set" sets POSIX access control rights on files and directories, "modify" + modifies one or more POSIX access control rights that pre-exist on files and directories, + "remove" removes one or more POSIX access control rights that were present earlier on files and + directories. Known values are: "set", "modify", and "remove". Required. + :paramtype mode: str or ~azure.storage.filedatalake.models.PathSetAccessControlRecursiveMode + :keyword continuation: Optional. When deleting a directory, the number of paths that are + deleted with each invocation is limited. If the number of paths to be deleted exceeds this + limit, a continuation token is returned in this response header. When a continuation token is + returned in the response, it must be specified in a subsequent invocation of the delete + operation to continue deleting the directory. Default value is None. + :paramtype continuation: str + :keyword force_flag: Optional. Valid for "SetAccessControlRecursive" operation. If set to + false, the operation will terminate quickly on encountering user errors (4XX). If true, the + operation will ignore user errors and proceed with the operation on other sub-entities of the + directory. Continuation token will only be returned when forceFlag is true in case of user + errors. If not set the default value is false for this. Default value is None. + :paramtype force_flag: bool + :keyword max_records: Optional. It specifies the maximum number of files or directories on + which the acl change will be applied. If omitted or greater than 2,000, the request will + process up to 2,000 items. Default value is None. + :paramtype max_records: int + :keyword acl: Sets POSIX access control rights on files and directories. The value is a + comma-separated list of access control entries. Each access control entry (ACE) consists of a + scope, a type, a user or group identifier, and permissions in the format + "[scope:][type]:[id]:[permissions]". Default value is None. + :paramtype acl: str + :keyword timeout: The timeout parameter is expressed in seconds. For more information, see Setting + Timeouts for Blob Service Operations.. Default value is None. + :paramtype timeout: int + :return: SetAccessControlRecursiveResponse. The SetAccessControlRecursiveResponse is compatible + with MutableMapping + :rtype: ~azure.storage.filedatalake._generated.models.SetAccessControlRecursiveResponse + :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[_models.SetAccessControlRecursiveResponse] = kwargs.pop("cls", None) + + _request = build_path_set_access_control_recursive_request( + mode=mode, + continuation=continuation, + force_flag=force_flag, + max_records=max_records, + acl=acl, + timeout=timeout, + version=self._config.version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "url": self._serialize.url("self._config.url", self._config.url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + 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 = _failsafe_deserialize( + _models.StorageError, + response, + ) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["x-ms-continuation"] = self._deserialize("str", response.headers.get("x-ms-continuation")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + 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["Content-Type"] = self._deserialize("str", response.headers.get("Content-Type")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SetAccessControlRecursiveResponse, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def flush_data( # pylint: disable=inconsistent-return-statements,too-many-locals + self, + *, + position: Optional[int] = None, + retain_uncommitted_data: Optional[bool] = None, + close: Optional[bool] = None, + content_length: Optional[int] = None, + content_md5: Optional[bytes] = None, + lease_id: Optional[str] = None, + lease_action: Optional[Union[str, _models.LeaseAction]] = None, + lease_duration: Optional[int] = None, + proposed_lease_id: Optional[str] = None, + cache_control: Optional[str] = None, + content_type: Optional[str] = None, + content_disposition: Optional[str] = None, + content_encoding: Optional[str] = None, + content_language: Optional[str] = None, + if_modified_since: Optional[datetime.datetime] = None, + if_unmodified_since: Optional[datetime.datetime] = None, + encryption_key: Optional[str] = None, + encryption_key_sha256: Optional[str] = None, + encryption_algorithm: Optional[Union[str, _models.EncryptionAlgorithmType]] = None, + timeout: Optional[int] = None, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> None: + """Set the owner, group, permissions, or access control list for a path. + + :keyword position: This parameter allows the caller to upload data in parallel and control the + order in which it is appended to the file. It is required when uploading data to be appended to + the file and when flushing previously uploaded data to the file. The value must be the position + where the data is to be appended. Uploaded data is not immediately flushed, or written, to the + file. To flush, the previously uploaded data must be contiguous, the position parameter must be + specified and equal to the length of the file after all data has been written, and there must + not be a request entity body included with the request. Default value is None. + :paramtype position: int + :keyword retain_uncommitted_data: Valid only for flush operations. If "true", uncommitted data + is retained after the flush operation completes; otherwise, the uncommitted data is deleted + after the flush operation. The default is false. Data at offsets less than the specified + position are written to the file when flush succeeds, but this optional parameter allows data + after the flush position to be retained for a future flush operation. Default value is None. + :paramtype retain_uncommitted_data: bool + :keyword close: Azure Storage Events allow applications to receive notifications when files + change. When Azure Storage Events are enabled, a file changed event is raised. This event has a + property indicating whether this is the final change to distinguish the difference between an + intermediate flush to a file stream and the final close of a file stream. The close query + parameter is valid only when the action is "flush" and change notifications are enabled. If the + value of close is "true" and the flush operation completes successfully, the service raises a + file change notification with a property indicating that this is the final update (the file + stream has been closed). If "false" a change notification is raised indicating the file has + changed. The default is false. This query parameter is set to true by the Hadoop ABFS driver to + indicate that the file stream has been closed. Default value is None. + :paramtype close: bool + :keyword content_length: Required for "Append Data" and "Flush Data". Must be 0 for "Flush + Data". Must be the length of the request content in bytes for "Append Data". Default value is + None. + :paramtype content_length: int + :keyword content_md5: Specify the transactional md5 for the body, to be validated by the + service. Default value is None. + :paramtype content_md5: bytes + :keyword lease_id: If specified, the operation only succeeds if the resource's lease is active + and matches this ID. Default value is None. + :paramtype lease_id: str + :keyword lease_action: Optional. If "acquire" it will acquire the lease. If "auto-renew" it + will renew the lease. If "release" it will release the lease only on flush. If + "acquire-release" it will acquire & complete the operation & release the lease once operation + is done. Known values are: "acquire", "auto-renew", "release", and "acquire-release". Default + value is None. + :paramtype lease_action: str or ~azure.storage.filedatalake.models.LeaseAction + :keyword lease_duration: The lease duration is required to acquire a lease, and specifies the + duration of the lease in seconds. The lease duration must be between 15 and 60 seconds or -1 + for infinite lease. Default value is None. + :paramtype lease_duration: int + :keyword proposed_lease_id: Proposed lease ID, in a GUID string format. Default value is None. + :paramtype proposed_lease_id: str + :keyword cache_control: Optional. Sets the blob's cache control. If specified, this property is + stored with the blob and returned with a read request. Default value is None. + :paramtype cache_control: str + :keyword content_type: Optional. Sets the blob's content type. If specified, this property is + stored with the blob and returned with a read request. Default value is None. + :paramtype content_type: str + :keyword content_disposition: Optional. Sets the blob's Content-Disposition header. Default + value is None. + :paramtype content_disposition: str + :keyword content_encoding: Optional. Sets the blob's content encoding. If specified, this + property is stored with the blob and returned with a read request. Default value is None. + :paramtype content_encoding: str + :keyword content_language: Optional. Set the blob's content language. If specified, this + property is stored with the blob and returned with a read request. Default value is None. + :paramtype content_language: str + :keyword if_modified_since: Specify this header value to operate only on a blob if it has been + modified since the specified date/time. Default value is None. + :paramtype if_modified_since: ~datetime.datetime + :keyword if_unmodified_since: Specify this header value to operate only on a blob if it has not + been modified since the specified date/time. Default value is None. + :paramtype if_unmodified_since: ~datetime.datetime + :keyword encryption_key: Optional. Specifies the encryption key to use to encrypt the data + provided in the request. If not specified, encryption is performed with the root account + encryption key. Default value is None. + :paramtype encryption_key: str + :keyword encryption_key_sha256: The SHA-256 hash of the provided encryption key. Must be + provided if the x-ms-encryption-key header is provided. Default value is None. + :paramtype encryption_key_sha256: str + :keyword encryption_algorithm: The algorithm used to produce the encryption key hash. + Currently, the only accepted value is "AES256". Must be provided if the x-ms-encryption-key + header is provided. "AES256" Default value is None. + :paramtype encryption_algorithm: str or + ~azure.storage.filedatalake.models.EncryptionAlgorithmType + :keyword timeout: The timeout parameter is expressed in seconds. For more information, see Setting + Timeouts for Blob Service Operations.. Default value is None. + :paramtype timeout: int + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + 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) + + _request = build_path_flush_data_request( + position=position, + retain_uncommitted_data=retain_uncommitted_data, + close=close, + content_length=content_length, + content_md5=content_md5, + lease_id=lease_id, + lease_action=lease_action, + lease_duration=lease_duration, + proposed_lease_id=proposed_lease_id, + cache_control=cache_control, + content_type=content_type, + content_disposition=content_disposition, + content_encoding=content_encoding, + content_language=content_language, + if_modified_since=if_modified_since, + if_unmodified_since=if_unmodified_since, + encryption_key=encryption_key, + encryption_key_sha256=encryption_key_sha256, + encryption_algorithm=encryption_algorithm, + timeout=timeout, + etag=etag, + match_condition=match_condition, + version=self._config.version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "url": self._serialize.url("self._config.url", self._config.url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = 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 = _failsafe_deserialize( + _models.StorageError, + 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-Length"] = self._deserialize("int", response.headers.get("Content-Length")) + response_headers["x-ms-request-server-encrypted"] = self._deserialize( + "bool", response.headers.get("x-ms-request-server-encrypted") + ) + response_headers["x-ms-encryption-key-sha256"] = self._deserialize( + "str", response.headers.get("x-ms-encryption-key-sha256") + ) + response_headers["x-ms-lease-renewed"] = self._deserialize("bool", response.headers.get("x-ms-lease-renewed")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + 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") + ) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace + def append_data( # pylint: disable=inconsistent-return-statements,too-many-locals + self, + body: bytes, + *, + position: Optional[int] = None, + content_length: Optional[int] = None, + transactional_content_hash: Optional[bytes] = None, + transactional_content_crc64: Optional[bytes] = None, + lease_id: Optional[str] = None, + lease_action: Optional[Union[str, _models.LeaseAction]] = None, + lease_duration: Optional[int] = None, + proposed_lease_id: Optional[str] = None, + encryption_key: Optional[str] = None, + encryption_key_sha256: Optional[str] = None, + encryption_algorithm: Optional[Union[str, _models.EncryptionAlgorithmType]] = None, + flush: Optional[bool] = None, + structured_body_type: Optional[str] = None, + structured_content_length: Optional[int] = None, + timeout: Optional[int] = None, + **kwargs: Any + ) -> None: + """Append data to the file. + + :param body: Initial data. Required. + :type body: bytes + :keyword position: This parameter allows the caller to upload data in parallel and control the + order in which it is appended to the file. It is required when uploading data to be appended to + the file and when flushing previously uploaded data to the file. The value must be the position + where the data is to be appended. Uploaded data is not immediately flushed, or written, to the + file. To flush, the previously uploaded data must be contiguous, the position parameter must be + specified and equal to the length of the file after all data has been written, and there must + not be a request entity body included with the request. Default value is None. + :paramtype position: int + :keyword content_length: Required for "Append Data" and "Flush Data". Must be 0 for "Flush + Data". Must be the length of the request content in bytes for "Append Data". Default value is + None. + :paramtype content_length: int + :keyword transactional_content_hash: Specify the transactional md5 for the body, to be + validated by the service. Default value is None. + :paramtype transactional_content_hash: bytes + :keyword transactional_content_crc64: Specify the transactional crc64 for the body, to be + validated by the service. Default value is None. + :paramtype transactional_content_crc64: bytes + :keyword lease_id: If specified, the operation only succeeds if the resource's lease is active + and matches this ID. Default value is None. + :paramtype lease_id: str + :keyword lease_action: Optional. If "acquire" it will acquire the lease. If "auto-renew" it + will renew the lease. If "release" it will release the lease only on flush. If + "acquire-release" it will acquire & complete the operation & release the lease once operation + is done. Known values are: "acquire", "auto-renew", "release", and "acquire-release". Default + value is None. + :paramtype lease_action: str or ~azure.storage.filedatalake.models.LeaseAction + :keyword lease_duration: The lease duration is required to acquire a lease, and specifies the + duration of the lease in seconds. The lease duration must be between 15 and 60 seconds or -1 + for infinite lease. Default value is None. + :paramtype lease_duration: int + :keyword proposed_lease_id: Proposed lease ID, in a GUID string format. Default value is None. + :paramtype proposed_lease_id: str + :keyword encryption_key: Optional. Specifies the encryption key to use to encrypt the data + provided in the request. If not specified, encryption is performed with the root account + encryption key. Default value is None. + :paramtype encryption_key: str + :keyword encryption_key_sha256: The SHA-256 hash of the provided encryption key. Must be + provided if the x-ms-encryption-key header is provided. Default value is None. + :paramtype encryption_key_sha256: str + :keyword encryption_algorithm: The algorithm used to produce the encryption key hash. + Currently, the only accepted value is "AES256". Must be provided if the x-ms-encryption-key + header is provided. "AES256" Default value is None. + :paramtype encryption_algorithm: str or + ~azure.storage.filedatalake.models.EncryptionAlgorithmType + :keyword flush: If file should be flushed after the append. Default value is None. + :paramtype flush: bool + :keyword structured_body_type: Required if the request body is a structured message. Specifies + the message schema version and properties. Default value is None. + :paramtype structured_body_type: str + :keyword 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. + :paramtype structured_content_length: int + :keyword timeout: The timeout parameter is expressed in seconds. For more information, see Setting + Timeouts for Blob Service Operations.. Default value is None. + :paramtype timeout: int + :return: None + :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 {} + + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/octet-stream")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _content = body + + _request = build_path_append_data_request( + position=position, + content_length=content_length, + transactional_content_hash=transactional_content_hash, + transactional_content_crc64=transactional_content_crc64, + lease_id=lease_id, + lease_action=lease_action, + lease_duration=lease_duration, + proposed_lease_id=proposed_lease_id, + encryption_key=encryption_key, + encryption_key_sha256=encryption_key_sha256, + encryption_algorithm=encryption_algorithm, + flush=flush, + structured_body_type=structured_body_type, + structured_content_length=structured_content_length, + timeout=timeout, + content_type=content_type, + version=self._config.version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "url": self._serialize.url("self._config.url", self._config.url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = 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 = _failsafe_deserialize( + _models.StorageError, + response, + ) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + response_headers["Content-MD5"] = self._deserialize("bytearray", response.headers.get("Content-MD5")) + response_headers["x-ms-content-crc64"] = self._deserialize( + "bytearray", response.headers.get("x-ms-content-crc64") + ) + response_headers["x-ms-request-server-encrypted"] = self._deserialize( + "bool", response.headers.get("x-ms-request-server-encrypted") + ) + response_headers["x-ms-encryption-key-sha256"] = self._deserialize( + "str", response.headers.get("x-ms-encryption-key-sha256") + ) + response_headers["x-ms-lease-renewed"] = self._deserialize("bool", response.headers.get("x-ms-lease-renewed")) + response_headers["x-ms-structured-body"] = self._deserialize( + "str", response.headers.get("x-ms-structured-body") + ) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + 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") + ) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace + def set_expiry( # pylint: disable=inconsistent-return-statements + self, + *, + expiry_options: Union[str, _models.PathExpiryOptions], + expires_on: Optional[str] = None, + timeout: Optional[int] = None, + **kwargs: Any + ) -> None: + """Sets the time a blob will expire and be deleted. + + :keyword expiry_options: Required. Indicates mode of the expiry time. Known values are: + "NeverExpire", "RelativeToCreation", "RelativeToNow", and "Absolute". Required. + :paramtype expiry_options: str or ~azure.storage.filedatalake.models.PathExpiryOptions + :keyword expires_on: The time to set the blob to expiry. Default value is None. + :paramtype expires_on: str + :keyword timeout: The timeout parameter is expressed in seconds. For more information, see Setting + Timeouts for Blob Service Operations.. Default value is None. + :paramtype timeout: int + :return: None + :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) + + _request = build_path_set_expiry_request( + expiry_options=expiry_options, + expires_on=expires_on, + timeout=timeout, + version=self._config.version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "url": self._serialize.url("self._config.url", self._config.url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = 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 = _failsafe_deserialize( + _models.StorageError, + 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["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + 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") + ) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + @distributed_trace + def undelete( # pylint: disable=inconsistent-return-statements + self, *, undelete_source: Optional[str] = None, timeout: Optional[int] = None, **kwargs: Any + ) -> None: + """Undelete a path that was previously soft deleted. + + :keyword undelete_source: Only for hierarchical namespace enabled accounts. Optional. The path + of the soft deleted blob to undelete. Default value is None. + :paramtype undelete_source: str + :keyword timeout: The timeout parameter is expressed in seconds. For more information, see Setting + Timeouts for Blob Service Operations.. Default value is None. + :paramtype timeout: int + :return: None + :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) + + _request = build_path_undelete_request( + undelete_source=undelete_source, + timeout=timeout, + version=self._config.version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "url": self._serialize.url("self._config.url", self._config.url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = 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 = _failsafe_deserialize( + _models.StorageError, + response, + ) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["x-ms-resource-type"] = self._deserialize("str", response.headers.get("x-ms-resource-type")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + 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") + ) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + +class ServiceOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.storage.filedatalake.DataLakeClient`'s + :attr:`service` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: DataLakeClientConfiguration = 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 + def list_file_systems( + self, + *, + resource: Union[str, _models.AccountResourceType], + prefix: Optional[str] = None, + continuation: Optional[str] = None, + max_results: Optional[int] = None, + timeout: Optional[int] = None, + **kwargs: Any + ) -> _models.FileSystemList: + """List filesystems and their properties in given account. + + :keyword resource: The value must be "account" for all account operations. "account" Required. + :paramtype resource: str or ~azure.storage.filedatalake.models.AccountResourceType + :keyword prefix: Filters results to filesystems within the specified prefix. Default value is + None. + :paramtype prefix: str + :keyword continuation: Optional. When deleting a directory, the number of paths that are + deleted with each invocation is limited. If the number of paths to be deleted exceeds this + limit, a continuation token is returned in this response header. When a continuation token is + returned in the response, it must be specified in a subsequent invocation of the delete + operation to continue deleting the directory. Default value is None. + :paramtype continuation: str + :keyword max_results: An optional value that specifies the maximum number of items to return. + If omitted or greater than 5,000, the response will include up to 5,000 items. Default value is + None. + :paramtype max_results: int + :keyword timeout: The timeout parameter is expressed in seconds. For more information, see Setting + Timeouts for Blob Service Operations.. Default value is None. + :paramtype timeout: int + :return: FileSystemList. The FileSystemList is compatible with MutableMapping + :rtype: ~azure.storage.filedatalake._generated.models.FileSystemList + :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[_models.FileSystemList] = kwargs.pop("cls", None) + + _request = build_service_list_file_systems_request( + resource=resource, + prefix=prefix, + continuation=continuation, + max_results=max_results, + timeout=timeout, + version=self._config.version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "url": self._serialize.url("self._config.url", self._config.url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + 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 = _failsafe_deserialize( + _models.StorageError, + response, + ) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["x-ms-continuation"] = self._deserialize("str", response.headers.get("x-ms-continuation")) + response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) + response_headers["x-ms-version"] = self._deserialize("str", response.headers.get("x-ms-version")) + 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["Content-Type"] = self._deserialize("str", response.headers.get("Content-Type")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.FileSystemList, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/operations/_patch.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/operations/_patch.py index f7dd32510333..71a40df69f9b 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/operations/_patch.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/operations/_patch.py @@ -1,14 +1,14 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# 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. +# -------------------------------------------------------------------------- """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 +__all__: list[str] = [] def patch_sdk(): diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/operations/_path_operations.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/operations/_path_operations.py deleted file mode 100644 index 40a2b8902804..000000000000 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/operations/_path_operations.py +++ /dev/null @@ -1,2881 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,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 collections.abc import MutableMapping -import datetime -from typing import Any, Callable, IO, Iterator, Literal, Optional, TypeVar, Union - -from azure.core import PipelineClient -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 HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict - -from .. import models as _models -from .._configuration import AzureDataLakeStorageRESTAPIConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_create_request( # pylint: disable=too-many-locals,too-many-statements,too-many-branches - url: str, - *, - version: str, - request_id_parameter: Optional[str] = None, - timeout: Optional[int] = None, - resource: Optional[Union[str, _models.PathResourceType]] = None, - continuation: Optional[str] = None, - mode: Optional[Union[str, _models.PathRenameMode]] = None, - cache_control: Optional[str] = None, - content_encoding: Optional[str] = None, - content_language: Optional[str] = None, - content_disposition: Optional[str] = None, - content_type_parameter: Optional[str] = None, - rename_source: Optional[str] = None, - lease_id: Optional[str] = None, - source_lease_id: Optional[str] = None, - properties: Optional[str] = None, - permissions: Optional[str] = None, - umask: Optional[str] = None, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, - if_modified_since: Optional[datetime.datetime] = None, - if_unmodified_since: Optional[datetime.datetime] = None, - source_if_match: Optional[str] = None, - source_if_none_match: Optional[str] = None, - source_if_modified_since: Optional[datetime.datetime] = None, - source_if_unmodified_since: Optional[datetime.datetime] = None, - encryption_key: Optional[str] = None, - encryption_key_sha256: Optional[str] = None, - encryption_algorithm: Literal["AES256"] = "AES256", - owner: Optional[str] = None, - group: Optional[str] = None, - acl: Optional[str] = None, - proposed_lease_id: Optional[str] = None, - lease_duration: Optional[int] = None, - expiry_options: Optional[Union[str, _models.PathExpiryOptions]] = None, - expires_on: Optional[str] = None, - encryption_context: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "{url}") - path_format_arguments = { - "url": _SERIALIZER.url("url", url, "str", skip_quote=True), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if timeout is not None: - _params["timeout"] = _SERIALIZER.query("timeout", timeout, "int", minimum=0) - if resource is not None: - _params["resource"] = _SERIALIZER.query("resource", resource, "str") - if continuation is not None: - _params["continuation"] = _SERIALIZER.query("continuation", continuation, "str") - if mode is not None: - _params["mode"] = _SERIALIZER.query("mode", mode, "str") - - # Construct headers - if request_id_parameter is not None: - _headers["x-ms-client-request-id"] = _SERIALIZER.header("request_id_parameter", request_id_parameter, "str") - _headers["x-ms-version"] = _SERIALIZER.header("version", version, "str") - if cache_control is not None: - _headers["x-ms-cache-control"] = _SERIALIZER.header("cache_control", cache_control, "str") - if content_encoding is not None: - _headers["x-ms-content-encoding"] = _SERIALIZER.header("content_encoding", content_encoding, "str") - if content_language is not None: - _headers["x-ms-content-language"] = _SERIALIZER.header("content_language", content_language, "str") - if content_disposition is not None: - _headers["x-ms-content-disposition"] = _SERIALIZER.header("content_disposition", content_disposition, "str") - if content_type_parameter is not None: - _headers["x-ms-content-type"] = _SERIALIZER.header("content_type_parameter", content_type_parameter, "str") - if rename_source is not None: - _headers["x-ms-rename-source"] = _SERIALIZER.header("rename_source", rename_source, "str") - if lease_id is not None: - _headers["x-ms-lease-id"] = _SERIALIZER.header("lease_id", lease_id, "str") - if source_lease_id is not None: - _headers["x-ms-source-lease-id"] = _SERIALIZER.header("source_lease_id", source_lease_id, "str") - if properties is not None: - _headers["x-ms-properties"] = _SERIALIZER.header("properties", properties, "str") - if permissions is not None: - _headers["x-ms-permissions"] = _SERIALIZER.header("permissions", permissions, "str") - if umask is not None: - _headers["x-ms-umask"] = _SERIALIZER.header("umask", umask, "str") - if if_match is not None: - _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") - if if_none_match is not None: - _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") - if if_modified_since is not None: - _headers["If-Modified-Since"] = _SERIALIZER.header("if_modified_since", if_modified_since, "rfc-1123") - if if_unmodified_since is not None: - _headers["If-Unmodified-Since"] = _SERIALIZER.header("if_unmodified_since", if_unmodified_since, "rfc-1123") - if source_if_match is not None: - _headers["x-ms-source-if-match"] = _SERIALIZER.header("source_if_match", source_if_match, "str") - if source_if_none_match is not None: - _headers["x-ms-source-if-none-match"] = _SERIALIZER.header("source_if_none_match", source_if_none_match, "str") - if source_if_modified_since is not None: - _headers["x-ms-source-if-modified-since"] = _SERIALIZER.header( - "source_if_modified_since", source_if_modified_since, "rfc-1123" - ) - if source_if_unmodified_since is not None: - _headers["x-ms-source-if-unmodified-since"] = _SERIALIZER.header( - "source_if_unmodified_since", source_if_unmodified_since, "rfc-1123" - ) - if encryption_key is not None: - _headers["x-ms-encryption-key"] = _SERIALIZER.header("encryption_key", encryption_key, "str") - if encryption_key_sha256 is not None: - _headers["x-ms-encryption-key-sha256"] = _SERIALIZER.header( - "encryption_key_sha256", encryption_key_sha256, "str" - ) - if encryption_algorithm is not None: - _headers["x-ms-encryption-algorithm"] = _SERIALIZER.header("encryption_algorithm", encryption_algorithm, "str") - if owner is not None: - _headers["x-ms-owner"] = _SERIALIZER.header("owner", owner, "str") - if group is not None: - _headers["x-ms-group"] = _SERIALIZER.header("group", group, "str") - if acl is not None: - _headers["x-ms-acl"] = _SERIALIZER.header("acl", acl, "str") - if proposed_lease_id is not None: - _headers["x-ms-proposed-lease-id"] = _SERIALIZER.header("proposed_lease_id", proposed_lease_id, "str") - if lease_duration is not None: - _headers["x-ms-lease-duration"] = _SERIALIZER.header("lease_duration", lease_duration, "int") - if expiry_options is not None: - _headers["x-ms-expiry-option"] = _SERIALIZER.header("expiry_options", expiry_options, "str") - if expires_on is not None: - _headers["x-ms-expiry-time"] = _SERIALIZER.header("expires_on", expires_on, "str") - if encryption_context is not None: - _headers["x-ms-encryption-context"] = _SERIALIZER.header("encryption_context", encryption_context, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( # pylint: disable=too-many-locals,too-many-statements,too-many-branches - url: str, - *, - action: Union[str, _models.PathUpdateAction], - mode: Union[str, _models.PathSetAccessControlRecursiveMode], - content: IO[bytes], - version: str, - request_id_parameter: Optional[str] = None, - timeout: Optional[int] = None, - max_records: Optional[int] = None, - continuation: Optional[str] = None, - force_flag: Optional[bool] = None, - position: Optional[int] = None, - retain_uncommitted_data: Optional[bool] = None, - close: Optional[bool] = None, - content_length: Optional[int] = None, - content_md5: Optional[bytes] = None, - lease_id: Optional[str] = None, - cache_control: Optional[str] = None, - content_type_parameter: Optional[str] = None, - content_disposition: Optional[str] = None, - content_encoding: Optional[str] = None, - content_language: Optional[str] = None, - properties: Optional[str] = None, - owner: Optional[str] = None, - group: Optional[str] = None, - permissions: Optional[str] = None, - acl: Optional[str] = None, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, - if_modified_since: Optional[datetime.datetime] = None, - if_unmodified_since: Optional[datetime.datetime] = None, - structured_body_type: Optional[str] = None, - structured_content_length: Optional[int] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "{url}") - path_format_arguments = { - "url": _SERIALIZER.url("url", url, "str", skip_quote=True), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if timeout is not None: - _params["timeout"] = _SERIALIZER.query("timeout", timeout, "int", minimum=0) - _params["action"] = _SERIALIZER.query("action", action, "str") - if max_records is not None: - _params["maxRecords"] = _SERIALIZER.query("max_records", max_records, "int", minimum=1) - if continuation is not None: - _params["continuation"] = _SERIALIZER.query("continuation", continuation, "str") - _params["mode"] = _SERIALIZER.query("mode", mode, "str") - if force_flag is not None: - _params["forceFlag"] = _SERIALIZER.query("force_flag", force_flag, "bool") - if position is not None: - _params["position"] = _SERIALIZER.query("position", position, "int") - if retain_uncommitted_data is not None: - _params["retainUncommittedData"] = _SERIALIZER.query("retain_uncommitted_data", retain_uncommitted_data, "bool") - if close is not None: - _params["close"] = _SERIALIZER.query("close", close, "bool") - - # Construct headers - if request_id_parameter is not None: - _headers["x-ms-client-request-id"] = _SERIALIZER.header("request_id_parameter", request_id_parameter, "str") - _headers["x-ms-version"] = _SERIALIZER.header("version", version, "str") - if content_length is not None: - _headers["Content-Length"] = _SERIALIZER.header("content_length", content_length, "int", minimum=0) - if content_md5 is not None: - _headers["x-ms-content-md5"] = _SERIALIZER.header("content_md5", content_md5, "bytearray") - if lease_id is not None: - _headers["x-ms-lease-id"] = _SERIALIZER.header("lease_id", lease_id, "str") - if cache_control is not None: - _headers["x-ms-cache-control"] = _SERIALIZER.header("cache_control", cache_control, "str") - if content_type_parameter is not None: - _headers["x-ms-content-type"] = _SERIALIZER.header("content_type_parameter", content_type_parameter, "str") - if content_disposition is not None: - _headers["x-ms-content-disposition"] = _SERIALIZER.header("content_disposition", content_disposition, "str") - if content_encoding is not None: - _headers["x-ms-content-encoding"] = _SERIALIZER.header("content_encoding", content_encoding, "str") - if content_language is not None: - _headers["x-ms-content-language"] = _SERIALIZER.header("content_language", content_language, "str") - if properties is not None: - _headers["x-ms-properties"] = _SERIALIZER.header("properties", properties, "str") - if owner is not None: - _headers["x-ms-owner"] = _SERIALIZER.header("owner", owner, "str") - if group is not None: - _headers["x-ms-group"] = _SERIALIZER.header("group", group, "str") - if permissions is not None: - _headers["x-ms-permissions"] = _SERIALIZER.header("permissions", permissions, "str") - if acl is not None: - _headers["x-ms-acl"] = _SERIALIZER.header("acl", acl, "str") - if if_match is not None: - _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") - if if_none_match is not None: - _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") - if if_modified_since is not None: - _headers["If-Modified-Since"] = _SERIALIZER.header("if_modified_since", if_modified_since, "rfc-1123") - if if_unmodified_since is not None: - _headers["If-Unmodified-Since"] = _SERIALIZER.header("if_unmodified_since", if_unmodified_since, "rfc-1123") - if structured_body_type is not None: - _headers["x-ms-structured-body"] = _SERIALIZER.header("structured_body_type", structured_body_type, "str") - if structured_content_length is not None: - _headers["x-ms-structured-content-length"] = _SERIALIZER.header( - "structured_content_length", structured_content_length, "int" - ) - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, content=content, **kwargs) - - -def build_lease_request( - url: str, - *, - x_ms_lease_action: Union[str, _models.PathLeaseAction], - version: str, - request_id_parameter: Optional[str] = None, - timeout: Optional[int] = None, - x_ms_lease_break_period: Optional[int] = None, - lease_id: Optional[str] = None, - proposed_lease_id: Optional[str] = None, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, - if_modified_since: Optional[datetime.datetime] = None, - if_unmodified_since: Optional[datetime.datetime] = None, - x_ms_lease_duration: Optional[int] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "{url}") - path_format_arguments = { - "url": _SERIALIZER.url("url", url, "str", skip_quote=True), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if timeout is not None: - _params["timeout"] = _SERIALIZER.query("timeout", timeout, "int", minimum=0) - - # Construct headers - if request_id_parameter is not None: - _headers["x-ms-client-request-id"] = _SERIALIZER.header("request_id_parameter", request_id_parameter, "str") - _headers["x-ms-version"] = _SERIALIZER.header("version", version, "str") - _headers["x-ms-lease-action"] = _SERIALIZER.header("x_ms_lease_action", x_ms_lease_action, "str") - if x_ms_lease_duration is not None: - _headers["x-ms-lease-duration"] = _SERIALIZER.header("x_ms_lease_duration", x_ms_lease_duration, "int") - if x_ms_lease_break_period is not None: - _headers["x-ms-lease-break-period"] = _SERIALIZER.header( - "x_ms_lease_break_period", x_ms_lease_break_period, "int" - ) - if lease_id is not None: - _headers["x-ms-lease-id"] = _SERIALIZER.header("lease_id", lease_id, "str") - if proposed_lease_id is not None: - _headers["x-ms-proposed-lease-id"] = _SERIALIZER.header("proposed_lease_id", proposed_lease_id, "str") - if if_match is not None: - _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") - if if_none_match is not None: - _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") - if if_modified_since is not None: - _headers["If-Modified-Since"] = _SERIALIZER.header("if_modified_since", if_modified_since, "rfc-1123") - if if_unmodified_since is not None: - _headers["If-Unmodified-Since"] = _SERIALIZER.header("if_unmodified_since", if_unmodified_since, "rfc-1123") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_read_request( - url: str, - *, - version: str, - request_id_parameter: Optional[str] = None, - timeout: Optional[int] = None, - range: Optional[str] = None, - lease_id: Optional[str] = None, - x_ms_range_get_content_md5: Optional[bool] = None, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, - if_modified_since: Optional[datetime.datetime] = None, - if_unmodified_since: Optional[datetime.datetime] = None, - encryption_key: Optional[str] = None, - encryption_key_sha256: Optional[str] = None, - encryption_algorithm: Literal["AES256"] = "AES256", - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "{url}") - path_format_arguments = { - "url": _SERIALIZER.url("url", url, "str", skip_quote=True), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if timeout is not None: - _params["timeout"] = _SERIALIZER.query("timeout", timeout, "int", minimum=0) - - # Construct headers - if request_id_parameter is not None: - _headers["x-ms-client-request-id"] = _SERIALIZER.header("request_id_parameter", request_id_parameter, "str") - _headers["x-ms-version"] = _SERIALIZER.header("version", version, "str") - if range is not None: - _headers["Range"] = _SERIALIZER.header("range", range, "str") - if lease_id is not None: - _headers["x-ms-lease-id"] = _SERIALIZER.header("lease_id", lease_id, "str") - if x_ms_range_get_content_md5 is not None: - _headers["x-ms-range-get-content-md5"] = _SERIALIZER.header( - "x_ms_range_get_content_md5", x_ms_range_get_content_md5, "bool" - ) - if if_match is not None: - _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") - if if_none_match is not None: - _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") - if if_modified_since is not None: - _headers["If-Modified-Since"] = _SERIALIZER.header("if_modified_since", if_modified_since, "rfc-1123") - if if_unmodified_since is not None: - _headers["If-Unmodified-Since"] = _SERIALIZER.header("if_unmodified_since", if_unmodified_since, "rfc-1123") - if encryption_key is not None: - _headers["x-ms-encryption-key"] = _SERIALIZER.header("encryption_key", encryption_key, "str") - if encryption_key_sha256 is not None: - _headers["x-ms-encryption-key-sha256"] = _SERIALIZER.header( - "encryption_key_sha256", encryption_key_sha256, "str" - ) - if encryption_algorithm is not None: - _headers["x-ms-encryption-algorithm"] = _SERIALIZER.header("encryption_algorithm", encryption_algorithm, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_properties_request( - url: str, - *, - version: str, - request_id_parameter: Optional[str] = None, - timeout: Optional[int] = None, - action: Optional[Union[str, _models.PathGetPropertiesAction]] = None, - upn: Optional[bool] = None, - lease_id: Optional[str] = None, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, - if_modified_since: Optional[datetime.datetime] = None, - if_unmodified_since: Optional[datetime.datetime] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "{url}") - path_format_arguments = { - "url": _SERIALIZER.url("url", url, "str", skip_quote=True), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if timeout is not None: - _params["timeout"] = _SERIALIZER.query("timeout", timeout, "int", minimum=0) - if action is not None: - _params["action"] = _SERIALIZER.query("action", action, "str") - if upn is not None: - _params["upn"] = _SERIALIZER.query("upn", upn, "bool") - - # Construct headers - if request_id_parameter is not None: - _headers["x-ms-client-request-id"] = _SERIALIZER.header("request_id_parameter", request_id_parameter, "str") - _headers["x-ms-version"] = _SERIALIZER.header("version", version, "str") - if lease_id is not None: - _headers["x-ms-lease-id"] = _SERIALIZER.header("lease_id", lease_id, "str") - if if_match is not None: - _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") - if if_none_match is not None: - _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") - if if_modified_since is not None: - _headers["If-Modified-Since"] = _SERIALIZER.header("if_modified_since", if_modified_since, "rfc-1123") - if if_unmodified_since is not None: - _headers["If-Unmodified-Since"] = _SERIALIZER.header("if_unmodified_since", if_unmodified_since, "rfc-1123") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - url: str, - *, - version: str, - request_id_parameter: Optional[str] = None, - timeout: Optional[int] = None, - recursive: Optional[bool] = None, - continuation: Optional[str] = None, - lease_id: Optional[str] = None, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, - if_modified_since: Optional[datetime.datetime] = None, - if_unmodified_since: Optional[datetime.datetime] = None, - paginated: Optional[bool] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "{url}") - path_format_arguments = { - "url": _SERIALIZER.url("url", url, "str", skip_quote=True), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if timeout is not None: - _params["timeout"] = _SERIALIZER.query("timeout", timeout, "int", minimum=0) - if recursive is not None: - _params["recursive"] = _SERIALIZER.query("recursive", recursive, "bool") - if continuation is not None: - _params["continuation"] = _SERIALIZER.query("continuation", continuation, "str") - if paginated is not None: - _params["paginated"] = _SERIALIZER.query("paginated", paginated, "bool") - - # Construct headers - if request_id_parameter is not None: - _headers["x-ms-client-request-id"] = _SERIALIZER.header("request_id_parameter", request_id_parameter, "str") - _headers["x-ms-version"] = _SERIALIZER.header("version", version, "str") - if lease_id is not None: - _headers["x-ms-lease-id"] = _SERIALIZER.header("lease_id", lease_id, "str") - if if_match is not None: - _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") - if if_none_match is not None: - _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") - if if_modified_since is not None: - _headers["If-Modified-Since"] = _SERIALIZER.header("if_modified_since", if_modified_since, "rfc-1123") - if if_unmodified_since is not None: - _headers["If-Unmodified-Since"] = _SERIALIZER.header("if_unmodified_since", if_unmodified_since, "rfc-1123") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_set_access_control_request( - url: str, - *, - version: str, - timeout: Optional[int] = None, - lease_id: Optional[str] = None, - owner: Optional[str] = None, - group: Optional[str] = None, - permissions: Optional[str] = None, - acl: Optional[str] = None, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, - if_modified_since: Optional[datetime.datetime] = None, - if_unmodified_since: Optional[datetime.datetime] = None, - request_id_parameter: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - action: Literal["setAccessControl"] = kwargs.pop("action", _params.pop("action", "setAccessControl")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "{url}") - path_format_arguments = { - "url": _SERIALIZER.url("url", url, "str", skip_quote=True), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["action"] = _SERIALIZER.query("action", action, "str") - if timeout is not None: - _params["timeout"] = _SERIALIZER.query("timeout", timeout, "int", minimum=0) - - # Construct headers - if lease_id is not None: - _headers["x-ms-lease-id"] = _SERIALIZER.header("lease_id", lease_id, "str") - if owner is not None: - _headers["x-ms-owner"] = _SERIALIZER.header("owner", owner, "str") - if group is not None: - _headers["x-ms-group"] = _SERIALIZER.header("group", group, "str") - if permissions is not None: - _headers["x-ms-permissions"] = _SERIALIZER.header("permissions", permissions, "str") - if acl is not None: - _headers["x-ms-acl"] = _SERIALIZER.header("acl", acl, "str") - if if_match is not None: - _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") - if if_none_match is not None: - _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") - if if_modified_since is not None: - _headers["If-Modified-Since"] = _SERIALIZER.header("if_modified_since", if_modified_since, "rfc-1123") - if if_unmodified_since is not None: - _headers["If-Unmodified-Since"] = _SERIALIZER.header("if_unmodified_since", if_unmodified_since, "rfc-1123") - if request_id_parameter is not None: - _headers["x-ms-client-request-id"] = _SERIALIZER.header("request_id_parameter", request_id_parameter, "str") - _headers["x-ms-version"] = _SERIALIZER.header("version", version, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_set_access_control_recursive_request( # pylint: disable=name-too-long - url: str, - *, - mode: Union[str, _models.PathSetAccessControlRecursiveMode], - version: str, - timeout: Optional[int] = None, - continuation: Optional[str] = None, - force_flag: Optional[bool] = None, - max_records: Optional[int] = None, - acl: Optional[str] = None, - request_id_parameter: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - action: Literal["setAccessControlRecursive"] = kwargs.pop( - "action", _params.pop("action", "setAccessControlRecursive") - ) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "{url}") - path_format_arguments = { - "url": _SERIALIZER.url("url", url, "str", skip_quote=True), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["action"] = _SERIALIZER.query("action", action, "str") - if timeout is not None: - _params["timeout"] = _SERIALIZER.query("timeout", timeout, "int", minimum=0) - if continuation is not None: - _params["continuation"] = _SERIALIZER.query("continuation", continuation, "str") - _params["mode"] = _SERIALIZER.query("mode", mode, "str") - if force_flag is not None: - _params["forceFlag"] = _SERIALIZER.query("force_flag", force_flag, "bool") - if max_records is not None: - _params["maxRecords"] = _SERIALIZER.query("max_records", max_records, "int", minimum=1) - - # Construct headers - if acl is not None: - _headers["x-ms-acl"] = _SERIALIZER.header("acl", acl, "str") - if request_id_parameter is not None: - _headers["x-ms-client-request-id"] = _SERIALIZER.header("request_id_parameter", request_id_parameter, "str") - _headers["x-ms-version"] = _SERIALIZER.header("version", version, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_flush_data_request( # pylint: disable=too-many-locals - url: str, - *, - version: str, - timeout: Optional[int] = None, - position: Optional[int] = None, - retain_uncommitted_data: Optional[bool] = None, - close: Optional[bool] = None, - content_length: Optional[int] = None, - content_md5: Optional[bytes] = None, - lease_id: Optional[str] = None, - lease_action: Optional[Union[str, _models.LeaseAction]] = None, - lease_duration: Optional[int] = None, - proposed_lease_id: Optional[str] = None, - cache_control: Optional[str] = None, - content_type_parameter: Optional[str] = None, - content_disposition: Optional[str] = None, - content_encoding: Optional[str] = None, - content_language: Optional[str] = None, - if_match: Optional[str] = None, - if_none_match: Optional[str] = None, - if_modified_since: Optional[datetime.datetime] = None, - if_unmodified_since: Optional[datetime.datetime] = None, - request_id_parameter: Optional[str] = None, - encryption_key: Optional[str] = None, - encryption_key_sha256: Optional[str] = None, - encryption_algorithm: Literal["AES256"] = "AES256", - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - action: Literal["flush"] = kwargs.pop("action", _params.pop("action", "flush")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "{url}") - path_format_arguments = { - "url": _SERIALIZER.url("url", url, "str", skip_quote=True), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["action"] = _SERIALIZER.query("action", action, "str") - if timeout is not None: - _params["timeout"] = _SERIALIZER.query("timeout", timeout, "int", minimum=0) - if position is not None: - _params["position"] = _SERIALIZER.query("position", position, "int") - if retain_uncommitted_data is not None: - _params["retainUncommittedData"] = _SERIALIZER.query("retain_uncommitted_data", retain_uncommitted_data, "bool") - if close is not None: - _params["close"] = _SERIALIZER.query("close", close, "bool") - - # Construct headers - if content_length is not None: - _headers["Content-Length"] = _SERIALIZER.header("content_length", content_length, "int", minimum=0) - if content_md5 is not None: - _headers["x-ms-content-md5"] = _SERIALIZER.header("content_md5", content_md5, "bytearray") - if lease_id is not None: - _headers["x-ms-lease-id"] = _SERIALIZER.header("lease_id", lease_id, "str") - if lease_action is not None: - _headers["x-ms-lease-action"] = _SERIALIZER.header("lease_action", lease_action, "str") - if lease_duration is not None: - _headers["x-ms-lease-duration"] = _SERIALIZER.header("lease_duration", lease_duration, "int") - if proposed_lease_id is not None: - _headers["x-ms-proposed-lease-id"] = _SERIALIZER.header("proposed_lease_id", proposed_lease_id, "str") - if cache_control is not None: - _headers["x-ms-cache-control"] = _SERIALIZER.header("cache_control", cache_control, "str") - if content_type_parameter is not None: - _headers["x-ms-content-type"] = _SERIALIZER.header("content_type_parameter", content_type_parameter, "str") - if content_disposition is not None: - _headers["x-ms-content-disposition"] = _SERIALIZER.header("content_disposition", content_disposition, "str") - if content_encoding is not None: - _headers["x-ms-content-encoding"] = _SERIALIZER.header("content_encoding", content_encoding, "str") - if content_language is not None: - _headers["x-ms-content-language"] = _SERIALIZER.header("content_language", content_language, "str") - if if_match is not None: - _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") - if if_none_match is not None: - _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") - if if_modified_since is not None: - _headers["If-Modified-Since"] = _SERIALIZER.header("if_modified_since", if_modified_since, "rfc-1123") - if if_unmodified_since is not None: - _headers["If-Unmodified-Since"] = _SERIALIZER.header("if_unmodified_since", if_unmodified_since, "rfc-1123") - if request_id_parameter is not None: - _headers["x-ms-client-request-id"] = _SERIALIZER.header("request_id_parameter", request_id_parameter, "str") - _headers["x-ms-version"] = _SERIALIZER.header("version", version, "str") - if encryption_key is not None: - _headers["x-ms-encryption-key"] = _SERIALIZER.header("encryption_key", encryption_key, "str") - if encryption_key_sha256 is not None: - _headers["x-ms-encryption-key-sha256"] = _SERIALIZER.header( - "encryption_key_sha256", encryption_key_sha256, "str" - ) - if encryption_algorithm is not None: - _headers["x-ms-encryption-algorithm"] = _SERIALIZER.header("encryption_algorithm", encryption_algorithm, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_append_data_request( # pylint: disable=too-many-locals - url: str, - *, - content: IO[bytes], - version: str, - position: Optional[int] = None, - timeout: Optional[int] = None, - content_length: Optional[int] = None, - transactional_content_hash: Optional[bytes] = None, - transactional_content_crc64: Optional[bytes] = None, - lease_id: Optional[str] = None, - lease_action: Optional[Union[str, _models.LeaseAction]] = None, - lease_duration: Optional[int] = None, - proposed_lease_id: Optional[str] = None, - request_id_parameter: Optional[str] = None, - encryption_key: Optional[str] = None, - encryption_key_sha256: Optional[str] = None, - encryption_algorithm: Literal["AES256"] = "AES256", - flush: Optional[bool] = None, - structured_body_type: Optional[str] = None, - structured_content_length: Optional[int] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - action: Literal["append"] = kwargs.pop("action", _params.pop("action", "append")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "{url}") - path_format_arguments = { - "url": _SERIALIZER.url("url", url, "str", skip_quote=True), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["action"] = _SERIALIZER.query("action", action, "str") - if position is not None: - _params["position"] = _SERIALIZER.query("position", position, "int") - if timeout is not None: - _params["timeout"] = _SERIALIZER.query("timeout", timeout, "int", minimum=0) - if flush is not None: - _params["flush"] = _SERIALIZER.query("flush", flush, "bool") - - # Construct headers - if content_length is not None: - _headers["Content-Length"] = _SERIALIZER.header("content_length", content_length, "int", minimum=0) - if transactional_content_hash is not None: - _headers["Content-MD5"] = _SERIALIZER.header( - "transactional_content_hash", transactional_content_hash, "bytearray" - ) - if transactional_content_crc64 is not None: - _headers["x-ms-content-crc64"] = _SERIALIZER.header( - "transactional_content_crc64", transactional_content_crc64, "bytearray" - ) - if lease_id is not None: - _headers["x-ms-lease-id"] = _SERIALIZER.header("lease_id", lease_id, "str") - if lease_action is not None: - _headers["x-ms-lease-action"] = _SERIALIZER.header("lease_action", lease_action, "str") - if lease_duration is not None: - _headers["x-ms-lease-duration"] = _SERIALIZER.header("lease_duration", lease_duration, "int") - if proposed_lease_id is not None: - _headers["x-ms-proposed-lease-id"] = _SERIALIZER.header("proposed_lease_id", proposed_lease_id, "str") - if request_id_parameter is not None: - _headers["x-ms-client-request-id"] = _SERIALIZER.header("request_id_parameter", request_id_parameter, "str") - _headers["x-ms-version"] = _SERIALIZER.header("version", version, "str") - if encryption_key is not None: - _headers["x-ms-encryption-key"] = _SERIALIZER.header("encryption_key", encryption_key, "str") - if encryption_key_sha256 is not None: - _headers["x-ms-encryption-key-sha256"] = _SERIALIZER.header( - "encryption_key_sha256", encryption_key_sha256, "str" - ) - if encryption_algorithm is not None: - _headers["x-ms-encryption-algorithm"] = _SERIALIZER.header("encryption_algorithm", encryption_algorithm, "str") - if structured_body_type is not None: - _headers["x-ms-structured-body"] = _SERIALIZER.header("structured_body_type", structured_body_type, "str") - if structured_content_length is not None: - _headers["x-ms-structured-content-length"] = _SERIALIZER.header( - "structured_content_length", structured_content_length, "int" - ) - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, content=content, **kwargs) - - -def build_set_expiry_request( - url: str, - *, - expiry_options: Union[str, _models.PathExpiryOptions], - version: str, - timeout: Optional[int] = None, - request_id_parameter: Optional[str] = None, - expires_on: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - comp: Literal["expiry"] = kwargs.pop("comp", _params.pop("comp", "expiry")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "{url}") - path_format_arguments = { - "url": _SERIALIZER.url("url", url, "str", skip_quote=True), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["comp"] = _SERIALIZER.query("comp", comp, "str") - if timeout is not None: - _params["timeout"] = _SERIALIZER.query("timeout", timeout, "int", minimum=0) - - # Construct headers - _headers["x-ms-version"] = _SERIALIZER.header("version", version, "str") - if request_id_parameter is not None: - _headers["x-ms-client-request-id"] = _SERIALIZER.header("request_id_parameter", request_id_parameter, "str") - _headers["x-ms-expiry-option"] = _SERIALIZER.header("expiry_options", expiry_options, "str") - if expires_on is not None: - _headers["x-ms-expiry-time"] = _SERIALIZER.header("expires_on", expires_on, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_undelete_request( - url: str, - *, - version: str, - timeout: Optional[int] = None, - undelete_source: Optional[str] = None, - request_id_parameter: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - comp: Literal["undelete"] = kwargs.pop("comp", _params.pop("comp", "undelete")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "{url}") - path_format_arguments = { - "url": _SERIALIZER.url("url", url, "str", skip_quote=True), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["comp"] = _SERIALIZER.query("comp", comp, "str") - if timeout is not None: - _params["timeout"] = _SERIALIZER.query("timeout", timeout, "int", minimum=0) - - # Construct headers - if undelete_source is not None: - _headers["x-ms-undelete-source"] = _SERIALIZER.header("undelete_source", undelete_source, "str") - _headers["x-ms-version"] = _SERIALIZER.header("version", version, "str") - if request_id_parameter is not None: - _headers["x-ms-client-request-id"] = _SERIALIZER.header("request_id_parameter", request_id_parameter, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -class PathOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.storage.filedatalake.AzureDataLakeStorageRESTAPI`'s - :attr:`path` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AzureDataLakeStorageRESTAPIConfiguration = ( - 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 - def create( # pylint: disable=inconsistent-return-statements,too-many-locals - self, - request_id_parameter: Optional[str] = None, - timeout: Optional[int] = None, - resource: Optional[Union[str, _models.PathResourceType]] = None, - continuation: Optional[str] = None, - mode: Optional[Union[str, _models.PathRenameMode]] = None, - rename_source: Optional[str] = None, - source_lease_id: Optional[str] = None, - properties: Optional[str] = None, - permissions: Optional[str] = None, - umask: Optional[str] = None, - owner: Optional[str] = None, - group: Optional[str] = None, - acl: Optional[str] = None, - proposed_lease_id: Optional[str] = None, - lease_duration: Optional[int] = None, - expiry_options: Optional[Union[str, _models.PathExpiryOptions]] = None, - expires_on: Optional[str] = None, - encryption_context: Optional[str] = None, - path_http_headers: Optional[_models.PathHTTPHeaders] = None, - lease_access_conditions: Optional[_models.LeaseAccessConditions] = None, - modified_access_conditions: Optional[_models.ModifiedAccessConditions] = None, - source_modified_access_conditions: Optional[_models.SourceModifiedAccessConditions] = None, - cpk_info: Optional[_models.CpkInfo] = None, - **kwargs: Any - ) -> None: - """Create File | Create Directory | Rename File | Rename Directory. - - Create or rename a file or directory. By default, the destination is overwritten and if the - destination already exists and has a lease the lease is broken. This operation supports - conditional HTTP requests. For more information, see `Specifying Conditional Headers for Blob - Service Operations - `_. - To fail if the destination already exists, use a conditional request with If-None-Match: "*". - - :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 timeout: The timeout parameter is expressed in seconds. For more information, see - :code:`Setting - Timeouts for Blob Service Operations.`. Default value is None. - :type timeout: int - :param resource: Required only for Create File and Create Directory. The value must be "file" - or "directory". Known values are: "directory" and "file". Default value is None. - :type resource: str or ~azure.storage.filedatalake.models.PathResourceType - :param continuation: Optional. When deleting a directory, the number of paths that are deleted - with each invocation is limited. If the number of paths to be deleted exceeds this limit, a - continuation token is returned in this response header. When a continuation token is returned - in the response, it must be specified in a subsequent invocation of the delete operation to - continue deleting the directory. Default value is None. - :type continuation: str - :param mode: Optional. Valid only when namespace is enabled. This parameter determines the - behavior of the rename operation. The value must be "legacy" or "posix", and the default value - will be "posix". Known values are: "legacy" and "posix". Default value is None. - :type mode: str or ~azure.storage.filedatalake.models.PathRenameMode - :param rename_source: An optional file or directory to be renamed. The value must have the - following format: "/{filesystem}/{path}". If "x-ms-properties" is specified, the properties - will overwrite the existing properties; otherwise, the existing properties will be preserved. - This value must be a URL percent-encoded string. Note that the string may only contain ASCII - characters in the ISO-8859-1 character set. Default value is None. - :type rename_source: str - :param source_lease_id: A lease ID for the source path. If specified, the source path must have - an active lease and the lease ID must match. Default value is None. - :type source_lease_id: str - :param properties: Optional. User-defined properties to be stored with the filesystem, in the - format of a comma-separated list of name and value pairs "n1=v1, n2=v2, ...", where each value - is a base64 encoded string. Note that the string may only contain ASCII characters in the - ISO-8859-1 character set. If the filesystem exists, any properties not included in the list - will be removed. All properties are removed if the header is omitted. To merge new and - existing properties, first get all existing properties and the current E-Tag, then make a - conditional request with the E-Tag and include values for all properties. Default value is - None. - :type properties: str - :param permissions: Optional and only valid if Hierarchical Namespace is enabled for the - account. Sets POSIX access permissions for the file owner, the file owning group, and others. - Each class may be granted read, write, or execute permission. The sticky bit is also - supported. Both symbolic (rwxrw-rw-) and 4-digit octal notation (e.g. 0766) are supported. - Default value is None. - :type permissions: str - :param umask: Optional and only valid if Hierarchical Namespace is enabled for the account. - When creating a file or directory and the parent folder does not have a default ACL, the umask - restricts the permissions of the file or directory to be created. The resulting permission is - given by p bitwise and not u, where p is the permission and u is the umask. For example, if p - is 0777 and u is 0057, then the resulting permission is 0720. The default permission is 0777 - for a directory and 0666 for a file. The default umask is 0027. The umask must be specified - in 4-digit octal notation (e.g. 0766). Default value is None. - :type umask: str - :param owner: Optional. The owner of the blob or directory. Default value is None. - :type owner: str - :param group: Optional. The owning group of the blob or directory. Default value is None. - :type group: str - :param acl: Sets POSIX access control rights on files and directories. The value is a - comma-separated list of access control entries. Each access control entry (ACE) consists of a - scope, a type, a user or group identifier, and permissions in the format - "[scope:][type]:[id]:[permissions]". Default value is None. - :type acl: str - :param proposed_lease_id: Proposed lease ID, in a GUID string format. The Blob 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 lease_duration: The lease duration is required to acquire a lease, and specifies the - duration of the lease in seconds. The lease duration must be between 15 and 60 seconds or -1 - for infinite lease. Default value is None. - :type lease_duration: int - :param expiry_options: Required. Indicates mode of the expiry time. Known values are: - "NeverExpire", "RelativeToCreation", "RelativeToNow", and "Absolute". Default value is None. - :type expiry_options: str or ~azure.storage.filedatalake.models.PathExpiryOptions - :param expires_on: The time to set the blob to expiry. Default value is None. - :type expires_on: str - :param encryption_context: Specifies the encryption context to set on the file. Default value - is None. - :type encryption_context: str - :param path_http_headers: Parameter group. Default value is None. - :type path_http_headers: ~azure.storage.filedatalake.models.PathHTTPHeaders - :param lease_access_conditions: Parameter group. Default value is None. - :type lease_access_conditions: ~azure.storage.filedatalake.models.LeaseAccessConditions - :param modified_access_conditions: Parameter group. Default value is None. - :type modified_access_conditions: ~azure.storage.filedatalake.models.ModifiedAccessConditions - :param source_modified_access_conditions: Parameter group. Default value is None. - :type source_modified_access_conditions: - ~azure.storage.filedatalake.models.SourceModifiedAccessConditions - :param cpk_info: Parameter group. Default value is None. - :type cpk_info: ~azure.storage.filedatalake.models.CpkInfo - :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) - - _cache_control = None - _content_encoding = None - _content_language = None - _content_disposition = None - _content_type_parameter = None - _lease_id = None - _if_match = None - _if_none_match = None - _if_modified_since = None - _if_unmodified_since = None - _source_if_match = None - _source_if_none_match = None - _source_if_modified_since = None - _source_if_unmodified_since = None - _encryption_key = None - _encryption_key_sha256 = None - _encryption_algorithm = None - if path_http_headers is not None: - _cache_control = path_http_headers.cache_control - _content_disposition = path_http_headers.content_disposition - _content_encoding = path_http_headers.content_encoding - _content_language = path_http_headers.content_language - _content_type_parameter = path_http_headers.content_type - if lease_access_conditions is not None: - _lease_id = lease_access_conditions.lease_id - if modified_access_conditions is not None: - _if_match = modified_access_conditions.if_match - _if_modified_since = modified_access_conditions.if_modified_since - _if_none_match = modified_access_conditions.if_none_match - _if_unmodified_since = modified_access_conditions.if_unmodified_since - if source_modified_access_conditions is not None: - _source_if_match = source_modified_access_conditions.source_if_match - _source_if_modified_since = source_modified_access_conditions.source_if_modified_since - _source_if_none_match = source_modified_access_conditions.source_if_none_match - _source_if_unmodified_since = source_modified_access_conditions.source_if_unmodified_since - if cpk_info is not None: - _encryption_algorithm = cpk_info.encryption_algorithm - _encryption_key = cpk_info.encryption_key - _encryption_key_sha256 = cpk_info.encryption_key_sha256 - - _request = build_create_request( - url=self._config.url, - version=self._config.version, - request_id_parameter=request_id_parameter, - timeout=timeout, - resource=resource, - continuation=continuation, - mode=mode, - cache_control=_cache_control, - content_encoding=_content_encoding, - content_language=_content_language, - content_disposition=_content_disposition, - content_type_parameter=_content_type_parameter, - rename_source=rename_source, - lease_id=_lease_id, - source_lease_id=source_lease_id, - properties=properties, - permissions=permissions, - umask=umask, - if_match=_if_match, - if_none_match=_if_none_match, - if_modified_since=_if_modified_since, - if_unmodified_since=_if_unmodified_since, - source_if_match=_source_if_match, - source_if_none_match=_source_if_none_match, - source_if_modified_since=_source_if_modified_since, - source_if_unmodified_since=_source_if_unmodified_since, - encryption_key=_encryption_key, - encryption_key_sha256=_encryption_key_sha256, - encryption_algorithm=_encryption_algorithm, # type: ignore - owner=owner, - group=group, - acl=acl, - proposed_lease_id=proposed_lease_id, - lease_duration=lease_duration, - expiry_options=expiry_options, - expires_on=expires_on, - encryption_context=encryption_context, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = 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["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) - 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["x-ms-continuation"] = self._deserialize("str", response.headers.get("x-ms-continuation")) - response_headers["Content-Length"] = self._deserialize("int", response.headers.get("Content-Length")) - response_headers["x-ms-request-server-encrypted"] = self._deserialize( - "bool", response.headers.get("x-ms-request-server-encrypted") - ) - response_headers["x-ms-encryption-key-sha256"] = self._deserialize( - "str", response.headers.get("x-ms-encryption-key-sha256") - ) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @distributed_trace - def update( # pylint: disable=too-many-locals - self, - action: Union[str, _models.PathUpdateAction], - mode: Union[str, _models.PathSetAccessControlRecursiveMode], - body: IO[bytes], - request_id_parameter: Optional[str] = None, - timeout: Optional[int] = None, - max_records: Optional[int] = None, - continuation: Optional[str] = None, - force_flag: Optional[bool] = None, - position: Optional[int] = None, - retain_uncommitted_data: Optional[bool] = None, - close: Optional[bool] = None, - content_length: Optional[int] = None, - properties: Optional[str] = None, - owner: Optional[str] = None, - group: Optional[str] = None, - permissions: Optional[str] = None, - acl: Optional[str] = None, - structured_body_type: Optional[str] = None, - structured_content_length: Optional[int] = None, - path_http_headers: Optional[_models.PathHTTPHeaders] = None, - lease_access_conditions: Optional[_models.LeaseAccessConditions] = None, - modified_access_conditions: Optional[_models.ModifiedAccessConditions] = None, - **kwargs: Any - ) -> Optional[_models.SetAccessControlRecursiveResponse]: - """Append Data | Flush Data | Set Properties | Set Access Control. - - Uploads data to be appended to a file, flushes (writes) previously uploaded data to a file, - sets properties for a file or directory, or sets access control for a file or directory. Data - can only be appended to a file. Concurrent writes to the same file using multiple clients are - not supported. This operation supports conditional HTTP requests. For more information, see - `Specifying Conditional Headers for Blob Service Operations - `_. - - :param action: The action must be "append" to upload data to be appended to a file, "flush" to - flush previously uploaded data to a file, "setProperties" to set the properties of a file or - directory, "setAccessControl" to set the owner, group, permissions, or access control list for - a file or directory, or "setAccessControlRecursive" to set the access control list for a - directory recursively. Note that Hierarchical Namespace must be enabled for the account in - order to use access control. Also note that the Access Control List (ACL) includes permissions - for the owner, owning group, and others, so the x-ms-permissions and x-ms-acl request headers - are mutually exclusive. Known values are: "append", "flush", "setProperties", - "setAccessControl", and "setAccessControlRecursive". Required. - :type action: str or ~azure.storage.filedatalake.models.PathUpdateAction - :param mode: Mode "set" sets POSIX access control rights on files and directories, "modify" - modifies one or more POSIX access control rights that pre-exist on files and directories, - "remove" removes one or more POSIX access control rights that were present earlier on files - and directories. Known values are: "set", "modify", and "remove". Required. - :type mode: str or ~azure.storage.filedatalake.models.PathSetAccessControlRecursiveMode - :param body: Initial data. Required. - :type body: IO[bytes] - :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 timeout: The timeout parameter is expressed in seconds. For more information, see - :code:`Setting - Timeouts for Blob Service Operations.`. Default value is None. - :type timeout: int - :param max_records: Optional. Valid for "SetAccessControlRecursive" operation. It specifies the - maximum number of files or directories on which the acl change will be applied. If omitted or - greater than 2,000, the request will process up to 2,000 items. Default value is None. - :type max_records: int - :param continuation: Optional. The number of paths processed with each invocation is limited. - If the number of paths to be processed exceeds this limit, a continuation token is returned in - the response header x-ms-continuation. When a continuation token is returned in the response, - it must be percent-encoded and specified in a subsequent invocation of - setAccessControlRecursive operation. Default value is None. - :type continuation: str - :param force_flag: Optional. Valid for "SetAccessControlRecursive" operation. If set to false, - the operation will terminate quickly on encountering user errors (4XX). If true, the operation - will ignore user errors and proceed with the operation on other sub-entities of the directory. - Continuation token will only be returned when forceFlag is true in case of user errors. If not - set the default value is false for this. Default value is None. - :type force_flag: bool - :param position: This parameter allows the caller to upload data in parallel and control the - order in which it is appended to the file. It is required when uploading data to be appended - to the file and when flushing previously uploaded data to the file. The value must be the - position where the data is to be appended. Uploaded data is not immediately flushed, or - written, to the file. To flush, the previously uploaded data must be contiguous, the position - parameter must be specified and equal to the length of the file after all data has been - written, and there must not be a request entity body included with the request. Default value - is None. - :type position: int - :param retain_uncommitted_data: Valid only for flush operations. If "true", uncommitted data - is retained after the flush operation completes; otherwise, the uncommitted data is deleted - after the flush operation. The default is false. Data at offsets less than the specified - position are written to the file when flush succeeds, but this optional parameter allows data - after the flush position to be retained for a future flush operation. Default value is None. - :type retain_uncommitted_data: bool - :param close: Azure Storage Events allow applications to receive notifications when files - change. When Azure Storage Events are enabled, a file changed event is raised. This event has a - property indicating whether this is the final change to distinguish the difference between an - intermediate flush to a file stream and the final close of a file stream. The close query - parameter is valid only when the action is "flush" and change notifications are enabled. If the - value of close is "true" and the flush operation completes successfully, the service raises a - file change notification with a property indicating that this is the final update (the file - stream has been closed). If "false" a change notification is raised indicating the file has - changed. The default is false. This query parameter is set to true by the Hadoop ABFS driver to - indicate that the file stream has been closed.". Default value is None. - :type close: bool - :param content_length: Required for "Append Data" and "Flush Data". Must be 0 for "Flush - Data". Must be the length of the request content in bytes for "Append Data". Default value is - None. - :type content_length: int - :param properties: Optional. User-defined properties to be stored with the filesystem, in the - format of a comma-separated list of name and value pairs "n1=v1, n2=v2, ...", where each value - is a base64 encoded string. Note that the string may only contain ASCII characters in the - ISO-8859-1 character set. If the filesystem exists, any properties not included in the list - will be removed. All properties are removed if the header is omitted. To merge new and - existing properties, first get all existing properties and the current E-Tag, then make a - conditional request with the E-Tag and include values for all properties. Default value is - None. - :type properties: str - :param owner: Optional. The owner of the blob or directory. Default value is None. - :type owner: str - :param group: Optional. The owning group of the blob or directory. Default value is None. - :type group: str - :param permissions: Optional and only valid if Hierarchical Namespace is enabled for the - account. Sets POSIX access permissions for the file owner, the file owning group, and others. - Each class may be granted read, write, or execute permission. The sticky bit is also - supported. Both symbolic (rwxrw-rw-) and 4-digit octal notation (e.g. 0766) are supported. - Default value is None. - :type permissions: str - :param acl: Sets POSIX access control rights on files and directories. The value is a - comma-separated list of access control entries. Each access control entry (ACE) consists of a - scope, a type, a user or group identifier, and permissions in the format - "[scope:][type]:[id]:[permissions]". Default value is None. - :type acl: str - :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 path_http_headers: Parameter group. Default value is None. - :type path_http_headers: ~azure.storage.filedatalake.models.PathHTTPHeaders - :param lease_access_conditions: Parameter group. Default value is None. - :type lease_access_conditions: ~azure.storage.filedatalake.models.LeaseAccessConditions - :param modified_access_conditions: Parameter group. Default value is None. - :type modified_access_conditions: ~azure.storage.filedatalake.models.ModifiedAccessConditions - :return: SetAccessControlRecursiveResponse or None or the result of cls(response) - :rtype: ~azure.storage.filedatalake.models.SetAccessControlRecursiveResponse or 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 {} - - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/octet-stream")) - cls: ClsType[Optional[_models.SetAccessControlRecursiveResponse]] = kwargs.pop("cls", None) - - _content_md5 = None - _lease_id = None - _cache_control = None - _content_type_parameter = None - _content_disposition = None - _content_encoding = None - _content_language = None - _if_match = None - _if_none_match = None - _if_modified_since = None - _if_unmodified_since = None - if path_http_headers is not None: - _cache_control = path_http_headers.cache_control - _content_disposition = path_http_headers.content_disposition - _content_encoding = path_http_headers.content_encoding - _content_language = path_http_headers.content_language - _content_md5 = path_http_headers.content_md5 - _content_type_parameter = path_http_headers.content_type - if lease_access_conditions is not None: - _lease_id = lease_access_conditions.lease_id - if modified_access_conditions is not None: - _if_match = modified_access_conditions.if_match - _if_modified_since = modified_access_conditions.if_modified_since - _if_none_match = modified_access_conditions.if_none_match - _if_unmodified_since = modified_access_conditions.if_unmodified_since - _content = body - - _request = build_update_request( - url=self._config.url, - action=action, - mode=mode, - version=self._config.version, - request_id_parameter=request_id_parameter, - timeout=timeout, - max_records=max_records, - continuation=continuation, - force_flag=force_flag, - position=position, - retain_uncommitted_data=retain_uncommitted_data, - close=close, - content_length=content_length, - content_md5=_content_md5, - lease_id=_lease_id, - cache_control=_cache_control, - content_type_parameter=_content_type_parameter, - content_disposition=_content_disposition, - content_encoding=_content_encoding, - content_language=_content_language, - properties=properties, - owner=owner, - group=group, - permissions=permissions, - acl=acl, - if_match=_if_match, - if_none_match=_if_none_match, - if_modified_since=_if_modified_since, - if_unmodified_since=_if_unmodified_since, - structured_body_type=structured_body_type, - structured_content_length=structured_content_length, - content_type=content_type, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 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) - - deserialized = None - response_headers = {} - if response.status_code == 200: - response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) - 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["Accept-Ranges"] = self._deserialize("str", response.headers.get("Accept-Ranges")) - 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-Encoding"] = self._deserialize("str", response.headers.get("Content-Encoding")) - response_headers["Content-Language"] = self._deserialize("str", response.headers.get("Content-Language")) - response_headers["Content-Length"] = self._deserialize("int", response.headers.get("Content-Length")) - response_headers["Content-Range"] = self._deserialize("str", response.headers.get("Content-Range")) - response_headers["Content-Type"] = self._deserialize("str", response.headers.get("Content-Type")) - response_headers["Content-MD5"] = self._deserialize("str", response.headers.get("Content-MD5")) - response_headers["x-ms-properties"] = self._deserialize("str", response.headers.get("x-ms-properties")) - response_headers["x-ms-continuation"] = self._deserialize("str", response.headers.get("x-ms-continuation")) - 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("SetAccessControlRecursiveResponse", pipeline_response.http_response) - - if response.status_code == 202: - response_headers["Content-MD5"] = self._deserialize("str", response.headers.get("Content-MD5")) - response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) - 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["x-ms-structured-body"] = self._deserialize( - "str", response.headers.get("x-ms-structured-body") - ) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def lease( # pylint: disable=inconsistent-return-statements - self, - x_ms_lease_action: Union[str, _models.PathLeaseAction], - request_id_parameter: Optional[str] = None, - timeout: Optional[int] = None, - x_ms_lease_break_period: Optional[int] = None, - proposed_lease_id: Optional[str] = None, - lease_access_conditions: Optional[_models.LeaseAccessConditions] = None, - modified_access_conditions: Optional[_models.ModifiedAccessConditions] = None, - **kwargs: Any - ) -> None: - """Lease Path. - - Create and manage a lease to restrict write and delete access to the path. This operation - supports conditional HTTP requests. For more information, see `Specifying Conditional Headers - for Blob Service Operations - `_. - - :param x_ms_lease_action: There are five lease actions: "acquire", "break", "change", "renew", - and "release". Use "acquire" and specify the "x-ms-proposed-lease-id" and "x-ms-lease-duration" - to acquire a new lease. Use "break" to break an existing lease. When a lease is broken, the - lease break period is allowed to elapse, during which time no lease operation except break and - release can be performed on the file. When a lease is successfully broken, the response - indicates the interval in seconds until a new lease can be acquired. Use "change" and specify - the current lease ID in "x-ms-lease-id" and the new lease ID in "x-ms-proposed-lease-id" to - change the lease ID of an active lease. Use "renew" and specify the "x-ms-lease-id" to renew an - existing lease. Use "release" and specify the "x-ms-lease-id" to release a lease. Known values - are: "acquire", "break", "change", "renew", and "release". Required. - :type x_ms_lease_action: str or ~azure.storage.filedatalake.models.PathLeaseAction - :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 timeout: The timeout parameter is expressed in seconds. For more information, see - :code:`Setting - Timeouts for Blob Service Operations.`. Default value is None. - :type timeout: int - :param x_ms_lease_break_period: The lease break period duration is optional to break a lease, - and specifies the break period of the lease in seconds. The lease break duration must be - between 0 and 60 seconds. Default value is None. - :type x_ms_lease_break_period: int - :param proposed_lease_id: Proposed lease ID, in a GUID string format. The Blob 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 lease_access_conditions: Parameter group. Default value is None. - :type lease_access_conditions: ~azure.storage.filedatalake.models.LeaseAccessConditions - :param modified_access_conditions: Parameter group. Default value is None. - :type modified_access_conditions: ~azure.storage.filedatalake.models.ModifiedAccessConditions - :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_match = None - _if_none_match = None - _if_modified_since = None - _if_unmodified_since = None - if lease_access_conditions is not None: - _lease_id = lease_access_conditions.lease_id - if modified_access_conditions is not None: - _if_match = modified_access_conditions.if_match - _if_modified_since = modified_access_conditions.if_modified_since - _if_none_match = modified_access_conditions.if_none_match - _if_unmodified_since = modified_access_conditions.if_unmodified_since - - _request = build_lease_request( - url=self._config.url, - x_ms_lease_action=x_ms_lease_action, - version=self._config.version, - request_id_parameter=request_id_parameter, - timeout=timeout, - x_ms_lease_break_period=x_ms_lease_break_period, - lease_id=_lease_id, - proposed_lease_id=proposed_lease_id, - if_match=_if_match, - if_none_match=_if_none_match, - if_modified_since=_if_modified_since, - if_unmodified_since=_if_unmodified_since, - x_ms_lease_duration=self._config.x_ms_lease_duration, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201, 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 = {} - if response.status_code == 200: - response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) - 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["x-ms-lease-id"] = self._deserialize("str", response.headers.get("x-ms-lease-id")) - - if response.status_code == 201: - response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) - 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["x-ms-lease-id"] = self._deserialize("str", response.headers.get("x-ms-lease-id")) - - if response.status_code == 202: - 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["x-ms-lease-time"] = self._deserialize("str", response.headers.get("x-ms-lease-time")) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @distributed_trace - def read( - self, - request_id_parameter: Optional[str] = None, - timeout: Optional[int] = None, - range: Optional[str] = None, - x_ms_range_get_content_md5: Optional[bool] = None, - lease_access_conditions: Optional[_models.LeaseAccessConditions] = None, - modified_access_conditions: Optional[_models.ModifiedAccessConditions] = None, - cpk_info: Optional[_models.CpkInfo] = None, - **kwargs: Any - ) -> Iterator[bytes]: - """Read File. - - Read the contents of a file. For read operations, range requests are supported. This operation - supports conditional HTTP requests. For more information, see `Specifying Conditional Headers - for Blob Service Operations - `_. - - :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 timeout: The timeout parameter is expressed in seconds. For more information, see - :code:`Setting - Timeouts for Blob Service Operations.`. Default value is None. - :type timeout: int - :param range: The HTTP Range request header specifies one or more byte ranges of the resource - to be retrieved. Default value is None. - :type range: str - :param x_ms_range_get_content_md5: Optional. 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 4MB in size. If this header is specified without the Range - header, the service returns status code 400 (Bad Request). If this header is set to true when - the range exceeds 4 MB in size, the service returns status code 400 (Bad Request). Default - value is None. - :type x_ms_range_get_content_md5: bool - :param lease_access_conditions: Parameter group. Default value is None. - :type lease_access_conditions: ~azure.storage.filedatalake.models.LeaseAccessConditions - :param modified_access_conditions: Parameter group. Default value is None. - :type modified_access_conditions: ~azure.storage.filedatalake.models.ModifiedAccessConditions - :param cpk_info: Parameter group. Default value is None. - :type cpk_info: ~azure.storage.filedatalake.models.CpkInfo - :return: Iterator[bytes] or the result of cls(response) - :rtype: Iterator[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[Iterator[bytes]] = kwargs.pop("cls", None) - - _lease_id = None - _if_match = None - _if_none_match = None - _if_modified_since = None - _if_unmodified_since = None - _encryption_key = None - _encryption_key_sha256 = None - _encryption_algorithm = None - if lease_access_conditions is not None: - _lease_id = lease_access_conditions.lease_id - if modified_access_conditions is not None: - _if_match = modified_access_conditions.if_match - _if_modified_since = modified_access_conditions.if_modified_since - _if_none_match = modified_access_conditions.if_none_match - _if_unmodified_since = modified_access_conditions.if_unmodified_since - if cpk_info is not None: - _encryption_algorithm = cpk_info.encryption_algorithm - _encryption_key = cpk_info.encryption_key - _encryption_key_sha256 = cpk_info.encryption_key_sha256 - - _request = build_read_request( - url=self._config.url, - version=self._config.version, - request_id_parameter=request_id_parameter, - timeout=timeout, - range=range, - lease_id=_lease_id, - x_ms_range_get_content_md5=x_ms_range_get_content_md5, - if_match=_if_match, - if_none_match=_if_none_match, - if_modified_since=_if_modified_since, - if_unmodified_since=_if_unmodified_since, - encryption_key=_encryption_key, - encryption_key_sha256=_encryption_key_sha256, - encryption_algorithm=_encryption_algorithm, # type: ignore - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = 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: - 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 = {} - if response.status_code == 200: - response_headers["Accept-Ranges"] = self._deserialize("str", response.headers.get("Accept-Ranges")) - 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-Encoding"] = self._deserialize("str", response.headers.get("Content-Encoding")) - response_headers["Content-Language"] = self._deserialize("str", response.headers.get("Content-Language")) - response_headers["Content-Length"] = self._deserialize("int", response.headers.get("Content-Length")) - response_headers["Content-Range"] = self._deserialize("str", response.headers.get("Content-Range")) - response_headers["Content-Type"] = self._deserialize("str", response.headers.get("Content-Type")) - response_headers["Content-MD5"] = self._deserialize("str", response.headers.get("Content-MD5")) - response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) - 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["x-ms-resource-type"] = self._deserialize( - "str", response.headers.get("x-ms-resource-type") - ) - response_headers["x-ms-properties"] = self._deserialize("str", response.headers.get("x-ms-properties")) - 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-request-server-encrypted"] = self._deserialize( - "bool", response.headers.get("x-ms-request-server-encrypted") - ) - response_headers["x-ms-encryption-key-sha256"] = self._deserialize( - "str", response.headers.get("x-ms-encryption-key-sha256") - ) - - if response.status_code == 206: - response_headers["Accept-Ranges"] = self._deserialize("str", response.headers.get("Accept-Ranges")) - 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-Encoding"] = self._deserialize("str", response.headers.get("Content-Encoding")) - response_headers["Content-Language"] = self._deserialize("str", response.headers.get("Content-Language")) - response_headers["Content-Length"] = self._deserialize("int", response.headers.get("Content-Length")) - response_headers["Content-Range"] = self._deserialize("str", response.headers.get("Content-Range")) - response_headers["Content-Type"] = self._deserialize("str", response.headers.get("Content-Type")) - response_headers["Content-MD5"] = self._deserialize("str", response.headers.get("Content-MD5")) - response_headers["x-ms-content-md5"] = self._deserialize("str", response.headers.get("x-ms-content-md5")) - response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) - 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["x-ms-resource-type"] = self._deserialize( - "str", response.headers.get("x-ms-resource-type") - ) - response_headers["x-ms-properties"] = self._deserialize("str", response.headers.get("x-ms-properties")) - 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-request-server-encrypted"] = self._deserialize( - "bool", response.headers.get("x-ms-request-server-encrypted") - ) - response_headers["x-ms-encryption-key-sha256"] = self._deserialize( - "str", response.headers.get("x-ms-encryption-key-sha256") - ) - - 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 - def get_properties( # pylint: disable=inconsistent-return-statements - self, - request_id_parameter: Optional[str] = None, - timeout: Optional[int] = None, - action: Optional[Union[str, _models.PathGetPropertiesAction]] = None, - upn: Optional[bool] = None, - lease_access_conditions: Optional[_models.LeaseAccessConditions] = None, - modified_access_conditions: Optional[_models.ModifiedAccessConditions] = None, - **kwargs: Any - ) -> None: - """Get Properties | Get Status | Get Access Control List. - - Get Properties returns all system and user defined properties for a path. Get Status returns - all system defined properties for a path. Get Access Control List returns the access control - list for a path. This operation supports conditional HTTP requests. For more information, see - `Specifying Conditional Headers for Blob Service Operations - `_. - - :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 timeout: The timeout parameter is expressed in seconds. For more information, see - :code:`Setting - Timeouts for Blob Service Operations.`. Default value is None. - :type timeout: int - :param action: Optional. If the value is "getStatus" only the system defined properties for the - path are returned. If the value is "getAccessControl" the access control list is returned in - the response headers (Hierarchical Namespace must be enabled for the account), otherwise the - properties are returned. Known values are: "getAccessControl" and "getStatus". Default value is - None. - :type action: str or ~azure.storage.filedatalake.models.PathGetPropertiesAction - :param upn: Optional. Valid only when Hierarchical Namespace is enabled for the account. If - "true", the user identity values returned in the x-ms-owner, x-ms-group, and x-ms-acl response - headers will be transformed from Azure Active Directory Object IDs to User Principal Names. If - "false", the values will be returned as Azure Active Directory Object IDs. The default value is - false. Note that group and application Object IDs are not translated because they do not have - unique friendly names. Default value is None. - :type upn: bool - :param lease_access_conditions: Parameter group. Default value is None. - :type lease_access_conditions: ~azure.storage.filedatalake.models.LeaseAccessConditions - :param modified_access_conditions: Parameter group. Default value is None. - :type modified_access_conditions: ~azure.storage.filedatalake.models.ModifiedAccessConditions - :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_match = None - _if_none_match = None - _if_modified_since = None - _if_unmodified_since = None - if lease_access_conditions is not None: - _lease_id = lease_access_conditions.lease_id - if modified_access_conditions is not None: - _if_match = modified_access_conditions.if_match - _if_modified_since = modified_access_conditions.if_modified_since - _if_none_match = modified_access_conditions.if_none_match - _if_unmodified_since = modified_access_conditions.if_unmodified_since - - _request = build_get_properties_request( - url=self._config.url, - version=self._config.version, - request_id_parameter=request_id_parameter, - timeout=timeout, - action=action, - upn=upn, - lease_id=_lease_id, - if_match=_if_match, - if_none_match=_if_none_match, - if_modified_since=_if_modified_since, - if_unmodified_since=_if_unmodified_since, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = 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["Accept-Ranges"] = self._deserialize("str", response.headers.get("Accept-Ranges")) - 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-Encoding"] = self._deserialize("str", response.headers.get("Content-Encoding")) - response_headers["Content-Language"] = self._deserialize("str", response.headers.get("Content-Language")) - response_headers["Content-Length"] = self._deserialize("int", response.headers.get("Content-Length")) - response_headers["Content-Range"] = self._deserialize("str", response.headers.get("Content-Range")) - response_headers["Content-Type"] = self._deserialize("str", response.headers.get("Content-Type")) - response_headers["Content-MD5"] = self._deserialize("str", response.headers.get("Content-MD5")) - response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) - 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["x-ms-resource-type"] = self._deserialize("str", response.headers.get("x-ms-resource-type")) - response_headers["x-ms-properties"] = self._deserialize("str", response.headers.get("x-ms-properties")) - 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-permissions"] = self._deserialize("str", response.headers.get("x-ms-permissions")) - response_headers["x-ms-acl"] = self._deserialize("str", response.headers.get("x-ms-acl")) - 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-server-encrypted"] = self._deserialize( - "bool", response.headers.get("x-ms-server-encrypted") - ) - response_headers["x-ms-encryption-key-sha256"] = self._deserialize( - "str", response.headers.get("x-ms-encryption-key-sha256") - ) - response_headers["x-ms-encryption-context"] = self._deserialize( - "str", response.headers.get("x-ms-encryption-context") - ) - response_headers["x-ms-encryption-scope"] = self._deserialize( - "str", response.headers.get("x-ms-encryption-scope") - ) - response_headers["x-ms-creation-time"] = self._deserialize( - "rfc-1123", response.headers.get("x-ms-creation-time") - ) - response_headers["x-ms-expiry-time"] = self._deserialize("rfc-1123", response.headers.get("x-ms-expiry-time")) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, - request_id_parameter: Optional[str] = None, - timeout: Optional[int] = None, - recursive: Optional[bool] = None, - continuation: Optional[str] = None, - paginated: Optional[bool] = None, - lease_access_conditions: Optional[_models.LeaseAccessConditions] = None, - modified_access_conditions: Optional[_models.ModifiedAccessConditions] = None, - **kwargs: Any - ) -> None: - """Delete File | Delete Directory. - - Delete the file or directory. This operation supports conditional HTTP requests. For more - information, see `Specifying Conditional Headers for Blob Service Operations - `_. - - :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 timeout: The timeout parameter is expressed in seconds. For more information, see - :code:`Setting - Timeouts for Blob Service Operations.`. Default value is None. - :type timeout: int - :param recursive: Required. Default value is None. - :type recursive: bool - :param continuation: Optional. When deleting a directory, the number of paths that are deleted - with each invocation is limited. If the number of paths to be deleted exceeds this limit, a - continuation token is returned in this response header. When a continuation token is returned - in the response, it must be specified in a subsequent invocation of the delete operation to - continue deleting the directory. Default value is None. - :type continuation: str - :param paginated: If true, paginated behavior will be seen. Pagination is for the recursive ACL - checks as a POSIX requirement in the server and Delete in an atomic operation once the ACL - checks are completed. If false or missing, normal default behavior will kick in, which may - timeout in case of very large directories due to recursive ACL checks. This new parameter is - introduced for backward compatibility. Default value is None. - :type paginated: bool - :param lease_access_conditions: Parameter group. Default value is None. - :type lease_access_conditions: ~azure.storage.filedatalake.models.LeaseAccessConditions - :param modified_access_conditions: Parameter group. Default value is None. - :type modified_access_conditions: ~azure.storage.filedatalake.models.ModifiedAccessConditions - :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_match = None - _if_none_match = None - _if_modified_since = None - _if_unmodified_since = None - if lease_access_conditions is not None: - _lease_id = lease_access_conditions.lease_id - if modified_access_conditions is not None: - _if_match = modified_access_conditions.if_match - _if_modified_since = modified_access_conditions.if_modified_since - _if_none_match = modified_access_conditions.if_none_match - _if_unmodified_since = modified_access_conditions.if_unmodified_since - - _request = build_delete_request( - url=self._config.url, - version=self._config.version, - request_id_parameter=request_id_parameter, - timeout=timeout, - recursive=recursive, - continuation=continuation, - lease_id=_lease_id, - if_match=_if_match, - if_none_match=_if_none_match, - if_modified_since=_if_modified_since, - if_unmodified_since=_if_unmodified_since, - paginated=paginated, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 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 = {} - if response.status_code == 200: - response_headers["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) - 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["x-ms-continuation"] = self._deserialize("str", response.headers.get("x-ms-continuation")) - response_headers["x-ms-deletion-id"] = self._deserialize("str", response.headers.get("x-ms-deletion-id")) - - if response.status_code == 202: - response_headers["Date"] = self._deserialize("str", response.headers.get("Date")) - 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["x-ms-continuation"] = self._deserialize("str", response.headers.get("x-ms-continuation")) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @distributed_trace - def set_access_control( # pylint: disable=inconsistent-return-statements - self, - timeout: Optional[int] = None, - owner: Optional[str] = None, - group: Optional[str] = None, - permissions: Optional[str] = None, - acl: Optional[str] = None, - request_id_parameter: Optional[str] = None, - lease_access_conditions: Optional[_models.LeaseAccessConditions] = None, - modified_access_conditions: Optional[_models.ModifiedAccessConditions] = None, - **kwargs: Any - ) -> None: - """Set the owner, group, permissions, or access control list for a path. - - :param timeout: The timeout parameter is expressed in seconds. For more information, see - :code:`Setting - Timeouts for Blob Service Operations.`. Default value is None. - :type timeout: int - :param owner: Optional. The owner of the blob or directory. Default value is None. - :type owner: str - :param group: Optional. The owning group of the blob or directory. Default value is None. - :type group: str - :param permissions: Optional and only valid if Hierarchical Namespace is enabled for the - account. Sets POSIX access permissions for the file owner, the file owning group, and others. - Each class may be granted read, write, or execute permission. The sticky bit is also - supported. Both symbolic (rwxrw-rw-) and 4-digit octal notation (e.g. 0766) are supported. - Default value is None. - :type permissions: str - :param acl: Sets POSIX access control rights on files and directories. The value is a - comma-separated list of access control entries. Each access control entry (ACE) consists of a - scope, a type, a user or group identifier, and permissions in the format - "[scope:][type]:[id]:[permissions]". Default value is None. - :type acl: 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 lease_access_conditions: Parameter group. Default value is None. - :type lease_access_conditions: ~azure.storage.filedatalake.models.LeaseAccessConditions - :param modified_access_conditions: Parameter group. Default value is None. - :type modified_access_conditions: ~azure.storage.filedatalake.models.ModifiedAccessConditions - :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 {}) - - action: Literal["setAccessControl"] = kwargs.pop("action", _params.pop("action", "setAccessControl")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _lease_id = None - _if_match = None - _if_none_match = None - _if_modified_since = None - _if_unmodified_since = None - if lease_access_conditions is not None: - _lease_id = lease_access_conditions.lease_id - if modified_access_conditions is not None: - _if_match = modified_access_conditions.if_match - _if_modified_since = modified_access_conditions.if_modified_since - _if_none_match = modified_access_conditions.if_none_match - _if_unmodified_since = modified_access_conditions.if_unmodified_since - - _request = build_set_access_control_request( - url=self._config.url, - version=self._config.version, - timeout=timeout, - lease_id=_lease_id, - owner=owner, - group=group, - permissions=permissions, - acl=acl, - if_match=_if_match, - if_none_match=_if_none_match, - if_modified_since=_if_modified_since, - if_unmodified_since=_if_unmodified_since, - request_id_parameter=request_id_parameter, - action=action, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = 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["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) - 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")) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @distributed_trace - def set_access_control_recursive( - self, - mode: Union[str, _models.PathSetAccessControlRecursiveMode], - timeout: Optional[int] = None, - continuation: Optional[str] = None, - force_flag: Optional[bool] = None, - max_records: Optional[int] = None, - acl: Optional[str] = None, - request_id_parameter: Optional[str] = None, - **kwargs: Any - ) -> _models.SetAccessControlRecursiveResponse: - """Set the access control list for a path and sub-paths. - - :param mode: Mode "set" sets POSIX access control rights on files and directories, "modify" - modifies one or more POSIX access control rights that pre-exist on files and directories, - "remove" removes one or more POSIX access control rights that were present earlier on files - and directories. Known values are: "set", "modify", and "remove". Required. - :type mode: str or ~azure.storage.filedatalake.models.PathSetAccessControlRecursiveMode - :param timeout: The timeout parameter is expressed in seconds. For more information, see - :code:`Setting - Timeouts for Blob Service Operations.`. Default value is None. - :type timeout: int - :param continuation: Optional. When deleting a directory, the number of paths that are deleted - with each invocation is limited. If the number of paths to be deleted exceeds this limit, a - continuation token is returned in this response header. When a continuation token is returned - in the response, it must be specified in a subsequent invocation of the delete operation to - continue deleting the directory. Default value is None. - :type continuation: str - :param force_flag: Optional. Valid for "SetAccessControlRecursive" operation. If set to false, - the operation will terminate quickly on encountering user errors (4XX). If true, the operation - will ignore user errors and proceed with the operation on other sub-entities of the directory. - Continuation token will only be returned when forceFlag is true in case of user errors. If not - set the default value is false for this. Default value is None. - :type force_flag: bool - :param max_records: Optional. It specifies the maximum number of files or directories on which - the acl change will be applied. If omitted or greater than 2,000, the request will process up - to 2,000 items. Default value is None. - :type max_records: int - :param acl: Sets POSIX access control rights on files and directories. The value is a - comma-separated list of access control entries. Each access control entry (ACE) consists of a - scope, a type, a user or group identifier, and permissions in the format - "[scope:][type]:[id]:[permissions]". Default value is None. - :type acl: 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: SetAccessControlRecursiveResponse or the result of cls(response) - :rtype: ~azure.storage.filedatalake.models.SetAccessControlRecursiveResponse - :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 {}) - - action: Literal["setAccessControlRecursive"] = kwargs.pop( - "action", _params.pop("action", "setAccessControlRecursive") - ) - cls: ClsType[_models.SetAccessControlRecursiveResponse] = kwargs.pop("cls", None) - - _request = build_set_access_control_recursive_request( - url=self._config.url, - mode=mode, - version=self._config.version, - timeout=timeout, - continuation=continuation, - force_flag=force_flag, - max_records=max_records, - acl=acl, - request_id_parameter=request_id_parameter, - action=action, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = 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["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) - response_headers["x-ms-client-request-id"] = self._deserialize( - "str", response.headers.get("x-ms-client-request-id") - ) - response_headers["x-ms-continuation"] = self._deserialize("str", response.headers.get("x-ms-continuation")) - 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("SetAccessControlRecursiveResponse", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def flush_data( # pylint: disable=inconsistent-return-statements,too-many-locals - self, - timeout: Optional[int] = None, - position: Optional[int] = None, - retain_uncommitted_data: Optional[bool] = None, - close: Optional[bool] = None, - content_length: Optional[int] = None, - lease_action: Optional[Union[str, _models.LeaseAction]] = None, - lease_duration: Optional[int] = None, - proposed_lease_id: Optional[str] = None, - request_id_parameter: Optional[str] = None, - path_http_headers: Optional[_models.PathHTTPHeaders] = None, - lease_access_conditions: Optional[_models.LeaseAccessConditions] = None, - modified_access_conditions: Optional[_models.ModifiedAccessConditions] = None, - cpk_info: Optional[_models.CpkInfo] = None, - **kwargs: Any - ) -> None: - """Set the owner, group, permissions, or access control list for a path. - - :param timeout: The timeout parameter is expressed in seconds. For more information, see - :code:`Setting - Timeouts for Blob Service Operations.`. Default value is None. - :type timeout: int - :param position: This parameter allows the caller to upload data in parallel and control the - order in which it is appended to the file. It is required when uploading data to be appended - to the file and when flushing previously uploaded data to the file. The value must be the - position where the data is to be appended. Uploaded data is not immediately flushed, or - written, to the file. To flush, the previously uploaded data must be contiguous, the position - parameter must be specified and equal to the length of the file after all data has been - written, and there must not be a request entity body included with the request. Default value - is None. - :type position: int - :param retain_uncommitted_data: Valid only for flush operations. If "true", uncommitted data - is retained after the flush operation completes; otherwise, the uncommitted data is deleted - after the flush operation. The default is false. Data at offsets less than the specified - position are written to the file when flush succeeds, but this optional parameter allows data - after the flush position to be retained for a future flush operation. Default value is None. - :type retain_uncommitted_data: bool - :param close: Azure Storage Events allow applications to receive notifications when files - change. When Azure Storage Events are enabled, a file changed event is raised. This event has a - property indicating whether this is the final change to distinguish the difference between an - intermediate flush to a file stream and the final close of a file stream. The close query - parameter is valid only when the action is "flush" and change notifications are enabled. If the - value of close is "true" and the flush operation completes successfully, the service raises a - file change notification with a property indicating that this is the final update (the file - stream has been closed). If "false" a change notification is raised indicating the file has - changed. The default is false. This query parameter is set to true by the Hadoop ABFS driver to - indicate that the file stream has been closed.". Default value is None. - :type close: bool - :param content_length: Required for "Append Data" and "Flush Data". Must be 0 for "Flush - Data". Must be the length of the request content in bytes for "Append Data". Default value is - None. - :type content_length: int - :param lease_action: Optional. If "acquire" it will acquire the lease. If "auto-renew" it will - renew the lease. If "release" it will release the lease only on flush. If "acquire-release" it - will acquire & complete the operation & release the lease once operation is done. Known values - are: "acquire", "auto-renew", "release", and "acquire-release". Default value is None. - :type lease_action: str or ~azure.storage.filedatalake.models.LeaseAction - :param lease_duration: The lease duration is required to acquire a lease, and specifies the - duration of the lease in seconds. The lease duration must be between 15 and 60 seconds or -1 - for infinite lease. Default value is None. - :type lease_duration: int - :param proposed_lease_id: Proposed lease ID, in a GUID string format. The Blob 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 - :param path_http_headers: Parameter group. Default value is None. - :type path_http_headers: ~azure.storage.filedatalake.models.PathHTTPHeaders - :param lease_access_conditions: Parameter group. Default value is None. - :type lease_access_conditions: ~azure.storage.filedatalake.models.LeaseAccessConditions - :param modified_access_conditions: Parameter group. Default value is None. - :type modified_access_conditions: ~azure.storage.filedatalake.models.ModifiedAccessConditions - :param cpk_info: Parameter group. Default value is None. - :type cpk_info: ~azure.storage.filedatalake.models.CpkInfo - :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 {}) - - action: Literal["flush"] = kwargs.pop("action", _params.pop("action", "flush")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _content_md5 = None - _lease_id = None - _cache_control = None - _content_type_parameter = None - _content_disposition = None - _content_encoding = None - _content_language = None - _if_match = None - _if_none_match = None - _if_modified_since = None - _if_unmodified_since = None - _encryption_key = None - _encryption_key_sha256 = None - _encryption_algorithm = None - if path_http_headers is not None: - _cache_control = path_http_headers.cache_control - _content_disposition = path_http_headers.content_disposition - _content_encoding = path_http_headers.content_encoding - _content_language = path_http_headers.content_language - _content_md5 = path_http_headers.content_md5 - _content_type_parameter = path_http_headers.content_type - if lease_access_conditions is not None: - _lease_id = lease_access_conditions.lease_id - if modified_access_conditions is not None: - _if_match = modified_access_conditions.if_match - _if_modified_since = modified_access_conditions.if_modified_since - _if_none_match = modified_access_conditions.if_none_match - _if_unmodified_since = modified_access_conditions.if_unmodified_since - if cpk_info is not None: - _encryption_algorithm = cpk_info.encryption_algorithm - _encryption_key = cpk_info.encryption_key - _encryption_key_sha256 = cpk_info.encryption_key_sha256 - - _request = build_flush_data_request( - url=self._config.url, - version=self._config.version, - timeout=timeout, - position=position, - retain_uncommitted_data=retain_uncommitted_data, - close=close, - content_length=content_length, - content_md5=_content_md5, - lease_id=_lease_id, - lease_action=lease_action, - lease_duration=lease_duration, - proposed_lease_id=proposed_lease_id, - cache_control=_cache_control, - content_type_parameter=_content_type_parameter, - content_disposition=_content_disposition, - content_encoding=_content_encoding, - content_language=_content_language, - if_match=_if_match, - if_none_match=_if_none_match, - if_modified_since=_if_modified_since, - if_unmodified_since=_if_unmodified_since, - request_id_parameter=request_id_parameter, - encryption_key=_encryption_key, - encryption_key_sha256=_encryption_key_sha256, - encryption_algorithm=_encryption_algorithm, # type: ignore - action=action, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = 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["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) - 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-Length"] = self._deserialize("int", response.headers.get("Content-Length")) - 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["x-ms-request-server-encrypted"] = self._deserialize( - "bool", response.headers.get("x-ms-request-server-encrypted") - ) - response_headers["x-ms-encryption-key-sha256"] = self._deserialize( - "str", response.headers.get("x-ms-encryption-key-sha256") - ) - response_headers["x-ms-lease-renewed"] = self._deserialize("bool", response.headers.get("x-ms-lease-renewed")) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @distributed_trace - def append_data( # pylint: disable=inconsistent-return-statements,too-many-locals - self, - body: IO[bytes], - position: Optional[int] = None, - timeout: Optional[int] = None, - content_length: Optional[int] = None, - transactional_content_crc64: Optional[bytes] = None, - lease_action: Optional[Union[str, _models.LeaseAction]] = None, - lease_duration: Optional[int] = None, - proposed_lease_id: Optional[str] = None, - request_id_parameter: Optional[str] = None, - flush: Optional[bool] = None, - structured_body_type: Optional[str] = None, - structured_content_length: Optional[int] = None, - path_http_headers: Optional[_models.PathHTTPHeaders] = None, - lease_access_conditions: Optional[_models.LeaseAccessConditions] = None, - cpk_info: Optional[_models.CpkInfo] = None, - **kwargs: Any - ) -> None: - """Append data to the file. - - :param body: Initial data. Required. - :type body: IO[bytes] - :param position: This parameter allows the caller to upload data in parallel and control the - order in which it is appended to the file. It is required when uploading data to be appended - to the file and when flushing previously uploaded data to the file. The value must be the - position where the data is to be appended. Uploaded data is not immediately flushed, or - written, to the file. To flush, the previously uploaded data must be contiguous, the position - parameter must be specified and equal to the length of the file after all data has been - written, and there must not be a request entity body included with the request. Default value - is None. - :type position: int - :param timeout: The timeout parameter is expressed in seconds. For more information, see - :code:`Setting - Timeouts for Blob Service Operations.`. Default value is None. - :type timeout: int - :param content_length: Required for "Append Data" and "Flush Data". Must be 0 for "Flush - Data". Must be the length of the request content in bytes for "Append Data". Default value is - None. - :type content_length: int - :param transactional_content_crc64: Specify the transactional crc64 for the body, to be - validated by the service. Default value is None. - :type transactional_content_crc64: bytes - :param lease_action: Optional. If "acquire" it will acquire the lease. If "auto-renew" it will - renew the lease. If "release" it will release the lease only on flush. If "acquire-release" it - will acquire & complete the operation & release the lease once operation is done. Known values - are: "acquire", "auto-renew", "release", and "acquire-release". Default value is None. - :type lease_action: str or ~azure.storage.filedatalake.models.LeaseAction - :param lease_duration: The lease duration is required to acquire a lease, and specifies the - duration of the lease in seconds. The lease duration must be between 15 and 60 seconds or -1 - for infinite lease. Default value is None. - :type lease_duration: int - :param proposed_lease_id: Proposed lease ID, in a GUID string format. The Blob 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 - :param flush: If file should be flushed after the append. Default value is None. - :type flush: bool - :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 path_http_headers: Parameter group. Default value is None. - :type path_http_headers: ~azure.storage.filedatalake.models.PathHTTPHeaders - :param lease_access_conditions: Parameter group. Default value is None. - :type lease_access_conditions: ~azure.storage.filedatalake.models.LeaseAccessConditions - :param cpk_info: Parameter group. Default value is None. - :type cpk_info: ~azure.storage.filedatalake.models.CpkInfo - :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 {}) - - action: Literal["append"] = kwargs.pop("action", _params.pop("action", "append")) - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _transactional_content_hash = None - _lease_id = None - _encryption_key = None - _encryption_key_sha256 = None - _encryption_algorithm = None - if path_http_headers is not None: - _transactional_content_hash = path_http_headers.transactional_content_hash - if lease_access_conditions is not None: - _lease_id = lease_access_conditions.lease_id - if cpk_info is not None: - _encryption_algorithm = cpk_info.encryption_algorithm - _encryption_key = cpk_info.encryption_key - _encryption_key_sha256 = cpk_info.encryption_key_sha256 - _content = body - - _request = build_append_data_request( - url=self._config.url, - version=self._config.version, - position=position, - timeout=timeout, - content_length=content_length, - transactional_content_hash=_transactional_content_hash, - transactional_content_crc64=transactional_content_crc64, - lease_id=_lease_id, - lease_action=lease_action, - lease_duration=lease_duration, - proposed_lease_id=proposed_lease_id, - request_id_parameter=request_id_parameter, - encryption_key=_encryption_key, - encryption_key_sha256=_encryption_key_sha256, - encryption_algorithm=_encryption_algorithm, # type: ignore - flush=flush, - structured_body_type=structured_body_type, - structured_content_length=structured_content_length, - action=action, - content_type=content_type, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = 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["Date"] = self._deserialize("rfc-1123", response.headers.get("Date")) - 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["ETag"] = self._deserialize("str", response.headers.get("ETag")) - response_headers["Content-MD5"] = self._deserialize("bytearray", response.headers.get("Content-MD5")) - response_headers["x-ms-content-crc64"] = self._deserialize( - "bytearray", response.headers.get("x-ms-content-crc64") - ) - response_headers["x-ms-request-server-encrypted"] = self._deserialize( - "bool", response.headers.get("x-ms-request-server-encrypted") - ) - response_headers["x-ms-encryption-key-sha256"] = self._deserialize( - "str", response.headers.get("x-ms-encryption-key-sha256") - ) - response_headers["x-ms-lease-renewed"] = self._deserialize("bool", response.headers.get("x-ms-lease-renewed")) - 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 - def set_expiry( # pylint: disable=inconsistent-return-statements - self, - expiry_options: Union[str, _models.PathExpiryOptions], - timeout: Optional[int] = None, - request_id_parameter: Optional[str] = None, - expires_on: Optional[str] = None, - **kwargs: Any - ) -> None: - """Sets the time a blob will expire and be deleted. - - :param expiry_options: Required. Indicates mode of the expiry time. Known values are: - "NeverExpire", "RelativeToCreation", "RelativeToNow", and "Absolute". Required. - :type expiry_options: str or ~azure.storage.filedatalake.models.PathExpiryOptions - :param timeout: The timeout parameter is expressed in seconds. For more information, see - :code:`Setting - Timeouts for Blob Service Operations.`. 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 expires_on: The time to set the blob to expiry. Default value is None. - :type expires_on: 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["expiry"] = kwargs.pop("comp", _params.pop("comp", "expiry")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_set_expiry_request( - url=self._config.url, - expiry_options=expiry_options, - version=self._config.version, - timeout=timeout, - request_id_parameter=request_id_parameter, - expires_on=expires_on, - comp=comp, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = 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 - def undelete( # pylint: disable=inconsistent-return-statements - self, - timeout: Optional[int] = None, - undelete_source: Optional[str] = None, - request_id_parameter: Optional[str] = None, - **kwargs: Any - ) -> None: - """Undelete a path that was previously soft deleted. - - :param timeout: The timeout parameter is expressed in seconds. For more information, see - :code:`Setting - Timeouts for Blob Service Operations.`. Default value is None. - :type timeout: int - :param undelete_source: Only for hierarchical namespace enabled accounts. Optional. The path of - the soft deleted blob to undelete. Default value is None. - :type undelete_source: 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 {}) - - comp: Literal["undelete"] = kwargs.pop("comp", _params.pop("comp", "undelete")) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_undelete_request( - url=self._config.url, - version=self._config.version, - timeout=timeout, - undelete_source=undelete_source, - request_id_parameter=request_id_parameter, - comp=comp, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = 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-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-resource-type"] = self._deserialize("str", response.headers.get("x-ms-resource-type")) - 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 diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/operations/_service_operations.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/operations/_service_operations.py deleted file mode 100644 index d0f5d710b7ac..000000000000 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_generated/operations/_service_operations.py +++ /dev/null @@ -1,207 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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 collections.abc import MutableMapping -from typing import Any, Callable, Literal, Optional, TypeVar - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict - -from .. import models as _models -from .._configuration import AzureDataLakeStorageRESTAPIConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_file_systems_request( - url: str, - *, - version: str, - prefix: Optional[str] = None, - continuation: Optional[str] = None, - max_results: Optional[int] = None, - request_id_parameter: Optional[str] = None, - timeout: Optional[int] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - resource: Literal["account"] = kwargs.pop("resource", _params.pop("resource", "account")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "{url}") - path_format_arguments = { - "url": _SERIALIZER.url("url", url, "str", skip_quote=True), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["resource"] = _SERIALIZER.query("resource", resource, "str") - if prefix is not None: - _params["prefix"] = _SERIALIZER.query("prefix", prefix, "str") - if continuation is not None: - _params["continuation"] = _SERIALIZER.query("continuation", continuation, "str") - if max_results is not None: - _params["maxResults"] = _SERIALIZER.query("max_results", max_results, "int", minimum=1) - if timeout is not None: - _params["timeout"] = _SERIALIZER.query("timeout", timeout, "int", minimum=0) - - # Construct headers - if request_id_parameter is not None: - _headers["x-ms-client-request-id"] = _SERIALIZER.header("request_id_parameter", request_id_parameter, "str") - _headers["x-ms-version"] = _SERIALIZER.header("version", version, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class ServiceOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.storage.filedatalake.AzureDataLakeStorageRESTAPI`'s - :attr:`service` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AzureDataLakeStorageRESTAPIConfiguration = ( - 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 - def list_file_systems( - self, - prefix: Optional[str] = None, - continuation: Optional[str] = None, - max_results: Optional[int] = None, - request_id_parameter: Optional[str] = None, - timeout: Optional[int] = None, - **kwargs: Any - ) -> ItemPaged["_models.FileSystem"]: - """List FileSystems. - - List filesystems and their properties in given account. - - :param prefix: Filters results to filesystems within the specified prefix. Default value is - None. - :type prefix: str - :param continuation: Optional. When deleting a directory, the number of paths that are deleted - with each invocation is limited. If the number of paths to be deleted exceeds this limit, a - continuation token is returned in this response header. When a continuation token is returned - in the response, it must be specified in a subsequent invocation of the delete operation to - continue deleting the directory. Default value is None. - :type continuation: str - :param max_results: An optional value that specifies the maximum number of items to return. If - omitted or greater than 5,000, the response will include up to 5,000 items. Default value is - None. - :type max_results: 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 timeout: The timeout parameter is expressed in seconds. For more information, see - :code:`Setting - Timeouts for Blob Service Operations.`. Default value is None. - :type timeout: int - :return: An iterator like instance of either FileSystem or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.storage.filedatalake.models.FileSystem] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - resource: Literal["account"] = kwargs.pop("resource", _params.pop("resource", "account")) - cls: ClsType[_models.FileSystemList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_file_systems_request( - url=self._config.url, - version=self._config.version, - prefix=prefix, - continuation=continuation, - max_results=max_results, - request_id_parameter=request_id_parameter, - timeout=timeout, - resource=resource, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _request = HttpRequest("GET", next_link) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("FileSystemList", pipeline_response) - list_of_elem = deserialized.filesystems - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = 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) - - return pipeline_response - - return ItemPaged(get_next, extract_data) diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_list_paths_helper.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_list_paths_helper.py index 56ff803994eb..1ed4ab752a74 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_list_paths_helper.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_list_paths_helper.py @@ -108,7 +108,7 @@ def _extract_data_cb(self, get_next_return): self.marker = self._response.marker self.results_per_page = self._response.max_results self.container = self._response.container_name - self.current_page = self._response.segment.blob_prefixes + self._response.segment.blob_items + self.current_page = (self._response.segment.blob_prefixes or []) + (self._response.segment.blob_items or []) self.current_page = [self._build_item(item) for item in self.current_page] self.delimiter = self._response.delimiter @@ -171,7 +171,7 @@ def __init__( def _get_next_cb(self, continuation_token): try: return self._command( - self.recursive, + recursive=self.recursive, continuation=continuation_token or None, path=self.path, max_results=self.results_per_page, diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_models.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_models.py index 97445299773a..cfebf12c2d02 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_models.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_models.py @@ -10,6 +10,7 @@ from typing_extensions import Self from azure.core import CaseInsensitiveEnumMeta +from azure.storage.filedatalake._generated.models._patch import _BackCompatMixin from azure.storage.blob import AccessPolicy as BlobAccessPolicy from azure.storage.blob import AccountSasPermissions as BlobAccountSasPermissions from azure.storage.blob import ArrowDialect as BlobArrowDialect @@ -21,12 +22,12 @@ from azure.storage.blob import LeaseProperties as BlobLeaseProperties from azure.storage.blob import ResourceTypes as BlobResourceTypes from azure.storage.blob import UserDelegationKey as BlobUserDelegationKey -from azure.storage.blob._generated.models import ( - CorsRule as GenCorsRule, - Logging as GenLogging, - Metrics as GenMetrics, - RetentionPolicy as GenRetentionPolicy, - StaticWebsite as GenStaticWebsite, +from azure.storage.blob import ( + BlobAnalyticsLogging, + CorsRule as BlobCorsRule, + Metrics as BlobMetrics, + RetentionPolicy as BlobRetentionPolicy, + StaticWebsite as BlobStaticWebsite, ) from azure.storage.blob._models import ContainerPropertiesPaged @@ -37,7 +38,7 @@ from datetime import datetime -class RetentionPolicy(GenRetentionPolicy): +class RetentionPolicy(_BackCompatMixin): """The retention policy which determines how long the associated data should persist. All required parameters must be populated in order to send to Azure. @@ -56,8 +57,14 @@ class RetentionPolicy(GenRetentionPolicy): """Indicates the number of days that metrics or logging or soft-deleted data should be retained. All data older than this value will be deleted.""" + _attribute_map = { + "enabled": {"key": "Enabled", "type": "bool"}, + "days": {"key": "Days", "type": "int"}, + } + def __init__(self, enabled: bool = False, days: Optional[int] = None) -> None: - super(RetentionPolicy, self).__init__(enabled=enabled, days=days, allow_permanent_delete=None) + self.enabled = enabled + self.days = days if self.enabled and (self.days is None): raise ValueError("If policy is enabled, 'days' must be specified.") @@ -70,8 +77,14 @@ def _from_generated(cls, generated): days=generated.days, ) + @classmethod + def _to_generated(cls, policy: Optional["RetentionPolicy"]) -> Optional[BlobRetentionPolicy]: + if policy is None: + return policy + return BlobRetentionPolicy(enabled=policy.enabled, days=policy.days) + -class Metrics(GenMetrics): +class Metrics(_BackCompatMixin): """A summary of request statistics grouped by API in hour or minute aggregates. All required parameters must be populated in order to send to Azure. @@ -97,6 +110,13 @@ class Metrics(GenMetrics): retention_policy: RetentionPolicy = RetentionPolicy() """Determines how long the associated data should persist.""" + _attribute_map = { + "version": {"key": "Version", "type": "str"}, + "enabled": {"key": "Enabled", "type": "bool"}, + "include_apis": {"key": "IncludeAPIs", "type": "bool"}, + "retention_policy": {"key": "RetentionPolicy", "type": "RetentionPolicy"}, + } + def __init__(self, **kwargs: Any) -> None: self.version = kwargs.get("version", "1.0") self.enabled = kwargs.get("enabled", False) @@ -116,8 +136,21 @@ def _from_generated(cls, generated): ), ) + @classmethod + def _to_generated(cls, metrics: Optional["Metrics"]) -> Optional[BlobMetrics]: + if metrics is None: + return metrics + return BlobMetrics( + version=metrics.version, + enabled=metrics.enabled, + include_apis=metrics.include_apis, + retention_policy=RetentionPolicy._to_generated( + metrics.retention_policy + ), # pylint: disable=protected-access + ) -class CorsRule(GenCorsRule): + +class CorsRule(_BackCompatMixin): """CORS is an HTTP feature that enables a web application running under one domain to access resources in another domain. Web browsers implement a security restriction known as same-origin policy that prevents a web page @@ -162,6 +195,14 @@ class CorsRule(GenCorsRule): max_age_in_seconds: int """The number of seconds that the client/browser should cache a pre-flight response.""" + _attribute_map = { + "allowed_origins": {"key": "AllowedOrigins", "type": "str"}, + "allowed_methods": {"key": "AllowedMethods", "type": "str"}, + "allowed_headers": {"key": "AllowedHeaders", "type": "str"}, + "exposed_headers": {"key": "ExposedHeaders", "type": "str"}, + "max_age_in_seconds": {"key": "MaxAgeInSeconds", "type": "int"}, + } + def __init__(self, allowed_origins: List[str], allowed_methods: List[str], **kwargs: Any) -> None: self.allowed_origins = ",".join(allowed_origins) self.allowed_methods = ",".join(allowed_methods) @@ -170,17 +211,19 @@ def __init__(self, allowed_origins: List[str], allowed_methods: List[str], **kwa self.max_age_in_seconds = kwargs.get("max_age_in_seconds", 0) @staticmethod - def _to_generated(rules: Optional[List["CorsRule"]]) -> Optional[List[GenCorsRule]]: + def _to_generated(rules: Optional[List["CorsRule"]]) -> Optional[List[BlobCorsRule]]: if rules is None: return rules + # Blob's public CorsRule ctor takes List[str] and joins on "," internally, + # so split the stored comma-joined strings back into lists before passing. generated_cors_list = [] for cors_rule in rules: - generated_cors = GenCorsRule( - allowed_origins=cors_rule.allowed_origins, - allowed_methods=cors_rule.allowed_methods, - allowed_headers=cors_rule.allowed_headers, - exposed_headers=cors_rule.exposed_headers, + generated_cors = BlobCorsRule( + cors_rule.allowed_origins.split(",") if cors_rule.allowed_origins else [], + cors_rule.allowed_methods.split(",") if cors_rule.allowed_methods else [], + allowed_headers=cors_rule.allowed_headers.split(",") if cors_rule.allowed_headers else [], + exposed_headers=cors_rule.exposed_headers.split(",") if cors_rule.exposed_headers else [], max_age_in_seconds=cors_rule.max_age_in_seconds, ) generated_cors_list.append(generated_cors) @@ -1004,7 +1047,7 @@ def _from_generated(cls, generated): path_prop.permissions = generated.permissions path_prop.last_modified = _rfc_1123_to_datetime(generated.last_modified) path_prop.is_directory = bool(generated.is_directory) - path_prop.etag = generated.additional_properties.get("etag") + path_prop.etag = generated.get("etag") path_prop.content_length = generated.content_length path_prop.creation_time = _filetime_to_datetime(generated.creation_time) path_prop.expiry_time = _filetime_to_datetime(generated.expiry_time) @@ -1298,7 +1341,7 @@ def __init__(self, **kwargs: Any) -> None: self.file_system = None -class AnalyticsLogging(GenLogging): +class AnalyticsLogging(_BackCompatMixin): """Azure Analytics Logging settings.""" version: str @@ -1313,6 +1356,14 @@ class AnalyticsLogging(GenLogging): """Determines how long the associated data should persist. If not specified the retention policy will be disabled by default.""" + _attribute_map = { + "version": {"key": "Version", "type": "str"}, + "delete": {"key": "Delete", "type": "bool"}, + "read": {"key": "Read", "type": "bool"}, + "write": {"key": "Write", "type": "bool"}, + "retention_policy": {"key": "RetentionPolicy", "type": "RetentionPolicy"}, + } + def __init__(self, **kwargs: Any) -> None: self.version = kwargs.get("version", "1.0") self.delete = kwargs.get("delete", False) @@ -1334,8 +1385,22 @@ def _from_generated(cls, generated): ), ) + @classmethod + def _to_generated(cls, logging: Optional["AnalyticsLogging"]) -> Optional[BlobAnalyticsLogging]: + if not logging: + return None + return BlobAnalyticsLogging( + version=logging.version, + delete=logging.delete, + read=logging.read, + write=logging.write, + retention_policy=RetentionPolicy._to_generated( + logging.retention_policy + ), # pylint: disable=protected-access + ) + -class StaticWebsite(GenStaticWebsite): +class StaticWebsite(_BackCompatMixin): """The properties that enable an account to host a static website. :keyword bool enabled: @@ -1358,6 +1423,13 @@ class StaticWebsite(GenStaticWebsite): default_index_document_path: Optional[str] """Absolute path of the default index page.""" + _attribute_map = { + "enabled": {"key": "Enabled", "type": "bool"}, + "index_document": {"key": "IndexDocument", "type": "str"}, + "error_document404_path": {"key": "ErrorDocument404Path", "type": "str"}, + "default_index_document_path": {"key": "DefaultIndexDocumentPath", "type": "str"}, + } + def __init__(self, **kwargs: Any) -> None: self.enabled = kwargs.get("enabled", False) if self.enabled: @@ -1379,3 +1451,14 @@ def _from_generated(cls, generated): error_document404_path=generated.error_document404_path, default_index_document_path=generated.default_index_document_path, ) + + @classmethod + def _to_generated(cls, static_website: Optional["StaticWebsite"]) -> Optional[BlobStaticWebsite]: + if not static_website: + return None + return BlobStaticWebsite( + enabled=static_website.enabled, + index_document=static_website.index_document, + error_document404_path=static_website.error_document404_path, + default_index_document_path=static_website.default_index_document_path, + ) diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_path_client.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_path_client.py index 0ca502394d02..65801c65e34c 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_path_client.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_path_client.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for @@ -14,7 +15,7 @@ from azure.storage.blob import BlobClient from ._data_lake_lease import DataLakeLeaseClient from ._deserialize import process_storage_error -from ._generated import AzureDataLakeStorageRESTAPI +from ._generated import DataLakeClient as AzureDataLakeStorageRESTAPI from ._models import ( AccessControlChangeCounters, AccessControlChangeFailure, @@ -85,7 +86,7 @@ def __init__( path_name: str, credential: Optional[ Union[str, Dict[str, str], "AzureNamedKeyCredential", "AzureSasCredential", "TokenCredential"] - ] = None, + ] = None, # pylint: disable=line-too-long **kwargs: Any ) -> None: # remove the preceding/trailing delimiter from the path components @@ -157,10 +158,10 @@ def close(self) -> None: def _build_generated_client(self, url: str) -> AzureDataLakeStorageRESTAPI: client = AzureDataLakeStorageRESTAPI( url, - version=self._api_version, base_url=url, file_system=self.file_system_name, path=self.path_name, + version=self._api_version, pipeline=self._pipeline, ) return client diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_path_client.pyi b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_path_client.pyi index b91eff42ff5f..8a8eb70abbeb 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_path_client.pyi +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_path_client.pyi @@ -21,7 +21,7 @@ from azure.core.credentials import AzureNamedKeyCredential, AzureSasCredential, from azure.core.tracing.decorator import distributed_trace from azure.storage.blob import BlobClient from ._data_lake_lease import DataLakeLeaseClient -from ._generated import AzureDataLakeStorageRESTAPI +from ._generated import DataLakeClient as AzureDataLakeStorageRESTAPI from ._models import ( AccessControlChangeResult, AccessControlChanges, diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_path_client_helpers.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_path_client_helpers.py index c5dba60c3ee3..961c674340bc 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_path_client_helpers.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_path_client_helpers.py @@ -53,10 +53,10 @@ def _create_path_options( metadata: Optional[Dict[str, str]] = None, **kwargs: Any, ) -> Dict[str, Any]: - access_conditions = get_access_conditions(kwargs.pop("lease", None)) + lease_id = get_access_conditions(kwargs.pop("lease", None)) mod_conditions = get_mod_conditions(kwargs) - path_http_headers = None + path_http_headers = {} if content_settings: path_http_headers = get_path_http_headers(content_settings) @@ -83,29 +83,32 @@ def _create_path_options( "lease_duration": kwargs.pop("lease_duration", None), "expiry_options": kwargs.pop("expiry_options", None), "expires_on": expires_on, - "path_http_headers": path_http_headers, - "lease_access_conditions": access_conditions, - "modified_access_conditions": mod_conditions, - "cpk_info": cpk_info, "timeout": kwargs.pop("timeout", None), "encryption_context": kwargs.pop("encryption_context", None), "cls": return_response_headers, } + if lease_id: + options["lease_id"] = lease_id + options.update(path_http_headers) + options.update(mod_conditions) + if cpk_info: + options.update(cpk_info) options.update(kwargs) return options def _delete_path_options(paginated: Optional[bool], **kwargs) -> Dict[str, Any]: - access_conditions = get_access_conditions(kwargs.pop("lease", None)) + lease_id = get_access_conditions(kwargs.pop("lease", None)) mod_conditions = get_mod_conditions(kwargs) options = { "paginated": paginated, - "lease_access_conditions": access_conditions, - "modified_access_conditions": mod_conditions, "cls": return_response_headers, "timeout": kwargs.pop("timeout", None), } + if lease_id: + options["lease_id"] = lease_id + options.update(mod_conditions) options.update(kwargs) return options @@ -117,7 +120,7 @@ def _set_access_control_options( acl: Optional[str] = None, **kwargs: Any, ) -> Dict[str, Any]: - access_conditions = get_access_conditions(kwargs.pop("lease", None)) + lease_id = get_access_conditions(kwargs.pop("lease", None)) mod_conditions = get_mod_conditions(kwargs) options = { @@ -125,27 +128,29 @@ def _set_access_control_options( "group": group, "permissions": permissions, "acl": acl, - "lease_access_conditions": access_conditions, - "modified_access_conditions": mod_conditions, "timeout": kwargs.pop("timeout", None), "cls": return_response_headers, } + if lease_id: + options["lease_id"] = lease_id + options.update(mod_conditions) options.update(kwargs) return options def _get_access_control_options(upn: Optional[bool] = None, **kwargs: Any) -> Dict[str, Any]: - access_conditions = get_access_conditions(kwargs.pop("lease", None)) + lease_id = get_access_conditions(kwargs.pop("lease", None)) mod_conditions = get_mod_conditions(kwargs) options = { "action": "getAccessControl", "upn": upn if upn else False, - "lease_access_conditions": access_conditions, - "modified_access_conditions": mod_conditions, "timeout": kwargs.pop("timeout", None), "cls": return_response_headers, } + if lease_id: + options["lease_id"] = lease_id + options.update(mod_conditions) options.update(kwargs) return options @@ -173,26 +178,27 @@ def _rename_path_options( if metadata or kwargs.pop("permissions", None) or kwargs.pop("umask", None): raise ValueError("metadata, permissions, umask is not supported for this operation") - access_conditions = get_access_conditions(kwargs.pop("lease", None)) + lease_id = get_access_conditions(kwargs.pop("lease", None)) source_lease_id = get_lease_id(kwargs.pop("source_lease", None)) mod_conditions = get_mod_conditions(kwargs) source_mod_conditions = get_source_mod_conditions(kwargs) - path_http_headers = None + path_http_headers = {} if content_settings: path_http_headers = get_path_http_headers(content_settings) options = { "rename_source": rename_source, - "path_http_headers": path_http_headers, - "lease_access_conditions": access_conditions, "source_lease_id": source_lease_id, - "modified_access_conditions": mod_conditions, - "source_modified_access_conditions": source_mod_conditions, "timeout": kwargs.pop("timeout", None), "mode": "legacy", "cls": return_response_headers, } + if lease_id: + options["lease_id"] = lease_id + options.update(path_http_headers) + options.update(mod_conditions) + options.update(source_mod_conditions) options.update(kwargs) return options @@ -210,7 +216,7 @@ def _parse_rename_path( "TokenCredential", "AsyncTokenCredential", ] - ], + ], # pylint: disable=line-too-long ) -> Tuple[str, str, Optional[str]]: new_name = new_name.strip("/") new_file_system = new_name.split("/")[0] diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_serialize.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_serialize.py index 87c2f41416a7..6fdd023a84f2 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_serialize.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_serialize.py @@ -7,13 +7,8 @@ from typing import Any, cast, Dict, Literal, Optional, Union, TYPE_CHECKING from azure.storage.blob._serialize import _get_match_headers -from ._generated.models import ( - CpkInfo, - LeaseAccessConditions, - ModifiedAccessConditions, - PathHTTPHeaders, - SourceModifiedAccessConditions, -) +from azure.core import MatchConditions + from ._shared import encode_base64 if TYPE_CHECKING: @@ -103,48 +98,73 @@ def add_metadata_headers(metadata: Optional[Dict[str, str]] = None) -> Optional[ return "".join(headers) -def get_mod_conditions(kwargs: Dict[str, Any]) -> ModifiedAccessConditions: +def get_mod_conditions(kwargs: Dict[str, Any]) -> Dict[str, Any]: if_match, if_none_match = _get_match_headers(kwargs, "match_condition", "etag") - return ModifiedAccessConditions( - if_modified_since=kwargs.pop("if_modified_since", None), - if_unmodified_since=kwargs.pop("if_unmodified_since", None), - if_match=if_match or kwargs.pop("if_match", None), - if_none_match=if_none_match or kwargs.pop("if_none_match", None), - ) - - -def get_source_mod_conditions(kwargs: Dict[str, Any]) -> SourceModifiedAccessConditions: + result: Dict[str, Any] = {} + if_modified_since = kwargs.pop("if_modified_since", None) + if_unmodified_since = kwargs.pop("if_unmodified_since", None) + # Also handle direct if_match/if_none_match kwargs + if_match = if_match or kwargs.pop("if_match", None) + if_none_match = if_none_match or kwargs.pop("if_none_match", None) + + if if_modified_since is not None: + result["if_modified_since"] = if_modified_since + if if_unmodified_since is not None: + result["if_unmodified_since"] = if_unmodified_since + # Convert if_match/if_none_match to etag/match_condition for generated ops + if if_match: + result["etag"] = if_match + result["match_condition"] = MatchConditions.IfNotModified + elif if_none_match == "*": + result["match_condition"] = MatchConditions.IfMissing + elif if_none_match: + result["etag"] = if_none_match + result["match_condition"] = MatchConditions.IfModified + return result + + +def get_source_mod_conditions(kwargs: Dict[str, Any]) -> Dict[str, Any]: if_match, if_none_match = _get_match_headers(kwargs, "source_match_condition", "source_etag") - return SourceModifiedAccessConditions( - source_if_modified_since=kwargs.pop("source_if_modified_since", None), - source_if_unmodified_since=kwargs.pop("source_if_unmodified_since", None), - source_if_match=if_match or kwargs.pop("source_if_match", None), - source_if_none_match=if_none_match or kwargs.pop("source_if_none_match", None), - ) - - -def get_path_http_headers(content_settings: "ContentSettings") -> PathHTTPHeaders: - path_headers = PathHTTPHeaders( - cache_control=content_settings.cache_control, - content_type=content_settings.content_type, - content_md5=bytearray(content_settings.content_md5) if content_settings.content_md5 else None, - content_encoding=content_settings.content_encoding, - content_language=content_settings.content_language, - content_disposition=content_settings.content_disposition, - ) - return path_headers - - -def get_access_conditions( - lease: Optional[Union["BlobLeaseClient", "BlobLeaseClientAsync", str]], -) -> Optional[LeaseAccessConditions]: + result: Dict[str, Any] = {} + source_if_modified_since = kwargs.pop("source_if_modified_since", None) + source_if_unmodified_since = kwargs.pop("source_if_unmodified_since", None) + source_if_match = if_match or kwargs.pop("source_if_match", None) + source_if_none_match = if_none_match or kwargs.pop("source_if_none_match", None) + + if source_if_modified_since is not None: + result["source_if_modified_since"] = source_if_modified_since + if source_if_unmodified_since is not None: + result["source_if_unmodified_since"] = source_if_unmodified_since + if source_if_match is not None: + result["source_if_match"] = source_if_match + if source_if_none_match is not None: + result["source_if_none_match"] = source_if_none_match + return result + + +def get_path_http_headers(content_settings: "ContentSettings") -> Dict[str, Any]: + result: Dict[str, Any] = {} + if content_settings.cache_control is not None: + result["cache_control"] = content_settings.cache_control + if content_settings.content_type is not None: + result["content_type"] = content_settings.content_type + if content_settings.content_md5 is not None: + result["content_md5"] = bytearray(content_settings.content_md5) + if content_settings.content_encoding is not None: + result["content_encoding"] = content_settings.content_encoding + if content_settings.content_language is not None: + result["content_language"] = content_settings.content_language + if content_settings.content_disposition is not None: + result["content_disposition"] = content_settings.content_disposition + return result + + +def get_access_conditions(lease: Optional[Union["BlobLeaseClient", "BlobLeaseClientAsync", str]]) -> Optional[str]: if not lease: return None if hasattr(lease, "id"): - lease_id = lease.id - else: - lease_id = lease - return LeaseAccessConditions(lease_id=lease_id) + return lease.id + return lease def get_lease_id(lease: Optional[Union["BlobLeaseClient", "BlobLeaseClientAsync", str]]) -> str: @@ -167,7 +187,6 @@ def get_lease_action_properties(kwargs: Dict[str, Any]) -> Dict[str, Any]: lease_id = lease proposed_lease_id = None - access_conditions = None # Acquiring a new lease if lease_action in ["acquire", "acquire-release"]: @@ -175,27 +194,28 @@ def get_lease_action_properties(kwargs: Dict[str, Any]) -> Dict[str, Any]: proposed_lease_id = lease_id # Assign a default lease duration if not provided lease_duration = lease_duration or -1 - else: - # Use lease id as access conditions - access_conditions = LeaseAccessConditions(lease_id=lease_id) if lease_id else None + # else: Use lease id as access conditions (flat lease_id param) - return { + result: Dict[str, Any] = { "lease_action": lease_action, "lease_duration": lease_duration, "proposed_lease_id": proposed_lease_id, - "lease_access_conditions": access_conditions, } + # Only set lease_id if not acquiring (for access conditions) + if lease_action not in ["acquire", "acquire-release"] and lease_id: + result["lease_id"] = lease_id + return result -def get_cpk_info(scheme: str, kwargs: Dict[str, Any]) -> Optional[CpkInfo]: +def get_cpk_info(scheme: str, kwargs: Dict[str, Any]) -> Optional[Dict[str, Any]]: cpk: Optional[CustomerProvidedEncryptionKey] = kwargs.pop("cpk", None) if cpk: if scheme.lower() != "https": raise ValueError("Customer provided encryption key must be used over HTTPS.") - return CpkInfo( - encryption_key=cpk.key_value, - encryption_key_sha256=cpk.key_hash, - encryption_algorithm=cast(EncryptionAlgorithmType, cpk.algorithm), - ) + return { + "encryption_key": cpk.key_value, + "encryption_key_sha256": cpk.key_hash, + "encryption_algorithm": cast(EncryptionAlgorithmType, cpk.algorithm), + } return None diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_shared/policies.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_shared/policies.py index b5d0b7d79766..826613de1700 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_shared/policies.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_shared/policies.py @@ -467,17 +467,30 @@ def _validate_content_response( # Raises exception if missing content_length = int(response.http_response.headers[CONTENT_LENGTH_HEADER]) - # Patch response to return response iterator wrapped in structured message decoder - original_stream_download = response.http_response.stream_download - - def wrapped_stream_download(*args, **kwargs): - iterator = original_stream_download(*args, **kwargs) - decoder = decoder_cls(iterator, content_length, block_size=DATA_BLOCK_SIZE) - decoder.request = iterator.request # type: ignore - decoder.response = iterator.response # type: ignore - return decoder - - response.http_response.stream_download = wrapped_stream_download + def _make_wrapper(original): + def wrapped(*args, **kwargs): + iterator = original(*args, **kwargs) + decoder = decoder_cls(iterator, content_length, block_size=DATA_BLOCK_SIZE) + if hasattr(iterator, "request"): + decoder.request = iterator.request # type: ignore + if hasattr(iterator, "response"): + decoder.response = iterator.response # type: ignore + return decoder + + return wrapped + + # Patch response to return response iterator wrapped in structured message decoder. + # Different generated code paths consume the response via different methods: + # * Legacy generated code (e.g. azure-storage-blob) calls `stream_download(...)`. + # * Modern generated code (filedatalake) calls `iter_bytes()`. + # Since filedatalake's pipeline is shared with the inner BlobClient, we must wrap + # whichever method ends up being called. + if hasattr(response.http_response, "iter_bytes"): + response.http_response.iter_bytes = _make_wrapper(response.http_response.iter_bytes) + if hasattr(response.http_response, "iter_raw"): + response.http_response.iter_raw = _make_wrapper(response.http_response.iter_raw) + if hasattr(response.http_response, "stream_download"): + response.http_response.stream_download = _make_wrapper(response.http_response.stream_download) class StorageContentValidation(SansIOHTTPPolicy): diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_shared/request_handlers.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_shared/request_handlers.py index 699635565b18..d8c71d33a961 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_shared/request_handlers.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_shared/request_handlers.py @@ -117,11 +117,11 @@ def validate_and_format_range_headers( if align_to_page: if start_range is not None and start_range % 512 != 0: raise ValueError( - f"Invalid page blob start_range: {start_range}. " "The size must be aligned to a 512-byte boundary." + f"Invalid page blob start_range: {start_range}. The size must be aligned to a 512-byte boundary." ) if end_range is not None and end_range % 512 != 511: raise ValueError( - f"Invalid page blob end_range: {end_range}. " "The size must be aligned to a 512-byte boundary." + f"Invalid page blob end_range: {end_range}. The size must be aligned to a 512-byte boundary." ) # Format based on whether end_range is present diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_shared/response_handlers.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_shared/response_handlers.py index ef7150cfe070..592c872f66ee 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_shared/response_handlers.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_shared/response_handlers.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for @@ -92,8 +93,14 @@ def process_storage_error(storage_error) -> NoReturn: # type: ignore [misc] # p ) if not storage_error.response or storage_error.response.status_code in [200, 204]: raise storage_error - # If it is one of those three then it has been serialized prior by the generated layer. - if isinstance( + # The generated layer now pre-maps 412 (Precondition Failed) responses to typed + # exceptions based on the request's match condition (e.g. ResourceExistsError for + # IfMissing, ResourceNotFoundError for IfPresent). Historically 412 was not + # pre-mapped and always flowed through the error-code mapping below, surfacing as + # ResourceModifiedError. Skip the "already serialized" shortcut for 412 so it is + # re-mapped from x-ms-error-code (ConditionNotMet -> ResourceModifiedError) and the + # public exception type is preserved for users. + if storage_error.response.status_code != 412 and isinstance( storage_error, (PartialBatchErrorException, ClientAuthenticationError, ResourceNotFoundError, ResourceExistsError), ): @@ -208,8 +215,16 @@ def parse_to_internal_user_delegation_key(service_user_delegation_key): internal_user_delegation_key.signed_oid = service_user_delegation_key.signed_oid internal_user_delegation_key.signed_tid = service_user_delegation_key.signed_tid internal_user_delegation_key.signed_delegated_user_tid = service_user_delegation_key.signed_delegated_user_tid - internal_user_delegation_key.signed_start = _to_utc_datetime(service_user_delegation_key.signed_start) - internal_user_delegation_key.signed_expiry = _to_utc_datetime(service_user_delegation_key.signed_expiry) + internal_user_delegation_key.signed_start = ( + service_user_delegation_key.signed_start + if isinstance(service_user_delegation_key.signed_start, str) + else _to_utc_datetime(service_user_delegation_key.signed_start) + ) + internal_user_delegation_key.signed_expiry = ( + service_user_delegation_key.signed_expiry + if isinstance(service_user_delegation_key.signed_expiry, str) + else _to_utc_datetime(service_user_delegation_key.signed_expiry) + ) internal_user_delegation_key.signed_service = service_user_delegation_key.signed_service internal_user_delegation_key.signed_version = service_user_delegation_key.signed_version internal_user_delegation_key.value = service_user_delegation_key.value diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_shared/uploads.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_shared/uploads.py index 88d52eab5d12..b2dc44770eec 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_shared/uploads.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_shared/uploads.py @@ -55,6 +55,10 @@ def upload_data_chunks( if parallel and "modified_access_conditions" in kwargs: # Access conditions do not work with parallelism kwargs["modified_access_conditions"] = None + if parallel: + # Access conditions do not work with parallelism + kwargs.pop("etag", None) + kwargs.pop("match_condition", None) uploader = uploader_class( service=service, @@ -95,6 +99,10 @@ def upload_substream_blocks( if parallel and "modified_access_conditions" in kwargs: # Access conditions do not work with parallelism kwargs["modified_access_conditions"] = None + if parallel: + # Access conditions do not work with parallelism + kwargs.pop("etag", None) + kwargs.pop("match_condition", None) uploader = uploader_class( service=service, total_size=total_size, @@ -261,9 +269,9 @@ def _upload_chunk(self, chunk_offset, chunk_data): index = f"{chunk_offset:032d}" block_id = encode_base64(url_quote(encode_base64(index))) self.service.stage_block( - block_id, - len(chunk_data), - chunk_data, + block_id=block_id, + content_length=len(chunk_data), + body=chunk_data, data_stream_total=self.total_size, upload_stream_current=self.progress_total, **self.request_options, @@ -274,9 +282,9 @@ def _upload_substream_block(self, index, block_stream): try: block_id = f"BlockId{(index//self.chunk_size):05}" self.service.stage_block( - block_id, - len(block_stream), - block_stream, + block_id=block_id, + content_length=len(block_stream), + body=block_stream, data_stream_total=self.total_size, upload_stream_current=self.progress_total, **self.request_options, @@ -310,8 +318,8 @@ def _upload_chunk(self, chunk_offset, chunk_data): **self.request_options, ) - if not self.parallel and self.request_options.get("modified_access_conditions"): - self.request_options["modified_access_conditions"].if_match = self.response_headers["etag"] + if not self.parallel and self.request_options.get("etag"): + self.request_options["etag"] = self.response_headers["etag"] def _upload_substream_block(self, index, block_stream): pass @@ -335,9 +343,7 @@ def _upload_chunk(self, chunk_offset, chunk_data): ) self.current_length = int(self.response_headers["blob_append_offset"]) else: - self.request_options["append_position_access_conditions"].append_position = ( - self.current_length + chunk_offset - ) + self.request_options["append_position"] = self.current_length + chunk_offset self.response_headers = self.service.append_block( body=chunk_data, content_length=len(chunk_data), diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_shared/uploads_async.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_shared/uploads_async.py index 6ed5ba1d0f91..c1fa2a428dcc 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_shared/uploads_async.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_shared/uploads_async.py @@ -73,6 +73,10 @@ async def upload_data_chunks( if parallel and "modified_access_conditions" in kwargs: # Access conditions do not work with parallelism kwargs["modified_access_conditions"] = None + if parallel: + # Access conditions do not work with parallelism + kwargs.pop("etag", None) + kwargs.pop("match_condition", None) uploader = uploader_class( service=service, @@ -119,6 +123,10 @@ async def upload_substream_blocks( if parallel and "modified_access_conditions" in kwargs: # Access conditions do not work with parallelism kwargs["modified_access_conditions"] = None + if parallel: + # Access conditions do not work with parallelism + kwargs.pop("etag", None) + kwargs.pop("match_condition", None) uploader = uploader_class( service=service, total_size=total_size, @@ -287,8 +295,8 @@ async def _upload_chunk(self, chunk_offset, chunk_data): index = f"{chunk_offset:032d}" block_id = encode_base64(url_quote(encode_base64(index))) await self.service.stage_block( - block_id, - len(chunk_data), + block_id=block_id, + content_length=len(chunk_data), body=chunk_data, data_stream_total=self.total_size, upload_stream_current=self.progress_total, @@ -300,9 +308,9 @@ async def _upload_substream_block(self, index, block_stream): try: block_id = f"BlockId{(index//self.chunk_size):05}" await self.service.stage_block( - block_id, - len(block_stream), - block_stream, + block_id=block_id, + content_length=len(block_stream), + body=block_stream, data_stream_total=self.total_size, upload_stream_current=self.progress_total, **self.request_options, @@ -339,8 +347,8 @@ async def _upload_chunk(self, chunk_offset, chunk_data): **self.request_options, ) - if not self.parallel and self.request_options.get("modified_access_conditions"): - self.request_options["modified_access_conditions"].if_match = self.response_headers["etag"] + if not self.parallel and self.request_options.get("etag"): + self.request_options["etag"] = self.response_headers["etag"] async def _upload_substream_block(self, index, block_stream): pass @@ -364,9 +372,7 @@ async def _upload_chunk(self, chunk_offset, chunk_data): ) self.current_length = int(self.response_headers["blob_append_offset"]) else: - self.request_options["append_position_access_conditions"].append_position = ( - self.current_length + chunk_offset - ) + self.request_options["append_position"] = self.current_length + chunk_offset self.response_headers = await self.service.append_block( body=chunk_data, content_length=len(chunk_data), diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_upload_helper.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_upload_helper.py index f45f9c68f36d..1364468e865e 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_upload_helper.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_upload_helper.py @@ -6,6 +6,7 @@ from typing import Any, cast, Dict, IO, Optional, TYPE_CHECKING +from azure.core import MatchConditions from azure.core.exceptions import HttpResponseError from ._deserialize import process_storage_error @@ -17,13 +18,13 @@ from ._shared.models import StorageConfiguration -def _any_conditions(modified_access_conditions=None, **kwargs): # pylint: disable=unused-argument +def _any_conditions(**kwargs): return any( [ - modified_access_conditions.if_modified_since, - modified_access_conditions.if_unmodified_since, - modified_access_conditions.if_none_match, - modified_access_conditions.if_match, + kwargs.get("if_modified_since"), + kwargs.get("if_unmodified_since"), + kwargs.get("etag"), + kwargs.get("match_condition"), ] ) @@ -44,16 +45,35 @@ def upload_datalake_file( properties = kwargs.pop("properties", None) umask = kwargs.pop("umask", None) permissions = kwargs.pop("permissions", None) - path_http_headers = kwargs.pop("path_http_headers", None) - modified_access_conditions = kwargs.pop("modified_access_conditions", None) chunk_size = kwargs.pop("chunk_size", 100 * 1024 * 1024) encryption_context = kwargs.pop("encryption_context", None) progress_hook = kwargs.pop("progress_hook", None) + # Extract the flat access condition params from kwargs + access_kwargs: Dict[str, Any] = {} + for key in ("if_modified_since", "if_unmodified_since", "etag", "match_condition"): + val = kwargs.pop(key, None) + if val is not None: + access_kwargs[key] = val + + # Extract path HTTP headers from kwargs + path_http_header_kwargs: Dict[str, Any] = {} + for key in ( + "cache_control", + "content_type", + "content_md5", + "content_encoding", + "content_language", + "content_disposition", + ): + val = kwargs.pop(key, None) + if val is not None: + path_http_header_kwargs[key] = val + if not overwrite: # if customers didn't specify access conditions, they cannot flush data to existing file - if not _any_conditions(modified_access_conditions): - modified_access_conditions.if_none_match = "*" + if not _any_conditions(**access_kwargs): + access_kwargs["match_condition"] = MatchConditions.IfMissing if properties or umask or permissions: raise ValueError("metadata, umask and permissions can be set only when overwrite is enabled") @@ -62,23 +82,22 @@ def upload_datalake_file( Dict[str, Any], client.create( resource="file", - path_http_headers=path_http_headers, properties=properties, - modified_access_conditions=modified_access_conditions, umask=umask, permissions=permissions, encryption_context=encryption_context, cls=return_response_headers, + **path_http_header_kwargs, + **access_kwargs, **kwargs ), ) - # this modified_access_conditions will be applied to flush_data to make sure - # no other flush between create and the current flush - modified_access_conditions.if_match = response["etag"] - modified_access_conditions.if_none_match = None - modified_access_conditions.if_modified_since = None - modified_access_conditions.if_unmodified_since = None + # Set etag-based conditions to ensure no other flush between create and the current flush + access_kwargs = { + "etag": response["etag"], + "match_condition": MatchConditions.IfNotModified, + } use_original_upload_path = ( file_settings.use_byte_buffer @@ -119,10 +138,10 @@ def upload_datalake_file( Dict[str, Any], client.flush_data( position=length, - path_http_headers=path_http_headers, - modified_access_conditions=modified_access_conditions, close=True, cls=return_response_headers, + **path_http_header_kwargs, + **access_kwargs, **kwargs ), ) diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_version.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_version.py index 29aa028e52cb..b992dd7e5110 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_version.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_version.py @@ -1,7 +1,9 @@ -# ------------------------------------------------------------------------- +# 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. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- VERSION = "12.26.0b1" diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_data_lake_directory_client_async.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_data_lake_directory_client_async.py index 13899faffc0d..c56fa9dd37f7 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_data_lake_directory_client_async.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_data_lake_directory_client_async.py @@ -92,7 +92,7 @@ def __init__( directory_name: str, credential: Optional[ Union[str, Dict[str, str], "AzureNamedKeyCredential", "AzureSasCredential", "AsyncTokenCredential"] - ] = None, + ] = None, # pylint: disable=line-too-long **kwargs: Any, ) -> None: super(DataLakeDirectoryClient, self).__init__( @@ -107,7 +107,7 @@ def from_connection_string( directory_name: str, credential: Optional[ Union[str, Dict[str, str], "AzureNamedKeyCredential", "AzureSasCredential", "AsyncTokenCredential"] - ] = None, + ] = None, # pylint: disable=line-too-long **kwargs: Any, ) -> Self: """ diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_data_lake_file_client_async.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_data_lake_file_client_async.py index 835c9dbd53aa..38824e1aeace 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_data_lake_file_client_async.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_data_lake_file_client_async.py @@ -90,7 +90,7 @@ def __init__( file_path: str, credential: Optional[ Union[str, Dict[str, str], "AzureNamedKeyCredential", "AzureSasCredential", "AsyncTokenCredential"] - ] = None, + ] = None, # pylint: disable=line-too-long **kwargs: Any, ) -> None: super(DataLakeFileClient, self).__init__( @@ -105,7 +105,7 @@ def from_connection_string( file_path: str, credential: Optional[ Union[str, Dict[str, str], "AzureNamedKeyCredential", "AzureSasCredential", "AsyncTokenCredential"] - ] = None, + ] = None, # pylint: disable=line-too-long **kwargs: Any, ) -> Self: """ @@ -395,7 +395,9 @@ async def set_file_expiry( expiry_time = convert_datetime_to_rfc1123(expires_on) elif expires_on is not None: expiry_time = str(expires_on) - await self._datalake_client_for_blob_operation.path.set_expiry(expiry_options, expires_on=expiry_time, **kwargs) + await self._datalake_client_for_blob_operation.path.set_expiry( + expiry_options=expiry_options, expires_on=expiry_time, **kwargs + ) @distributed_trace_async async def upload_data( diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_data_lake_lease_async.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_data_lake_lease_async.py index 49661cb409ae..d6b3d98b1ebf 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_data_lake_lease_async.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_data_lake_lease_async.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_data_lake_service_client_async.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_data_lake_service_client_async.py index 1dff85fd469a..67095ec8849a 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_data_lake_service_client_async.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_data_lake_service_client_async.py @@ -15,8 +15,19 @@ from azure.storage.blob.aio import BlobServiceClient from .._data_lake_service_client_helpers import _format_url, _parse_url from .._deserialize import get_datalake_service_properties -from .._generated.aio import AzureDataLakeStorageRESTAPI -from .._models import DirectoryProperties, FileProperties, FileSystemProperties, LocationMode, UserDelegationKey +from .._generated.aio import DataLakeClient as AzureDataLakeStorageRESTAPI +from .._models import ( + AnalyticsLogging, + CorsRule, + DirectoryProperties, + FileProperties, + FileSystemProperties, + LocationMode, + Metrics, + RetentionPolicy, + StaticWebsite, + UserDelegationKey, +) from .._serialize import convert_dfs_url_to_blob_url, get_api_version from .._shared.base_client import parse_query, StorageAccountHostsMixin from .._shared.base_client_async import AsyncStorageAccountHostsMixin, AsyncTransportWrapper, parse_connection_str @@ -95,7 +106,7 @@ def __init__( account_url: str, credential: Optional[ Union[str, Dict[str, str], "AzureNamedKeyCredential", "AzureSasCredential", "AsyncTokenCredential"] - ] = None, + ] = None, # pylint: disable=line-too-long **kwargs: Any ) -> None: kwargs["retry_policy"] = kwargs.get("retry_policy") or ExponentialRetry(**kwargs) @@ -116,10 +127,8 @@ def __init__( # ADLS doesn't support secondary endpoint, make sure it's empty self._hosts[LocationMode.SECONDARY] = "" - self._api_version = get_api_version(kwargs) - self._client = AzureDataLakeStorageRESTAPI( - self.url, version=self._api_version, base_url=self.url, pipeline=self._pipeline - ) + self._client = AzureDataLakeStorageRESTAPI(self.url, base_url=self.url, pipeline=self._pipeline) + self._client._config.version = get_api_version(kwargs) # type: ignore [assignment] self._loop = kwargs.get("loop", None) async def __aenter__(self) -> Self: @@ -156,7 +165,7 @@ def from_connection_string( conn_str: str, credential: Optional[ Union[str, Dict[str, str], "AzureNamedKeyCredential", "AzureSasCredential", "AsyncTokenCredential"] - ] = None, + ] = None, # pylint: disable=line-too-long **kwargs: Any ) -> Self: """ @@ -643,6 +652,29 @@ async def set_service_properties(self, **kwargs: Any) -> None: see `here `_. """ + # Convert datalake-public service-property models to blob-public types so + # this code path remains correct once azure-storage-blob migrates to typespec + # models (msrest duck-typing through StorageServiceProperties goes away). + if "analytics_logging" in kwargs: + kwargs["analytics_logging"] = AnalyticsLogging._to_generated( # pylint: disable=protected-access + kwargs["analytics_logging"] + ) + if "hour_metrics" in kwargs: + kwargs["hour_metrics"] = Metrics._to_generated(kwargs["hour_metrics"]) # pylint: disable=protected-access + if "minute_metrics" in kwargs: + kwargs["minute_metrics"] = Metrics._to_generated( # pylint: disable=protected-access + kwargs["minute_metrics"] + ) + if "cors" in kwargs: + kwargs["cors"] = CorsRule._to_generated(kwargs["cors"]) # pylint: disable=protected-access + if "delete_retention_policy" in kwargs: + kwargs["delete_retention_policy"] = RetentionPolicy._to_generated( # pylint: disable=protected-access + kwargs["delete_retention_policy"] + ) + if "static_website" in kwargs: + kwargs["static_website"] = StaticWebsite._to_generated( # pylint: disable=protected-access + kwargs["static_website"] + ) await self._blob_service_client.set_service_properties(**kwargs) @distributed_trace_async diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_file_system_client_async.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_file_system_client_async.py index 3cad9c572c21..179218f3391f 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_file_system_client_async.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_file_system_client_async.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for @@ -17,7 +18,7 @@ from azure.storage.blob.aio import ContainerClient from .._deserialize import is_file_path, process_storage_error from .._file_system_client_helpers import _format_url, _parse_url, _undelete_path_options -from .._generated.aio import AzureDataLakeStorageRESTAPI +from .._generated.aio import DataLakeClient as AzureDataLakeStorageRESTAPI from .._models import ( DeletedPathProperties, DirectoryProperties, @@ -99,7 +100,7 @@ def __init__( file_system_name: str, credential: Optional[ Union[str, Dict[str, str], "AzureNamedKeyCredential", "AzureSasCredential", "AsyncTokenCredential"] - ] = None, + ] = None, # pylint: disable=line-too-long **kwargs: Any, ) -> None: kwargs["retry_policy"] = kwargs.get("retry_policy") or ExponentialRetry(**kwargs) @@ -161,7 +162,7 @@ async def close(self) -> None: # type: ignore def _build_generated_client(self, url: str) -> AzureDataLakeStorageRESTAPI: client = AzureDataLakeStorageRESTAPI( - url, version=self._api_version, base_url=url, file_system=self.file_system_name, pipeline=self._pipeline + url, base_url=url, file_system=self.file_system_name, version=self._api_version, pipeline=self._pipeline ) return client @@ -175,7 +176,7 @@ def from_connection_string( file_system_name: str, credential: Optional[ Union[str, Dict[str, str], "AzureNamedKeyCredential", "AzureSasCredential", "AsyncTokenCredential"] - ] = None, + ] = None, # pylint: disable=line-too-long **kwargs: Any, ) -> Self: """ @@ -956,7 +957,7 @@ async def _undelete_path( policies=self._pipeline._impl_policies, # type: ignore [arg-type] # pylint: disable=protected-access ) path_client = AzureDataLakeStorageRESTAPI( - url, version=self._api_version, filesystem=self.file_system_name, path=deleted_path_name, pipeline=pipeline + url, filesystem=self.file_system_name, path=deleted_path_name, pipeline=pipeline ) try: is_file = cast( diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_list_paths_helper.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_list_paths_helper.py index 6e1245bacc65..a442851b047e 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_list_paths_helper.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_list_paths_helper.py @@ -108,7 +108,7 @@ async def _extract_data_cb(self, get_next_return): self.marker = self._response.marker self.results_per_page = self._response.max_results self.container = self._response.container_name - self.current_page = self._response.segment.blob_prefixes + self._response.segment.blob_items + self.current_page = (self._response.segment.blob_prefixes or []) + (self._response.segment.blob_items or []) self.current_page = [self._build_item(item) for item in self.current_page] self.delimiter = self._response.delimiter @@ -169,7 +169,7 @@ def __init__( async def _get_next_cb(self, continuation_token): try: return await self._command( - self.recursive, + recursive=self.recursive, continuation=continuation_token or None, path=self.path, max_results=self.results_per_page, diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_path_client_async.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_path_client_async.py index 5f0a7cb8fa06..7de706baef19 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_path_client_async.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_path_client_async.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for @@ -13,7 +14,7 @@ from azure.core.tracing.decorator_async import distributed_trace_async from azure.storage.blob.aio import BlobClient from .._deserialize import process_storage_error -from .._generated.aio import AzureDataLakeStorageRESTAPI +from .._generated.aio import DataLakeClient as AzureDataLakeStorageRESTAPI from .._models import ( AccessControlChangeCounters, AccessControlChangeFailure, @@ -84,7 +85,7 @@ def __init__( path_name: str, credential: Optional[ Union[str, Dict[str, str], "AzureNamedKeyCredential", "AzureSasCredential", "AsyncTokenCredential"] - ] = None, + ] = None, # pylint: disable=line-too-long **kwargs: Any ) -> None: kwargs["retry_policy"] = kwargs.get("retry_policy") or ExponentialRetry(**kwargs) @@ -160,10 +161,10 @@ async def close(self) -> None: # type: ignore def _build_generated_client(self, url: str) -> AzureDataLakeStorageRESTAPI: client = AzureDataLakeStorageRESTAPI( url, - version=self._api_version, base_url=url, file_system=self.file_system_name, path=self.path_name, + version=self._api_version, pipeline=self._pipeline, ) return client diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_path_client_async.pyi b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_path_client_async.pyi index 28084c7fc960..de723142712a 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_path_client_async.pyi +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_path_client_async.pyi @@ -22,7 +22,7 @@ from azure.core.credentials import AzureNamedKeyCredential, AzureSasCredential from azure.core.credentials_async import AsyncTokenCredential from azure.core.tracing.decorator_async import distributed_trace_async from azure.storage.blob.aio import BlobClient -from .._generated import AzureDataLakeStorageRESTAPI +from .._generated import DataLakeClient as AzureDataLakeStorageRESTAPI from .._models import ( AccessControlChangeResult, AccessControlChanges, diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_upload_helper.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_upload_helper.py index 8c50e1f41519..fb293332d209 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_upload_helper.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_upload_helper.py @@ -6,6 +6,7 @@ from typing import Any, cast, Dict, IO, Optional, TYPE_CHECKING +from azure.core import MatchConditions from azure.core.exceptions import HttpResponseError from .._deserialize import process_storage_error @@ -17,13 +18,13 @@ from .._shared.models import StorageConfiguration -def _any_conditions(modified_access_conditions=None, **kwargs): # pylint: disable=unused-argument +def _any_conditions(**kwargs): return any( [ - modified_access_conditions.if_modified_since, - modified_access_conditions.if_unmodified_since, - modified_access_conditions.if_none_match, - modified_access_conditions.if_match, + kwargs.get("if_modified_since"), + kwargs.get("if_unmodified_since"), + kwargs.get("etag"), + kwargs.get("match_condition"), ] ) @@ -44,16 +45,35 @@ async def upload_datalake_file( properties = kwargs.pop("properties", None) umask = kwargs.pop("umask", None) permissions = kwargs.pop("permissions", None) - path_http_headers = kwargs.pop("path_http_headers", None) - modified_access_conditions = kwargs.pop("modified_access_conditions", None) chunk_size = kwargs.pop("chunk_size", 100 * 1024 * 1024) encryption_context = kwargs.pop("encryption_context", None) progress_hook = kwargs.pop("progress_hook", None) + # Extract the flat access condition params from kwargs + access_kwargs: Dict[str, Any] = {} + for key in ("if_modified_since", "if_unmodified_since", "etag", "match_condition"): + val = kwargs.pop(key, None) + if val is not None: + access_kwargs[key] = val + + # Extract path HTTP headers from kwargs + path_http_header_kwargs: Dict[str, Any] = {} + for key in ( + "cache_control", + "content_type", + "content_md5", + "content_encoding", + "content_language", + "content_disposition", + ): + val = kwargs.pop(key, None) + if val is not None: + path_http_header_kwargs[key] = val + if not overwrite: # if customers didn't specify access conditions, they cannot flush data to existing file - if not _any_conditions(modified_access_conditions): - modified_access_conditions.if_none_match = "*" + if not _any_conditions(**access_kwargs): + access_kwargs["match_condition"] = MatchConditions.IfMissing if properties or umask or permissions: raise ValueError("metadata, umask and permissions can be set only when overwrite is enabled") @@ -62,23 +82,22 @@ async def upload_datalake_file( Dict[str, Any], await client.create( resource="file", - path_http_headers=path_http_headers, properties=properties, - modified_access_conditions=modified_access_conditions, umask=umask, permissions=permissions, encryption_context=encryption_context, cls=return_response_headers, + **path_http_header_kwargs, + **access_kwargs, **kwargs ), ) - # this modified_access_conditions will be applied to flush_data to make sure - # no other flush between create and the current flush - modified_access_conditions.if_match = response["etag"] - modified_access_conditions.if_none_match = None - modified_access_conditions.if_modified_since = None - modified_access_conditions.if_unmodified_since = None + # Set etag-based conditions to ensure no other flush between create and the current flush + access_kwargs = { + "etag": response["etag"], + "match_condition": MatchConditions.IfNotModified, + } use_original_upload_path = ( file_settings.use_byte_buffer @@ -119,10 +138,10 @@ async def upload_datalake_file( Dict[str, Any], await client.flush_data( position=length, - path_http_headers=path_http_headers, - modified_access_conditions=modified_access_conditions, close=True, cls=return_response_headers, + **path_http_header_kwargs, + **access_kwargs, **kwargs ), ) diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/py.typed b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/py.typed index e69de29bb2d1..e5aff4f83af8 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/py.typed +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/storage/azure-storage-file-datalake/conftest.py b/sdk/storage/azure-storage-file-datalake/conftest.py index ffcb0c5bce44..9376e86cd8d1 100644 --- a/sdk/storage/azure-storage-file-datalake/conftest.py +++ b/sdk/storage/azure-storage-file-datalake/conftest.py @@ -16,6 +16,7 @@ add_uri_string_sanitizer, test_proxy, remove_batch_sanitizers, + set_custom_default_matcher, ) # Ignore async tests for PyPy @@ -42,3 +43,8 @@ def add_sanitizers(test_proxy): # Remove the following sanitizers since certain fields are needed in tests and are non-sensitive: # - AZSDK3493: $..name remove_batch_sanitizers(["AZSDK3493"]) + + set_custom_default_matcher( + ignore_query_ordering=True, + excluded_headers="Accept", + ) diff --git a/sdk/storage/azure-storage-file-datalake/pyproject.toml b/sdk/storage/azure-storage-file-datalake/pyproject.toml index 1f4a580e95d4..f1eeea7af95a 100644 --- a/sdk/storage/azure-storage-file-datalake/pyproject.toml +++ b/sdk/storage/azure-storage-file-datalake/pyproject.toml @@ -1,3 +1,70 @@ +# -------------------------------------------------------------------------- +# 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) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +[build-system] +requires = ["setuptools>=77.0.3", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "azure-storage-file-datalake" +authors = [ + { name = "Microsoft Corporation", email = "ascl@microsoft.com" }, +] +description = "Microsoft Corporation Azure Storage File Datalake Client Library for Python" +license = "MIT" +classifiers = [ + "Development Status :: 4 - Beta", + "Programming Language :: Python", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", +] +requires-python = ">=3.9" +keywords = ["azure", "azure sdk"] + +dependencies = [ + "isodate>=0.6.1", + "azure-core>=1.38.3", + "typing-extensions>=4.6.0", +] +dynamic = [ +"version", "readme" +] + +[project.optional-dependencies] +aio = [ + "azure-core[aio]>=1.38.3", +] + +[project.urls] +repository = "https://github.com/Azure/azure-sdk-for-python" + +[tool.setuptools.dynamic] +version = {attr = "azure.storage.filedatalake._version.VERSION"} +readme = {file = ["README.md", "CHANGELOG.md"], content-type = "text/markdown"} + +[tool.setuptools.packages.find] +exclude = [ + "tests*", + "generated_tests*", + "samples*", + "generated_samples*", + "doc*", + "azure", + "azure.storage", +] + +[tool.setuptools.package-data] +pytyped = ["py.typed"] + [tool.azure-sdk-build] mypy = true pyright = false diff --git a/sdk/storage/azure-storage-file-datalake/setup.py b/sdk/storage/azure-storage-file-datalake/setup.py deleted file mode 100644 index 158e3a31a3d1..000000000000 --- a/sdk/storage/azure-storage-file-datalake/setup.py +++ /dev/null @@ -1,94 +0,0 @@ -#!/usr/bin/env python - -# ------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -------------------------------------------------------------------------- - - -import os -import re - -from setuptools import setup, find_packages - -# Change the PACKAGE_NAME only to change folder and different name -PACKAGE_NAME = "azure-storage-file-datalake" -NAMESPACE_NAME = "azure.storage.filedatalake" -PACKAGE_PPRINT_NAME = "Azure File DataLake Storage" - -# a-b-c => a/b/c -package_folder_path = NAMESPACE_NAME.replace(".", "/") - -# azure-storage v0.36.0 and prior are not compatible with this package -try: - import azure.storage - - try: - ver = azure.storage.__version__ - raise Exception( - f"This package is incompatible with azure-storage=={ver}. " - + ' Uninstall it with "pip uninstall azure-storage".' - ) - except AttributeError: - pass -except ImportError: - pass - -# Version extraction inspired from 'requests' -with open(os.path.join(package_folder_path, "_version.py"), "r") as fd: - version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE).group(1) - -if not version: - raise RuntimeError("Cannot find version information") - -setup( - name=PACKAGE_NAME, - version=version, - include_package_data=True, - description=f"Microsoft {PACKAGE_PPRINT_NAME} Client Library for Python", - long_description=open("README.md", "r").read(), - long_description_content_type="text/markdown", - license="MIT License", - author="Microsoft Corporation", - author_email="ascl@microsoft.com", - url="https://github.com/Azure/azure-sdk-for-python", - keywords="azure, azure sdk", - classifiers=[ - "Development Status :: 4 - Beta", - "Programming Language :: Python", - "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - "Programming Language :: Python :: 3.13", - "Programming Language :: Python :: 3.14", - "License :: OSI Approved :: MIT License", - ], - zip_safe=False, - packages=find_packages( - exclude=[ - # Exclude packages that will be covered by PEP420 or nspkg - "azure", - "azure.storage", - "tests", - ] - ), - python_requires=">=3.9", - install_requires=[ - "azure-core>=1.37.0", - "azure-storage-blob>=12.31.0b1", - "typing-extensions>=4.6.0", - "isodate>=0.6.1", - ], - extras_require={ - "aio": [ - "azure-core[aio]>=1.37.0", - ], - "ext-checksums": [ - "azure-storage-extensions>=0.1.0,<1.0.0", - ], - }, -) diff --git a/sdk/storage/azure-storage-file-datalake/tests/test_file.py b/sdk/storage/azure-storage-file-datalake/tests/test_file.py index d52b6fdce6f6..ab7be5c6f672 100644 --- a/sdk/storage/azure-storage-file-datalake/tests/test_file.py +++ b/sdk/storage/azure-storage-file-datalake/tests/test_file.py @@ -1702,6 +1702,7 @@ def test_bad_audience_file_client(self, **kwargs): fc.get_file_properties() fc.upload_data(data, overwrite=True) + @pytest.mark.skip(reason="We drop support for legacy transports") @DataLakePreparer() def test_mock_transport_no_content_validation(self, **kwargs): datalake_storage_account_name = kwargs.pop("datalake_storage_account_name") @@ -1733,6 +1734,7 @@ def test_mock_transport_no_content_validation(self, **kwargs): resp = file_client.delete_file() assert resp is not None + @pytest.mark.skip(reason="We drop support for legacy transports") @DataLakePreparer() def test_mock_transport_with_content_validation(self, **kwargs): datalake_storage_account_name = kwargs.pop("datalake_storage_account_name") diff --git a/sdk/storage/azure-storage-file-datalake/tests/test_file_async.py b/sdk/storage/azure-storage-file-datalake/tests/test_file_async.py index 86aed283a6f6..1361232ddf12 100644 --- a/sdk/storage/azure-storage-file-datalake/tests/test_file_async.py +++ b/sdk/storage/azure-storage-file-datalake/tests/test_file_async.py @@ -1596,6 +1596,7 @@ async def test_bad_audience_file_client(self, **kwargs): await fc.get_file_properties() await fc.upload_data(data, overwrite=True) + @pytest.mark.skip(reason="We drop support for legacy transports") @DataLakePreparer() async def test_mock_transport_no_content_validation(self, **kwargs): datalake_storage_account_name = kwargs.pop("datalake_storage_account_name") @@ -1628,6 +1629,7 @@ async def test_mock_transport_no_content_validation(self, **kwargs): resp = await file_client.delete_file() assert resp is not None + @pytest.mark.skip(reason="We drop support for legacy transports") @DataLakePreparer() async def test_mock_transport_with_content_validation(self, **kwargs): datalake_storage_account_name = kwargs.pop("datalake_storage_account_name") diff --git a/sdk/storage/azure-storage-file-datalake/tsp-location.yaml b/sdk/storage/azure-storage-file-datalake/tsp-location.yaml new file mode 100644 index 000000000000..ab9d2589f874 --- /dev/null +++ b/sdk/storage/azure-storage-file-datalake/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/storage/data-plane/DataLakeStorage +commit: +repo: +additionalDirectories: