Skip to content

Commit e341a19

Browse files
feat(api): api update (#22)
1 parent 6a135a2 commit e341a19

File tree

6 files changed

+114
-10
lines changed

6 files changed

+114
-10
lines changed

src/codex/resources/projects/projects.py

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from __future__ import annotations
44

55
from typing import Optional
6+
from typing_extensions import Literal
67

78
import httpx
89

@@ -195,6 +196,12 @@ def list(
195196
self,
196197
*,
197198
organization_id: str,
199+
include_entry_counts: bool | NotGiven = NOT_GIVEN,
200+
limit: int | NotGiven = NOT_GIVEN,
201+
offset: int | NotGiven = NOT_GIVEN,
202+
order: Literal["asc", "desc"] | NotGiven = NOT_GIVEN,
203+
query: Optional[str] | NotGiven = NOT_GIVEN,
204+
sort: Literal["created_at", "updated_at"] | NotGiven = NOT_GIVEN,
198205
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
199206
# The extra values given here take precedence over values defined on the client or passed to this method.
200207
extra_headers: Headers | None = None,
@@ -221,7 +228,18 @@ def list(
221228
extra_query=extra_query,
222229
extra_body=extra_body,
223230
timeout=timeout,
224-
query=maybe_transform({"organization_id": organization_id}, project_list_params.ProjectListParams),
231+
query=maybe_transform(
232+
{
233+
"organization_id": organization_id,
234+
"include_entry_counts": include_entry_counts,
235+
"limit": limit,
236+
"offset": offset,
237+
"order": order,
238+
"query": query,
239+
"sort": sort,
240+
},
241+
project_list_params.ProjectListParams,
242+
),
225243
),
226244
cast_to=ProjectListResponse,
227245
)
@@ -446,6 +464,12 @@ async def list(
446464
self,
447465
*,
448466
organization_id: str,
467+
include_entry_counts: bool | NotGiven = NOT_GIVEN,
468+
limit: int | NotGiven = NOT_GIVEN,
469+
offset: int | NotGiven = NOT_GIVEN,
470+
order: Literal["asc", "desc"] | NotGiven = NOT_GIVEN,
471+
query: Optional[str] | NotGiven = NOT_GIVEN,
472+
sort: Literal["created_at", "updated_at"] | NotGiven = NOT_GIVEN,
449473
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
450474
# The extra values given here take precedence over values defined on the client or passed to this method.
451475
extra_headers: Headers | None = None,
@@ -473,7 +497,16 @@ async def list(
473497
extra_body=extra_body,
474498
timeout=timeout,
475499
query=await async_maybe_transform(
476-
{"organization_id": organization_id}, project_list_params.ProjectListParams
500+
{
501+
"organization_id": organization_id,
502+
"include_entry_counts": include_entry_counts,
503+
"limit": limit,
504+
"offset": offset,
505+
"order": order,
506+
"query": query,
507+
"sort": sort,
508+
},
509+
project_list_params.ProjectListParams,
477510
),
478511
),
479512
cast_to=ProjectListResponse,

src/codex/types/project_list_params.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,23 @@
22

33
from __future__ import annotations
44

5-
from typing_extensions import Required, TypedDict
5+
from typing import Optional
6+
from typing_extensions import Literal, Required, TypedDict
67

78
__all__ = ["ProjectListParams"]
89

910

1011
class ProjectListParams(TypedDict, total=False):
1112
organization_id: Required[str]
13+
14+
include_entry_counts: bool
15+
16+
limit: int
17+
18+
offset: int
19+
20+
order: Literal["asc", "desc"]
21+
22+
query: Optional[str]
23+
24+
sort: Literal["created_at", "updated_at"]
Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,38 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

3-
from typing import List
4-
from typing_extensions import TypeAlias
3+
from typing import List, Optional
4+
from datetime import datetime
55

6-
from .project_return_schema import ProjectReturnSchema
6+
from .._models import BaseModel
77

8-
__all__ = ["ProjectListResponse"]
8+
__all__ = ["ProjectListResponse", "Project", "ProjectConfig"]
99

10-
ProjectListResponse: TypeAlias = List[ProjectReturnSchema]
10+
11+
class ProjectConfig(BaseModel):
12+
max_distance: Optional[float] = None
13+
14+
15+
class Project(BaseModel):
16+
id: str
17+
18+
config: ProjectConfig
19+
20+
created_at: datetime
21+
22+
created_by_user_id: str
23+
24+
name: str
25+
26+
organization_id: str
27+
28+
updated_at: datetime
29+
30+
description: Optional[str] = None
31+
32+
unanswered_entries_count: Optional[int] = None
33+
34+
35+
class ProjectListResponse(BaseModel):
36+
projects: List[Project]
37+
38+
total_count: int

src/codex/types/projects/entry.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99

1010

1111
class Entry(BaseModel):
12-
id: str
13-
1412
created_at: datetime
1513

1614
question: str
1715

16+
id: Optional[str] = None
17+
1818
answer: Optional[str] = None
1919

2020
answered_at: Optional[datetime] = None

src/codex/types/users/user_schema_public.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@ class UserSchemaPublic(BaseModel):
1515
email: str
1616

1717
name: Optional[str] = None
18+
19+
email_verified: Optional[bool] = None

tests/api_resources/test_projects.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,20 @@ def test_method_list(self, client: Codex) -> None:
182182
)
183183
assert_matches_type(ProjectListResponse, project, path=["response"])
184184

185+
@pytest.mark.skip()
186+
@parametrize
187+
def test_method_list_with_all_params(self, client: Codex) -> None:
188+
project = client.projects.list(
189+
organization_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
190+
include_entry_counts=True,
191+
limit=0,
192+
offset=0,
193+
order="asc",
194+
query="query",
195+
sort="created_at",
196+
)
197+
assert_matches_type(ProjectListResponse, project, path=["response"])
198+
185199
@pytest.mark.skip()
186200
@parametrize
187201
def test_raw_response_list(self, client: Codex) -> None:
@@ -458,6 +472,20 @@ async def test_method_list(self, async_client: AsyncCodex) -> None:
458472
)
459473
assert_matches_type(ProjectListResponse, project, path=["response"])
460474

475+
@pytest.mark.skip()
476+
@parametrize
477+
async def test_method_list_with_all_params(self, async_client: AsyncCodex) -> None:
478+
project = await async_client.projects.list(
479+
organization_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
480+
include_entry_counts=True,
481+
limit=0,
482+
offset=0,
483+
order="asc",
484+
query="query",
485+
sort="created_at",
486+
)
487+
assert_matches_type(ProjectListResponse, project, path=["response"])
488+
461489
@pytest.mark.skip()
462490
@parametrize
463491
async def test_raw_response_list(self, async_client: AsyncCodex) -> None:

0 commit comments

Comments
 (0)