Skip to content

Commit 8149052

Browse files
authored
fix: default_build() returns BuildClient (#389)
This PR updates the `Actor.default_build()` method to return a BuildClient instance instead of a raw response object.
1 parent e7bcf5c commit 8149052

File tree

1 file changed

+19
-6
lines changed
  • src/apify_client/clients/resource_clients

1 file changed

+19
-6
lines changed

src/apify_client/clients/resource_clients/actor.py

+19-6
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
ActorVersionCollectionClient,
1717
ActorVersionCollectionClientAsync,
1818
)
19+
from apify_client.clients.resource_clients.build import BuildClient, BuildClientAsync
1920
from apify_client.clients.resource_clients.build_collection import BuildCollectionClient, BuildCollectionClientAsync
2021
from apify_client.clients.resource_clients.run import RunClient, RunClientAsync
2122
from apify_client.clients.resource_clients.run_collection import RunCollectionClient, RunCollectionClientAsync
@@ -385,7 +386,7 @@ async def default_build(
385386
self,
386387
*,
387388
wait_for_finish: int | None = None,
388-
) -> dict:
389+
) -> BuildClient:
389390
"""Retrieve Actor's default build.
390391
391392
https://docs.apify.com/api/v2/act-build-default-get
@@ -395,15 +396,21 @@ async def default_build(
395396
By default it is 0, the maximum value is 60.
396397
397398
Returns:
398-
The build object.
399+
The resource client for the default build of this Actor.
399400
"""
400401
request_params = self._params(
401402
waitForFinish=wait_for_finish,
402403
)
403404

404405
response = self.http_client.call(url=self._url('builds/default'), method='GET', params=request_params)
406+
data = pluck_data(response.json())
405407

406-
return parse_date_fields(pluck_data(response.json()))
408+
return BuildClient(
409+
base_url=self.base_url,
410+
http_client=self.http_client,
411+
root_client=self.root_client,
412+
resource_id=data['id'],
413+
)
407414

408415
def last_run(
409416
self,
@@ -746,7 +753,7 @@ async def default_build(
746753
self,
747754
*,
748755
wait_for_finish: int | None = None,
749-
) -> dict:
756+
) -> BuildClientAsync:
750757
"""Retrieve Actor's default build.
751758
752759
https://docs.apify.com/api/v2/act-build-default-get
@@ -756,7 +763,7 @@ async def default_build(
756763
By default it is 0, the maximum value is 60.
757764
758765
Returns:
759-
The build object.
766+
The resource client for the default build of this Actor.
760767
"""
761768
request_params = self._params(
762769
waitForFinish=wait_for_finish,
@@ -767,8 +774,14 @@ async def default_build(
767774
method='GET',
768775
params=request_params,
769776
)
777+
data = pluck_data(response.json())
770778

771-
return parse_date_fields(pluck_data(response.json()))
779+
return BuildClientAsync(
780+
base_url=self.base_url,
781+
http_client=self.http_client,
782+
root_client=self.root_client,
783+
resource_id=data['id'],
784+
)
772785

773786
def last_run(
774787
self,

0 commit comments

Comments
 (0)