Skip to content

Commit 74aa17d

Browse files
committed
Update
1 parent 1afcd25 commit 74aa17d

File tree

4 files changed

+40
-28
lines changed

4 files changed

+40
-28
lines changed

src/apify_client/_models.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# generated by datamodel-codegen:
22
# filename: openapi.json
3-
# timestamp: 2025-12-28T21:31:16+00:00
3+
# timestamp: 2026-01-02T15:04:48+00:00
44

55
from __future__ import annotations
66

@@ -197,13 +197,15 @@ class ActorStats(BaseModel):
197197
total_users7_days: Annotated[float, Field(alias='totalUsers7Days', examples=[2])]
198198
total_users30_days: Annotated[float, Field(alias='totalUsers30Days', examples=[6])]
199199
total_users90_days: Annotated[float, Field(alias='totalUsers90Days', examples=[6])]
200-
total_metamorphs: Annotated[float, Field(alias='totalMetamorphs', examples=[2])]
201-
last_run_started_at: Annotated[str, Field(alias='lastRunStartedAt', examples=['2019-07-08T14:01:05.546Z'])]
200+
total_metamorphs: Annotated[float | None, Field(alias='totalMetamorphs', examples=[2])] = None
201+
last_run_started_at: Annotated[
202+
str | None, Field(alias='lastRunStartedAt', examples=['2019-07-08T14:01:05.546Z'])
203+
] = None
202204

203205

204206
class ExampleRunInput(BaseModel):
205-
body: Annotated[str | None, Field(examples=[{'helloWorld': 123}])] = None
206-
content_type: Annotated[str | None, Field(alias='contentType', examples=['application/json; charset=utf-8'])] = None
207+
body: Annotated[str, Field(examples=[{'helloWorld': 123}])]
208+
content_type: Annotated[str, Field(alias='contentType', examples=['application/json; charset=utf-8'])]
207209

208210

209211
class Latest(BaseModel):
@@ -242,7 +244,7 @@ class Actor(BaseModel):
242244
default_run_options: Annotated[DefaultRunOptions, Field(alias='defaultRunOptions')]
243245
example_run_input: Annotated[Any | ExampleRunInput | None, Field(alias='exampleRunInput')] = None
244246
is_deprecated: Annotated[bool | None, Field(alias='isDeprecated', examples=[False])] = None
245-
deployment_key: Annotated[str, Field(alias='deploymentKey', examples=['ssh-rsa AAAA ...'])]
247+
deployment_key: Annotated[str | None, Field(alias='deploymentKey', examples=['ssh-rsa AAAA ...'])] = None
246248
title: Annotated[str | None, Field(examples=['My Actor'])] = None
247249
tagged_builds: Annotated[Any | TaggedBuilds | None, Field(alias='taggedBuilds')] = None
248250

@@ -416,7 +418,7 @@ class GetListOfWebhooksResponse(BaseModel):
416418

417419
class BuildsMeta(BaseModel):
418420
origin: Annotated[str, Field(examples=['WEB'])]
419-
client_ip: Annotated[str, Field(alias='clientIp', examples=['172.234.12.34'])]
421+
client_ip: Annotated[str | None, Field(alias='clientIp', examples=['172.234.12.34'])] = None
420422
user_agent: Annotated[str, Field(alias='userAgent', examples=['Mozilla/5.0 (iPad)'])]
421423

422424

@@ -444,8 +446,8 @@ class GetBuildListResponse(BaseModel):
444446

445447

446448
class BuildStats(BaseModel):
447-
duration_millis: Annotated[float, Field(alias='durationMillis', examples=[1000])]
448-
run_time_secs: Annotated[float, Field(alias='runTimeSecs', examples=[45.718])]
449+
duration_millis: Annotated[float | None, Field(alias='durationMillis', examples=[1000])] = None
450+
run_time_secs: Annotated[float | None, Field(alias='runTimeSecs', examples=[45.718])] = None
449451
compute_units: Annotated[float, Field(alias='computeUnits', examples=[0.0126994444444444])]
450452

451453

src/apify_client/_resource_clients/actor.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def get_actor_representation(
7373
actor_permission_level: ActorPermissionLevel | None = None,
7474
) -> dict:
7575
"""Get dictionary representation of the Actor."""
76-
return {
76+
actor_dict = {
7777
'name': name,
7878
'title': title,
7979
'description': description,
@@ -92,10 +92,6 @@ def get_actor_representation(
9292
'restartOnError': restart_on_error,
9393
'forcePermissionLevel': default_run_force_permission_level,
9494
},
95-
'exampleRunInput': {
96-
'body': example_run_input_body,
97-
'contentType': example_run_input_content_type,
98-
},
9995
'actorStandby': {
10096
'isEnabled': actor_standby_is_enabled,
10197
'desiredRequestsPerActorRun': actor_standby_desired_requests_per_actor_run,
@@ -108,6 +104,15 @@ def get_actor_representation(
108104
'actorPermissionLevel': actor_permission_level,
109105
}
110106

107+
# Only include exampleRunInput if at least one field is provided
108+
if example_run_input_body is not None or example_run_input_content_type is not None:
109+
actor_dict['exampleRunInput'] = {
110+
'body': example_run_input_body,
111+
'contentType': example_run_input_content_type,
112+
}
113+
114+
return actor_dict
115+
111116

112117
class ActorClient(ResourceClient):
113118
"""Sub-client for manipulating a single Actor."""

src/apify_client/_resource_clients/actor_collection.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from typing import TYPE_CHECKING, Any, Literal
44

5-
from apify_client._models import Actor, ActorShort
5+
from apify_client._models import Actor, ActorShort, CreateActorResponse
66
from apify_client._resource_clients.actor import get_actor_representation
77
from apify_client._resource_clients.base import ResourceCollectionClient, ResourceCollectionClientAsync
88
from apify_client._utils import filter_out_none_values_recursively
@@ -133,8 +133,8 @@ def create(
133133
actor_standby_memory_mbytes=actor_standby_memory_mbytes,
134134
)
135135

136-
result = self._create(filter_out_none_values_recursively(actor_representation))
137-
return Actor.model_validate(result)
136+
result = self._create(filter_out_none_values_recursively(actor_representation, remove_empty_dicts=True))
137+
return CreateActorResponse.model_validate(result).data
138138

139139

140140
class ActorCollectionClientAsync(ResourceCollectionClientAsync):
@@ -259,5 +259,5 @@ async def create(
259259
actor_standby_memory_mbytes=actor_standby_memory_mbytes,
260260
)
261261

262-
result = await self._create(filter_out_none_values_recursively(actor_representation))
263-
return Actor.model_validate(result)
262+
result = await self._create(filter_out_none_values_recursively(actor_representation, remove_empty_dicts=True))
263+
return CreateActorResponse.model_validate(result).data

src/apify_client/_resource_clients/run.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ def get(self) -> Run | None:
5252
The retrieved Actor run data.
5353
"""
5454
result = self._get()
55-
return RunResponse.model_validate(result).data if result is not None else None
55+
56+
if result is None:
57+
return None
58+
59+
return RunResponse.model_validate(result).data
5660

5761
def update(
5862
self,
@@ -290,9 +294,9 @@ def get_streamed_log(self, to_logger: logging.Logger | None = None, *, from_star
290294
run_data = self.get()
291295
run_id = f'runId:{run_data.id}' if run_data and run_data.id else ''
292296

293-
actor_id = run_data.act_id if run_data and run_data.act_id else ''
297+
actor_id = run_data.act_id if run_data else ''
294298
actor_data = self.root_client.actor(actor_id=actor_id).get() if actor_id else None
295-
actor_name = actor_data.name if actor_data and hasattr(actor_data, 'name') and actor_data.name else ''
299+
actor_name = actor_data.name if actor_data else ''
296300

297301
if not to_logger:
298302
name = ' '.join(part for part in (actor_name, run_id) if part)
@@ -354,9 +358,9 @@ def get_status_message_watcher(
354358
run_data = self.get()
355359
run_id = f'runId:{run_data.id}' if run_data and run_data.id else ''
356360

357-
actor_id = run_data.act_id if run_data and run_data.act_id else ''
361+
actor_id = run_data.act_id if run_data else ''
358362
actor_data = self.root_client.actor(actor_id=actor_id).get() if actor_id else None
359-
actor_name = actor_data.name if actor_data and hasattr(actor_data, 'name') and actor_data.name else ''
363+
actor_name = actor_data.name if actor_data else ''
360364

361365
if not to_logger:
362366
name = ' '.join(part for part in (actor_name, run_id) if part)
@@ -624,9 +628,9 @@ async def get_streamed_log(
624628
run_data = await self.get()
625629
run_id = f'runId:{run_data.id}' if run_data and run_data.id else ''
626630

627-
actor_id = run_data.act_id if run_data and run_data.act_id else ''
631+
actor_id = run_data.act_id if run_data else ''
628632
actor_data = await self.root_client.actor(actor_id=actor_id).get() if actor_id else None
629-
actor_name = actor_data.name if actor_data and hasattr(actor_data, 'name') and actor_data.name else ''
633+
actor_name = actor_data.name if actor_data else ''
630634

631635
if not to_logger:
632636
name = ' '.join(part for part in (actor_name, run_id) if part)
@@ -687,10 +691,11 @@ async def get_status_message_watcher(
687691
`StatusMessageWatcher` instance.
688692
"""
689693
run_data = await self.get()
690-
run_id = f'runId:{run_data.id}' if run_data else ''
694+
695+
run_id = f'runId:{run_data.id}' if run_data and run_data.id else ''
691696

692697
actor_id = run_data.act_id if run_data else ''
693-
actor_data = await self.root_client.actor(actor_id=actor_id).get()
698+
actor_data = await self.root_client.actor(actor_id=actor_id).get() if actor_id else None
694699
actor_name = actor_data.name if actor_data else ''
695700

696701
if not to_logger:

0 commit comments

Comments
 (0)