Skip to content

Commit 68187ee

Browse files
feat(api): expose test retrieval endpoint
1 parent ad65396 commit 68187ee

File tree

7 files changed

+475
-5
lines changed

7 files changed

+475
-5
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
configured_endpoints: 16
1+
configured_endpoints: 17
22
openapi_spec_hash: 8827ead72aa0c635ccafac5e008fe247
3-
config_hash: 0383360784fc87d799bad2be203142b5
3+
config_hash: 087e6b8013c398a6d24031d24594fdec

api.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,13 @@ Methods:
4242
Types:
4343

4444
```python
45-
from openlayer.types.projects import TestCreateResponse
45+
from openlayer.types.projects import TestCreateResponse, TestListResponse
4646
```
4747

4848
Methods:
4949

5050
- <code title="post /projects/{projectId}/tests">client.projects.tests.<a href="./src/openlayer/resources/projects/tests.py">create</a>(project_id, \*\*<a href="src/openlayer/types/projects/test_create_params.py">params</a>) -> <a href="./src/openlayer/types/projects/test_create_response.py">TestCreateResponse</a></code>
51+
- <code title="get /projects/{projectId}/tests">client.projects.tests.<a href="./src/openlayer/resources/projects/tests.py">list</a>(project_id, \*\*<a href="src/openlayer/types/projects/test_list_params.py">params</a>) -> <a href="./src/openlayer/types/projects/test_list_response.py">TestListResponse</a></code>
5152

5253
# Commits
5354

src/openlayer/resources/projects/tests.py

Lines changed: 154 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
async_to_streamed_response_wrapper,
1919
)
2020
from ..._base_client import make_request_options
21-
from ...types.projects import test_create_params
21+
from ...types.projects import test_list_params, test_create_params
22+
from ...types.projects.test_list_response import TestListResponse
2223
from ...types.projects.test_create_response import TestCreateResponse
2324

2425
__all__ = ["TestsResource", "AsyncTestsResource"]
@@ -177,6 +178,76 @@ def create(
177178
cast_to=TestCreateResponse,
178179
)
179180

181+
def list(
182+
self,
183+
project_id: str,
184+
*,
185+
include_archived: bool | NotGiven = NOT_GIVEN,
186+
origin_version_id: Optional[str] | NotGiven = NOT_GIVEN,
187+
page: int | NotGiven = NOT_GIVEN,
188+
per_page: int | NotGiven = NOT_GIVEN,
189+
suggested: bool | NotGiven = NOT_GIVEN,
190+
type: Literal["integrity", "consistency", "performance", "fairness", "robustness"] | NotGiven = NOT_GIVEN,
191+
uses_production_data: Optional[bool] | NotGiven = NOT_GIVEN,
192+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
193+
# The extra values given here take precedence over values defined on the client or passed to this method.
194+
extra_headers: Headers | None = None,
195+
extra_query: Query | None = None,
196+
extra_body: Body | None = None,
197+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
198+
) -> TestListResponse:
199+
"""
200+
List tests under a project.
201+
202+
Args:
203+
include_archived: Filter for archived tests.
204+
205+
origin_version_id: Retrive tests created by a specific project version.
206+
207+
page: The page to return in a paginated query.
208+
209+
per_page: Maximum number of items to return per page.
210+
211+
suggested: Filter for suggested tests.
212+
213+
type: Filter objects by test type. Available types are `integrity`, `consistency`,
214+
`performance`, `fairness`, and `robustness`.
215+
216+
uses_production_data: Retrive tests with usesProductionData (monitoring).
217+
218+
extra_headers: Send extra headers
219+
220+
extra_query: Add additional query parameters to the request
221+
222+
extra_body: Add additional JSON properties to the request
223+
224+
timeout: Override the client-level default timeout for this request, in seconds
225+
"""
226+
if not project_id:
227+
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
228+
return self._get(
229+
f"/projects/{project_id}/tests",
230+
options=make_request_options(
231+
extra_headers=extra_headers,
232+
extra_query=extra_query,
233+
extra_body=extra_body,
234+
timeout=timeout,
235+
query=maybe_transform(
236+
{
237+
"include_archived": include_archived,
238+
"origin_version_id": origin_version_id,
239+
"page": page,
240+
"per_page": per_page,
241+
"suggested": suggested,
242+
"type": type,
243+
"uses_production_data": uses_production_data,
244+
},
245+
test_list_params.TestListParams,
246+
),
247+
),
248+
cast_to=TestListResponse,
249+
)
250+
180251

181252
class AsyncTestsResource(AsyncAPIResource):
182253
@cached_property
@@ -329,6 +400,76 @@ async def create(
329400
cast_to=TestCreateResponse,
330401
)
331402

403+
async def list(
404+
self,
405+
project_id: str,
406+
*,
407+
include_archived: bool | NotGiven = NOT_GIVEN,
408+
origin_version_id: Optional[str] | NotGiven = NOT_GIVEN,
409+
page: int | NotGiven = NOT_GIVEN,
410+
per_page: int | NotGiven = NOT_GIVEN,
411+
suggested: bool | NotGiven = NOT_GIVEN,
412+
type: Literal["integrity", "consistency", "performance", "fairness", "robustness"] | NotGiven = NOT_GIVEN,
413+
uses_production_data: Optional[bool] | NotGiven = NOT_GIVEN,
414+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
415+
# The extra values given here take precedence over values defined on the client or passed to this method.
416+
extra_headers: Headers | None = None,
417+
extra_query: Query | None = None,
418+
extra_body: Body | None = None,
419+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
420+
) -> TestListResponse:
421+
"""
422+
List tests under a project.
423+
424+
Args:
425+
include_archived: Filter for archived tests.
426+
427+
origin_version_id: Retrive tests created by a specific project version.
428+
429+
page: The page to return in a paginated query.
430+
431+
per_page: Maximum number of items to return per page.
432+
433+
suggested: Filter for suggested tests.
434+
435+
type: Filter objects by test type. Available types are `integrity`, `consistency`,
436+
`performance`, `fairness`, and `robustness`.
437+
438+
uses_production_data: Retrive tests with usesProductionData (monitoring).
439+
440+
extra_headers: Send extra headers
441+
442+
extra_query: Add additional query parameters to the request
443+
444+
extra_body: Add additional JSON properties to the request
445+
446+
timeout: Override the client-level default timeout for this request, in seconds
447+
"""
448+
if not project_id:
449+
raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}")
450+
return await self._get(
451+
f"/projects/{project_id}/tests",
452+
options=make_request_options(
453+
extra_headers=extra_headers,
454+
extra_query=extra_query,
455+
extra_body=extra_body,
456+
timeout=timeout,
457+
query=await async_maybe_transform(
458+
{
459+
"include_archived": include_archived,
460+
"origin_version_id": origin_version_id,
461+
"page": page,
462+
"per_page": per_page,
463+
"suggested": suggested,
464+
"type": type,
465+
"uses_production_data": uses_production_data,
466+
},
467+
test_list_params.TestListParams,
468+
),
469+
),
470+
cast_to=TestListResponse,
471+
)
472+
332473

333474
class TestsResourceWithRawResponse:
334475
__test__ = False
@@ -339,6 +480,9 @@ def __init__(self, tests: TestsResource) -> None:
339480
self.create = to_raw_response_wrapper(
340481
tests.create,
341482
)
483+
self.list = to_raw_response_wrapper(
484+
tests.list,
485+
)
342486

343487

344488
class AsyncTestsResourceWithRawResponse:
@@ -348,6 +492,9 @@ def __init__(self, tests: AsyncTestsResource) -> None:
348492
self.create = async_to_raw_response_wrapper(
349493
tests.create,
350494
)
495+
self.list = async_to_raw_response_wrapper(
496+
tests.list,
497+
)
351498

352499

353500
class TestsResourceWithStreamingResponse:
@@ -359,6 +506,9 @@ def __init__(self, tests: TestsResource) -> None:
359506
self.create = to_streamed_response_wrapper(
360507
tests.create,
361508
)
509+
self.list = to_streamed_response_wrapper(
510+
tests.list,
511+
)
362512

363513

364514
class AsyncTestsResourceWithStreamingResponse:
@@ -368,3 +518,6 @@ def __init__(self, tests: AsyncTestsResource) -> None:
368518
self.create = async_to_streamed_response_wrapper(
369519
tests.create,
370520
)
521+
self.list = async_to_streamed_response_wrapper(
522+
tests.list,
523+
)

src/openlayer/types/projects/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
from __future__ import annotations
44

5+
from .test_list_params import TestListParams as TestListParams
56
from .commit_list_params import CommitListParams as CommitListParams
67
from .test_create_params import TestCreateParams as TestCreateParams
8+
from .test_list_response import TestListResponse as TestListResponse
79
from .commit_create_params import CommitCreateParams as CommitCreateParams
810
from .commit_list_response import CommitListResponse as CommitListResponse
911
from .test_create_response import TestCreateResponse as TestCreateResponse
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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 Literal, Annotated, TypedDict
7+
8+
from ..._utils import PropertyInfo
9+
10+
__all__ = ["TestListParams"]
11+
12+
13+
class TestListParams(TypedDict, total=False):
14+
include_archived: Annotated[bool, PropertyInfo(alias="includeArchived")]
15+
"""Filter for archived tests."""
16+
17+
origin_version_id: Annotated[Optional[str], PropertyInfo(alias="originVersionId")]
18+
"""Retrive tests created by a specific project version."""
19+
20+
page: int
21+
"""The page to return in a paginated query."""
22+
23+
per_page: Annotated[int, PropertyInfo(alias="perPage")]
24+
"""Maximum number of items to return per page."""
25+
26+
suggested: bool
27+
"""Filter for suggested tests."""
28+
29+
type: Literal["integrity", "consistency", "performance", "fairness", "robustness"]
30+
"""Filter objects by test type.
31+
32+
Available types are `integrity`, `consistency`, `performance`, `fairness`, and
33+
`robustness`.
34+
"""
35+
36+
uses_production_data: Annotated[Optional[bool], PropertyInfo(alias="usesProductionData")]
37+
"""Retrive tests with usesProductionData (monitoring)."""

0 commit comments

Comments
 (0)