Skip to content

Commit bf64cb2

Browse files
authored
Add support for specifying the max_items parameter for pay-per result Actors and their runs (#148)
When we introduced pay-per result Actors, we did not add support for specifying the max items limit to the Python API client. This adds it hopefully everywhere it's supported. Closes #146.
1 parent afe796a commit bf64cb2

File tree

6 files changed

+136
-16
lines changed

6 files changed

+136
-16
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ Changelog
44
[1.4.1](../../releases/tag/v1.4.1) - Unreleased
55
-----------------------------------------------
66

7+
### Added
8+
9+
- support for specifying the `max_items` parameter for pay-per result Actors and their runs
10+
711
### Internal changes
812

913
- Improved logging of HTTP requests

docs/docs.md

Lines changed: 64 additions & 16 deletions
Large diffs are not rendered by default.

src/apify_client/clients/resource_clients/actor.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def _get_actor_representation(
2727
is_anonymously_runnable: Optional[bool] = None,
2828
categories: Optional[List[str]] = None,
2929
default_run_build: Optional[str] = None,
30+
default_run_max_items: Optional[int] = None,
3031
default_run_memory_mbytes: Optional[int] = None,
3132
default_run_timeout_secs: Optional[int] = None,
3233
example_run_input_body: Optional[Any] = None,
@@ -46,6 +47,7 @@ def _get_actor_representation(
4647
'categories': categories,
4748
'defaultRunOptions': {
4849
'build': default_run_build,
50+
'maxItems': default_run_max_items,
4951
'memoryMbytes': default_run_memory_mbytes,
5052
'timeoutSecs': default_run_timeout_secs,
5153
},
@@ -90,6 +92,7 @@ def update(
9092
is_anonymously_runnable: Optional[bool] = None,
9193
categories: Optional[List[str]] = None,
9294
default_run_build: Optional[str] = None,
95+
default_run_max_items: Optional[int] = None,
9396
default_run_memory_mbytes: Optional[int] = None,
9497
default_run_timeout_secs: Optional[int] = None,
9598
example_run_input_body: Optional[Any] = None,
@@ -112,6 +115,8 @@ def update(
112115
is_anonymously_runnable (bool, optional): Whether the actor is anonymously runnable.
113116
categories (list of str, optional): The categories to which the actor belongs to.
114117
default_run_build (str, optional): Tag or number of the build that you want to run by default.
118+
default_run_max_items (int, optional): Default limit of the number of results that will be returned by runs of this Actor,
119+
if the Actor is charged per result.
115120
default_run_memory_mbytes (int, optional): Default amount of memory allocated for the runs of this actor, in megabytes.
116121
default_run_timeout_secs (int, optional): Default timeout for the runs of this actor in seconds.
117122
example_run_input_body (Any, optional): Input to be prefilled as default input to new users of this actor.
@@ -133,6 +138,7 @@ def update(
133138
is_anonymously_runnable=is_anonymously_runnable,
134139
categories=categories,
135140
default_run_build=default_run_build,
141+
default_run_max_items=default_run_max_items,
136142
default_run_memory_mbytes=default_run_memory_mbytes,
137143
default_run_timeout_secs=default_run_timeout_secs,
138144
example_run_input_body=example_run_input_body,
@@ -154,6 +160,7 @@ def start(
154160
run_input: Optional[Any] = None,
155161
content_type: Optional[str] = None,
156162
build: Optional[str] = None,
163+
max_items: Optional[int] = None,
157164
memory_mbytes: Optional[int] = None,
158165
timeout_secs: Optional[int] = None,
159166
wait_for_finish: Optional[int] = None,
@@ -168,6 +175,8 @@ def start(
168175
content_type (str, optional): The content type of the input.
169176
build (str, optional): Specifies the actor build to run. It can be either a build tag or build number.
170177
By default, the run uses the build specified in the default run configuration for the actor (typically latest).
178+
max_items (int, optional): Maximum number of results that will be returned by this run.
179+
If the Actor is charged per result, you will not be charged for more results than the given limit.
171180
memory_mbytes (int, optional): Memory limit for the run, in megabytes.
172181
By default, the run uses a memory limit specified in the default run configuration for the actor.
173182
timeout_secs (int, optional): Optional timeout for the run, in seconds.
@@ -190,6 +199,7 @@ def start(
190199

191200
request_params = self._params(
192201
build=build,
202+
maxItems=max_items,
193203
memory=memory_mbytes,
194204
timeout=timeout_secs,
195205
waitForFinish=wait_for_finish,
@@ -212,6 +222,7 @@ def call(
212222
run_input: Optional[Any] = None,
213223
content_type: Optional[str] = None,
214224
build: Optional[str] = None,
225+
max_items: Optional[int] = None,
215226
memory_mbytes: Optional[int] = None,
216227
timeout_secs: Optional[int] = None,
217228
webhooks: Optional[List[Dict]] = None,
@@ -228,6 +239,8 @@ def call(
228239
content_type (str, optional): The content type of the input.
229240
build (str, optional): Specifies the actor build to run. It can be either a build tag or build number.
230241
By default, the run uses the build specified in the default run configuration for the actor (typically latest).
242+
max_items (int, optional): Maximum number of results that will be returned by this run.
243+
If the Actor is charged per result, you will not be charged for more results than the given limit.
231244
memory_mbytes (int, optional): Memory limit for the run, in megabytes.
232245
By default, the run uses a memory limit specified in the default run configuration for the actor.
233246
timeout_secs (int, optional): Optional timeout for the run, in seconds.
@@ -244,6 +257,7 @@ def call(
244257
run_input=run_input,
245258
content_type=content_type,
246259
build=build,
260+
max_items=max_items,
247261
memory_mbytes=memory_mbytes,
248262
timeout_secs=timeout_secs,
249263
webhooks=webhooks,
@@ -378,6 +392,7 @@ async def update(
378392
is_anonymously_runnable: Optional[bool] = None,
379393
categories: Optional[List[str]] = None,
380394
default_run_build: Optional[str] = None,
395+
default_run_max_items: Optional[int] = None,
381396
default_run_memory_mbytes: Optional[int] = None,
382397
default_run_timeout_secs: Optional[int] = None,
383398
example_run_input_body: Optional[Any] = None,
@@ -400,6 +415,8 @@ async def update(
400415
is_anonymously_runnable (bool, optional): Whether the actor is anonymously runnable.
401416
categories (list of str, optional): The categories to which the actor belongs to.
402417
default_run_build (str, optional): Tag or number of the build that you want to run by default.
418+
default_run_max_items (int, optional): Default limit of the number of results that will be returned by runs of this Actor,
419+
if the Actor is charged per result.
403420
default_run_memory_mbytes (int, optional): Default amount of memory allocated for the runs of this actor, in megabytes.
404421
default_run_timeout_secs (int, optional): Default timeout for the runs of this actor in seconds.
405422
example_run_input_body (Any, optional): Input to be prefilled as default input to new users of this actor.
@@ -421,6 +438,7 @@ async def update(
421438
is_anonymously_runnable=is_anonymously_runnable,
422439
categories=categories,
423440
default_run_build=default_run_build,
441+
default_run_max_items=default_run_max_items,
424442
default_run_memory_mbytes=default_run_memory_mbytes,
425443
default_run_timeout_secs=default_run_timeout_secs,
426444
example_run_input_body=example_run_input_body,
@@ -442,6 +460,7 @@ async def start(
442460
run_input: Optional[Any] = None,
443461
content_type: Optional[str] = None,
444462
build: Optional[str] = None,
463+
max_items: Optional[int] = None,
445464
memory_mbytes: Optional[int] = None,
446465
timeout_secs: Optional[int] = None,
447466
wait_for_finish: Optional[int] = None,
@@ -456,6 +475,8 @@ async def start(
456475
content_type (str, optional): The content type of the input.
457476
build (str, optional): Specifies the actor build to run. It can be either a build tag or build number.
458477
By default, the run uses the build specified in the default run configuration for the actor (typically latest).
478+
max_items (int, optional): Maximum number of results that will be returned by this run.
479+
If the Actor is charged per result, you will not be charged for more results than the given limit.
459480
memory_mbytes (int, optional): Memory limit for the run, in megabytes.
460481
By default, the run uses a memory limit specified in the default run configuration for the actor.
461482
timeout_secs (int, optional): Optional timeout for the run, in seconds.
@@ -478,6 +499,7 @@ async def start(
478499

479500
request_params = self._params(
480501
build=build,
502+
maxItems=max_items,
481503
memory=memory_mbytes,
482504
timeout=timeout_secs,
483505
waitForFinish=wait_for_finish,
@@ -500,6 +522,7 @@ async def call(
500522
run_input: Optional[Any] = None,
501523
content_type: Optional[str] = None,
502524
build: Optional[str] = None,
525+
max_items: Optional[int] = None,
503526
memory_mbytes: Optional[int] = None,
504527
timeout_secs: Optional[int] = None,
505528
webhooks: Optional[List[Dict]] = None,
@@ -516,6 +539,8 @@ async def call(
516539
content_type (str, optional): The content type of the input.
517540
build (str, optional): Specifies the actor build to run. It can be either a build tag or build number.
518541
By default, the run uses the build specified in the default run configuration for the actor (typically latest).
542+
max_items (int, optional): Maximum number of results that will be returned by this run.
543+
If the Actor is charged per result, you will not be charged for more results than the given limit.
519544
memory_mbytes (int, optional): Memory limit for the run, in megabytes.
520545
By default, the run uses a memory limit specified in the default run configuration for the actor.
521546
timeout_secs (int, optional): Optional timeout for the run, in seconds.
@@ -532,6 +557,7 @@ async def call(
532557
run_input=run_input,
533558
content_type=content_type,
534559
build=build,
560+
max_items=max_items,
535561
memory_mbytes=memory_mbytes,
536562
timeout_secs=timeout_secs,
537563
webhooks=webhooks,

src/apify_client/clients/resource_clients/actor_collection.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ def create(
5454
is_anonymously_runnable: Optional[bool] = None,
5555
categories: Optional[List[str]] = None,
5656
default_run_build: Optional[str] = None,
57+
default_run_max_items: Optional[int] = None,
5758
default_run_memory_mbytes: Optional[int] = None,
5859
default_run_timeout_secs: Optional[int] = None,
5960
example_run_input_body: Optional[Any] = None,
@@ -76,6 +77,8 @@ def create(
7677
is_anonymously_runnable (bool, optional): Whether the actor is anonymously runnable.
7778
categories (list of str, optional): The categories to which the actor belongs to.
7879
default_run_build (str, optional): Tag or number of the build that you want to run by default.
80+
default_run_max_items (int, optional): Default limit of the number of results that will be returned by runs of this Actor,
81+
if the Actor is charged per result.
7982
default_run_memory_mbytes (int, optional): Default amount of memory allocated for the runs of this actor, in megabytes.
8083
default_run_timeout_secs (int, optional): Default timeout for the runs of this actor in seconds.
8184
example_run_input_body (Any, optional): Input to be prefilled as default input to new users of this actor.
@@ -97,6 +100,7 @@ def create(
97100
is_anonymously_runnable=is_anonymously_runnable,
98101
categories=categories,
99102
default_run_build=default_run_build,
103+
default_run_max_items=default_run_max_items,
100104
default_run_memory_mbytes=default_run_memory_mbytes,
101105
default_run_timeout_secs=default_run_timeout_secs,
102106
example_run_input_body=example_run_input_body,
@@ -153,6 +157,7 @@ async def create(
153157
is_anonymously_runnable: Optional[bool] = None,
154158
categories: Optional[List[str]] = None,
155159
default_run_build: Optional[str] = None,
160+
default_run_max_items: Optional[int] = None,
156161
default_run_memory_mbytes: Optional[int] = None,
157162
default_run_timeout_secs: Optional[int] = None,
158163
example_run_input_body: Optional[Any] = None,
@@ -175,6 +180,8 @@ async def create(
175180
is_anonymously_runnable (bool, optional): Whether the actor is anonymously runnable.
176181
categories (list of str, optional): The categories to which the actor belongs to.
177182
default_run_build (str, optional): Tag or number of the build that you want to run by default.
183+
default_run_max_items (int, optional): Default limit of the number of results that will be returned by runs of this Actor,
184+
if the Actor is charged per result.
178185
default_run_memory_mbytes (int, optional): Default amount of memory allocated for the runs of this actor, in megabytes.
179186
default_run_timeout_secs (int, optional): Default timeout for the runs of this actor in seconds.
180187
example_run_input_body (Any, optional): Input to be prefilled as default input to new users of this actor.
@@ -196,6 +203,7 @@ async def create(
196203
is_anonymously_runnable=is_anonymously_runnable,
197204
categories=categories,
198205
default_run_build=default_run_build,
206+
default_run_max_items=default_run_max_items,
199207
default_run_memory_mbytes=default_run_memory_mbytes,
200208
default_run_timeout_secs=default_run_timeout_secs,
201209
example_run_input_body=example_run_input_body,

0 commit comments

Comments
 (0)