Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1c5bf85

Browse filesBrowse files
authored
feat: Add validate_input endpoint (#396)
### Description Add `validate_input` endpoint ### Issues - Closes: #151
1 parent 0c5ed97 commit 1c5bf85
Copy full SHA for 1c5bf85

1 file changed

+50Lines changed: 50 additions & 0 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src/apify_client/clients/resource_clients
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/apify_client/clients/resource_clients/actor.py‎

Copy file name to clipboardExpand all lines: src/apify_client/clients/resource_clients/actor.py
+50Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,31 @@ def webhooks(self) -> WebhookCollectionClient:
459459
"""Retrieve a client for webhooks associated with this Actor."""
460460
return WebhookCollectionClient(**self._sub_resource_init_options())
461461

462+
def validate_input(
463+
self, run_input: Any = None, *, build_tag: str | None = None, content_type: str | None = None
464+
) -> bool:
465+
"""Validate an input for the Actor that defines an input schema.
466+
467+
Args:
468+
run_input: The input to validate.
469+
build_tag: The actor's build tag.
470+
content_type: The content type of the input.
471+
472+
Returns:
473+
True if the input is valid, else raise an exception with validation error details.
474+
"""
475+
run_input, content_type = encode_key_value_store_record_value(run_input, content_type)
476+
477+
self.http_client.call(
478+
url=self._url('validate-input'),
479+
method='POST',
480+
headers={'content-type': content_type},
481+
data=run_input,
482+
params=self._params(build=build_tag),
483+
)
484+
485+
return True
486+
462487

463488
class ActorClientAsync(ResourceClientAsync):
464489
"""Async sub-client for manipulating a single Actor."""
@@ -829,3 +854,28 @@ def version(self, version_number: str) -> ActorVersionClientAsync:
829854
def webhooks(self) -> WebhookCollectionClientAsync:
830855
"""Retrieve a client for webhooks associated with this Actor."""
831856
return WebhookCollectionClientAsync(**self._sub_resource_init_options())
857+
858+
async def validate_input(
859+
self, run_input: Any = None, *, build_tag: str | None = None, content_type: str | None = None
860+
) -> bool:
861+
"""Validate an input for the Actor that defines an input schema.
862+
863+
Args:
864+
run_input: The input to validate.
865+
build_tag: The actor's build tag.
866+
content_type: The content type of the input.
867+
868+
Returns:
869+
True if the input is valid, else raise an exception with validation error details.
870+
"""
871+
run_input, content_type = encode_key_value_store_record_value(run_input, content_type)
872+
873+
await self.http_client.call(
874+
url=self._url('validate-input'),
875+
method='POST',
876+
headers={'content-type': content_type},
877+
data=run_input,
878+
params=self._params(build=build_tag),
879+
)
880+
881+
return True

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.