Skip to content

Commit 8dd5b67

Browse files
authored
feat: add missing Standby fields to Actor update and create (#1107)
`actor.update()` and `actors().create()` (sync and async) get two keyword arguments for Standby fields the API and the generated models already support: - `actor_standby_disable_standby_fields_override` sets `actorStandby.disableStandbyFieldsOverride` - `actor_standby_should_pass_actor_input` sets `actorStandby.shouldPassActorInput` The JS client exposes both through `ActorUpdateOptions`. The forced permission level from the same issue is in #1111. Closes: #1101 *✍️ Drafted by Claude Code*
1 parent e7131fe commit 8dd5b67

3 files changed

Lines changed: 133 additions & 0 deletions

File tree

‎src/apify_client/_resource_clients/actor.py‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ def update(
127127
actor_standby_idle_timeout: timedelta | None = None,
128128
actor_standby_build: str | None = None,
129129
actor_standby_memory_mbytes: int | None = None,
130+
actor_standby_disable_standby_fields_override: bool | None = None,
131+
actor_standby_should_pass_actor_input: bool | None = None,
130132
pricing_infos: list[dict[str, Any]] | None = None,
131133
actor_permission_level: ActorPermissionLevel | None = None,
132134
tagged_builds: dict[str, dict[str, str] | None] | None = None,
@@ -164,6 +166,10 @@ def update(
164166
it will be shut down.
165167
actor_standby_build: The build tag or number to run when the Actor is in Standby mode.
166168
actor_standby_memory_mbytes: The memory in megabytes to use when the Actor is in Standby mode.
169+
actor_standby_disable_standby_fields_override: If true, prevents the Standby configuration from being
170+
overridden elsewhere.
171+
actor_standby_should_pass_actor_input: Whether to pass the Actor input to the Standby runs. If false,
172+
the Standby runs start with no input.
167173
pricing_infos: A list of objects that describes the pricing of the Actor.
168174
actor_permission_level: The permission level of the Actor on Apify platform.
169175
tagged_builds: A dictionary mapping build tag names to their settings. Use it to create, update,
@@ -200,6 +206,8 @@ def update(
200206
idle_timeout_secs=to_seconds(actor_standby_idle_timeout, as_int=True),
201207
build=actor_standby_build,
202208
memory_mbytes=actor_standby_memory_mbytes,
209+
disable_standby_fields_override=actor_standby_disable_standby_fields_override,
210+
should_pass_actor_input=actor_standby_should_pass_actor_input,
203211
),
204212
example_run_input=ExampleRunInput(
205213
body=example_run_input_body,
@@ -661,6 +669,8 @@ async def update(
661669
actor_standby_idle_timeout: timedelta | None = None,
662670
actor_standby_build: str | None = None,
663671
actor_standby_memory_mbytes: int | None = None,
672+
actor_standby_disable_standby_fields_override: bool | None = None,
673+
actor_standby_should_pass_actor_input: bool | None = None,
664674
pricing_infos: list[dict[str, Any]] | None = None,
665675
actor_permission_level: ActorPermissionLevel | None = None,
666676
tagged_builds: dict[str, dict[str, str] | None] | None = None,
@@ -698,6 +708,10 @@ async def update(
698708
it will be shut down.
699709
actor_standby_build: The build tag or number to run when the Actor is in Standby mode.
700710
actor_standby_memory_mbytes: The memory in megabytes to use when the Actor is in Standby mode.
711+
actor_standby_disable_standby_fields_override: If true, prevents the Standby configuration from being
712+
overridden elsewhere.
713+
actor_standby_should_pass_actor_input: Whether to pass the Actor input to the Standby runs. If false,
714+
the Standby runs start with no input.
701715
pricing_infos: A list of objects that describes the pricing of the Actor.
702716
actor_permission_level: The permission level of the Actor on Apify platform.
703717
tagged_builds: A dictionary mapping build tag names to their settings. Use it to create, update,
@@ -734,6 +748,8 @@ async def update(
734748
idle_timeout_secs=to_seconds(actor_standby_idle_timeout, as_int=True),
735749
build=actor_standby_build,
736750
memory_mbytes=actor_standby_memory_mbytes,
751+
disable_standby_fields_override=actor_standby_disable_standby_fields_override,
752+
should_pass_actor_input=actor_standby_should_pass_actor_input,
737753
),
738754
example_run_input=ExampleRunInput(
739755
body=example_run_input_body,

‎src/apify_client/_resource_clients/actor_collection.py‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ def create(
131131
actor_standby_idle_timeout: timedelta | None = None,
132132
actor_standby_build: str | None = None,
133133
actor_standby_memory_mbytes: int | None = None,
134+
actor_standby_disable_standby_fields_override: bool | None = None,
135+
actor_standby_should_pass_actor_input: bool | None = None,
134136
timeout: Timeout = 'medium',
135137
) -> Actor:
136138
"""Create a new Actor.
@@ -165,6 +167,10 @@ def create(
165167
it will be shut down.
166168
actor_standby_build: The build tag or number to run when the Actor is in Standby mode.
167169
actor_standby_memory_mbytes: The memory in megabytes to use when the Actor is in Standby mode.
170+
actor_standby_disable_standby_fields_override: If true, prevents the Standby configuration from being
171+
overridden elsewhere.
172+
actor_standby_should_pass_actor_input: Whether to pass the Actor input to the Standby runs. If false,
173+
the Standby runs start with no input.
168174
timeout: Timeout for the API HTTP request.
169175
170176
Returns:
@@ -194,6 +200,8 @@ def create(
194200
idle_timeout_secs=to_seconds(actor_standby_idle_timeout, as_int=True),
195201
build=actor_standby_build,
196202
memory_mbytes=actor_standby_memory_mbytes,
203+
disable_standby_fields_override=actor_standby_disable_standby_fields_override,
204+
should_pass_actor_input=actor_standby_should_pass_actor_input,
197205
),
198206
example_run_input=ExampleRunInput(
199207
body=example_run_input_body,
@@ -310,6 +318,8 @@ async def create(
310318
actor_standby_idle_timeout: timedelta | None = None,
311319
actor_standby_build: str | None = None,
312320
actor_standby_memory_mbytes: int | None = None,
321+
actor_standby_disable_standby_fields_override: bool | None = None,
322+
actor_standby_should_pass_actor_input: bool | None = None,
313323
timeout: Timeout = 'medium',
314324
) -> Actor:
315325
"""Create a new Actor.
@@ -344,6 +354,10 @@ async def create(
344354
it will be shut down.
345355
actor_standby_build: The build tag or number to run when the Actor is in Standby mode.
346356
actor_standby_memory_mbytes: The memory in megabytes to use when the Actor is in Standby mode.
357+
actor_standby_disable_standby_fields_override: If true, prevents the Standby configuration from being
358+
overridden elsewhere.
359+
actor_standby_should_pass_actor_input: Whether to pass the Actor input to the Standby runs. If false,
360+
the Standby runs start with no input.
347361
timeout: Timeout for the API HTTP request.
348362
349363
Returns:
@@ -373,6 +387,8 @@ async def create(
373387
idle_timeout_secs=to_seconds(actor_standby_idle_timeout, as_int=True),
374388
build=actor_standby_build,
375389
memory_mbytes=actor_standby_memory_mbytes,
390+
disable_standby_fields_override=actor_standby_disable_standby_fields_override,
391+
should_pass_actor_input=actor_standby_should_pass_actor_input,
376392
),
377393
example_run_input=ExampleRunInput(
378394
body=example_run_input_body,
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
from __future__ import annotations
2+
3+
import json
4+
from typing import TYPE_CHECKING, Any
5+
6+
import pytest
7+
from werkzeug import Request, Response
8+
9+
if TYPE_CHECKING:
10+
from collections.abc import Callable
11+
12+
from pytest_httpserver import HTTPServer
13+
14+
from apify_client import ApifyClient, ApifyClientAsync
15+
16+
pytestmark = pytest.mark.usefixtures('http_client_classes')
17+
18+
_MOCKED_ACTOR_ID = 'test_actor_id'
19+
_ACTOR_PATH = f'/v2/actors/{_MOCKED_ACTOR_ID}'
20+
_ACTORS_PATH = '/v2/actors'
21+
22+
_ACTOR_RESPONSE = {
23+
'data': {
24+
'id': _MOCKED_ACTOR_ID,
25+
'userId': 'test_user_id',
26+
'name': 'test-actor',
27+
'username': 'test-user',
28+
'isPublic': False,
29+
'createdAt': '2026-08-01T10:00:00.000Z',
30+
'modifiedAt': '2026-08-01T10:00:00.000Z',
31+
'stats': {},
32+
'versions': [],
33+
'defaultRunOptions': {},
34+
}
35+
}
36+
37+
_FIELDS: dict[str, Any] = {
38+
'actor_standby_disable_standby_fields_override': True,
39+
'actor_standby_should_pass_actor_input': False,
40+
}
41+
42+
_EXPECTED_BODY = {
43+
'actorStandby': {'disableStandbyFieldsOverride': True, 'shouldPassActorInput': False},
44+
}
45+
46+
47+
def capture(captured: list[Request]) -> Callable[[Request], Response]:
48+
def handler(request: Request) -> Response:
49+
captured.append(request)
50+
return Response(json.dumps(_ACTOR_RESPONSE), status=200, mimetype='application/json')
51+
52+
return handler
53+
54+
55+
def body_subset(request: Request) -> dict[str, Any]:
56+
body = json.loads(request.get_data())
57+
return {key: body[key] for key in _EXPECTED_BODY}
58+
59+
60+
def test_update_sends_standby_fields(httpserver: HTTPServer, sync_client: ApifyClient) -> None:
61+
"""`update` nests the Standby flags into `actorStandby`."""
62+
captured: list[Request] = []
63+
httpserver.expect_request(_ACTOR_PATH, method='PUT').respond_with_handler(capture(captured))
64+
65+
sync_client.actor(_MOCKED_ACTOR_ID).update(**_FIELDS)
66+
67+
assert len(captured) == 1
68+
assert body_subset(captured[0]) == _EXPECTED_BODY
69+
70+
71+
async def test_update_sends_standby_fields_async(httpserver: HTTPServer, async_client: ApifyClientAsync) -> None:
72+
"""Async `update` nests the Standby flags into `actorStandby`."""
73+
captured: list[Request] = []
74+
httpserver.expect_request(_ACTOR_PATH, method='PUT').respond_with_handler(capture(captured))
75+
76+
await async_client.actor(_MOCKED_ACTOR_ID).update(**_FIELDS)
77+
78+
assert len(captured) == 1
79+
assert body_subset(captured[0]) == _EXPECTED_BODY
80+
81+
82+
def test_create_sends_standby_fields(httpserver: HTTPServer, sync_client: ApifyClient) -> None:
83+
"""`create` nests the Standby flags into `actorStandby`."""
84+
captured: list[Request] = []
85+
httpserver.expect_request(_ACTORS_PATH, method='POST').respond_with_handler(capture(captured))
86+
87+
sync_client.actors().create(name='test-actor', **_FIELDS)
88+
89+
assert len(captured) == 1
90+
assert body_subset(captured[0]) == _EXPECTED_BODY
91+
92+
93+
async def test_create_sends_standby_fields_async(httpserver: HTTPServer, async_client: ApifyClientAsync) -> None:
94+
"""Async `create` nests the Standby flags into `actorStandby`."""
95+
captured: list[Request] = []
96+
httpserver.expect_request(_ACTORS_PATH, method='POST').respond_with_handler(capture(captured))
97+
98+
await async_client.actors().create(name='test-actor', **_FIELDS)
99+
100+
assert len(captured) == 1
101+
assert body_subset(captured[0]) == _EXPECTED_BODY

0 commit comments

Comments
 (0)