Skip to content

Commit 5bf31f7

Browse files
feat(api): add project increment_queries and other recent endpoints
1 parent e81cc3d commit 5bf31f7

13 files changed

+44
-103
lines changed

.stats.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
configured_endpoints: 42
2-
openapi_spec_hash: 71ff1de391293cdfb6dcb761ed89210d
2+
openapi_spec_hash: 8d2e7726c60bca0dcfc72b1e2df34ef1
33
config_hash: 2d88a0a41f5faca603ff2789a116d988

src/codex/_client.py

-71
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from ._types import (
1414
NOT_GIVEN,
1515
Omit,
16-
Headers,
1716
Timeout,
1817
NotGiven,
1918
Transport,
@@ -151,25 +150,6 @@ def __init__(
151150
def qs(self) -> Querystring:
152151
return Querystring(array_format="comma")
153152

154-
@property
155-
@override
156-
def auth_headers(self) -> dict[str, str]:
157-
return {**self._authenticated_api_key, **self._public_access_key}
158-
159-
@property
160-
def _authenticated_api_key(self) -> dict[str, str]:
161-
api_key = self.api_key
162-
if api_key is None:
163-
return {}
164-
return {"X-API-Key": api_key}
165-
166-
@property
167-
def _public_access_key(self) -> dict[str, str]:
168-
access_key = self.access_key
169-
if access_key is None:
170-
return {}
171-
return {"X-Access-Key": access_key}
172-
173153
@property
174154
@override
175155
def default_headers(self) -> dict[str, str | Omit]:
@@ -179,22 +159,6 @@ def default_headers(self) -> dict[str, str | Omit]:
179159
**self._custom_headers,
180160
}
181161

182-
@override
183-
def _validate_headers(self, headers: Headers, custom_headers: Headers) -> None:
184-
if self.api_key and headers.get("X-API-Key"):
185-
return
186-
if isinstance(custom_headers.get("X-API-Key"), Omit):
187-
return
188-
189-
if self.access_key and headers.get("X-Access-Key"):
190-
return
191-
if isinstance(custom_headers.get("X-Access-Key"), Omit):
192-
return
193-
194-
raise TypeError(
195-
'"Could not resolve authentication method. Expected either api_key or access_key to be set. Or for one of the `X-API-Key` or `X-Access-Key` headers to be explicitly omitted"'
196-
)
197-
198162
def copy(
199163
self,
200164
*,
@@ -379,25 +343,6 @@ def __init__(
379343
def qs(self) -> Querystring:
380344
return Querystring(array_format="comma")
381345

382-
@property
383-
@override
384-
def auth_headers(self) -> dict[str, str]:
385-
return {**self._authenticated_api_key, **self._public_access_key}
386-
387-
@property
388-
def _authenticated_api_key(self) -> dict[str, str]:
389-
api_key = self.api_key
390-
if api_key is None:
391-
return {}
392-
return {"X-API-Key": api_key}
393-
394-
@property
395-
def _public_access_key(self) -> dict[str, str]:
396-
access_key = self.access_key
397-
if access_key is None:
398-
return {}
399-
return {"X-Access-Key": access_key}
400-
401346
@property
402347
@override
403348
def default_headers(self) -> dict[str, str | Omit]:
@@ -407,22 +352,6 @@ def default_headers(self) -> dict[str, str | Omit]:
407352
**self._custom_headers,
408353
}
409354

410-
@override
411-
def _validate_headers(self, headers: Headers, custom_headers: Headers) -> None:
412-
if self.api_key and headers.get("X-API-Key"):
413-
return
414-
if isinstance(custom_headers.get("X-API-Key"), Omit):
415-
return
416-
417-
if self.access_key and headers.get("X-Access-Key"):
418-
return
419-
if isinstance(custom_headers.get("X-Access-Key"), Omit):
420-
return
421-
422-
raise TypeError(
423-
'"Could not resolve authentication method. Expected either api_key or access_key to be set. Or for one of the `X-API-Key` or `X-Access-Key` headers to be explicitly omitted"'
424-
)
425-
426355
def copy(
427356
self,
428357
*,

src/codex/resources/projects/access_keys.py

+4
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ def create(
5757
name: str,
5858
description: Optional[str] | NotGiven = NOT_GIVEN,
5959
expires_at: Union[str, datetime, None] | NotGiven = NOT_GIVEN,
60+
x_access_key: str | NotGiven = NOT_GIVEN,
6061
x_client_library_version: str | NotGiven = NOT_GIVEN,
6162
x_integration_type: str | NotGiven = NOT_GIVEN,
6263
x_source: str | NotGiven = NOT_GIVEN,
@@ -85,6 +86,7 @@ def create(
8586
extra_headers = {
8687
**strip_not_given(
8788
{
89+
"x-access-key": x_access_key,
8890
"x-client-library-version": x_client_library_version,
8991
"x-integration-type": x_integration_type,
9092
"x-source": x_source,
@@ -346,6 +348,7 @@ async def create(
346348
name: str,
347349
description: Optional[str] | NotGiven = NOT_GIVEN,
348350
expires_at: Union[str, datetime, None] | NotGiven = NOT_GIVEN,
351+
x_access_key: str | NotGiven = NOT_GIVEN,
349352
x_client_library_version: str | NotGiven = NOT_GIVEN,
350353
x_integration_type: str | NotGiven = NOT_GIVEN,
351354
x_source: str | NotGiven = NOT_GIVEN,
@@ -374,6 +377,7 @@ async def create(
374377
extra_headers = {
375378
**strip_not_given(
376379
{
380+
"x-access-key": x_access_key,
377381
"x-client-library-version": x_client_library_version,
378382
"x-integration-type": x_integration_type,
379383
"x-source": x_source,

src/codex/resources/projects/clusters.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def list_variants(
115115
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
116116
) -> ClusterListVariantsResponse:
117117
"""
118-
Get Cluster Variants Route
118+
Get Cluster Variants
119119
120120
Args:
121121
extra_headers: Send extra headers
@@ -230,7 +230,7 @@ async def list_variants(
230230
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
231231
) -> ClusterListVariantsResponse:
232232
"""
233-
Get Cluster Variants Route
233+
Get Cluster Variants
234234
235235
Args:
236236
extra_headers: Send extra headers

src/codex/resources/projects/entries.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ def create(
5757
answer: Optional[str] | NotGiven = NOT_GIVEN,
5858
client_query_metadata: Iterable[object] | NotGiven = NOT_GIVEN,
5959
draft_answer: Optional[str] | NotGiven = NOT_GIVEN,
60+
x_access_key: str | NotGiven = NOT_GIVEN,
6061
x_client_library_version: str | NotGiven = NOT_GIVEN,
6162
x_integration_type: str | NotGiven = NOT_GIVEN,
6263
x_source: str | NotGiven = NOT_GIVEN,
@@ -85,6 +86,7 @@ def create(
8586
extra_headers = {
8687
**strip_not_given(
8788
{
89+
"x-access-key": x_access_key,
8890
"x-client-library-version": x_client_library_version,
8991
"x-integration-type": x_integration_type,
9092
"x-source": x_source,
@@ -323,6 +325,7 @@ def query(
323325
question: str,
324326
use_llm_matching: bool | NotGiven = NOT_GIVEN,
325327
client_metadata: Optional[object] | NotGiven = NOT_GIVEN,
328+
x_access_key: str | NotGiven = NOT_GIVEN,
326329
x_client_library_version: str | NotGiven = NOT_GIVEN,
327330
x_integration_type: str | NotGiven = NOT_GIVEN,
328331
x_source: str | NotGiven = NOT_GIVEN,
@@ -335,7 +338,7 @@ def query(
335338
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
336339
) -> EntryQueryResponse:
337340
"""
338-
Query Entries Route
341+
Query Entries
339342
340343
Args:
341344
extra_headers: Send extra headers
@@ -351,6 +354,7 @@ def query(
351354
extra_headers = {
352355
**strip_not_given(
353356
{
357+
"x-access-key": x_access_key,
354358
"x-client-library-version": x_client_library_version,
355359
"x-integration-type": x_integration_type,
356360
"x-source": x_source,
@@ -446,6 +450,7 @@ async def create(
446450
answer: Optional[str] | NotGiven = NOT_GIVEN,
447451
client_query_metadata: Iterable[object] | NotGiven = NOT_GIVEN,
448452
draft_answer: Optional[str] | NotGiven = NOT_GIVEN,
453+
x_access_key: str | NotGiven = NOT_GIVEN,
449454
x_client_library_version: str | NotGiven = NOT_GIVEN,
450455
x_integration_type: str | NotGiven = NOT_GIVEN,
451456
x_source: str | NotGiven = NOT_GIVEN,
@@ -474,6 +479,7 @@ async def create(
474479
extra_headers = {
475480
**strip_not_given(
476481
{
482+
"x-access-key": x_access_key,
477483
"x-client-library-version": x_client_library_version,
478484
"x-integration-type": x_integration_type,
479485
"x-source": x_source,
@@ -712,6 +718,7 @@ async def query(
712718
question: str,
713719
use_llm_matching: bool | NotGiven = NOT_GIVEN,
714720
client_metadata: Optional[object] | NotGiven = NOT_GIVEN,
721+
x_access_key: str | NotGiven = NOT_GIVEN,
715722
x_client_library_version: str | NotGiven = NOT_GIVEN,
716723
x_integration_type: str | NotGiven = NOT_GIVEN,
717724
x_source: str | NotGiven = NOT_GIVEN,
@@ -724,7 +731,7 @@ async def query(
724731
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
725732
) -> EntryQueryResponse:
726733
"""
727-
Query Entries Route
734+
Query Entries
728735
729736
Args:
730737
extra_headers: Send extra headers
@@ -740,6 +747,7 @@ async def query(
740747
extra_headers = {
741748
**strip_not_given(
742749
{
750+
"x-access-key": x_access_key,
743751
"x-client-library-version": x_client_library_version,
744752
"x-integration-type": x_integration_type,
745753
"x-source": x_source,

src/codex/resources/projects/projects.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,11 @@ def update(
208208
def list(
209209
self,
210210
*,
211-
organization_id: str,
212211
include_entry_counts: bool | NotGiven = NOT_GIVEN,
213212
limit: int | NotGiven = NOT_GIVEN,
214213
offset: int | NotGiven = NOT_GIVEN,
215214
order: Literal["asc", "desc"] | NotGiven = NOT_GIVEN,
215+
organization_id: str | NotGiven = NOT_GIVEN,
216216
query: Optional[str] | NotGiven = NOT_GIVEN,
217217
sort: Literal["created_at", "updated_at"] | NotGiven = NOT_GIVEN,
218218
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -243,11 +243,11 @@ def list(
243243
timeout=timeout,
244244
query=maybe_transform(
245245
{
246-
"organization_id": organization_id,
247246
"include_entry_counts": include_entry_counts,
248247
"limit": limit,
249248
"offset": offset,
250249
"order": order,
250+
"organization_id": organization_id,
251251
"query": query,
252252
"sort": sort,
253253
},
@@ -513,11 +513,11 @@ async def update(
513513
async def list(
514514
self,
515515
*,
516-
organization_id: str,
517516
include_entry_counts: bool | NotGiven = NOT_GIVEN,
518517
limit: int | NotGiven = NOT_GIVEN,
519518
offset: int | NotGiven = NOT_GIVEN,
520519
order: Literal["asc", "desc"] | NotGiven = NOT_GIVEN,
520+
organization_id: str | NotGiven = NOT_GIVEN,
521521
query: Optional[str] | NotGiven = NOT_GIVEN,
522522
sort: Literal["created_at", "updated_at"] | NotGiven = NOT_GIVEN,
523523
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -548,11 +548,11 @@ async def list(
548548
timeout=timeout,
549549
query=await async_maybe_transform(
550550
{
551-
"organization_id": organization_id,
552551
"include_entry_counts": include_entry_counts,
553552
"limit": limit,
554553
"offset": offset,
555554
"order": order,
555+
"organization_id": organization_id,
556556
"query": query,
557557
"sort": sort,
558558
},

src/codex/types/project_list_params.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@
33
from __future__ import annotations
44

55
from typing import Optional
6-
from typing_extensions import Literal, Required, TypedDict
6+
from typing_extensions import Literal, TypedDict
77

88
__all__ = ["ProjectListParams"]
99

1010

1111
class ProjectListParams(TypedDict, total=False):
12-
organization_id: Required[str]
13-
1412
include_entry_counts: bool
1513

1614
limit: int
@@ -19,6 +17,8 @@ class ProjectListParams(TypedDict, total=False):
1917

2018
order: Literal["asc", "desc"]
2119

20+
organization_id: str
21+
2222
query: Optional[str]
2323

2424
sort: Literal["created_at", "updated_at"]

src/codex/types/projects/access_key_create_params.py

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ class AccessKeyCreateParams(TypedDict, total=False):
1818

1919
expires_at: Annotated[Union[str, datetime, None], PropertyInfo(format="iso8601")]
2020

21+
x_access_key: Annotated[str, PropertyInfo(alias="x-access-key")]
22+
2123
x_client_library_version: Annotated[str, PropertyInfo(alias="x-client-library-version")]
2224

2325
x_integration_type: Annotated[str, PropertyInfo(alias="x-integration-type")]

src/codex/types/projects/entry_create_params.py

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ class EntryCreateParams(TypedDict, total=False):
1919

2020
draft_answer: Optional[str]
2121

22+
x_access_key: Annotated[str, PropertyInfo(alias="x-access-key")]
23+
2224
x_client_library_version: Annotated[str, PropertyInfo(alias="x-client-library-version")]
2325

2426
x_integration_type: Annotated[str, PropertyInfo(alias="x-integration-type")]

src/codex/types/projects/entry_query_params.py

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ class EntryQueryParams(TypedDict, total=False):
1717

1818
client_metadata: Optional[object]
1919

20+
x_access_key: Annotated[str, PropertyInfo(alias="x-access-key")]
21+
2022
x_client_library_version: Annotated[str, PropertyInfo(alias="x-client-library-version")]
2123

2224
x_integration_type: Annotated[str, PropertyInfo(alias="x-integration-type")]

tests/api_resources/projects/test_access_keys.py

+2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ def test_method_create_with_all_params(self, client: Codex) -> None:
3939
name="name",
4040
description="description",
4141
expires_at=parse_datetime("2019-12-27T18:11:19.117Z"),
42+
x_access_key="x-access-key",
4243
x_client_library_version="x-client-library-version",
4344
x_integration_type="x-integration-type",
4445
x_source="x-source",
@@ -399,6 +400,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCodex) ->
399400
name="name",
400401
description="description",
401402
expires_at=parse_datetime("2019-12-27T18:11:19.117Z"),
403+
x_access_key="x-access-key",
402404
x_client_library_version="x-client-library-version",
403405
x_integration_type="x-integration-type",
404406
x_source="x-source",

tests/api_resources/projects/test_entries.py

+4
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ def test_method_create_with_all_params(self, client: Codex) -> None:
3939
answer="answer",
4040
client_query_metadata=[{}],
4141
draft_answer="draft_answer",
42+
x_access_key="x-access-key",
4243
x_client_library_version="x-client-library-version",
4344
x_integration_type="x-integration-type",
4445
x_source="x-source",
@@ -396,6 +397,7 @@ def test_method_query_with_all_params(self, client: Codex) -> None:
396397
question="question",
397398
use_llm_matching=True,
398399
client_metadata={},
400+
x_access_key="x-access-key",
399401
x_client_library_version="x-client-library-version",
400402
x_integration_type="x-integration-type",
401403
x_source="x-source",
@@ -514,6 +516,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCodex) ->
514516
answer="answer",
515517
client_query_metadata=[{}],
516518
draft_answer="draft_answer",
519+
x_access_key="x-access-key",
517520
x_client_library_version="x-client-library-version",
518521
x_integration_type="x-integration-type",
519522
x_source="x-source",
@@ -871,6 +874,7 @@ async def test_method_query_with_all_params(self, async_client: AsyncCodex) -> N
871874
question="question",
872875
use_llm_matching=True,
873876
client_metadata={},
877+
x_access_key="x-access-key",
874878
x_client_library_version="x-client-library-version",
875879
x_integration_type="x-integration-type",
876880
x_source="x-source",

0 commit comments

Comments
 (0)