Skip to content

feat(api): api update #90

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions src/codex/resources/projects/access_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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(
Expand Down Expand Up @@ -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,
Expand All @@ -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(
Expand Down
91 changes: 91 additions & 0 deletions src/codex/resources/projects/entries.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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(
Expand Down Expand Up @@ -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,
Expand All @@ -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),
Expand All @@ -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,
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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,
Expand All @@ -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(
Expand Down Expand Up @@ -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,
Expand All @@ -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),
Expand All @@ -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,
Expand Down Expand Up @@ -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),
Expand Down
8 changes: 8 additions & 0 deletions src/codex/types/projects/access_key_create_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
12 changes: 11 additions & 1 deletion src/codex/types/projects/entry_add_question_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
12 changes: 11 additions & 1 deletion src/codex/types/projects/entry_create_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand All @@ -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")]
12 changes: 11 additions & 1 deletion src/codex/types/projects/entry_query_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
8 changes: 8 additions & 0 deletions tests/api_resources/projects/test_access_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])

Expand Down Expand Up @@ -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"])

Expand Down
Loading