Skip to content

Commit 10d1e45

Browse files
authored
feat: Add signature arguments for dataset and kvs methods (#530)
### Description Add signature argument to: - `DatasetClient(Async).list_items` - `DatasetClient(Async).iterate_items` - `DatasetClient(Async).get_items_as_bytes` - `DatasetClient(Async).stream_items` - `DatasetClient(Async).list_keys` - `DatasetClient(Async).get_record` - `DatasetClient(Async).get_record_as_bytes` - `DatasetClient(Async).stream_record` Added tests that point to pre-created storage of specific test user. ### Issues Closes: #517
1 parent 60530ca commit 10d1e45

File tree

6 files changed

+356
-15
lines changed

6 files changed

+356
-15
lines changed

src/apify_client/clients/resource_clients/dataset.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ def list_items(
8585
skip_hidden: bool | None = None,
8686
flatten: list[str] | None = None,
8787
view: str | None = None,
88+
signature: str | None = None,
8889
) -> ListPage:
8990
"""List the items of the dataset.
9091
@@ -116,6 +117,7 @@ def list_items(
116117
the # character.
117118
flatten: A list of fields that should be flattened.
118119
view: Name of the dataset view to be used.
120+
signature: Signature used to access the items.
119121
120122
Returns:
121123
A page of the list of dataset items according to the specified filters.
@@ -132,6 +134,7 @@ def list_items(
132134
skipHidden=skip_hidden,
133135
flatten=flatten,
134136
view=view,
137+
signature=signature,
135138
)
136139

137140
response = self.http_client.call(
@@ -169,6 +172,7 @@ def iterate_items(
169172
unwind: list[str] | None = None,
170173
skip_empty: bool | None = None,
171174
skip_hidden: bool | None = None,
175+
signature: str | None = None,
172176
) -> Iterator[dict]:
173177
"""Iterate over the items in the dataset.
174178
@@ -198,6 +202,7 @@ def iterate_items(
198202
contain less items than the limit value.
199203
skip_hidden: If True, then hidden fields are skipped from the output, i.e. fields starting with
200204
the # character.
205+
signature: Signature used to access the items.
201206
202207
Yields:
203208
An item from the dataset.
@@ -227,6 +232,7 @@ def iterate_items(
227232
unwind=unwind,
228233
skip_empty=skip_empty,
229234
skip_hidden=skip_hidden,
235+
signature=signature,
230236
)
231237

232238
yield from current_items_page.items
@@ -256,6 +262,7 @@ def download_items(
256262
xml_root: str | None = None,
257263
xml_row: str | None = None,
258264
flatten: list[str] | None = None,
265+
signature: str | None = None,
259266
) -> bytes:
260267
"""Get the items in the dataset as raw bytes.
261268
@@ -300,6 +307,7 @@ def download_items(
300307
xml_row: Overrides default element name that wraps each page or page function result object in xml output.
301308
By default the element name is item.
302309
flatten: A list of fields that should be flattened.
310+
signature: Signature used to access the items.
303311
304312
Returns:
305313
The dataset items as raw bytes.
@@ -327,6 +335,7 @@ def download_items(
327335
xml_root=xml_root,
328336
xml_row=xml_row,
329337
flatten=flatten,
338+
signature=signature,
330339
)
331340

332341
def get_items_as_bytes(
@@ -348,6 +357,7 @@ def get_items_as_bytes(
348357
xml_root: str | None = None,
349358
xml_row: str | None = None,
350359
flatten: list[str] | None = None,
360+
signature: str | None = None,
351361
) -> bytes:
352362
"""Get the items in the dataset as raw bytes.
353363
@@ -390,6 +400,7 @@ def get_items_as_bytes(
390400
xml_row: Overrides default element name that wraps each page or page function result object in xml output.
391401
By default the element name is item.
392402
flatten: A list of fields that should be flattened.
403+
signature: Signature used to access the items.
393404
394405
Returns:
395406
The dataset items as raw bytes.
@@ -411,6 +422,7 @@ def get_items_as_bytes(
411422
xmlRoot=xml_root,
412423
xmlRow=xml_row,
413424
flatten=flatten,
425+
signature=signature,
414426
)
415427

416428
response = self.http_client.call(
@@ -440,6 +452,7 @@ def stream_items(
440452
skip_hidden: bool | None = None,
441453
xml_root: str | None = None,
442454
xml_row: str | None = None,
455+
signature: str | None = None,
443456
) -> Iterator[impit.Response]:
444457
"""Retrieve the items in the dataset as a stream.
445458
@@ -481,6 +494,7 @@ def stream_items(
481494
xml_root: Overrides default root element name of xml output. By default the root element is items.
482495
xml_row: Overrides default element name that wraps each page or page function result object in xml output.
483496
By default the element name is item.
497+
signature: Signature used to access the items.
484498
485499
Returns:
486500
The dataset items as a context-managed streaming `Response`.
@@ -503,6 +517,7 @@ def stream_items(
503517
skipHidden=skip_hidden,
504518
xmlRoot=xml_root,
505519
xmlRow=xml_row,
520+
signature=signature,
506521
)
507522

508523
response = self.http_client.call(
@@ -683,6 +698,7 @@ async def list_items(
683698
skip_hidden: bool | None = None,
684699
flatten: list[str] | None = None,
685700
view: str | None = None,
701+
signature: str | None = None,
686702
) -> ListPage:
687703
"""List the items of the dataset.
688704
@@ -714,6 +730,7 @@ async def list_items(
714730
the # character.
715731
flatten: A list of fields that should be flattened.
716732
view: Name of the dataset view to be used.
733+
signature: Signature used to access the items.
717734
718735
Returns:
719736
A page of the list of dataset items according to the specified filters.
@@ -730,6 +747,7 @@ async def list_items(
730747
skipHidden=skip_hidden,
731748
flatten=flatten,
732749
view=view,
750+
signature=signature,
733751
)
734752

735753
response = await self.http_client.call(
@@ -767,6 +785,7 @@ async def iterate_items(
767785
unwind: list[str] | None = None,
768786
skip_empty: bool | None = None,
769787
skip_hidden: bool | None = None,
788+
signature: str | None = None,
770789
) -> AsyncIterator[dict]:
771790
"""Iterate over the items in the dataset.
772791
@@ -796,6 +815,7 @@ async def iterate_items(
796815
contain less items than the limit value.
797816
skip_hidden: If True, then hidden fields are skipped from the output, i.e. fields starting with
798817
the # character.
818+
signature: Signature used to access the items.
799819
800820
Yields:
801821
An item from the dataset.
@@ -825,6 +845,7 @@ async def iterate_items(
825845
unwind=unwind,
826846
skip_empty=skip_empty,
827847
skip_hidden=skip_hidden,
848+
signature=signature,
828849
)
829850

830851
for item in current_items_page.items:
@@ -855,6 +876,7 @@ async def get_items_as_bytes(
855876
xml_root: str | None = None,
856877
xml_row: str | None = None,
857878
flatten: list[str] | None = None,
879+
signature: str | None = None,
858880
) -> bytes:
859881
"""Get the items in the dataset as raw bytes.
860882
@@ -897,6 +919,7 @@ async def get_items_as_bytes(
897919
xml_row: Overrides default element name that wraps each page or page function result object in xml output.
898920
By default the element name is item.
899921
flatten: A list of fields that should be flattened.
922+
signature: Signature used to access the items.
900923
901924
Returns:
902925
The dataset items as raw bytes.
@@ -918,6 +941,7 @@ async def get_items_as_bytes(
918941
xmlRoot=xml_root,
919942
xmlRow=xml_row,
920943
flatten=flatten,
944+
signature=signature,
921945
)
922946

923947
response = await self.http_client.call(
@@ -947,6 +971,7 @@ async def stream_items(
947971
skip_hidden: bool | None = None,
948972
xml_root: str | None = None,
949973
xml_row: str | None = None,
974+
signature: str | None = None,
950975
) -> AsyncIterator[impit.Response]:
951976
"""Retrieve the items in the dataset as a stream.
952977
@@ -988,6 +1013,7 @@ async def stream_items(
9881013
xml_root: Overrides default root element name of xml output. By default the root element is items.
9891014
xml_row: Overrides default element name that wraps each page or page function result object in xml output.
9901015
By default the element name is item.
1016+
signature: Signature used to access the items.
9911017
9921018
Returns:
9931019
The dataset items as a context-managed streaming `Response`.
@@ -1010,6 +1036,7 @@ async def stream_items(
10101036
skipHidden=skip_hidden,
10111037
xmlRoot=xml_root,
10121038
xmlRow=xml_row,
1039+
signature=signature,
10131040
)
10141041

10151042
response = await self.http_client.call(

0 commit comments

Comments
 (0)