Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions src/apify_client/clients/resource_clients/actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,31 @@ def webhooks(self) -> WebhookCollectionClient:
"""Retrieve a client for webhooks associated with this Actor."""
return WebhookCollectionClient(**self._sub_resource_init_options())

def validate_input(
self, run_input: Any = None, *, build_tag: str | None = None, content_type: str | None = None
) -> bool:
"""Validate an input for the Actor that defines an input schema.

Args:
run_input: The input to validate.
build_tag: The actor's build tag.
content_type: The content type of the input.

Returns:
True if the input is valid, else raise an exception with validation error details.
"""
run_input, content_type = encode_key_value_store_record_value(run_input, content_type)

self.http_client.call(
url=self._url('validate-input'),
method='POST',
headers={'content-type': content_type},
data=run_input,
params=self._params(build=build_tag),
)

return True


class ActorClientAsync(ResourceClientAsync):
"""Async sub-client for manipulating a single Actor."""
Expand Down Expand Up @@ -829,3 +854,28 @@ def version(self, version_number: str) -> ActorVersionClientAsync:
def webhooks(self) -> WebhookCollectionClientAsync:
"""Retrieve a client for webhooks associated with this Actor."""
return WebhookCollectionClientAsync(**self._sub_resource_init_options())

async def validate_input(
self, run_input: Any = None, *, build_tag: str | None = None, content_type: str | None = None
) -> bool:
"""Validate an input for the Actor that defines an input schema.

Args:
run_input: The input to validate.
build_tag: The actor's build tag.
content_type: The content type of the input.

Returns:
True if the input is valid, else raise an exception with validation error details.
"""
run_input, content_type = encode_key_value_store_record_value(run_input, content_type)

await self.http_client.call(
url=self._url('validate-input'),
method='POST',
headers={'content-type': content_type},
data=run_input,
params=self._params(build=build_tag),
)

return True