-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[Storage-Queue][Storage-File] Kwargify positional params #7877
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f4a5aeb
f393688
efeebdd
6bc6c2b
954e3c5
171ee84
e76ff0e
d559601
a9d9b64
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -74,18 +74,20 @@ class DirectoryClient(AsyncStorageAccountHostsMixin, DirectoryClientBase): | |
| The credential with which to authenticate. This is optional if the | ||
| account URL already has a SAS token. The value can be a SAS token string or an account | ||
| shared access key. | ||
| :keyword loop: | ||
| The event loop to run the asynchronous tasks. | ||
| """ | ||
| def __init__( # type: ignore | ||
| self, account_url, # type: str | ||
| share_name, # type: str | ||
| directory_path, # type: str | ||
| snapshot=None, # type: Optional[Union[str, Dict[str, Any]]] | ||
| credential=None, # type: Optional[Any] | ||
| loop=None, # type: Any | ||
| **kwargs # type: Optional[Any] | ||
| ): | ||
| # type: (...) -> None | ||
| kwargs['retry_policy'] = kwargs.get('retry_policy') or ExponentialRetry(**kwargs) | ||
| loop = kwargs.pop('loop', None) | ||
| super(DirectoryClient, self).__init__( | ||
| account_url, | ||
| share_name=share_name, | ||
|
|
@@ -142,18 +144,14 @@ def get_subdirectory_client(self, directory_name, **kwargs): | |
| _pipeline=self._pipeline, _location_mode=self._location_mode, loop=self._loop, **kwargs) | ||
|
|
||
| @distributed_trace_async | ||
| async def create_directory( # type: ignore | ||
| self, metadata=None, # type: Optional[Dict[str, str]] | ||
| timeout=None, # type: Optional[int] | ||
| **kwargs # type: Optional[Any] | ||
| ): | ||
| # type: (...) -> Dict[str, Any] | ||
| async def create_directory(self, **kwargs): # type: ignore | ||
| # type: (Any) -> Dict[str, Any] | ||
| """Creates a new directory under the directory referenced by the client. | ||
|
|
||
| :param metadata: | ||
| :keyword metadata: | ||
| Name-value pairs associated with the directory as metadata. | ||
| :type metadata: dict(str, str) | ||
| :param int timeout: | ||
| :keyword int timeout: | ||
| The timeout parameter is expressed in seconds. | ||
| :returns: Directory-updated property dict (Etag and last modified). | ||
| :rtype: dict(str, Any) | ||
|
|
@@ -167,6 +165,8 @@ async def create_directory( # type: ignore | |
| :dedent: 12 | ||
| :caption: Creates a directory. | ||
| """ | ||
| metadata = kwargs.pop('metadata', None) | ||
| timeout = kwargs.pop('timeout', None) | ||
| headers = kwargs.pop('headers', {}) | ||
| headers.update(add_metadata_headers(metadata)) # type: ignore | ||
| try: | ||
|
|
@@ -179,12 +179,12 @@ async def create_directory( # type: ignore | |
| process_storage_error(error) | ||
|
|
||
| @distributed_trace_async | ||
| async def delete_directory(self, timeout=None, **kwargs): | ||
| # type: (Optional[int], **Any) -> None | ||
| async def delete_directory(self, **kwargs): | ||
| # type: (**Any) -> None | ||
| """Marks the directory for deletion. The directory is | ||
| later deleted during garbage collection. | ||
|
|
||
| :param int timeout: | ||
| :keyword int timeout: | ||
| The timeout parameter is expressed in seconds. | ||
| :rtype: None | ||
|
|
||
|
|
@@ -197,20 +197,21 @@ async def delete_directory(self, timeout=None, **kwargs): | |
| :dedent: 12 | ||
| :caption: Deletes a directory. | ||
| """ | ||
| timeout = kwargs.pop('timeout', None) | ||
| try: | ||
| await self._client.directory.delete(timeout=timeout, **kwargs) | ||
| except StorageErrorException as error: | ||
| process_storage_error(error) | ||
|
|
||
| @distributed_trace | ||
| def list_directories_and_files(self, name_starts_with=None, timeout=None, **kwargs): | ||
| # type: (Optional[str], Optional[int], **Any) -> AsyncItemPaged | ||
| def list_directories_and_files(self, name_starts_with=None, **kwargs): | ||
| # type: (Optional[str], Any) -> AsyncItemPaged | ||
| """Lists all the directories and files under the directory. | ||
|
|
||
| :param str name_starts_with: | ||
| Filters the results to return only entities whose names | ||
| begin with the specified prefix. | ||
| :param int timeout: | ||
| :keyword int timeout: | ||
| The timeout parameter is expressed in seconds. | ||
| :returns: An auto-paging iterable of dict-like DirectoryProperties and FileProperties | ||
| :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.storage.file.DirectoryProperties] | ||
|
|
@@ -224,6 +225,7 @@ def list_directories_and_files(self, name_starts_with=None, timeout=None, **kwar | |
| :dedent: 12 | ||
| :caption: List directories and files. | ||
| """ | ||
| timeout = kwargs.pop('timeout', None) | ||
| results_per_page = kwargs.pop('results_per_page', None) | ||
| command = functools.partial( | ||
| self._client.directory.list_files_and_directories_segment, | ||
|
|
@@ -235,18 +237,19 @@ def list_directories_and_files(self, name_starts_with=None, timeout=None, **kwar | |
| page_iterator_class=DirectoryPropertiesPaged) | ||
|
|
||
| @distributed_trace | ||
| def list_handles(self, recursive=False, timeout=None, **kwargs): | ||
| # type: (bool, Optional[int], Any) -> AsyncItemPaged | ||
| def list_handles(self, recursive=False, **kwargs): | ||
| # type: (bool, Any) -> AsyncItemPaged | ||
| """Lists opened handles on a directory or a file under the directory. | ||
|
|
||
| :param bool recursive: | ||
| Boolean that specifies if operation should apply to the directory specified by the client, | ||
| its files, its subdirectories and their files. Default value is False. | ||
| :param int timeout: | ||
| :keyword int timeout: | ||
| The timeout parameter is expressed in seconds. | ||
| :returns: An auto-paging iterable of HandleItem | ||
| :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.storage.file.HandleItem] | ||
| """ | ||
| timeout = kwargs.pop('timeout', None) | ||
| results_per_page = kwargs.pop('results_per_page', None) | ||
| command = functools.partial( | ||
| self._client.directory.list_handles, | ||
|
|
@@ -262,7 +265,6 @@ def list_handles(self, recursive=False, timeout=None, **kwargs): | |
| async def close_handles( | ||
| self, handle=None, # type: Union[str, HandleItem] | ||
| recursive=False, # type: bool | ||
| timeout=None, # type: Optional[int] | ||
| **kwargs # type: Any | ||
| ): | ||
| # type: (...) -> int | ||
|
|
@@ -275,11 +277,12 @@ async def close_handles( | |
| :param bool recursive: | ||
| Boolean that specifies if operation should apply to the directory specified by the client, | ||
| its files, its subdirectories and their files. Default value is False. | ||
| :param int timeout: | ||
| :keyword int timeout: | ||
| The timeout parameter is expressed in seconds. | ||
| :returns: The number of file handles that were closed. | ||
| :rtype: int | ||
| """ | ||
| timeout = kwargs.pop('timeout', None) | ||
| try: | ||
| handle_id = handle.id # type: ignore | ||
| except AttributeError: | ||
|
|
@@ -305,17 +308,18 @@ async def close_handles( | |
| polling_method) | ||
|
|
||
| @distributed_trace_async | ||
| async def get_directory_properties(self, timeout=None, **kwargs): | ||
| # type: (Optional[int], Any) -> DirectoryProperties | ||
| async def get_directory_properties(self, **kwargs): | ||
| # type: (Any) -> DirectoryProperties | ||
| """Returns all user-defined metadata and system properties for the | ||
| specified directory. The data returned does not include the directory's | ||
| list of files. | ||
|
|
||
| :param int timeout: | ||
| :keyword int timeout: | ||
| The timeout parameter is expressed in seconds. | ||
| :returns: DirectoryProperties | ||
| :rtype: ~azure.storage.file.DirectoryProperties | ||
| """ | ||
| timeout = kwargs.pop('timeout', None) | ||
| try: | ||
| response = await self._client.directory.get_properties( | ||
| timeout=timeout, | ||
|
|
@@ -326,8 +330,8 @@ async def get_directory_properties(self, timeout=None, **kwargs): | |
| return response # type: ignore | ||
|
|
||
| @distributed_trace_async | ||
| async def set_directory_metadata(self, metadata, timeout=None, **kwargs): # type: ignore | ||
| # type: (Dict[str, Any], Optional[int], Any) -> Dict[str, Any] | ||
| async def set_directory_metadata(self, metadata, **kwargs): # type: ignore | ||
| # type: (Dict[str, Any], Any) -> Dict[str, Any] | ||
| """Sets the metadata for the directory. | ||
|
|
||
| Each call to this operation replaces all existing metadata | ||
|
|
@@ -337,11 +341,12 @@ async def set_directory_metadata(self, metadata, timeout=None, **kwargs): # type | |
| :param metadata: | ||
| Name-value pairs associated with the directory as metadata. | ||
| :type metadata: dict(str, str) | ||
| :param int timeout: | ||
| :keyword int timeout: | ||
| The timeout parameter is expressed in seconds. | ||
| :returns: Directory-updated property dict (Etag and last modified). | ||
| :rtype: dict(str, Any) | ||
| """ | ||
| timeout = kwargs.pop('timeout', None) | ||
| headers = kwargs.pop('headers', {}) | ||
| headers.update(add_metadata_headers(metadata)) | ||
| try: | ||
|
|
@@ -359,12 +364,11 @@ async def set_http_headers(self, file_attributes="none", # type: Union[str, NTF | |
| file_last_write_time="preserve", # type: Union[str, datetime] | ||
| file_permission=None, # type: Optional[str] | ||
| permission_key=None, # type: Optional[str] | ||
| timeout=None, # type: Optional[int] | ||
| **kwargs): # type: ignore | ||
| # type: (...) -> Dict[str, Any] | ||
| """Sets HTTP headers on the directory. | ||
|
|
||
| :param int timeout: | ||
| :keyword int timeout: | ||
| The timeout parameter is expressed in seconds. | ||
| :param file_attributes: | ||
| The file system attributes for files and directories. | ||
|
|
@@ -391,6 +395,7 @@ async def set_http_headers(self, file_attributes="none", # type: Union[str, NTF | |
| :returns: File-updated property dict (Etag and last modified). | ||
| :rtype: dict(str, Any) | ||
| """ | ||
| timeout = kwargs.pop('timeout', None) | ||
| file_permission = _get_file_permission(file_permission, permission_key, 'preserve') | ||
| try: | ||
| return await self._client.directory.set_properties( # type: ignore | ||
|
|
@@ -408,8 +413,6 @@ async def set_http_headers(self, file_attributes="none", # type: Union[str, NTF | |
| @distributed_trace_async | ||
| async def create_subdirectory( | ||
| self, directory_name, # type: str | ||
| metadata=None, #type: Optional[Dict[str, Any]] | ||
| timeout=None, # type: Optional[int] | ||
| **kwargs | ||
| ): | ||
| # type: (...) -> DirectoryClient | ||
|
|
@@ -418,10 +421,10 @@ async def create_subdirectory( | |
|
|
||
| :param str directory_name: | ||
| The name of the subdirectory. | ||
| :param metadata: | ||
| :keyword metadata: | ||
| Name-value pairs associated with the subdirectory as metadata. | ||
| :type metadata: dict(str, str) | ||
| :param int timeout: | ||
| :keyword int timeout: | ||
| The timeout parameter is expressed in seconds. | ||
| :returns: DirectoryClient | ||
| :rtype: ~azure.storage.file.aio.directory_client_async.DirectoryClient | ||
|
|
@@ -435,22 +438,23 @@ async def create_subdirectory( | |
| :dedent: 12 | ||
| :caption: Create a subdirectory. | ||
| """ | ||
| metadata = kwargs.pop('metadata', None) | ||
| timeout = kwargs.pop('timeout', None) | ||
| subdir = self.get_subdirectory_client(directory_name) | ||
| await subdir.create_directory(metadata=metadata, timeout=timeout, **kwargs) | ||
| return subdir # type: ignore | ||
|
|
||
| @distributed_trace_async | ||
| async def delete_subdirectory( | ||
| self, directory_name, # type: str | ||
| timeout=None, # type: Optional[int] | ||
| **kwargs | ||
| ): | ||
| # type: (...) -> None | ||
| """Deletes a subdirectory. | ||
|
|
||
| :param str directory_name: | ||
| The name of the subdirectory. | ||
| :param int timeout: | ||
| :keyword int timeout: | ||
| The timeout parameter is expressed in seconds. | ||
| :rtype: None | ||
|
|
||
|
|
@@ -463,6 +467,7 @@ async def delete_subdirectory( | |
| :dedent: 12 | ||
| :caption: Delete a subdirectory. | ||
| """ | ||
| timeout = kwargs.pop('timeout', None) | ||
| subdir = self.get_subdirectory_client(directory_name) | ||
| await subdir.delete_directory(timeout=timeout, **kwargs) | ||
|
|
||
|
|
@@ -471,12 +476,6 @@ async def upload_file( | |
| self, file_name, # type: str | ||
| data, # type: Any | ||
| length=None, # type: Optional[int] | ||
| metadata=None, # type: Optional[Dict[str, str]] | ||
| content_settings=None, # type: Optional[ContentSettings] | ||
| validate_content=False, # type: bool | ||
| max_concurrency=1, # type: Optional[int] | ||
| timeout=None, # type: Optional[int] | ||
| encoding='UTF-8', # type: str | ||
| **kwargs # type: Any | ||
| ): | ||
| # type: (...) -> FileClient | ||
|
|
@@ -489,23 +488,23 @@ async def upload_file( | |
| Content of the file. | ||
| :param int length: | ||
| Length of the file in bytes. Specify its maximum size, up to 1 TiB. | ||
| :param metadata: | ||
| :keyword metadata: | ||
| Name-value pairs associated with the file as metadata. | ||
| :type metadata: dict(str, str) | ||
| :param ~azure.storage.file.ContentSettings content_settings: | ||
| :keyword ~azure.storage.file.ContentSettings content_settings: | ||
| ContentSettings object used to set file properties. | ||
| :param bool validate_content: | ||
| :keyword bool validate_content: | ||
| If true, calculates an MD5 hash for each range of the file. The storage | ||
| service checks the hash of the content that has arrived with the hash | ||
| that was sent. This is primarily valuable for detecting bitflips on | ||
| the wire if using http instead of https as https (the default) will | ||
| already validate. Note that this MD5 hash is not stored with the | ||
| file. | ||
| :param int max_concurrency: | ||
| :keyword int max_concurrency: | ||
| Maximum number of parallel connections to use. | ||
| :param int timeout: | ||
| :keyword int timeout: | ||
| The timeout parameter is expressed in seconds. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need to change metadata, content_settings, validate_content, max_concurrency, and encoding to :keyword: as well. |
||
| :param str encoding: | ||
| :keyword str encoding: | ||
| Defaults to UTF-8. | ||
| :returns: FileClient | ||
| :rtype: ~azure.storage.file.aio.file_client_async.FileClient | ||
|
|
@@ -523,19 +522,12 @@ async def upload_file( | |
| await file_client.upload_file( | ||
| data, | ||
| length=length, | ||
| metadata=metadata, | ||
| content_settings=content_settings, | ||
| validate_content=validate_content, | ||
| max_concurrency=max_concurrency, | ||
| timeout=timeout, | ||
| encoding=encoding, | ||
| **kwargs) | ||
| return file_client # type: ignore | ||
|
|
||
| @distributed_trace_async | ||
| async def delete_file( | ||
| self, file_name, # type: str | ||
| timeout=None, # type: Optional[int] | ||
| **kwargs # type: Optional[Any] | ||
| ): | ||
| # type: (...) -> None | ||
|
|
@@ -544,7 +536,7 @@ async def delete_file( | |
|
|
||
| :param str file_name: | ||
| The name of the file to delete. | ||
| :param int timeout: | ||
| :keyword int timeout: | ||
| The timeout parameter is expressed in seconds. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like we're keeping this timeout as a param.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On second thought, was this one just missed being put into kwargs? |
||
| :rtype: None | ||
|
|
||
|
|
@@ -558,4 +550,4 @@ async def delete_file( | |
| :caption: Delete a file in a directory. | ||
| """ | ||
| file_client = self.get_file_client(file_name) | ||
| await file_client.delete_file(timeout, **kwargs) | ||
| await file_client.delete_file(**kwargs) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add :keyword loop: to docstring?