feat: added get_files method
This commit is contained in:
parent
b998ef968f
commit
01f97d40b6
1 changed files with 33 additions and 0 deletions
|
@ -191,6 +191,39 @@ class ZiplineApi:
|
|||
raise NotFound('image not found on filesystem')
|
||||
raise PyZiplineError(f"{result.status_code}: {result.message}\n{result.data}")
|
||||
|
||||
def get_files(self, favorite: bool = False, media_only: bool = False) -> list[File]:
|
||||
"""Get a list of the files uploaded by the authenticated user
|
||||
|
||||
/// admonition | Requires Authentication
|
||||
type: warning
|
||||
///
|
||||
|
||||
Args:
|
||||
favorite (bool): Whether or not to return only favorite files
|
||||
media_only (bool): Whether or not to return only media files
|
||||
|
||||
Raises:
|
||||
Forbidden: The user is not authenticated
|
||||
PyZiplineError: Raised if the API changes, causing a breaking change in this method
|
||||
|
||||
Returns:
|
||||
File: List of files uploaded by the authenticated user
|
||||
"""
|
||||
params = {}
|
||||
if favorite:
|
||||
params['favorite'] = favorite
|
||||
if media_only:
|
||||
params['media_only'] = media_only
|
||||
result: Result = self._rest_adapter.get(endpoint="/user/files", params=params)
|
||||
if result.status_code == 200:
|
||||
files = []
|
||||
for file in result.data:
|
||||
f = File(**file)
|
||||
files.append(f)
|
||||
return files
|
||||
if result.status_code == 401:
|
||||
raise Forbidden(result.message)
|
||||
|
||||
def get_self(self) -> User:
|
||||
"""Get the currently authenticated user
|
||||
|
||||
|
|
Loading…
Reference in a new issue