-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
668 additions
and
271 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,56 @@ | ||
from typing import List | ||
from __future__ import annotations | ||
|
||
from typing import Dict, List | ||
from uuid import UUID | ||
|
||
from darwin.future.core.client import ClientCore | ||
from darwin.future.core.types.common import JSONType | ||
from darwin.future.data_objects.typing import UnknownType | ||
|
||
|
||
def move_items_to_stage( | ||
api_client: ClientCore, | ||
client: ClientCore, | ||
team_slug: str, | ||
workflow_id: UUID, | ||
dataset_id: int, | ||
dataset_ids: int | List[int], | ||
stage_id: UUID, | ||
item_ids: List[UUID], | ||
filters: Dict[str, UnknownType] = {}, | ||
) -> JSONType: | ||
""" | ||
Moves a list of items to a stage | ||
Parameters | ||
---------- | ||
client: Client | ||
The client to use for the request | ||
The client to use for the request. | ||
team_slug: str | ||
The slug of the team to move items for | ||
dataset_id: str | ||
The id or slug of the dataset to move items for | ||
stage_id: str | ||
The id or slug of the stage to move items to | ||
item_ids: List[UUID] | ||
A list of item ids to move to the stage | ||
The slug of the team to move items for. | ||
workflow_id: UUID | ||
The id of the workflow to move items for. | ||
dataset_ids: int | List[int] | ||
The ID(s) of the dataset(s) containing the items. | ||
stage_id: UUID | ||
The id of the workflow to move items for. | ||
filters: Dict[str, UnknownType] | ||
Filter parameters. | ||
Returns | ||
------- | ||
JSONType | ||
The response data. | ||
""" | ||
|
||
return api_client.post( | ||
f"/v2/teams/{team_slug}/items/stage", | ||
{ | ||
"filters": { | ||
"dataset_ids": [dataset_id], | ||
"item_ids": [str(id) for id in item_ids], | ||
}, | ||
"stage_id": str(stage_id), | ||
"workflow_id": str(workflow_id), | ||
assert ( | ||
filters | ||
), "No parameters provided, please provide at least one non-dataset id filter" | ||
payload = { | ||
"filters": { | ||
"dataset_ids": dataset_ids | ||
if isinstance(dataset_ids, list) | ||
else [dataset_ids], | ||
**filters, | ||
}, | ||
) | ||
"stage_id": str(stage_id), | ||
"workflow_id": str(workflow_id), | ||
} | ||
|
||
return client.post(f"/v2/teams/{team_slug}/items/stage", data=payload) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
from __future__ import annotations | ||
|
||
from typing import Dict, List | ||
|
||
from darwin.future.core.client import ClientCore | ||
from darwin.future.core.types.common import JSONType | ||
from darwin.future.data_objects.typing import UnknownType | ||
|
||
|
||
def move_list_of_items_to_folder( | ||
client: ClientCore, | ||
team_slug: str, | ||
dataset_ids: int | List[int], | ||
path: str, | ||
filters: Dict[str, UnknownType] = {}, | ||
) -> JSONType: | ||
""" | ||
Move specified items to a folder | ||
Parameters | ||
---------- | ||
client: Client | ||
The client to use for the request. | ||
team_slug: str | ||
The slug of the team containing the items. | ||
dataset_ids: int | List[int] | ||
The ID(s) of the dataset(s) containing the items. | ||
path: str | ||
The path to the folder to move the items to. | ||
filters: Dict[str, UnknownType] | ||
Filter parameters. | ||
Returns | ||
------- | ||
JSONType | ||
The response data. | ||
""" | ||
assert ( | ||
filters | ||
), "No parameters provided, please provide at least one non-dataset id filter" | ||
payload = { | ||
"filters": { | ||
"dataset_ids": dataset_ids | ||
if isinstance(dataset_ids, list) | ||
else [dataset_ids], | ||
**filters, | ||
} | ||
} | ||
|
||
return client.post(f"/v2/teams/{team_slug}/items/path", data=payload) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
from __future__ import annotations | ||
|
||
from typing import Dict | ||
|
||
from darwin.future.core.client import ClientCore | ||
from darwin.future.core.types.common import JSONType | ||
from darwin.future.data_objects.item import ItemLayout | ||
from darwin.future.data_objects.typing import UnknownType | ||
|
||
|
||
def set_item_layout( | ||
client: ClientCore, | ||
team_slug: str, | ||
dataset_ids: int | list[int], | ||
layout: ItemLayout, | ||
filters: Dict[str, UnknownType], | ||
) -> JSONType: | ||
""" | ||
Set the layout of a dataset and filtered items via filters. | ||
Args: | ||
client (ClientCore): The Darwin Core client. | ||
team_slug (str): The team slug. | ||
dataset_ids (int | list[int]): The dataset ids. | ||
layout (ItemLayout): The layout. | ||
filters Dict[str, UnknownType]: The parameters of the filter. | ||
Returns: | ||
JSONType: The response data. | ||
""" | ||
assert ( | ||
filters | ||
), "No parameters provided, please provide at least one non-dataset id filter" | ||
payload = { | ||
"filters": { | ||
"dataset_ids": dataset_ids | ||
if isinstance(dataset_ids, list) | ||
else [dataset_ids], | ||
**filters, | ||
}, | ||
"layout": dict(layout), | ||
} | ||
|
||
return client.post(f"/v2/teams/{team_slug}/items/layout", data=payload) |
Oops, something went wrong.