-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathbuild_collection.py
More file actions
99 lines (79 loc) · 3.16 KB
/
build_collection.py
File metadata and controls
99 lines (79 loc) · 3.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
from __future__ import annotations
from typing import Any
from apify_client._docs import docs_group
from apify_client._models import ListOfBuilds, ListOfBuildsResponse
from apify_client._resource_clients._resource_client import ResourceClient, ResourceClientAsync
@docs_group('Resource clients')
class BuildCollectionClient(ResourceClient):
"""Sub-client for the Actor build collection.
Provides methods to manage Actor builds, e.g. list them. Obtain an instance via an appropriate method on the
`ApifyClient` class.
"""
def __init__(
self,
*,
resource_path: str = 'actor-builds',
**kwargs: Any,
) -> None:
super().__init__(
resource_path=resource_path,
**kwargs,
)
def list(
self,
*,
limit: int | None = None,
offset: int | None = None,
desc: bool | None = None,
) -> ListOfBuilds:
"""List all Actor builds.
List all Actor builds, either of a single Actor, or all user's Actors, depending on where this client
was initialized from.
https://docs.apify.com/api/v2#/reference/actors/build-collection/get-list-of-builds
https://docs.apify.com/api/v2#/reference/actor-builds/build-collection/get-user-builds-list
Args:
limit: How many builds to retrieve.
offset: What build to include as first when retrieving the list.
desc: Whether to sort the builds in descending order based on their start date.
Returns:
The retrieved Actor builds.
"""
result = self._list(limit=limit, offset=offset, desc=desc)
return ListOfBuildsResponse.model_validate(result).data
@docs_group('Resource clients')
class BuildCollectionClientAsync(ResourceClientAsync):
"""Sub-client for the Actor build collection.
Provides methods to manage Actor builds, e.g. list them. Obtain an instance via an appropriate method on the
`ApifyClientAsync` class.
"""
def __init__(
self,
*,
resource_path: str = 'actor-builds',
**kwargs: Any,
) -> None:
super().__init__(
resource_path=resource_path,
**kwargs,
)
async def list(
self,
*,
limit: int | None = None,
offset: int | None = None,
desc: bool | None = None,
) -> ListOfBuilds:
"""List all Actor builds.
List all Actor builds, either of a single Actor, or all user's Actors, depending on where this client
was initialized from.
https://docs.apify.com/api/v2#/reference/actors/build-collection/get-list-of-builds
https://docs.apify.com/api/v2#/reference/actor-builds/build-collection/get-user-builds-list
Args:
limit: How many builds to retrieve.
offset: What build to include as first when retrieving the list.
desc: Whether to sort the builds in descending order based on their start date.
Returns:
The retrieved Actor builds.
"""
result = await self._list(limit=limit, offset=offset, desc=desc)
return ListOfBuildsResponse.model_validate(result).data