Skip to content

Commit 91ab38a

Browse files
committed
Prefer generated models rather than apify_shared.consts
1 parent da4966e commit 91ab38a

4 files changed

Lines changed: 33 additions & 36 deletions

File tree

src/apify_client/_resource_clients/actor.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44

55
from apify_client._models import (
66
Actor,
7+
ActorPermissionLevel,
78
Build,
89
BuildActorResponse,
910
GetActorResponse,
1011
Run,
12+
RunOrigin,
1113
RunResponse,
1214
UpdateActorResponse,
1315
)
@@ -40,7 +42,7 @@
4042
from decimal import Decimal
4143
from logging import Logger
4244

43-
from apify_shared.consts import ActorJobStatus, ActorPermissionLevel, MetaOrigin
45+
from apify_shared.consts import ActorJobStatus
4446

4547

4648
def get_actor_representation(
@@ -495,7 +497,7 @@ def last_run(
495497
self,
496498
*,
497499
status: ActorJobStatus | None = None,
498-
origin: MetaOrigin | None = None,
500+
origin: RunOrigin | None = None,
499501
) -> RunClient:
500502
"""Retrieve the client for the last run of this Actor.
501503
@@ -930,7 +932,7 @@ def last_run(
930932
self,
931933
*,
932934
status: ActorJobStatus | None = None,
933-
origin: MetaOrigin | None = None,
935+
origin: RunOrigin | None = None,
934936
) -> RunClientAsync:
935937
"""Retrieve the client for the last run of this Actor.
936938

src/apify_client/_resource_clients/actor_version.py

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from __future__ import annotations
22

3-
from typing import TYPE_CHECKING, Any
3+
from typing import Any
44

5-
from apify_client._models import Version
5+
from apify_client._models import Version, VersionSourceType
66
from apify_client._resource_clients.actor_env_var import ActorEnvVarClient, ActorEnvVarClientAsync
77
from apify_client._resource_clients.actor_env_var_collection import (
88
ActorEnvVarCollectionClient,
@@ -11,17 +11,14 @@
1111
from apify_client._resource_clients.base import ResourceClient, ResourceClientAsync
1212
from apify_client._utils import filter_out_none_values_recursively, maybe_extract_enum_member_value
1313

14-
if TYPE_CHECKING:
15-
from apify_shared.consts import ActorSourceType
16-
1714

1815
def _get_actor_version_representation(
1916
*,
2017
version_number: str | None = None,
2118
build_tag: str | None = None,
2219
env_vars: list[dict] | None = None,
2320
apply_env_vars_to_build: bool | None = None,
24-
source_type: ActorSourceType | None = None,
21+
source_type: VersionSourceType | None = None,
2522
source_files: list[dict] | None = None,
2623
git_repo_url: str | None = None,
2724
tarball_url: str | None = None,
@@ -64,7 +61,7 @@ def update(
6461
build_tag: str | None = None,
6562
env_vars: list[dict] | None = None,
6663
apply_env_vars_to_build: bool | None = None,
67-
source_type: ActorSourceType | None = None,
64+
source_type: VersionSourceType | None = None,
6865
source_files: list[dict] | None = None,
6966
git_repo_url: str | None = None,
7067
tarball_url: str | None = None,
@@ -82,13 +79,13 @@ def update(
8279
be set to the Actor build process.
8380
source_type: What source type is the Actor version using.
8481
source_files: Source code comprised of multiple files, each an item of the array. Required when
85-
`source_type` is `ActorSourceType.SOURCE_FILES`. See the API docs for the exact structure.
82+
`source_type` is `VersionSourceType.SOURCE_FILES`. See the API docs for the exact structure.
8683
git_repo_url: The URL of a Git repository from which the source code will be cloned.
87-
Required when `source_type` is `ActorSourceType.GIT_REPO`.
84+
Required when `source_type` is `VersionSourceType.GIT_REPO`.
8885
tarball_url: The URL of a tarball or a zip archive from which the source code will be downloaded.
89-
Required when `source_type` is `ActorSourceType.TARBALL`.
86+
Required when `source_type` is `VersionSourceType.TARBALL`.
9087
github_gist_url: The URL of a GitHub Gist from which the source will be downloaded.
91-
Required when `source_type` is `ActorSourceType.GITHUB_GIST`.
88+
Required when `source_type` is `VersionSourceType.GITHUB_GIST`.
9289
9390
Returns:
9491
The updated Actor version.
@@ -154,7 +151,7 @@ async def update(
154151
build_tag: str | None = None,
155152
env_vars: list[dict] | None = None,
156153
apply_env_vars_to_build: bool | None = None,
157-
source_type: ActorSourceType | None = None,
154+
source_type: VersionSourceType | None = None,
158155
source_files: list[dict] | None = None,
159156
git_repo_url: str | None = None,
160157
tarball_url: str | None = None,
@@ -172,13 +169,13 @@ async def update(
172169
be set to the Actor build process.
173170
source_type: What source type is the Actor version using.
174171
source_files: Source code comprised of multiple files, each an item of the array. Required when
175-
`source_type` is `ActorSourceType.SOURCE_FILES`. See the API docs for the exact structure.
172+
`source_type` is `VersionSourceType.SOURCE_FILES`. See the API docs for the exact structure.
176173
git_repo_url: The URL of a Git repository from which the source code will be cloned.
177-
Required when `source_type` is `ActorSourceType.GIT_REPO`.
174+
Required when `source_type` is `VersionSourceType.GIT_REPO`.
178175
tarball_url: The URL of a tarball or a zip archive from which the source code will be downloaded.
179-
Required when `source_type` is `ActorSourceType.TARBALL`.
176+
Required when `source_type` is `VersionSourceType.TARBALL`.
180177
github_gist_url: The URL of a GitHub Gist from which the source will be downloaded.
181-
Required when `source_type` is `ActorSourceType.GITHUB_GIST`.
178+
Required when `source_type` is `VersionSourceType.GITHUB_GIST`.
182179
183180
Returns:
184181
The updated Actor version.

src/apify_client/_resource_clients/actor_version_collection.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@
22

33
from typing import TYPE_CHECKING, Any
44

5-
from apify_client._models import Version
5+
from apify_client._models import Version, VersionSourceType
66
from apify_client._resource_clients.actor_version import _get_actor_version_representation
77
from apify_client._resource_clients.base import ResourceCollectionClient, ResourceCollectionClientAsync
88
from apify_client._utils import filter_out_none_values_recursively
99

1010
if TYPE_CHECKING:
11-
from apify_shared.consts import ActorSourceType
12-
1311
from apify_client._types import ListPage
1412

1513

@@ -37,7 +35,7 @@ def create(
3735
build_tag: str | None = None,
3836
env_vars: list[dict] | None = None, # ty: ignore[invalid-type-form]
3937
apply_env_vars_to_build: bool | None = None,
40-
source_type: ActorSourceType,
38+
source_type: VersionSourceType,
4139
source_files: list[dict] | None = None, # ty: ignore[invalid-type-form]
4240
git_repo_url: str | None = None,
4341
tarball_url: str | None = None,
@@ -56,13 +54,13 @@ def create(
5654
be set to the Actor build process.
5755
source_type: What source type is the Actor version using.
5856
source_files: Source code comprised of multiple files, each an item of the array. Required
59-
when `source_type` is `ActorSourceType.SOURCE_FILES`. See the API docs for the exact structure.
57+
when `source_type` is `VersionSourceType.SOURCE_FILES`. See the API docs for the exact structure.
6058
git_repo_url: The URL of a Git repository from which the source code will be cloned.
61-
Required when `source_type` is `ActorSourceType.GIT_REPO`.
59+
Required when `source_type` is `VersionSourceType.GIT_REPO`.
6260
tarball_url: The URL of a tarball or a zip archive from which the source code will be downloaded.
63-
Required when `source_type` is `ActorSourceType.TARBALL`.
61+
Required when `source_type` is `VersionSourceType.TARBALL`.
6462
github_gist_url: The URL of a GitHub Gist from which the source will be downloaded.
65-
Required when `source_type` is `ActorSourceType.GITHUB_GIST`.
63+
Required when `source_type` is `VersionSourceType.GITHUB_GIST`.
6664
6765
Returns:
6866
The created Actor version.
@@ -107,7 +105,7 @@ async def create(
107105
build_tag: str | None = None,
108106
env_vars: list[dict] | None = None, # ty: ignore[invalid-type-form]
109107
apply_env_vars_to_build: bool | None = None,
110-
source_type: ActorSourceType,
108+
source_type: VersionSourceType,
111109
source_files: list[dict] | None = None, # ty: ignore[invalid-type-form]
112110
git_repo_url: str | None = None,
113111
tarball_url: str | None = None,
@@ -126,13 +124,13 @@ async def create(
126124
be set to the Actor build process.
127125
source_type: What source type is the Actor version using.
128126
source_files: Source code comprised of multiple files, each an item of the array. Required
129-
when `source_type` is `ActorSourceType.SOURCE_FILES`. See the API docs for the exact structure.
127+
when `source_type` is `VersionSourceType.SOURCE_FILES`. See the API docs for the exact structure.
130128
git_repo_url: The URL of a Git repository from which the source code will be cloned.
131-
Required when `source_type` is `ActorSourceType.GIT_REPO`.
129+
Required when `source_type` is `VersionSourceType.GIT_REPO`.
132130
tarball_url: The URL of a tarball or a zip archive from which the source code will be downloaded.
133-
Required when `source_type` is `ActorSourceType.TARBALL`.
131+
Required when `source_type` is `VersionSourceType.TARBALL`.
134132
github_gist_url: The URL of a GitHub Gist from which the source will be downloaded.
135-
Required when `source_type` is `ActorSourceType.GITHUB_GIST`.
133+
Required when `source_type` is `VersionSourceType.GITHUB_GIST`.
136134
137135
Returns:
138136
The created Actor version.

src/apify_client/_resource_clients/task.py

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

33
from typing import TYPE_CHECKING, Any, cast
44

5-
from apify_client._models import Run, RunResponse, Task
5+
from apify_client._models import Run, RunOrigin, RunResponse, Task
66
from apify_client._resource_clients.base import ResourceClient, ResourceClientAsync
77
from apify_client._resource_clients.run import RunClient, RunClientAsync
88
from apify_client._resource_clients.run_collection import RunCollectionClient, RunCollectionClientAsync
@@ -16,7 +16,7 @@
1616
from apify_client.errors import ApifyApiError
1717

1818
if TYPE_CHECKING:
19-
from apify_shared.consts import ActorJobStatus, MetaOrigin
19+
from apify_shared.consts import ActorJobStatus
2020

2121

2222
def get_task_representation(
@@ -315,7 +315,7 @@ def runs(self) -> RunCollectionClient:
315315
"""Retrieve a client for the runs of this task."""
316316
return RunCollectionClient(**self._sub_resource_init_options(resource_path='runs'))
317317

318-
def last_run(self, *, status: ActorJobStatus | None = None, origin: MetaOrigin | None = None) -> RunClient:
318+
def last_run(self, *, status: ActorJobStatus | None = None, origin: RunOrigin | None = None) -> RunClient:
319319
"""Retrieve the client for the last run of this task.
320320
321321
Last run is retrieved based on the start time of the runs.
@@ -586,7 +586,7 @@ def runs(self) -> RunCollectionClientAsync:
586586
"""Retrieve a client for the runs of this task."""
587587
return RunCollectionClientAsync(**self._sub_resource_init_options(resource_path='runs'))
588588

589-
def last_run(self, *, status: ActorJobStatus | None = None, origin: MetaOrigin | None = None) -> RunClientAsync:
589+
def last_run(self, *, status: ActorJobStatus | None = None, origin: RunOrigin | None = None) -> RunClientAsync:
590590
"""Retrieve the client for the last run of this task.
591591
592592
Last run is retrieved based on the start time of the runs.

0 commit comments

Comments
 (0)