Skip to content

Commit 89cb8dc

Browse files
feat: Add API-backed API key management endpoints
1 parent c21b441 commit 89cb8dc

3 files changed

Lines changed: 29 additions & 4 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/resources/api-keys.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,23 @@ export interface APIKeyUpdateParams {
181181
name: string;
182182
}
183183

184-
export interface APIKeyListParams extends OffsetPaginationParams {}
184+
export interface APIKeyListParams extends OffsetPaginationParams {
185+
/**
186+
* Case-insensitive substring match against API key name, creator, and project. API
187+
* key identifiers and masked keys match by exact value or prefix.
188+
*/
189+
query?: string;
190+
191+
/**
192+
* Field to sort API keys by.
193+
*/
194+
sort_by?: 'created_at' | 'name' | 'expires_at';
195+
196+
/**
197+
* Sort direction for API keys.
198+
*/
199+
sort_direction?: 'asc' | 'desc';
200+
}
185201

186202
export declare namespace APIKeys {
187203
export {

tests/api-resources/api-keys.test.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,16 @@ describe('resource apiKeys', () => {
7474
test.skip('list: request options and params are passed correctly', async () => {
7575
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
7676
await expect(
77-
client.apiKeys.list({ limit: 100, offset: 0 }, { path: '/_stainless_unknown_path' }),
77+
client.apiKeys.list(
78+
{
79+
limit: 100,
80+
offset: 0,
81+
query: 'query',
82+
sort_by: 'created_at',
83+
sort_direction: 'asc',
84+
},
85+
{ path: '/_stainless_unknown_path' },
86+
),
7887
).rejects.toThrow(Kernel.NotFoundError);
7988
});
8089

0 commit comments

Comments
 (0)