Skip to content

Commit 0d0a0c5

Browse files
authored
Add get_agent_statistics method (#163)
* Add get_agent_statistics method * Add get_agent_statistics method * Changelog
1 parent 422e5ea commit 0d0a0c5

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
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.10 - 2025-11-24
4+
5+
- Add get_agent_statistics method
6+
37
## Version 0.4.9 - 2025-11-18
48

59
- Add delete_agent_run method

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.9"
3+
version = "0.4.10"
44
description = "Python SDK for Cradl"
55
authors = [{ name = "Cradl", email = "hello@cradl.ai" }]
66
readme = "README.md"

src/cradl/client.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2963,6 +2963,29 @@ def delete_agent_run(self, agent_id: str, run_id: str) -> Dict:
29632963
"""
29642964
return self._make_request(requests.delete, f'/agents/{agent_id}/runs/{run_id}')
29652965

2966+
def get_agent_statistics(self, agent_id: str, *, after: Union[str, datetime], before: Union[str, datetime]) -> Dict:
2967+
"""Get agent statistics, calls the GET /agents/{agentId}/statistics endpoint.
2968+
2969+
:param agent_id: Id of the agent
2970+
:type agent_id: str
2971+
:param after: Start time for statistics interval
2972+
:type after: str or datetime, optional
2973+
:param before: End time for statistics interval
2974+
:type before: str or datetime, optional
2975+
:return: Agent statistics response from REST API
2976+
:rtype: dict
2977+
2978+
:raises: :py:class:`~cradl.InvalidCredentialsException`, :py:class:`~cradl.TooManyRequestsException`,\
2979+
:py:class:`~cradl.LimitExceededException`, :py:class:`requests.exception.RequestException`
2980+
"""
2981+
params = {
2982+
'after': datetimestr(after),
2983+
'before': datetimestr(before),
2984+
}
2985+
2986+
agent_statistics = self._make_request(requests.get, f'/agents/{agent_id}/statistics', params=params)
2987+
return agent_statistics
2988+
29662989
def list_hooks(self, *, max_results: Optional[int] = None, next_token: Optional[str] = None) -> Dict:
29672990
"""List hooks available, calls the GET /hooks endpoint.
29682991

0 commit comments

Comments
 (0)