Skip to content

Commit

Permalink
add attachment url option flag (#77)
Browse files Browse the repository at this point in the history
* add attachment url option flag

* include test

* formating

* more reformatting

* remove test case
  • Loading branch information
jonathanfeng-scale committed Jun 13, 2023
1 parent c418cad commit 97c8940
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
20 changes: 20 additions & 0 deletions scaleapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,10 @@ def tasks(self, **kwargs) -> Tasklist:
limit (int):
Determines the page size (1-100)
include_attachment_url (bool):
If true, returns a pre-signed s3 url for the
attachment used to create the task.
next_token (str):
Can be use to fetch the next page of tasks
"""
Expand All @@ -288,6 +292,7 @@ def tasks(self, **kwargs) -> Tasklist:
"updated_before",
"updated_after",
"unique_id",
"include_attachment_url",
}

for key in kwargs:
Expand Down Expand Up @@ -323,6 +328,7 @@ def get_tasks(
created_after: str = None,
created_before: str = None,
tags: Union[List[str], str] = None,
include_attachment_url: bool = True,
) -> Generator[Task, None, None]:
"""Retrieve all tasks as a `generator` method, with the
given parameters. This methods handles pagination of
Expand Down Expand Up @@ -382,6 +388,11 @@ def get_tasks(
The tags of a task; multiple tags can be
specified as a list.
include_attachment_url (bool):
If true, returns a pre-signed s3 url for the
attachment used to create the task.
Yields:
Generator[Task]:
Yields Task objects, can be iterated.
Expand All @@ -404,6 +415,7 @@ def get_tasks(
created_after,
created_before,
tags,
include_attachment_url,
)

while has_more:
Expand Down Expand Up @@ -431,6 +443,7 @@ def get_tasks_count(
created_after: str = None,
created_before: str = None,
tags: Union[List[str], str] = None,
include_attachment_url: bool = True,
) -> int:
"""Returns number of tasks with given filters.
Expand Down Expand Up @@ -485,6 +498,10 @@ def get_tasks_count(
The tags of a task; multiple tags can be
specified as a list.
include_attachment_url (bool):
If true, returns a pre-signed s3 url for the
attachment used to create the task.
Returns:
int:
Returns number of tasks
Expand All @@ -504,6 +521,7 @@ def get_tasks_count(
created_after,
created_before,
tags,
include_attachment_url,
)

tasks_args["limit"] = 1
Expand All @@ -526,6 +544,7 @@ def _process_tasks_endpoint_args(
created_after: str = None,
created_before: str = None,
tags: Union[List[str], str] = None,
include_attachment_url: bool = True,
):
"""Generates args for /tasks endpoint."""
tasks_args = {
Expand All @@ -539,6 +558,7 @@ def _process_tasks_endpoint_args(
"updated_before": updated_before,
"updated_after": updated_after,
"unique_id": unique_id,
"include_attachment_url": include_attachment_url,
}

if status:
Expand Down
2 changes: 1 addition & 1 deletion scaleapi/_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = "2.14.3"
__version__ = "2.14.4"
__package_name__ = "scaleapi"

0 comments on commit 97c8940

Please sign in to comment.