capawesome-cloud 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,72 @@
1
+ """Offset-based pagination.
2
+
3
+ List endpoints return a bare JSON array with no pagination metadata. Pages are
4
+ walked using ``limit`` / ``offset`` query parameters: a page shorter than the
5
+ requested ``page_size`` (or an empty page) marks the end.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ from collections import deque
11
+ from typing import Any, Callable, Iterator, TypeVar
12
+
13
+ from .models import CapawesomeModel
14
+
15
+ T = TypeVar("T", bound=CapawesomeModel)
16
+
17
+ DEFAULT_PAGE_SIZE = 100
18
+
19
+ # A callable that fetches one raw page given (limit, offset).
20
+ PageFetcher = Callable[[int, int], list[Any]]
21
+
22
+
23
+ class Paginator(Iterator[T]):
24
+ """Lazily iterates over every item across all pages.
25
+
26
+ Iterate it directly to transparently page through the full result set::
27
+
28
+ for channel in client.apps.channels.list(app_id="..."):
29
+ ...
30
+ """
31
+
32
+ def __init__(
33
+ self,
34
+ fetch_page: PageFetcher,
35
+ model: type[T],
36
+ *,
37
+ page_size: int = DEFAULT_PAGE_SIZE,
38
+ start_offset: int = 0,
39
+ ) -> None:
40
+ if page_size < 1:
41
+ raise ValueError("page_size must be >= 1")
42
+ self._fetch_page = fetch_page
43
+ self._model = model
44
+ self._page_size = page_size
45
+ self._offset = start_offset
46
+ self._buffer: deque[Any] = deque()
47
+ self._exhausted = False
48
+
49
+ def __iter__(self) -> Paginator[T]:
50
+ return self
51
+
52
+ def __next__(self) -> T:
53
+ while not self._buffer:
54
+ if self._exhausted:
55
+ raise StopIteration
56
+ self._load_next_page()
57
+ item = self._buffer.popleft()
58
+ return self._model.model_validate(item)
59
+
60
+ def _load_next_page(self) -> None:
61
+ page = self._fetch_page(self._page_size, self._offset)
62
+ if not page:
63
+ self._exhausted = True
64
+ return
65
+ self._buffer.extend(page)
66
+ self._offset += len(page)
67
+ if len(page) < self._page_size:
68
+ self._exhausted = True
69
+
70
+ def to_list(self) -> list[T]:
71
+ """Eagerly fetch and return every item as a list."""
72
+ return list(self)
File without changes
@@ -0,0 +1,36 @@
1
+ """Resource clients."""
2
+
3
+ from .apps import AppsResource
4
+ from .automations import AutomationsResource
5
+ from .build_sources import BuildSourcesResource
6
+ from .builds import BuildArtifactsResource, BuildsResource
7
+ from .certificates import CertificatesResource
8
+ from .channels import ChannelsResource
9
+ from .deployments import DeploymentsResource
10
+ from .destinations import DestinationsResource
11
+ from .devices import DevicesResource
12
+ from .environments import (
13
+ EnvironmentSecretsResource,
14
+ EnvironmentsResource,
15
+ EnvironmentVariablesResource,
16
+ )
17
+ from .jobs import JobsResource
18
+ from .webhooks import WebhooksResource
19
+
20
+ __all__ = [
21
+ "AppsResource",
22
+ "AutomationsResource",
23
+ "BuildArtifactsResource",
24
+ "BuildSourcesResource",
25
+ "BuildsResource",
26
+ "CertificatesResource",
27
+ "ChannelsResource",
28
+ "DeploymentsResource",
29
+ "DestinationsResource",
30
+ "DevicesResource",
31
+ "EnvironmentSecretsResource",
32
+ "EnvironmentVariablesResource",
33
+ "EnvironmentsResource",
34
+ "JobsResource",
35
+ "WebhooksResource",
36
+ ]
@@ -0,0 +1,100 @@
1
+ """Shared functionality for resource clients."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any, List, Mapping, Optional, TypeVar
6
+
7
+ from .._http import HttpClient
8
+ from .._types import NotGiven
9
+ from ..models import CapawesomeModel
10
+ from ..pagination import DEFAULT_PAGE_SIZE, Paginator
11
+
12
+ T = TypeVar("T", bound=CapawesomeModel)
13
+
14
+
15
+ def build_body(values: Mapping[str, Any]) -> dict[str, Any]:
16
+ """Drop :data:`NOT_GIVEN` entries, keeping explicit ``None`` values."""
17
+ return {key: value for key, value in values.items() if not isinstance(value, NotGiven)}
18
+
19
+
20
+ def build_params(values: Mapping[str, Any]) -> dict[str, Any]:
21
+ """Drop both :data:`NOT_GIVEN` and ``None`` query parameters."""
22
+ return {
23
+ key: value
24
+ for key, value in values.items()
25
+ if value is not None and not isinstance(value, NotGiven)
26
+ }
27
+
28
+
29
+ class BaseResource:
30
+ def __init__(self, http: HttpClient) -> None:
31
+ self._http = http
32
+
33
+ # -- single object ------------------------------------------------------
34
+
35
+ def _request_model(
36
+ self,
37
+ method: str,
38
+ path: str,
39
+ model: type[T],
40
+ *,
41
+ params: Optional[Mapping[str, Any]] = None,
42
+ json: Optional[Any] = None,
43
+ files: Optional[Mapping[str, Any]] = None,
44
+ data: Optional[Mapping[str, Any]] = None,
45
+ ) -> T:
46
+ payload = self._http.request_json(
47
+ method, path, params=params, json=json, files=files, data=data
48
+ )
49
+ return model.model_validate(payload)
50
+
51
+ def _request_none(
52
+ self,
53
+ method: str,
54
+ path: str,
55
+ *,
56
+ params: Optional[Mapping[str, Any]] = None,
57
+ json: Optional[Any] = None,
58
+ ) -> None:
59
+ self._http.request(method, path, params=params, json=json)
60
+
61
+ # -- collections --------------------------------------------------------
62
+
63
+ def _list_page(
64
+ self,
65
+ path: str,
66
+ model: type[T],
67
+ *,
68
+ params: Optional[Mapping[str, Any]] = None,
69
+ ) -> List[T]:
70
+ payload = self._http.request_json("GET", path, params=params)
71
+ items = payload if isinstance(payload, list) else []
72
+ return [model.model_validate(item) for item in items]
73
+
74
+ def _paginate(
75
+ self,
76
+ path: str,
77
+ model: type[T],
78
+ *,
79
+ params: Optional[Mapping[str, Any]] = None,
80
+ page_size: int = DEFAULT_PAGE_SIZE,
81
+ ) -> Paginator[T]:
82
+ base_params = dict(params or {})
83
+
84
+ def fetch(limit: int, offset: int) -> List[Any]:
85
+ page_params = {**base_params, "limit": limit, "offset": offset}
86
+ payload = self._http.request_json("GET", path, params=page_params)
87
+ return payload if isinstance(payload, list) else []
88
+
89
+ return Paginator(fetch, model, page_size=page_size)
90
+
91
+ # -- binary -------------------------------------------------------------
92
+
93
+ def _download(
94
+ self,
95
+ path: str,
96
+ *,
97
+ params: Optional[Mapping[str, Any]] = None,
98
+ ) -> bytes:
99
+ response = self._http.request("GET", path, params=params)
100
+ return response.content
@@ -0,0 +1,135 @@
1
+ """Apps resource and its app-scoped sub-resources."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import List, Optional, Union
6
+
7
+ from .._http import HttpClient
8
+ from .._types import NOT_GIVEN, NotGiven
9
+ from ..models import App
10
+ from ..pagination import DEFAULT_PAGE_SIZE, Paginator
11
+ from ._base import BaseResource, build_body, build_params
12
+ from .automations import AutomationsResource
13
+ from .build_sources import BuildSourcesResource
14
+ from .builds import BuildsResource
15
+ from .certificates import CertificatesResource
16
+ from .channels import ChannelsResource
17
+ from .deployments import DeploymentsResource
18
+ from .destinations import DestinationsResource
19
+ from .devices import DevicesResource
20
+ from .environments import EnvironmentsResource
21
+ from .webhooks import WebhooksResource
22
+
23
+
24
+ class AppsResource(BaseResource):
25
+ """Apps, plus all resources scoped under ``/v1/apps/{appId}/...``.
26
+
27
+ App-scoped resources are exposed as attributes (``client.apps.channels``,
28
+ ``client.apps.builds``, ...). Each of their methods takes ``app_id`` as the
29
+ first argument.
30
+ """
31
+
32
+ _path = "/v1/apps"
33
+
34
+ def __init__(self, http: HttpClient) -> None:
35
+ super().__init__(http)
36
+ self.channels = ChannelsResource(http)
37
+ self.builds = BuildsResource(http)
38
+ self.build_sources = BuildSourcesResource(http)
39
+ self.deployments = DeploymentsResource(http)
40
+ self.destinations = DestinationsResource(http)
41
+ self.devices = DevicesResource(http)
42
+ self.environments = EnvironmentsResource(http)
43
+ self.certificates = CertificatesResource(http)
44
+ self.webhooks = WebhooksResource(http)
45
+ self.automations = AutomationsResource(http)
46
+
47
+ def create(
48
+ self,
49
+ *,
50
+ name: str,
51
+ type: Union[str, NotGiven] = NOT_GIVEN,
52
+ organization_id: Union[str, NotGiven] = NOT_GIVEN,
53
+ ) -> App:
54
+ """Create a new app. ``type`` is one of ``android``, ``capacitor``, ``cordova``, ``ios``."""
55
+ body = build_body({"name": name, "type": type})
56
+ params = build_params({"organizationId": organization_id})
57
+ return self._request_model("POST", self._path, App, params=params, json=body)
58
+
59
+ def list(
60
+ self,
61
+ *,
62
+ organization_id: Optional[str] = None,
63
+ query: Optional[str] = None,
64
+ relations: Optional[str] = None,
65
+ page_size: int = DEFAULT_PAGE_SIZE,
66
+ ) -> Paginator[App]:
67
+ """Iterate over all apps, transparently paging through the result set."""
68
+ params = build_params(
69
+ {"organizationId": organization_id, "query": query, "relations": relations}
70
+ )
71
+ return self._paginate(self._path, App, params=params, page_size=page_size)
72
+
73
+ def list_page(
74
+ self,
75
+ *,
76
+ limit: Optional[int] = None,
77
+ offset: Optional[int] = None,
78
+ organization_id: Optional[str] = None,
79
+ query: Optional[str] = None,
80
+ relations: Optional[str] = None,
81
+ ) -> List[App]:
82
+ """Fetch a single page of apps."""
83
+ params = build_params(
84
+ {
85
+ "limit": limit,
86
+ "offset": offset,
87
+ "organizationId": organization_id,
88
+ "query": query,
89
+ "relations": relations,
90
+ }
91
+ )
92
+ return self._list_page(self._path, App, params=params)
93
+
94
+ def get(self, app_id: str, *, relations: Optional[str] = None) -> App:
95
+ """Retrieve a single app by id."""
96
+ params = build_params({"relations": relations})
97
+ return self._request_model("GET", f"{self._path}/{app_id}", App, params=params)
98
+
99
+ def update(
100
+ self,
101
+ app_id: str,
102
+ *,
103
+ name: Union[str, NotGiven] = NOT_GIVEN,
104
+ type: Union[str, NotGiven] = NOT_GIVEN,
105
+ app_channel_id: Union[str, None, NotGiven] = NOT_GIVEN,
106
+ app_environment_id: Union[str, None, NotGiven] = NOT_GIVEN,
107
+ app_channel_discovery_enabled: Union[bool, NotGiven] = NOT_GIVEN,
108
+ git_repository_url: Union[str, None, NotGiven] = NOT_GIVEN,
109
+ next_app_build_number: Union[int, NotGiven] = NOT_GIVEN,
110
+ ) -> App:
111
+ """Update an app."""
112
+ body = build_body(
113
+ {
114
+ "name": name,
115
+ "type": type,
116
+ "appChannelId": app_channel_id,
117
+ "appEnvironmentId": app_environment_id,
118
+ "appChannelDiscoveryEnabled": app_channel_discovery_enabled,
119
+ "gitRepositoryUrl": git_repository_url,
120
+ "nextAppBuildNumber": next_app_build_number,
121
+ }
122
+ )
123
+ return self._request_model("PATCH", f"{self._path}/{app_id}", App, json=body)
124
+
125
+ def delete(self, app_id: str) -> None:
126
+ """Delete an app."""
127
+ self._request_none("DELETE", f"{self._path}/{app_id}")
128
+
129
+ def transfer(self, app_id: str, *, organization_id: str) -> None:
130
+ """Transfer an app to another organization."""
131
+ self._request_none(
132
+ "POST",
133
+ f"{self._path}/{app_id}/transfer",
134
+ json={"organizationId": organization_id},
135
+ )
@@ -0,0 +1,109 @@
1
+ """Automations resource."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import List, Optional
6
+
7
+ from .._types import NotGiven
8
+ from ..models import AppAutomation
9
+ from ..pagination import DEFAULT_PAGE_SIZE, Paginator
10
+ from ._base import BaseResource, build_params
11
+
12
+ _WRITE_FIELDS = {
13
+ "name": "name",
14
+ "trigger_type": "triggerType",
15
+ "trigger_pattern": "triggerPattern",
16
+ "commit_message_pattern": "commitMessagePattern",
17
+ "platform": "platform",
18
+ "build_type": "buildType",
19
+ "build_stack": "buildStack",
20
+ "enabled": "enabled",
21
+ "app_certificate_id": "appCertificateId",
22
+ "app_channel_id": "appChannelId",
23
+ "app_destination_id": "appDestinationId",
24
+ "app_environment_id": "appEnvironmentId",
25
+ }
26
+
27
+
28
+ class AutomationsResource(BaseResource):
29
+ def _base(self, app_id: str) -> str:
30
+ return f"/v1/apps/{app_id}/automations"
31
+
32
+ def create(
33
+ self, app_id: str, *, name: str, trigger_type: str, **fields: object
34
+ ) -> AppAutomation:
35
+ """Create an automation.
36
+
37
+ ``name`` and ``trigger_type`` (``branch`` or ``tag``) are required. Provide
38
+ further fields by their snake_case names (e.g. ``platform``,
39
+ ``trigger_pattern``, ``app_channel_id``).
40
+ """
41
+ body = _map_write_fields({"name": name, "trigger_type": trigger_type, **fields})
42
+ return self._request_model("POST", self._base(app_id), AppAutomation, json=body)
43
+
44
+ def list(
45
+ self,
46
+ app_id: str,
47
+ *,
48
+ platform: Optional[str] = None,
49
+ query: Optional[str] = None,
50
+ relations: Optional[str] = None,
51
+ page_size: int = DEFAULT_PAGE_SIZE,
52
+ ) -> Paginator[AppAutomation]:
53
+ """Iterate over all automations of an app."""
54
+ params = build_params({"platform": platform, "query": query, "relations": relations})
55
+ return self._paginate(self._base(app_id), AppAutomation, params=params, page_size=page_size)
56
+
57
+ def list_page(
58
+ self,
59
+ app_id: str,
60
+ *,
61
+ limit: Optional[int] = None,
62
+ offset: Optional[int] = None,
63
+ platform: Optional[str] = None,
64
+ query: Optional[str] = None,
65
+ relations: Optional[str] = None,
66
+ ) -> List[AppAutomation]:
67
+ """Fetch a single page of automations."""
68
+ params = build_params(
69
+ {
70
+ "limit": limit,
71
+ "offset": offset,
72
+ "platform": platform,
73
+ "query": query,
74
+ "relations": relations,
75
+ }
76
+ )
77
+ return self._list_page(self._base(app_id), AppAutomation, params=params)
78
+
79
+ def get(
80
+ self, app_id: str, automation_id: str, *, relations: Optional[str] = None
81
+ ) -> AppAutomation:
82
+ """Retrieve an automation by id."""
83
+ params = build_params({"relations": relations})
84
+ return self._request_model(
85
+ "GET", f"{self._base(app_id)}/{automation_id}", AppAutomation, params=params
86
+ )
87
+
88
+ def update(self, app_id: str, automation_id: str, **fields: object) -> AppAutomation:
89
+ """Update an automation. Provide fields by their snake_case names."""
90
+ body = _map_write_fields(fields)
91
+ return self._request_model(
92
+ "PATCH", f"{self._base(app_id)}/{automation_id}", AppAutomation, json=body
93
+ )
94
+
95
+ def delete(self, app_id: str, automation_id: str) -> None:
96
+ """Delete an automation."""
97
+ self._request_none("DELETE", f"{self._base(app_id)}/{automation_id}")
98
+
99
+
100
+ def _map_write_fields(fields: dict[str, object]) -> dict[str, object]:
101
+ body: dict[str, object] = {}
102
+ for key, value in fields.items():
103
+ if isinstance(value, NotGiven):
104
+ continue
105
+ api_key = _WRITE_FIELDS.get(key)
106
+ if api_key is None:
107
+ raise TypeError(f"Unknown automation field: {key!r}")
108
+ body[api_key] = value
109
+ return body
@@ -0,0 +1,29 @@
1
+ """Build sources resource."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Union
6
+
7
+ from .._types import NOT_GIVEN, NotGiven
8
+ from ..models import AppBuildSource
9
+ from ._base import BaseResource, build_body
10
+
11
+
12
+ class BuildSourcesResource(BaseResource):
13
+ def _base(self, app_id: str) -> str:
14
+ return f"/v1/apps/{app_id}/build-sources"
15
+
16
+ def create(
17
+ self,
18
+ app_id: str,
19
+ *,
20
+ file_url: Union[str, None, NotGiven] = NOT_GIVEN,
21
+ file_size_in_bytes: Union[int, None, NotGiven] = NOT_GIVEN,
22
+ ) -> AppBuildSource:
23
+ """Create a build source (e.g. register an uploaded archive)."""
24
+ body = build_body({"fileUrl": file_url, "fileSizeInBytes": file_size_in_bytes})
25
+ return self._request_model("POST", self._base(app_id), AppBuildSource, json=body)
26
+
27
+ def download(self, app_id: str, build_source_id: str) -> bytes:
28
+ """Download a build source archive."""
29
+ return self._download(f"{self._base(app_id)}/{build_source_id}/download")
@@ -0,0 +1,195 @@
1
+ """Builds resource (Native Builds) and build artifacts."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any, List, Mapping, Optional, Union
6
+
7
+ from .._http import HttpClient
8
+ from .._types import NOT_GIVEN, NotGiven
9
+ from ..models import AppBuild, AppBuildArtifact
10
+ from ..pagination import DEFAULT_PAGE_SIZE, Paginator
11
+ from ._base import BaseResource, build_body, build_params
12
+
13
+
14
+ class BuildsResource(BaseResource):
15
+ def __init__(self, http: HttpClient) -> None:
16
+ super().__init__(http)
17
+ self.artifacts = BuildArtifactsResource(http)
18
+
19
+ def _base(self, app_id: str) -> str:
20
+ return f"/v1/apps/{app_id}/builds"
21
+
22
+ def create(
23
+ self,
24
+ app_id: str,
25
+ *,
26
+ platform: Union[str, None, NotGiven] = NOT_GIVEN,
27
+ type: Union[str, None, NotGiven] = NOT_GIVEN,
28
+ stack: Union[str, NotGiven] = NOT_GIVEN,
29
+ git_ref: Union[str, None, NotGiven] = NOT_GIVEN,
30
+ app_build_source_id: Union[str, None, NotGiven] = NOT_GIVEN,
31
+ app_certificate_id: Union[str, None, NotGiven] = NOT_GIVEN,
32
+ app_certificate_name: Union[str, None, NotGiven] = NOT_GIVEN,
33
+ app_channel_id: Union[str, None, NotGiven] = NOT_GIVEN,
34
+ app_destination_id: Union[str, None, NotGiven] = NOT_GIVEN,
35
+ app_environment_id: Union[str, None, NotGiven] = NOT_GIVEN,
36
+ app_environment_name: Union[str, None, NotGiven] = NOT_GIVEN,
37
+ ad_hoc_environment_variables: Union[Mapping[str, str], None, NotGiven] = NOT_GIVEN,
38
+ ) -> AppBuild:
39
+ """Trigger a native build. Returns the build (poll its ``job_id`` for progress)."""
40
+ body = build_body(
41
+ {
42
+ "platform": platform,
43
+ "type": type,
44
+ "stack": stack,
45
+ "gitRef": git_ref,
46
+ "appBuildSourceId": app_build_source_id,
47
+ "appCertificateId": app_certificate_id,
48
+ "appCertificateName": app_certificate_name,
49
+ "appChannelId": app_channel_id,
50
+ "appDestinationId": app_destination_id,
51
+ "appEnvironmentId": app_environment_id,
52
+ "appEnvironmentName": app_environment_name,
53
+ "adHocEnvironmentVariables": ad_hoc_environment_variables,
54
+ }
55
+ )
56
+ return self._request_model("POST", self._base(app_id), AppBuild, json=body)
57
+
58
+ def list(
59
+ self,
60
+ app_id: str,
61
+ *,
62
+ platform: Optional[str] = None,
63
+ app_automation_id: Optional[str] = None,
64
+ app_git_commit: Optional[str] = None,
65
+ query: Optional[str] = None,
66
+ relations: Optional[str] = None,
67
+ page_size: int = DEFAULT_PAGE_SIZE,
68
+ ) -> Paginator[AppBuild]:
69
+ """Iterate over all builds of an app."""
70
+ params = build_params(
71
+ {
72
+ "platform": platform,
73
+ "appAutomationId": app_automation_id,
74
+ "appGitCommit": app_git_commit,
75
+ "query": query,
76
+ "relations": relations,
77
+ }
78
+ )
79
+ return self._paginate(self._base(app_id), AppBuild, params=params, page_size=page_size)
80
+
81
+ def list_page(
82
+ self,
83
+ app_id: str,
84
+ *,
85
+ limit: Optional[int] = None,
86
+ offset: Optional[int] = None,
87
+ platform: Optional[str] = None,
88
+ app_automation_id: Optional[str] = None,
89
+ app_git_commit: Optional[str] = None,
90
+ query: Optional[str] = None,
91
+ relations: Optional[str] = None,
92
+ ) -> List[AppBuild]:
93
+ """Fetch a single page of builds."""
94
+ params = build_params(
95
+ {
96
+ "limit": limit,
97
+ "offset": offset,
98
+ "platform": platform,
99
+ "appAutomationId": app_automation_id,
100
+ "appGitCommit": app_git_commit,
101
+ "query": query,
102
+ "relations": relations,
103
+ }
104
+ )
105
+ return self._list_page(self._base(app_id), AppBuild, params=params)
106
+
107
+ def get(self, app_id: str, build_id: str, *, relations: Optional[str] = None) -> AppBuild:
108
+ """Retrieve a build by id."""
109
+ params = build_params({"relations": relations})
110
+ return self._request_model(
111
+ "GET", f"{self._base(app_id)}/{build_id}", AppBuild, params=params
112
+ )
113
+
114
+ def update(
115
+ self,
116
+ app_id: str,
117
+ build_id: str,
118
+ *,
119
+ display_name: Union[str, None, NotGiven] = NOT_GIVEN,
120
+ package_name: Union[str, None, NotGiven] = NOT_GIVEN,
121
+ package_version: Union[str, None, NotGiven] = NOT_GIVEN,
122
+ custom_properties: Union[Mapping[str, Any], None, NotGiven] = NOT_GIVEN,
123
+ ) -> AppBuild:
124
+ """Update build metadata."""
125
+ body = build_body(
126
+ {
127
+ "displayName": display_name,
128
+ "packageName": package_name,
129
+ "packageVersion": package_version,
130
+ "customProperties": custom_properties,
131
+ }
132
+ )
133
+ return self._request_model("PATCH", f"{self._base(app_id)}/{build_id}", AppBuild, json=body)
134
+
135
+
136
+ class BuildArtifactsResource(BaseResource):
137
+ def _base(self, app_id: str, build_id: str) -> str:
138
+ return f"/v1/apps/{app_id}/builds/{build_id}/artifacts"
139
+
140
+ def list(
141
+ self,
142
+ app_id: str,
143
+ build_id: str,
144
+ *,
145
+ relations: Optional[str] = None,
146
+ page_size: int = DEFAULT_PAGE_SIZE,
147
+ ) -> Paginator[AppBuildArtifact]:
148
+ """Iterate over all artifacts of a build."""
149
+ params = build_params({"relations": relations})
150
+ return self._paginate(
151
+ self._base(app_id, build_id), AppBuildArtifact, params=params, page_size=page_size
152
+ )
153
+
154
+ def list_page(
155
+ self,
156
+ app_id: str,
157
+ build_id: str,
158
+ *,
159
+ limit: Optional[int] = None,
160
+ offset: Optional[int] = None,
161
+ relations: Optional[str] = None,
162
+ ) -> List[AppBuildArtifact]:
163
+ """Fetch a single page of build artifacts."""
164
+ params = build_params({"limit": limit, "offset": offset, "relations": relations})
165
+ return self._list_page(self._base(app_id, build_id), AppBuildArtifact, params=params)
166
+
167
+ def get_download_url(
168
+ self,
169
+ app_id: str,
170
+ build_id: str,
171
+ artifact_id: str,
172
+ *,
173
+ file_name: Optional[str] = None,
174
+ ) -> Any:
175
+ """Return the signed download URL payload for an artifact."""
176
+ params = build_params({"fileName": file_name})
177
+ return self._http.request_json(
178
+ "GET",
179
+ f"{self._base(app_id, build_id)}/{artifact_id}/signed-download-url",
180
+ params=params,
181
+ )
182
+
183
+ def download(
184
+ self,
185
+ app_id: str,
186
+ build_id: str,
187
+ artifact_id: str,
188
+ *,
189
+ file_name: Optional[str] = None,
190
+ ) -> bytes:
191
+ """Download an artifact's bytes."""
192
+ params = build_params({"fileName": file_name})
193
+ return self._download(
194
+ f"{self._base(app_id, build_id)}/{artifact_id}/download", params=params
195
+ )