Skip to content

Commit b41e3bf

Browse files
feat(api): api update (#83)
1 parent 7ee4e09 commit b41e3bf

File tree

6 files changed

+33
-1
lines changed

6 files changed

+33
-1
lines changed

src/codex/resources/projects/entries.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from __future__ import annotations
44

5-
from typing import Optional
5+
from typing import List, Optional
66
from typing_extensions import Literal
77

88
import httpx
@@ -60,6 +60,7 @@ def create(
6060
*,
6161
question: str,
6262
answer: Optional[str] | NotGiven = NOT_GIVEN,
63+
draft_answer: Optional[str] | NotGiven = NOT_GIVEN,
6364
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
6465
# The extra values given here take precedence over values defined on the client or passed to this method.
6566
extra_headers: Headers | None = None,
@@ -89,6 +90,7 @@ def create(
8990
{
9091
"question": question,
9192
"answer": answer,
93+
"draft_answer": draft_answer,
9294
},
9395
entry_create_params.EntryCreateParams,
9496
),
@@ -140,6 +142,7 @@ def update(
140142
*,
141143
project_id: str,
142144
answer: Optional[str] | NotGiven = NOT_GIVEN,
145+
draft_answer: Optional[str] | NotGiven = NOT_GIVEN,
143146
frequency_count: Optional[int] | NotGiven = NOT_GIVEN,
144147
question: Optional[str] | NotGiven = NOT_GIVEN,
145148
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -170,6 +173,7 @@ def update(
170173
body=maybe_transform(
171174
{
172175
"answer": answer,
176+
"draft_answer": draft_answer,
173177
"frequency_count": frequency_count,
174178
"question": question,
175179
},
@@ -190,6 +194,7 @@ def list(
190194
offset: int | NotGiven = NOT_GIVEN,
191195
order: Literal["asc", "desc"] | NotGiven = NOT_GIVEN,
192196
sort: Literal["created_at", "answered_at"] | NotGiven = NOT_GIVEN,
197+
states: List[Literal["unanswered", "draft", "published", "published_with_draft"]] | NotGiven = NOT_GIVEN,
193198
unanswered_only: bool | NotGiven = NOT_GIVEN,
194199
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
195200
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -227,6 +232,7 @@ def list(
227232
"offset": offset,
228233
"order": order,
229234
"sort": sort,
235+
"states": states,
230236
"unanswered_only": unanswered_only,
231237
},
232238
entry_list_params.EntryListParams,
@@ -379,6 +385,7 @@ async def create(
379385
*,
380386
question: str,
381387
answer: Optional[str] | NotGiven = NOT_GIVEN,
388+
draft_answer: Optional[str] | NotGiven = NOT_GIVEN,
382389
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
383390
# The extra values given here take precedence over values defined on the client or passed to this method.
384391
extra_headers: Headers | None = None,
@@ -408,6 +415,7 @@ async def create(
408415
{
409416
"question": question,
410417
"answer": answer,
418+
"draft_answer": draft_answer,
411419
},
412420
entry_create_params.EntryCreateParams,
413421
),
@@ -459,6 +467,7 @@ async def update(
459467
*,
460468
project_id: str,
461469
answer: Optional[str] | NotGiven = NOT_GIVEN,
470+
draft_answer: Optional[str] | NotGiven = NOT_GIVEN,
462471
frequency_count: Optional[int] | NotGiven = NOT_GIVEN,
463472
question: Optional[str] | NotGiven = NOT_GIVEN,
464473
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -489,6 +498,7 @@ async def update(
489498
body=await async_maybe_transform(
490499
{
491500
"answer": answer,
501+
"draft_answer": draft_answer,
492502
"frequency_count": frequency_count,
493503
"question": question,
494504
},
@@ -509,6 +519,7 @@ def list(
509519
offset: int | NotGiven = NOT_GIVEN,
510520
order: Literal["asc", "desc"] | NotGiven = NOT_GIVEN,
511521
sort: Literal["created_at", "answered_at"] | NotGiven = NOT_GIVEN,
522+
states: List[Literal["unanswered", "draft", "published", "published_with_draft"]] | NotGiven = NOT_GIVEN,
512523
unanswered_only: bool | NotGiven = NOT_GIVEN,
513524
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
514525
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -546,6 +557,7 @@ def list(
546557
"offset": offset,
547558
"order": order,
548559
"sort": sort,
560+
"states": states,
549561
"unanswered_only": unanswered_only,
550562
},
551563
entry_list_params.EntryListParams,

src/codex/types/projects/entry.py

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

33
from typing import Optional
44
from datetime import datetime
5+
from typing_extensions import Literal
56

67
from ..._models import BaseModel
78

@@ -13,10 +14,16 @@ class Entry(BaseModel):
1314

1415
question: str
1516

17+
state: Literal["unanswered", "draft", "published", "published_with_draft"]
18+
1619
id: Optional[str] = None
1720

1821
answer: Optional[str] = None
1922

2023
answered_at: Optional[datetime] = None
2124

25+
draft_answer: Optional[str] = None
26+
27+
draft_answer_last_edited: Optional[datetime] = None
28+
2229
frequency_count: Optional[int] = None

src/codex/types/projects/entry_create_params.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@ class EntryCreateParams(TypedDict, total=False):
1212
question: Required[str]
1313

1414
answer: Optional[str]
15+
16+
draft_answer: Optional[str]

src/codex/types/projects/entry_list_params.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from __future__ import annotations
44

5+
from typing import List
56
from typing_extensions import Literal, TypedDict
67

78
__all__ = ["EntryListParams"]
@@ -18,4 +19,6 @@ class EntryListParams(TypedDict, total=False):
1819

1920
sort: Literal["created_at", "answered_at"]
2021

22+
states: List[Literal["unanswered", "draft", "published", "published_with_draft"]]
23+
2124
unanswered_only: bool

src/codex/types/projects/entry_update_params.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ class EntryUpdateParams(TypedDict, total=False):
1313

1414
answer: Optional[str]
1515

16+
draft_answer: Optional[str]
17+
1618
frequency_count: Optional[int]
1719

1820
question: Optional[str]

tests/api_resources/projects/test_entries.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def test_method_create_with_all_params(self, client: Codex) -> None:
3636
project_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
3737
question="question",
3838
answer="answer",
39+
draft_answer="draft_answer",
3940
)
4041
assert_matches_type(Entry, entry, path=["response"])
4142

@@ -144,6 +145,7 @@ def test_method_update_with_all_params(self, client: Codex) -> None:
144145
entry_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
145146
project_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
146147
answer="answer",
148+
draft_answer="draft_answer",
147149
frequency_count=0,
148150
question="question",
149151
)
@@ -210,6 +212,7 @@ def test_method_list_with_all_params(self, client: Codex) -> None:
210212
offset=0,
211213
order="asc",
212214
sort="created_at",
215+
states=["unanswered"],
213216
unanswered_only=True,
214217
)
215218
assert_matches_type(SyncOffsetPageEntries[Entry], entry, path=["response"])
@@ -412,6 +415,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCodex) ->
412415
project_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
413416
question="question",
414417
answer="answer",
418+
draft_answer="draft_answer",
415419
)
416420
assert_matches_type(Entry, entry, path=["response"])
417421

@@ -520,6 +524,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCodex) ->
520524
entry_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
521525
project_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
522526
answer="answer",
527+
draft_answer="draft_answer",
523528
frequency_count=0,
524529
question="question",
525530
)
@@ -586,6 +591,7 @@ async def test_method_list_with_all_params(self, async_client: AsyncCodex) -> No
586591
offset=0,
587592
order="asc",
588593
sort="created_at",
594+
states=["unanswered"],
589595
unanswered_only=True,
590596
)
591597
assert_matches_type(AsyncOffsetPageEntries[Entry], entry, path=["response"])

0 commit comments

Comments
 (0)