Skip to content

feat(api): api update #33

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
Jan 22, 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
2 changes: 1 addition & 1 deletion api.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ Methods:
- <code title="put /api/projects/{project_id}/access_keys/{access_key_id}">client.projects.access_keys.<a href="./src/codex/resources/projects/access_keys.py">update</a>(access_key_id, \*, project_id, \*\*<a href="src/codex/types/projects/access_key_update_params.py">params</a>) -> <a href="./src/codex/types/projects/access_key_schema.py">AccessKeySchema</a></code>
- <code title="get /api/projects/{project_id}/access_keys/">client.projects.access_keys.<a href="./src/codex/resources/projects/access_keys.py">list</a>(project_id) -> <a href="./src/codex/types/projects/access_key_list_response.py">AccessKeyListResponse</a></code>
- <code title="delete /api/projects/{project_id}/access_keys/{access_key_id}">client.projects.access_keys.<a href="./src/codex/resources/projects/access_keys.py">delete</a>(access_key_id, \*, project_id) -> None</code>
- <code title="get /api/projects/id_from_access_key">client.projects.access_keys.<a href="./src/codex/resources/projects/access_keys.py">retrieve_project_id</a>() -> str</code>
- <code title="get /api/projects/id_from_access_key">client.projects.access_keys.<a href="./src/codex/resources/projects/access_keys.py">retrieve_project_id</a>() -> <a href="./src/codex/types/projects/access_key_retrieve_project_id_response.py">AccessKeyRetrieveProjectIDResponse</a></code>
- <code title="post /api/projects/{project_id}/access_keys/{access_key_id}/revoke">client.projects.access_keys.<a href="./src/codex/resources/projects/access_keys.py">revoke</a>(access_key_id, \*, project_id) -> None</code>

## Entries
Expand Down
9 changes: 5 additions & 4 deletions src/codex/resources/projects/access_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from ...types.projects import access_key_create_params, access_key_update_params
from ...types.projects.access_key_schema import AccessKeySchema
from ...types.projects.access_key_list_response import AccessKeyListResponse
from ...types.projects.access_key_retrieve_project_id_response import AccessKeyRetrieveProjectIDResponse

__all__ = ["AccessKeysResource", "AsyncAccessKeysResource"]

Expand Down Expand Up @@ -254,14 +255,14 @@ def retrieve_project_id(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> str:
) -> AccessKeyRetrieveProjectIDResponse:
"""Get the project ID from an access key."""
return self._get(
"/api/projects/id_from_access_key",
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=str,
cast_to=AccessKeyRetrieveProjectIDResponse,
)

def revoke(
Expand Down Expand Up @@ -528,14 +529,14 @@ async def retrieve_project_id(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> str:
) -> AccessKeyRetrieveProjectIDResponse:
"""Get the project ID from an access key."""
return await self._get(
"/api/projects/id_from_access_key",
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=str,
cast_to=AccessKeyRetrieveProjectIDResponse,
)

async def revoke(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from typing_extensions import TypeAlias

from ..._models import BaseModel

__all__ = ["AccessKeyRetrieveProjectIDResponse"]

AccessKeyRetrieveProjectIDResponse: TypeAlias = str

class AccessKeyRetrieveProjectIDResponse(BaseModel):
project_id: str
13 changes: 7 additions & 6 deletions tests/api_resources/projects/test_access_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from codex.types.projects import (
AccessKeySchema,
AccessKeyListResponse,
AccessKeyRetrieveProjectIDResponse,
)

base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
Expand Down Expand Up @@ -297,7 +298,7 @@ def test_path_params_delete(self, client: Codex) -> None:
@parametrize
def test_method_retrieve_project_id(self, client: Codex) -> None:
access_key = client.projects.access_keys.retrieve_project_id()
assert_matches_type(str, access_key, path=["response"])
assert_matches_type(AccessKeyRetrieveProjectIDResponse, access_key, path=["response"])

@pytest.mark.skip()
@parametrize
Expand All @@ -307,7 +308,7 @@ def test_raw_response_retrieve_project_id(self, client: Codex) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
access_key = response.parse()
assert_matches_type(str, access_key, path=["response"])
assert_matches_type(AccessKeyRetrieveProjectIDResponse, access_key, path=["response"])

@pytest.mark.skip()
@parametrize
Expand All @@ -317,7 +318,7 @@ def test_streaming_response_retrieve_project_id(self, client: Codex) -> None:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"

access_key = response.parse()
assert_matches_type(str, access_key, path=["response"])
assert_matches_type(AccessKeyRetrieveProjectIDResponse, access_key, path=["response"])

assert cast(Any, response.is_closed) is True

Expand Down Expand Up @@ -653,7 +654,7 @@ async def test_path_params_delete(self, async_client: AsyncCodex) -> None:
@parametrize
async def test_method_retrieve_project_id(self, async_client: AsyncCodex) -> None:
access_key = await async_client.projects.access_keys.retrieve_project_id()
assert_matches_type(str, access_key, path=["response"])
assert_matches_type(AccessKeyRetrieveProjectIDResponse, access_key, path=["response"])

@pytest.mark.skip()
@parametrize
Expand All @@ -663,7 +664,7 @@ async def test_raw_response_retrieve_project_id(self, async_client: AsyncCodex)
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
access_key = await response.parse()
assert_matches_type(str, access_key, path=["response"])
assert_matches_type(AccessKeyRetrieveProjectIDResponse, access_key, path=["response"])

@pytest.mark.skip()
@parametrize
Expand All @@ -673,7 +674,7 @@ async def test_streaming_response_retrieve_project_id(self, async_client: AsyncC
assert response.http_request.headers.get("X-Stainless-Lang") == "python"

access_key = await response.parse()
assert_matches_type(str, access_key, path=["response"])
assert_matches_type(AccessKeyRetrieveProjectIDResponse, access_key, path=["response"])

assert cast(Any, response.is_closed) is True

Expand Down