Skip to content

Commit 342f436

Browse files
feat: [codex] Expose API keys in SDK config
1 parent 14d3265 commit 342f436

6 files changed

Lines changed: 372 additions & 3 deletions

File tree

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 112
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel/kernel-0a186c486b56f555cab374ea5f2adbef2d718b5c9190a48c862f0fdf1232324f.yml
1+
configured_endpoints: 117
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel/kernel-54d9016df9730e65881df9f694df4f33620b0c032f177849d36ccc426cd42fa8.yml
33
openapi_spec_hash: fad386b8e8712e6639ed9689e9dfc070
4-
config_hash: 5dde8b5de321a7bb96f695a69eb21c23
4+
config_hash: 58396d6c1fafaf72b26596b9117edf48

api.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,23 @@ Methods:
367367
- <code title="get /org/projects/{id}/limits">client.projects.limits.<a href="./src/resources/projects/limits.ts">retrieve</a>(id) -> ProjectLimits</code>
368368
- <code title="patch /org/projects/{id}/limits">client.projects.limits.<a href="./src/resources/projects/limits.ts">update</a>(id, { ...params }) -> ProjectLimits</code>
369369

370+
# APIKeys
371+
372+
Types:
373+
374+
- <code><a href="./src/resources/api-keys.ts">APIKey</a></code>
375+
- <code><a href="./src/resources/api-keys.ts">CreateAPIKeyRequest</a></code>
376+
- <code><a href="./src/resources/api-keys.ts">CreatedAPIKey</a></code>
377+
- <code><a href="./src/resources/api-keys.ts">UpdateAPIKeyRequest</a></code>
378+
379+
Methods:
380+
381+
- <code title="post /org/api_keys">client.apiKeys.<a href="./src/resources/api-keys.ts">create</a>({ ...params }) -> CreatedAPIKey</code>
382+
- <code title="get /org/api_keys/{id}">client.apiKeys.<a href="./src/resources/api-keys.ts">retrieve</a>(id) -> APIKey</code>
383+
- <code title="patch /org/api_keys/{id}">client.apiKeys.<a href="./src/resources/api-keys.ts">update</a>(id, { ...params }) -> APIKey</code>
384+
- <code title="get /org/api_keys">client.apiKeys.<a href="./src/resources/api-keys.ts">list</a>({ ...params }) -> APIKeysOffsetPagination</code>
385+
- <code title="delete /org/api_keys/{id}">client.apiKeys.<a href="./src/resources/api-keys.ts">delete</a>(id) -> void</code>
386+
370387
# CredentialProviders
371388

372389
Types:

src/client.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,17 @@ import { AbstractPage, type OffsetPaginationParams, OffsetPaginationResponse } f
1919
import * as Uploads from './core/uploads';
2020
import * as API from './resources/index';
2121
import { APIPromise } from './core/api-promise';
22+
import {
23+
APIKey,
24+
APIKeyCreateParams,
25+
APIKeyListParams,
26+
APIKeyUpdateParams,
27+
APIKeys,
28+
APIKeysOffsetPagination,
29+
CreateAPIKeyRequest,
30+
CreatedAPIKey,
31+
UpdateAPIKeyRequest,
32+
} from './resources/api-keys';
2233
import { AppListParams, AppListResponse, AppListResponsesOffsetPagination, Apps } from './resources/apps';
2334
import {
2435
BrowserRouteCache,
@@ -970,6 +981,10 @@ export class Kernel {
970981
* Create and manage projects for resource isolation within an organization.
971982
*/
972983
projects: API.Projects = new API.Projects(this);
984+
/**
985+
* Create and manage API keys for organization and project-scoped access.
986+
*/
987+
apiKeys: API.APIKeys = new API.APIKeys(this);
973988
/**
974989
* Configure external credential providers like 1Password.
975990
*/
@@ -987,6 +1002,7 @@ Kernel.Extensions = Extensions;
9871002
Kernel.BrowserPools = BrowserPools;
9881003
Kernel.Credentials = Credentials;
9891004
Kernel.Projects = Projects;
1005+
Kernel.APIKeys = APIKeys;
9901006
Kernel.CredentialProviders = CredentialProviders;
9911007

9921008
export declare namespace Kernel {
@@ -1114,6 +1130,18 @@ export declare namespace Kernel {
11141130
type ProjectListParams as ProjectListParams,
11151131
};
11161132

1133+
export {
1134+
APIKeys as APIKeys,
1135+
type APIKey as APIKey,
1136+
type CreateAPIKeyRequest as CreateAPIKeyRequest,
1137+
type CreatedAPIKey as CreatedAPIKey,
1138+
type UpdateAPIKeyRequest as UpdateAPIKeyRequest,
1139+
type APIKeysOffsetPagination as APIKeysOffsetPagination,
1140+
type APIKeyCreateParams as APIKeyCreateParams,
1141+
type APIKeyUpdateParams as APIKeyUpdateParams,
1142+
type APIKeyListParams as APIKeyListParams,
1143+
};
1144+
11171145
export {
11181146
CredentialProviders as CredentialProviders,
11191147
type CreateCredentialProviderRequest as CreateCredentialProviderRequest,

src/resources/api-keys.ts

Lines changed: 221 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,221 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
import { APIResource } from '../core/resource';
4+
import { APIPromise } from '../core/api-promise';
5+
import { OffsetPagination, type OffsetPaginationParams, PagePromise } from '../core/pagination';
6+
import { buildHeaders } from '../internal/headers';
7+
import { RequestOptions } from '../internal/request-options';
8+
import { path } from '../internal/utils/path';
9+
10+
/**
11+
* Create and manage API keys for organization and project-scoped access.
12+
*/
13+
export class APIKeys extends APIResource {
14+
/**
15+
* Create a new API key within the authenticated organization.
16+
*
17+
* @example
18+
* ```ts
19+
* const createdAPIKey = await client.apiKeys.create({
20+
* name: 'staging',
21+
* });
22+
* ```
23+
*/
24+
create(body: APIKeyCreateParams, options?: RequestOptions): APIPromise<CreatedAPIKey> {
25+
return this._client.post('/org/api_keys', { body, ...options });
26+
}
27+
28+
/**
29+
* Retrieve an API key by ID for the authenticated organization. API keys are
30+
* masked.
31+
*
32+
* @example
33+
* ```ts
34+
* const apiKey = await client.apiKeys.retrieve('id');
35+
* ```
36+
*/
37+
retrieve(id: string, options?: RequestOptions): APIPromise<APIKey> {
38+
return this._client.get(path`/org/api_keys/${id}`, options);
39+
}
40+
41+
/**
42+
* Update an API key's name.
43+
*
44+
* @example
45+
* ```ts
46+
* const apiKey = await client.apiKeys.update('id', {
47+
* name: 'new-api-name',
48+
* });
49+
* ```
50+
*/
51+
update(id: string, body: APIKeyUpdateParams, options?: RequestOptions): APIPromise<APIKey> {
52+
return this._client.patch(path`/org/api_keys/${id}`, { body, ...options });
53+
}
54+
55+
/**
56+
* List API keys for the authenticated organization. API keys are masked.
57+
*
58+
* @example
59+
* ```ts
60+
* // Automatically fetches more pages as needed.
61+
* for await (const apiKey of client.apiKeys.list()) {
62+
* // ...
63+
* }
64+
* ```
65+
*/
66+
list(
67+
query: APIKeyListParams | null | undefined = {},
68+
options?: RequestOptions,
69+
): PagePromise<APIKeysOffsetPagination, APIKey> {
70+
return this._client.getAPIList('/org/api_keys', OffsetPagination<APIKey>, { query, ...options });
71+
}
72+
73+
/**
74+
* Delete an API key.
75+
*
76+
* @example
77+
* ```ts
78+
* await client.apiKeys.delete('id');
79+
* ```
80+
*/
81+
delete(id: string, options?: RequestOptions): APIPromise<void> {
82+
return this._client.delete(path`/org/api_keys/${id}`, {
83+
...options,
84+
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
85+
});
86+
}
87+
}
88+
89+
export type APIKeysOffsetPagination = OffsetPagination<APIKey>;
90+
91+
export interface APIKey {
92+
/**
93+
* Unique API key identifier
94+
*/
95+
id: string;
96+
97+
/**
98+
* When the API key was created
99+
*/
100+
created_at: string;
101+
102+
created_by: APIKey.CreatedBy;
103+
104+
/**
105+
* When the API key expires
106+
*/
107+
expires_at: string | null;
108+
109+
/**
110+
* Masked version of the API key
111+
*/
112+
masked_key: string;
113+
114+
/**
115+
* API key name
116+
*/
117+
name: string;
118+
119+
/**
120+
* Project identifier for project-scoped API keys. Null means org-wide.
121+
*/
122+
project_id: string | null;
123+
124+
/**
125+
* Project name for project-scoped API keys. Null means the key is org-wide or the
126+
* project name is unavailable.
127+
*/
128+
project_name: string | null;
129+
}
130+
131+
export namespace APIKey {
132+
export interface CreatedBy {
133+
/**
134+
* Kernel user ID of the creator.
135+
*/
136+
id: string;
137+
138+
/**
139+
* Email address of the creator.
140+
*/
141+
email: string;
142+
143+
/**
144+
* Display name of the creator, if available.
145+
*/
146+
name: string | null;
147+
}
148+
}
149+
150+
export interface CreateAPIKeyRequest {
151+
/**
152+
* API key name (1-255 characters)
153+
*/
154+
name: string;
155+
156+
/**
157+
* Number of days until expiry, up to 3650. Use null for never.
158+
*/
159+
days_to_expire?: number | null;
160+
161+
/**
162+
* Unique project identifier
163+
*/
164+
project_id?: string | null;
165+
}
166+
167+
/**
168+
* API key returned immediately after creation. Includes the plaintext key once.
169+
*/
170+
export interface CreatedAPIKey extends APIKey {
171+
/**
172+
* Plaintext API key. Only returned once when the key is created.
173+
*/
174+
key: string;
175+
}
176+
177+
export interface UpdateAPIKeyRequest {
178+
/**
179+
* New API key name
180+
*/
181+
name: string;
182+
}
183+
184+
export interface APIKeyCreateParams {
185+
/**
186+
* API key name (1-255 characters)
187+
*/
188+
name: string;
189+
190+
/**
191+
* Number of days until expiry, up to 3650. Use null for never.
192+
*/
193+
days_to_expire?: number | null;
194+
195+
/**
196+
* Unique project identifier
197+
*/
198+
project_id?: string | null;
199+
}
200+
201+
export interface APIKeyUpdateParams {
202+
/**
203+
* New API key name
204+
*/
205+
name: string;
206+
}
207+
208+
export interface APIKeyListParams extends OffsetPaginationParams {}
209+
210+
export declare namespace APIKeys {
211+
export {
212+
type APIKey as APIKey,
213+
type CreateAPIKeyRequest as CreateAPIKeyRequest,
214+
type CreatedAPIKey as CreatedAPIKey,
215+
type UpdateAPIKeyRequest as UpdateAPIKeyRequest,
216+
type APIKeysOffsetPagination as APIKeysOffsetPagination,
217+
type APIKeyCreateParams as APIKeyCreateParams,
218+
type APIKeyUpdateParams as APIKeyUpdateParams,
219+
type APIKeyListParams as APIKeyListParams,
220+
};
221+
}

src/resources/index.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

33
export * from './shared';
4+
export {
5+
APIKeys,
6+
type APIKey,
7+
type CreateAPIKeyRequest,
8+
type CreatedAPIKey,
9+
type UpdateAPIKeyRequest,
10+
type APIKeyCreateParams,
11+
type APIKeyUpdateParams,
12+
type APIKeyListParams,
13+
type APIKeysOffsetPagination,
14+
} from './api-keys';
415
export {
516
Apps,
617
type AppListResponse,

0 commit comments

Comments
 (0)