Skip to content

Commit b5b63b7

Browse files
authored
Add create_action_run method (#160)
* Add create_action_run method * Bookkeeping * Fix * Add agent_run_id * Sort args * Fixes * Lint * input is required * Don't default input value
1 parent 984299b commit b5b63b7

File tree

3 files changed

+39
-3
lines changed

3 files changed

+39
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## Version 0.4.7 - 2025-11-14
4+
5+
- Add create_action_run method
6+
37
## Version 0.4.6 - 2025-10-17
48

59
- Add documentRetentionInDays to update_organization

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "cradl"
3-
version = "0.4.6"
3+
version = "0.4.7"
44
description = "Python SDK for Cradl"
55
authors = [{ name = "Cradl", email = "[email protected]" }]
66
readme = "README.md"

src/cradl/client.py

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3169,7 +3169,7 @@ def create_action(
31693169
secret_id: Optional[str] = None,
31703170
) -> Dict:
31713171

3172-
"""Get action, calls the POST /actions endpoint.
3172+
"""Create action, calls the POST /actions endpoint.
31733173
31743174
:param function_id: Id of the function to run
31753175
:type function_id: str
@@ -3293,7 +3293,7 @@ def list_action_runs(
32933293
return self._make_request(requests.get, f'/actions/{action_id}/runs', params=dictstrip(params))
32943294

32953295
def get_action_run(self, action_id: str, run_id: str) -> Dict:
3296-
"""Get action, calls the GET /actions/{actionId}/runs/{runId} endpoint.
3296+
"""Get action run, calls the GET /actions/{actionId}/runs/{runId} endpoint.
32973297
32983298
:param action_id: Id of the action
32993299
:type action_id: str
@@ -3306,3 +3306,35 @@ def get_action_run(self, action_id: str, run_id: str) -> Dict:
33063306
:py:class:`~cradl.LimitExceededException`, :py:class:`requests.exception.RequestException`
33073307
"""
33083308
return self._make_request(requests.get, f'/actions/{action_id}/runs/{run_id}')
3309+
3310+
def create_action_run(
3311+
self,
3312+
action_id: str,
3313+
input: dict,
3314+
*,
3315+
agent_run_id: Optional[str] = None,
3316+
metadata: Optional[dict] = None,
3317+
) -> Dict:
3318+
"""Create action run, calls the POST /actions/{actionId}/runs endpoint.
3319+
3320+
:param action_id: Id of the action
3321+
:type action_id: str
3322+
:param input: Dictionary with input to the run
3323+
:type input: dict
3324+
:param agent_run_id: Id of an agent run to associate with the action run
3325+
:type agent_run_id: str, optional
3326+
:param metadata: Dictionary that can be used to store additional information
3327+
:type metadata: dict, optional
3328+
:return: Action response from REST API
3329+
:rtype: dict
3330+
3331+
:raises: :py:class:`~cradl.InvalidCredentialsException`, :py:class:`~cradl.TooManyRequestsException`,\
3332+
:py:class:`~cradl.LimitExceededException`, :py:class:`requests.exception.RequestException`
3333+
"""
3334+
body = dictstrip({
3335+
'agentRunId': agent_run_id,
3336+
'input': input,
3337+
'metadata': metadata,
3338+
})
3339+
return self._make_request(requests.post, f'/actions/{action_id}/runs', body=body)
3340+

0 commit comments

Comments
 (0)