From 71054ebc57bbc3f7770aada13a126bd9dacf692b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 19 Mar 2025 17:29:02 +0000 Subject: [PATCH] feat(api): api update --- src/codex/resources/projects/access_keys.py | 31 +++++++ src/codex/resources/projects/entries.py | 91 +++++++++++++++++++ .../projects/access_key_create_params.py | 8 ++ .../projects/entry_add_question_params.py | 12 ++- .../types/projects/entry_create_params.py | 12 ++- .../types/projects/entry_query_params.py | 12 ++- .../projects/test_access_keys.py | 8 ++ tests/api_resources/projects/test_entries.py | 60 ++++++++++++ 8 files changed, 231 insertions(+), 3 deletions(-) diff --git a/src/codex/resources/projects/access_keys.py b/src/codex/resources/projects/access_keys.py index d375dbc..6198739 100644 --- a/src/codex/resources/projects/access_keys.py +++ b/src/codex/resources/projects/access_keys.py @@ -10,6 +10,7 @@ from ..._types import NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven from ..._utils import ( maybe_transform, + strip_not_given, async_maybe_transform, ) from ..._compat import cached_property @@ -56,6 +57,10 @@ def create( name: str, description: Optional[str] | NotGiven = NOT_GIVEN, expires_at: Union[str, datetime, None] | NotGiven = NOT_GIVEN, + x_client_library_version: str | NotGiven = NOT_GIVEN, + x_integration_type: str | NotGiven = NOT_GIVEN, + x_source: str | NotGiven = NOT_GIVEN, + x_stainless_package_version: str | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -77,6 +82,17 @@ def create( """ if not project_id: raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}") + extra_headers = { + **strip_not_given( + { + "x-client-library-version": x_client_library_version, + "x-integration-type": x_integration_type, + "x-source": x_source, + "x-stainless-package-version": x_stainless_package_version, + } + ), + **(extra_headers or {}), + } return self._post( f"/api/projects/{project_id}/access_keys/", body=maybe_transform( @@ -330,6 +346,10 @@ async def create( name: str, description: Optional[str] | NotGiven = NOT_GIVEN, expires_at: Union[str, datetime, None] | NotGiven = NOT_GIVEN, + x_client_library_version: str | NotGiven = NOT_GIVEN, + x_integration_type: str | NotGiven = NOT_GIVEN, + x_source: str | NotGiven = NOT_GIVEN, + x_stainless_package_version: str | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -351,6 +371,17 @@ async def create( """ if not project_id: raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}") + extra_headers = { + **strip_not_given( + { + "x-client-library-version": x_client_library_version, + "x-integration-type": x_integration_type, + "x-source": x_source, + "x-stainless-package-version": x_stainless_package_version, + } + ), + **(extra_headers or {}), + } return await self._post( f"/api/projects/{project_id}/access_keys/", body=await async_maybe_transform( diff --git a/src/codex/resources/projects/entries.py b/src/codex/resources/projects/entries.py index e2c1654..f5eebad 100644 --- a/src/codex/resources/projects/entries.py +++ b/src/codex/resources/projects/entries.py @@ -10,6 +10,7 @@ from ..._types import NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven from ..._utils import ( maybe_transform, + strip_not_given, async_maybe_transform, ) from ..._compat import cached_property @@ -61,6 +62,10 @@ def create( question: str, answer: Optional[str] | NotGiven = NOT_GIVEN, draft_answer: Optional[str] | NotGiven = NOT_GIVEN, + x_client_library_version: str | NotGiven = NOT_GIVEN, + x_integration_type: str | NotGiven = NOT_GIVEN, + x_source: str | NotGiven = NOT_GIVEN, + x_stainless_package_version: str | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -84,6 +89,17 @@ def create( """ if not project_id: raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}") + extra_headers = { + **strip_not_given( + { + "x-client-library-version": x_client_library_version, + "x-integration-type": x_integration_type, + "x-source": x_source, + "x-stainless-package-version": x_stainless_package_version, + } + ), + **(extra_headers or {}), + } return self._post( f"/api/projects/{project_id}/entries/", body=maybe_transform( @@ -283,6 +299,10 @@ def add_question( project_id: str, *, question: str, + x_client_library_version: str | NotGiven = NOT_GIVEN, + x_integration_type: str | NotGiven = NOT_GIVEN, + x_source: str | NotGiven = NOT_GIVEN, + x_stainless_package_version: str | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -307,6 +327,17 @@ def add_question( """ if not project_id: raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}") + extra_headers = { + **strip_not_given( + { + "x-client-library-version": x_client_library_version, + "x-integration-type": x_integration_type, + "x-source": x_source, + "x-stainless-package-version": x_stainless_package_version, + } + ), + **(extra_headers or {}), + } return self._post( f"/api/projects/{project_id}/entries/add_question", body=maybe_transform({"question": question}, entry_add_question_params.EntryAddQuestionParams), @@ -321,6 +352,10 @@ def query( project_id: str, *, question: str, + x_client_library_version: str | NotGiven = NOT_GIVEN, + x_integration_type: str | NotGiven = NOT_GIVEN, + x_source: str | NotGiven = NOT_GIVEN, + x_stainless_package_version: str | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -349,6 +384,17 @@ def query( """ if not project_id: raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}") + extra_headers = { + **strip_not_given( + { + "x-client-library-version": x_client_library_version, + "x-integration-type": x_integration_type, + "x-source": x_source, + "x-stainless-package-version": x_stainless_package_version, + } + ), + **(extra_headers or {}), + } return self._post( f"/api/projects/{project_id}/entries/query", body=maybe_transform({"question": question}, entry_query_params.EntryQueryParams), @@ -386,6 +432,10 @@ async def create( question: str, answer: Optional[str] | NotGiven = NOT_GIVEN, draft_answer: Optional[str] | NotGiven = NOT_GIVEN, + x_client_library_version: str | NotGiven = NOT_GIVEN, + x_integration_type: str | NotGiven = NOT_GIVEN, + x_source: str | NotGiven = NOT_GIVEN, + x_stainless_package_version: str | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -409,6 +459,17 @@ async def create( """ if not project_id: raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}") + extra_headers = { + **strip_not_given( + { + "x-client-library-version": x_client_library_version, + "x-integration-type": x_integration_type, + "x-source": x_source, + "x-stainless-package-version": x_stainless_package_version, + } + ), + **(extra_headers or {}), + } return await self._post( f"/api/projects/{project_id}/entries/", body=await async_maybe_transform( @@ -608,6 +669,10 @@ async def add_question( project_id: str, *, question: str, + x_client_library_version: str | NotGiven = NOT_GIVEN, + x_integration_type: str | NotGiven = NOT_GIVEN, + x_source: str | NotGiven = NOT_GIVEN, + x_stainless_package_version: str | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -632,6 +697,17 @@ async def add_question( """ if not project_id: raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}") + extra_headers = { + **strip_not_given( + { + "x-client-library-version": x_client_library_version, + "x-integration-type": x_integration_type, + "x-source": x_source, + "x-stainless-package-version": x_stainless_package_version, + } + ), + **(extra_headers or {}), + } return await self._post( f"/api/projects/{project_id}/entries/add_question", body=await async_maybe_transform({"question": question}, entry_add_question_params.EntryAddQuestionParams), @@ -646,6 +722,10 @@ async def query( project_id: str, *, question: str, + x_client_library_version: str | NotGiven = NOT_GIVEN, + x_integration_type: str | NotGiven = NOT_GIVEN, + x_source: str | NotGiven = NOT_GIVEN, + x_stainless_package_version: str | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -674,6 +754,17 @@ async def query( """ if not project_id: raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}") + extra_headers = { + **strip_not_given( + { + "x-client-library-version": x_client_library_version, + "x-integration-type": x_integration_type, + "x-source": x_source, + "x-stainless-package-version": x_stainless_package_version, + } + ), + **(extra_headers or {}), + } return await self._post( f"/api/projects/{project_id}/entries/query", body=await async_maybe_transform({"question": question}, entry_query_params.EntryQueryParams), diff --git a/src/codex/types/projects/access_key_create_params.py b/src/codex/types/projects/access_key_create_params.py index 1cbc202..cf5f00f 100644 --- a/src/codex/types/projects/access_key_create_params.py +++ b/src/codex/types/projects/access_key_create_params.py @@ -17,3 +17,11 @@ class AccessKeyCreateParams(TypedDict, total=False): description: Optional[str] expires_at: Annotated[Union[str, datetime, None], PropertyInfo(format="iso8601")] + + x_client_library_version: Annotated[str, PropertyInfo(alias="x-client-library-version")] + + x_integration_type: Annotated[str, PropertyInfo(alias="x-integration-type")] + + x_source: Annotated[str, PropertyInfo(alias="x-source")] + + x_stainless_package_version: Annotated[str, PropertyInfo(alias="x-stainless-package-version")] diff --git a/src/codex/types/projects/entry_add_question_params.py b/src/codex/types/projects/entry_add_question_params.py index e2d009b..b310f96 100644 --- a/src/codex/types/projects/entry_add_question_params.py +++ b/src/codex/types/projects/entry_add_question_params.py @@ -2,10 +2,20 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import Required, Annotated, TypedDict + +from ..._utils import PropertyInfo __all__ = ["EntryAddQuestionParams"] class EntryAddQuestionParams(TypedDict, total=False): question: Required[str] + + x_client_library_version: Annotated[str, PropertyInfo(alias="x-client-library-version")] + + x_integration_type: Annotated[str, PropertyInfo(alias="x-integration-type")] + + x_source: Annotated[str, PropertyInfo(alias="x-source")] + + x_stainless_package_version: Annotated[str, PropertyInfo(alias="x-stainless-package-version")] diff --git a/src/codex/types/projects/entry_create_params.py b/src/codex/types/projects/entry_create_params.py index daf3089..0022942 100644 --- a/src/codex/types/projects/entry_create_params.py +++ b/src/codex/types/projects/entry_create_params.py @@ -3,7 +3,9 @@ from __future__ import annotations from typing import Optional -from typing_extensions import Required, TypedDict +from typing_extensions import Required, Annotated, TypedDict + +from ..._utils import PropertyInfo __all__ = ["EntryCreateParams"] @@ -14,3 +16,11 @@ class EntryCreateParams(TypedDict, total=False): answer: Optional[str] draft_answer: Optional[str] + + x_client_library_version: Annotated[str, PropertyInfo(alias="x-client-library-version")] + + x_integration_type: Annotated[str, PropertyInfo(alias="x-integration-type")] + + x_source: Annotated[str, PropertyInfo(alias="x-source")] + + x_stainless_package_version: Annotated[str, PropertyInfo(alias="x-stainless-package-version")] diff --git a/src/codex/types/projects/entry_query_params.py b/src/codex/types/projects/entry_query_params.py index b6fbc43..bc0e317 100644 --- a/src/codex/types/projects/entry_query_params.py +++ b/src/codex/types/projects/entry_query_params.py @@ -2,10 +2,20 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import Required, Annotated, TypedDict + +from ..._utils import PropertyInfo __all__ = ["EntryQueryParams"] class EntryQueryParams(TypedDict, total=False): question: Required[str] + + x_client_library_version: Annotated[str, PropertyInfo(alias="x-client-library-version")] + + x_integration_type: Annotated[str, PropertyInfo(alias="x-integration-type")] + + x_source: Annotated[str, PropertyInfo(alias="x-source")] + + x_stainless_package_version: Annotated[str, PropertyInfo(alias="x-stainless-package-version")] diff --git a/tests/api_resources/projects/test_access_keys.py b/tests/api_resources/projects/test_access_keys.py index 240c31e..ad4ee5e 100644 --- a/tests/api_resources/projects/test_access_keys.py +++ b/tests/api_resources/projects/test_access_keys.py @@ -39,6 +39,10 @@ def test_method_create_with_all_params(self, client: Codex) -> None: name="name", description="description", expires_at=parse_datetime("2019-12-27T18:11:19.117Z"), + x_client_library_version="x-client-library-version", + x_integration_type="x-integration-type", + x_source="x-source", + x_stainless_package_version="x-stainless-package-version", ) assert_matches_type(AccessKeySchema, access_key, path=["response"]) @@ -395,6 +399,10 @@ async def test_method_create_with_all_params(self, async_client: AsyncCodex) -> name="name", description="description", expires_at=parse_datetime("2019-12-27T18:11:19.117Z"), + x_client_library_version="x-client-library-version", + x_integration_type="x-integration-type", + x_source="x-source", + x_stainless_package_version="x-stainless-package-version", ) assert_matches_type(AccessKeySchema, access_key, path=["response"]) diff --git a/tests/api_resources/projects/test_entries.py b/tests/api_resources/projects/test_entries.py index fbbf6f2..8a18dc0 100644 --- a/tests/api_resources/projects/test_entries.py +++ b/tests/api_resources/projects/test_entries.py @@ -37,6 +37,10 @@ def test_method_create_with_all_params(self, client: Codex) -> None: question="question", answer="answer", draft_answer="draft_answer", + x_client_library_version="x-client-library-version", + x_integration_type="x-integration-type", + x_source="x-source", + x_stainless_package_version="x-stainless-package-version", ) assert_matches_type(Entry, entry, path=["response"]) @@ -312,6 +316,19 @@ def test_method_add_question(self, client: Codex) -> None: ) assert_matches_type(Entry, entry, path=["response"]) + @pytest.mark.skip() + @parametrize + def test_method_add_question_with_all_params(self, client: Codex) -> None: + entry = client.projects.entries.add_question( + project_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + question="question", + x_client_library_version="x-client-library-version", + x_integration_type="x-integration-type", + x_source="x-source", + x_stainless_package_version="x-stainless-package-version", + ) + assert_matches_type(Entry, entry, path=["response"]) + @pytest.mark.skip() @parametrize def test_raw_response_add_question(self, client: Codex) -> None: @@ -358,6 +375,19 @@ def test_method_query(self, client: Codex) -> None: ) assert_matches_type(Optional[Entry], entry, path=["response"]) + @pytest.mark.skip() + @parametrize + def test_method_query_with_all_params(self, client: Codex) -> None: + entry = client.projects.entries.query( + project_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + question="question", + x_client_library_version="x-client-library-version", + x_integration_type="x-integration-type", + x_source="x-source", + x_stainless_package_version="x-stainless-package-version", + ) + assert_matches_type(Optional[Entry], entry, path=["response"]) + @pytest.mark.skip() @parametrize def test_raw_response_query(self, client: Codex) -> None: @@ -416,6 +446,10 @@ async def test_method_create_with_all_params(self, async_client: AsyncCodex) -> question="question", answer="answer", draft_answer="draft_answer", + x_client_library_version="x-client-library-version", + x_integration_type="x-integration-type", + x_source="x-source", + x_stainless_package_version="x-stainless-package-version", ) assert_matches_type(Entry, entry, path=["response"]) @@ -691,6 +725,19 @@ async def test_method_add_question(self, async_client: AsyncCodex) -> None: ) assert_matches_type(Entry, entry, path=["response"]) + @pytest.mark.skip() + @parametrize + async def test_method_add_question_with_all_params(self, async_client: AsyncCodex) -> None: + entry = await async_client.projects.entries.add_question( + project_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + question="question", + x_client_library_version="x-client-library-version", + x_integration_type="x-integration-type", + x_source="x-source", + x_stainless_package_version="x-stainless-package-version", + ) + assert_matches_type(Entry, entry, path=["response"]) + @pytest.mark.skip() @parametrize async def test_raw_response_add_question(self, async_client: AsyncCodex) -> None: @@ -737,6 +784,19 @@ async def test_method_query(self, async_client: AsyncCodex) -> None: ) assert_matches_type(Optional[Entry], entry, path=["response"]) + @pytest.mark.skip() + @parametrize + async def test_method_query_with_all_params(self, async_client: AsyncCodex) -> None: + entry = await async_client.projects.entries.query( + project_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + question="question", + x_client_library_version="x-client-library-version", + x_integration_type="x-integration-type", + x_source="x-source", + x_stainless_package_version="x-stainless-package-version", + ) + assert_matches_type(Optional[Entry], entry, path=["response"]) + @pytest.mark.skip() @parametrize async def test_raw_response_query(self, async_client: AsyncCodex) -> None: