diff --git a/CHANGELOG.md b/CHANGELOG.md index 31c8f78..e1a3df6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## Version 0.4.7 - 2025-11-14 + +- Add create_action_run method + ## Version 0.4.6 - 2025-10-17 - Add documentRetentionInDays to update_organization diff --git a/pyproject.toml b/pyproject.toml index 461ba70..55ee073 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "cradl" -version = "0.4.6" +version = "0.4.7" description = "Python SDK for Cradl" authors = [{ name = "Cradl", email = "hello@cradl.ai" }] readme = "README.md" diff --git a/src/cradl/client.py b/src/cradl/client.py index 5b59485..565eb2c 100644 --- a/src/cradl/client.py +++ b/src/cradl/client.py @@ -3169,7 +3169,7 @@ def create_action( secret_id: Optional[str] = None, ) -> Dict: - """Get action, calls the POST /actions endpoint. + """Create action, calls the POST /actions endpoint. :param function_id: Id of the function to run :type function_id: str @@ -3293,7 +3293,7 @@ def list_action_runs( return self._make_request(requests.get, f'/actions/{action_id}/runs', params=dictstrip(params)) def get_action_run(self, action_id: str, run_id: str) -> Dict: - """Get action, calls the GET /actions/{actionId}/runs/{runId} endpoint. + """Get action run, calls the GET /actions/{actionId}/runs/{runId} endpoint. :param action_id: Id of the action :type action_id: str @@ -3306,3 +3306,35 @@ def get_action_run(self, action_id: str, run_id: str) -> Dict: :py:class:`~cradl.LimitExceededException`, :py:class:`requests.exception.RequestException` """ return self._make_request(requests.get, f'/actions/{action_id}/runs/{run_id}') + + def create_action_run( + self, + action_id: str, + input: dict, + *, + agent_run_id: Optional[str] = None, + metadata: Optional[dict] = None, + ) -> Dict: + """Create action run, calls the POST /actions/{actionId}/runs endpoint. + + :param action_id: Id of the action + :type action_id: str + :param input: Dictionary with input to the run + :type input: dict + :param agent_run_id: Id of an agent run to associate with the action run + :type agent_run_id: str, optional + :param metadata: Dictionary that can be used to store additional information + :type metadata: dict, optional + :return: Action response from REST API + :rtype: dict + + :raises: :py:class:`~cradl.InvalidCredentialsException`, :py:class:`~cradl.TooManyRequestsException`,\ + :py:class:`~cradl.LimitExceededException`, :py:class:`requests.exception.RequestException` + """ + body = dictstrip({ + 'agentRunId': agent_run_id, + 'input': input, + 'metadata': metadata, + }) + return self._make_request(requests.post, f'/actions/{action_id}/runs', body=body) +