1
- from .constants import DATASET_ITEM_ID_KEY
1
+ from typing import List , Dict , Any
2
+ from .constants import DATASET_ITEM_ID_KEY , REFERENCE_IDS_KEY
2
3
3
4
4
5
class Slice :
@@ -15,7 +16,6 @@ def info(self, id_type: str = DATASET_ITEM_ID_KEY) -> dict:
15
16
This endpoint provides information about specified slice.
16
17
17
18
:param
18
- slice_id: id of the slice
19
19
id_type: the type of IDs you want in response (either "reference_id" or "dataset_item_id")
20
20
to identify the DatasetItems
21
21
@@ -27,3 +27,38 @@ def info(self, id_type: str = DATASET_ITEM_ID_KEY) -> dict:
27
27
}
28
28
"""
29
29
return self ._client .slice_info (self .slice_id , id_type )
30
+
31
+ def append (
32
+ self ,
33
+ dataset_item_ids : List [str ] = None ,
34
+ reference_ids : List [str ] = None
35
+ ) -> dict :
36
+ """
37
+ Appends to a slice from items already present in a dataset.
38
+ The caller must exclusively use either datasetItemIds or reference_ids
39
+ as a means of identifying items in the dataset.
40
+
41
+ :param
42
+ dataset_item_ids: List[str],
43
+ reference_ids: List[str],
44
+
45
+ :return:
46
+ {
47
+ "slice_id": str,
48
+ }
49
+ """
50
+ if dataset_item_ids and reference_ids :
51
+ raise Exception (
52
+ "You cannot specify both dataset_item_ids and reference_ids"
53
+ )
54
+
55
+ payload : Dict [str , Any ] = {}
56
+ if dataset_item_ids :
57
+ payload [DATASET_ITEM_IDS_KEY ] = dataset_item_ids
58
+ if reference_ids :
59
+ payload [REFERENCE_IDS_KEY ] = reference_ids
60
+
61
+ response = self ._client ._make_request (
62
+ payload , f"slice/{ self .slice_id } /append"
63
+ )
64
+ return response
0 commit comments