Skip to content

Commit d4902d5

Browse files
feat(api): add query params to tasks.list
allows listing tasks with filters on agent ID and name
1 parent 8e4dccb commit d4902d5

File tree

6 files changed

+90
-7
lines changed

6 files changed

+90
-7
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 34
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/sgp%2Fagentex-sdk-733bcb26b2f53abaac835267d630274ca18eba7726350b65fa2a74cc490908c1.yml
3-
openapi_spec_hash: f9a141a82a0b19bde31d6ea48ae4d6d6
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/sgp%2Fagentex-sdk-02d466207a009c07fd85804f8917889d1d5503dc600ff6d7fd78ef29cf9e93a1.yml
3+
openapi_spec_hash: e40b923e3cd395998d53a4d5830ab7e4
44
config_hash: f6ec6016df1ff072b5b60cdf7b438361

api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ from agentex.types import Task, TaskListResponse
4747
Methods:
4848

4949
- <code title="get /tasks/{task_id}">client.tasks.<a href="./src/agentex/resources/tasks.py">retrieve</a>(task_id) -> <a href="./src/agentex/types/task.py">Task</a></code>
50-
- <code title="get /tasks">client.tasks.<a href="./src/agentex/resources/tasks.py">list</a>() -> <a href="./src/agentex/types/task_list_response.py">TaskListResponse</a></code>
50+
- <code title="get /tasks">client.tasks.<a href="./src/agentex/resources/tasks.py">list</a>(\*\*<a href="src/agentex/types/task_list_params.py">params</a>) -> <a href="./src/agentex/types/task_list_response.py">TaskListResponse</a></code>
5151
- <code title="delete /tasks/{task_id}">client.tasks.<a href="./src/agentex/resources/tasks.py">delete</a>(task_id) -> <a href="./src/agentex/types/shared/delete_response.py">DeleteResponse</a></code>
5252
- <code title="delete /tasks/name/{task_name}">client.tasks.<a href="./src/agentex/resources/tasks.py">delete_by_name</a>(task_name) -> <a href="./src/agentex/types/shared/delete_response.py">DeleteResponse</a></code>
5353
- <code title="get /tasks/name/{task_name}">client.tasks.<a href="./src/agentex/resources/tasks.py">retrieve_by_name</a>(task_name) -> <a href="./src/agentex/types/task.py">Task</a></code>

src/agentex/resources/tasks.py

Lines changed: 54 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22

33
from __future__ import annotations
44

5+
from typing import Optional
6+
57
import httpx
68

9+
from ..types import task_list_params
710
from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven
11+
from .._utils import maybe_transform, async_maybe_transform
812
from .._compat import cached_property
913
from .._resource import SyncAPIResource, AsyncAPIResource
1014
from .._response import (
@@ -78,18 +82,41 @@ def retrieve(
7882
def list(
7983
self,
8084
*,
85+
agent_id: Optional[str] | NotGiven = NOT_GIVEN,
86+
agent_name: Optional[str] | NotGiven = NOT_GIVEN,
8187
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
8288
# The extra values given here take precedence over values defined on the client or passed to this method.
8389
extra_headers: Headers | None = None,
8490
extra_query: Query | None = None,
8591
extra_body: Body | None = None,
8692
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
8793
) -> TaskListResponse:
88-
"""List all tasks."""
94+
"""
95+
List all tasks.
96+
97+
Args:
98+
extra_headers: Send extra headers
99+
100+
extra_query: Add additional query parameters to the request
101+
102+
extra_body: Add additional JSON properties to the request
103+
104+
timeout: Override the client-level default timeout for this request, in seconds
105+
"""
89106
return self._get(
90107
"/tasks",
91108
options=make_request_options(
92-
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
109+
extra_headers=extra_headers,
110+
extra_query=extra_query,
111+
extra_body=extra_body,
112+
timeout=timeout,
113+
query=maybe_transform(
114+
{
115+
"agent_id": agent_id,
116+
"agent_name": agent_name,
117+
},
118+
task_list_params.TaskListParams,
119+
),
93120
),
94121
cast_to=TaskListResponse,
95122
)
@@ -320,18 +347,41 @@ async def retrieve(
320347
async def list(
321348
self,
322349
*,
350+
agent_id: Optional[str] | NotGiven = NOT_GIVEN,
351+
agent_name: Optional[str] | NotGiven = NOT_GIVEN,
323352
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
324353
# The extra values given here take precedence over values defined on the client or passed to this method.
325354
extra_headers: Headers | None = None,
326355
extra_query: Query | None = None,
327356
extra_body: Body | None = None,
328357
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
329358
) -> TaskListResponse:
330-
"""List all tasks."""
359+
"""
360+
List all tasks.
361+
362+
Args:
363+
extra_headers: Send extra headers
364+
365+
extra_query: Add additional query parameters to the request
366+
367+
extra_body: Add additional JSON properties to the request
368+
369+
timeout: Override the client-level default timeout for this request, in seconds
370+
"""
331371
return await self._get(
332372
"/tasks",
333373
options=make_request_options(
334-
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
374+
extra_headers=extra_headers,
375+
extra_query=extra_query,
376+
extra_body=extra_body,
377+
timeout=timeout,
378+
query=await async_maybe_transform(
379+
{
380+
"agent_id": agent_id,
381+
"agent_name": agent_name,
382+
},
383+
task_list_params.TaskListParams,
384+
),
335385
),
336386
cast_to=TaskListResponse,
337387
)

src/agentex/types/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from .agent_rpc_params import AgentRpcParams as AgentRpcParams
2020
from .agent_rpc_result import AgentRpcResult as AgentRpcResult
2121
from .span_list_params import SpanListParams as SpanListParams
22+
from .task_list_params import TaskListParams as TaskListParams
2223
from .agent_list_params import AgentListParams as AgentListParams
2324
from .event_list_params import EventListParams as EventListParams
2425
from .state_list_params import StateListParams as StateListParams
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from __future__ import annotations
4+
5+
from typing import Optional
6+
from typing_extensions import TypedDict
7+
8+
__all__ = ["TaskListParams"]
9+
10+
11+
class TaskListParams(TypedDict, total=False):
12+
agent_id: Optional[str]
13+
14+
agent_name: Optional[str]

tests/api_resources/test_tasks.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,15 @@ def test_method_list(self, client: Agentex) -> None:
6666
task = client.tasks.list()
6767
assert_matches_type(TaskListResponse, task, path=["response"])
6868

69+
@pytest.mark.skip()
70+
@parametrize
71+
def test_method_list_with_all_params(self, client: Agentex) -> None:
72+
task = client.tasks.list(
73+
agent_id="agent_id",
74+
agent_name="agent_name",
75+
)
76+
assert_matches_type(TaskListResponse, task, path=["response"])
77+
6978
@pytest.mark.skip()
7079
@parametrize
7180
def test_raw_response_list(self, client: Agentex) -> None:
@@ -350,6 +359,15 @@ async def test_method_list(self, async_client: AsyncAgentex) -> None:
350359
task = await async_client.tasks.list()
351360
assert_matches_type(TaskListResponse, task, path=["response"])
352361

362+
@pytest.mark.skip()
363+
@parametrize
364+
async def test_method_list_with_all_params(self, async_client: AsyncAgentex) -> None:
365+
task = await async_client.tasks.list(
366+
agent_id="agent_id",
367+
agent_name="agent_name",
368+
)
369+
assert_matches_type(TaskListResponse, task, path=["response"])
370+
353371
@pytest.mark.skip()
354372
@parametrize
355373
async def test_raw_response_list(self, async_client: AsyncAgentex) -> None:

0 commit comments

Comments
 (0)