Skip to content

Commit 55bd31e

Browse files
feat: Add API-backed API key management endpoints
1 parent 903fe13 commit 55bd31e

4 files changed

Lines changed: 48 additions & 3 deletions

File tree

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 117
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel/kernel-2d1337eec44e036b9c896b7db4691f0a12edfa79d3f28b611818bcedf62d44ee.yml
3-
openapi_spec_hash: 30110dbbe733b16e40a6d0aa41d0c8c4
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel/kernel-3a1db7f11a92b28681929255ada59d2317ee4db98b5ff5aa6ce142a0664058b3.yml
3+
openapi_spec_hash: b3064eaa589ae2a84993686ad1a3ee43
44
config_hash: ede72e4ae65cc5a6d6927938b3455c46

src/kernel/resources/api_keys.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from __future__ import annotations
44

55
from typing import Optional
6+
from typing_extensions import Literal
67

78
import httpx
89

@@ -171,6 +172,9 @@ def list(
171172
*,
172173
limit: int | Omit = omit,
173174
offset: int | Omit = omit,
175+
query: str | Omit = omit,
176+
sort_by: Literal["created_at", "name", "expires_at"] | Omit = omit,
177+
sort_direction: Literal["asc", "desc"] | Omit = omit,
174178
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
175179
# The extra values given here take precedence over values defined on the client or passed to this method.
176180
extra_headers: Headers | None = None,
@@ -187,6 +191,13 @@ def list(
187191
188192
offset: Number of results to skip
189193
194+
query: Case-insensitive substring match against API key name, creator, and project. API
195+
key identifiers and masked keys match by exact value or prefix.
196+
197+
sort_by: Field to sort API keys by.
198+
199+
sort_direction: Sort direction for API keys.
200+
190201
extra_headers: Send extra headers
191202
192203
extra_query: Add additional query parameters to the request
@@ -207,6 +218,9 @@ def list(
207218
{
208219
"limit": limit,
209220
"offset": offset,
221+
"query": query,
222+
"sort_by": sort_by,
223+
"sort_direction": sort_direction,
210224
},
211225
api_key_list_params.APIKeyListParams,
212226
),
@@ -395,6 +409,9 @@ def list(
395409
*,
396410
limit: int | Omit = omit,
397411
offset: int | Omit = omit,
412+
query: str | Omit = omit,
413+
sort_by: Literal["created_at", "name", "expires_at"] | Omit = omit,
414+
sort_direction: Literal["asc", "desc"] | Omit = omit,
398415
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
399416
# The extra values given here take precedence over values defined on the client or passed to this method.
400417
extra_headers: Headers | None = None,
@@ -411,6 +428,13 @@ def list(
411428
412429
offset: Number of results to skip
413430
431+
query: Case-insensitive substring match against API key name, creator, and project. API
432+
key identifiers and masked keys match by exact value or prefix.
433+
434+
sort_by: Field to sort API keys by.
435+
436+
sort_direction: Sort direction for API keys.
437+
414438
extra_headers: Send extra headers
415439
416440
extra_query: Add additional query parameters to the request
@@ -431,6 +455,9 @@ def list(
431455
{
432456
"limit": limit,
433457
"offset": offset,
458+
"query": query,
459+
"sort_by": sort_by,
460+
"sort_direction": sort_direction,
434461
},
435462
api_key_list_params.APIKeyListParams,
436463
),

src/kernel/types/api_key_list_params.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_extensions import TypedDict
5+
from typing_extensions import Literal, TypedDict
66

77
__all__ = ["APIKeyListParams"]
88

@@ -13,3 +13,15 @@ class APIKeyListParams(TypedDict, total=False):
1313

1414
offset: int
1515
"""Number of results to skip"""
16+
17+
query: str
18+
"""Case-insensitive substring match against API key name, creator, and project.
19+
20+
API key identifiers and masked keys match by exact value or prefix.
21+
"""
22+
23+
sort_by: Literal["created_at", "name", "expires_at"]
24+
"""Field to sort API keys by."""
25+
26+
sort_direction: Literal["asc", "desc"]
27+
"""Sort direction for API keys."""

tests/api_resources/test_api_keys.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,9 @@ def test_method_list_with_all_params(self, client: Kernel) -> None:
162162
api_key = client.api_keys.list(
163163
limit=100,
164164
offset=0,
165+
query="query",
166+
sort_by="created_at",
167+
sort_direction="asc",
165168
)
166169
assert_matches_type(SyncOffsetPagination[APIKey], api_key, path=["response"])
167170

@@ -379,6 +382,9 @@ async def test_method_list_with_all_params(self, async_client: AsyncKernel) -> N
379382
api_key = await async_client.api_keys.list(
380383
limit=100,
381384
offset=0,
385+
query="query",
386+
sort_by="created_at",
387+
sort_direction="asc",
382388
)
383389
assert_matches_type(AsyncOffsetPagination[APIKey], api_key, path=["response"])
384390

0 commit comments

Comments
 (0)