-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcredential-providers.ts
More file actions
350 lines (303 loc) · 8 KB
/
credential-providers.ts
File metadata and controls
350 lines (303 loc) · 8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../core/resource';
import { APIPromise } from '../core/api-promise';
import { buildHeaders } from '../internal/headers';
import { RequestOptions } from '../internal/request-options';
import { path } from '../internal/utils/path';
/**
* Configure external credential providers like 1Password.
*/
export class CredentialProviders extends APIResource {
/**
* Configure an external credential provider (e.g., 1Password) for automatic
* credential lookup.
*
* @example
* ```ts
* const credentialProvider =
* await client.credentialProviders.create({
* token: 'ops_eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...',
* name: 'my-1password',
* provider_type: 'onepassword',
* });
* ```
*/
create(body: CredentialProviderCreateParams, options?: RequestOptions): APIPromise<CredentialProvider> {
return this._client.post('/org/credential_providers', { body, ...options });
}
/**
* Retrieve a credential provider by its ID.
*
* @example
* ```ts
* const credentialProvider =
* await client.credentialProviders.retrieve('id');
* ```
*/
retrieve(id: string, options?: RequestOptions): APIPromise<CredentialProvider> {
return this._client.get(path`/org/credential_providers/${id}`, options);
}
/**
* Update a credential provider's configuration.
*
* @example
* ```ts
* const credentialProvider =
* await client.credentialProviders.update('id');
* ```
*/
update(
id: string,
body: CredentialProviderUpdateParams,
options?: RequestOptions,
): APIPromise<CredentialProvider> {
return this._client.patch(path`/org/credential_providers/${id}`, { body, ...options });
}
/**
* List external credential providers configured for the organization.
*
* @example
* ```ts
* const credentialProviders =
* await client.credentialProviders.list();
* ```
*/
list(options?: RequestOptions): APIPromise<CredentialProviderListResponse> {
return this._client.get('/org/credential_providers', options);
}
/**
* Delete a credential provider by its ID.
*
* @example
* ```ts
* await client.credentialProviders.delete('id');
* ```
*/
delete(id: string, options?: RequestOptions): APIPromise<void> {
return this._client.delete(path`/org/credential_providers/${id}`, {
...options,
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
});
}
/**
* Returns available credential items (e.g., 1Password login items) from the
* provider.
*
* @example
* ```ts
* const response = await client.credentialProviders.listItems(
* 'id',
* );
* ```
*/
listItems(id: string, options?: RequestOptions): APIPromise<CredentialProviderListItemsResponse> {
return this._client.get(path`/org/credential_providers/${id}/items`, options);
}
/**
* Validate the credential provider's token and list accessible vaults.
*
* @example
* ```ts
* const credentialProviderTestResult =
* await client.credentialProviders.test('id');
* ```
*/
test(id: string, options?: RequestOptions): APIPromise<CredentialProviderTestResult> {
return this._client.post(path`/org/credential_providers/${id}/test`, options);
}
}
/**
* Request to create an external credential provider
*/
export interface CreateCredentialProviderRequest {
/**
* Service account token for the provider (e.g., 1Password service account token)
*/
token: string;
/**
* Human-readable name for this provider instance (unique per org)
*/
name: string;
/**
* Type of credential provider
*/
provider_type: 'onepassword';
/**
* How long to cache credential lists (default 300 seconds)
*/
cache_ttl_seconds?: number;
}
/**
* An external credential provider (e.g., 1Password) for automatic credential
* lookup
*/
export interface CredentialProvider {
/**
* Unique identifier for the credential provider
*/
id: string;
/**
* When the credential provider was created
*/
created_at: string;
/**
* Whether the provider is enabled for credential lookups
*/
enabled: boolean;
/**
* Human-readable name for this provider instance
*/
name: string;
/**
* Priority order for credential lookups (lower numbers are checked first)
*/
priority: number;
/**
* Type of credential provider
*/
provider_type: 'onepassword';
/**
* When the credential provider was last updated
*/
updated_at: string;
}
/**
* A credential item from an external provider (e.g., a 1Password login item)
*/
export interface CredentialProviderItem {
/**
* Unique identifier for the item within the provider
*/
id: string;
/**
* Path to reference this item (VaultName/ItemTitle format)
*/
path: string;
/**
* Display name of the credential item
*/
title: string;
/**
* ID of the vault containing this item
*/
vault_id: string;
/**
* Name of the vault containing this item
*/
vault_name: string;
/**
* URLs associated with this credential
*/
urls?: Array<string>;
}
/**
* Result of testing a credential provider connection
*/
export interface CredentialProviderTestResult {
/**
* Whether the connection test was successful
*/
success: boolean;
/**
* List of vaults accessible by the service account
*/
vaults: Array<CredentialProviderTestResult.Vault>;
/**
* Error message if the test failed
*/
error?: string;
}
export namespace CredentialProviderTestResult {
export interface Vault {
/**
* Vault ID
*/
id: string;
/**
* Vault name
*/
name: string;
}
}
/**
* Request to update a credential provider
*/
export interface UpdateCredentialProviderRequest {
/**
* New service account token (to rotate credentials)
*/
token?: string;
/**
* How long to cache credential lists
*/
cache_ttl_seconds?: number;
/**
* Whether the provider is enabled for credential lookups
*/
enabled?: boolean;
/**
* Human-readable name for this provider instance
*/
name?: string;
/**
* Priority order for credential lookups (lower numbers are checked first)
*/
priority?: number;
}
export type CredentialProviderListResponse = Array<CredentialProvider>;
export interface CredentialProviderListItemsResponse {
items?: Array<CredentialProviderItem>;
}
export interface CredentialProviderCreateParams {
/**
* Service account token for the provider (e.g., 1Password service account token)
*/
token: string;
/**
* Human-readable name for this provider instance (unique per org)
*/
name: string;
/**
* Type of credential provider
*/
provider_type: 'onepassword';
/**
* How long to cache credential lists (default 300 seconds)
*/
cache_ttl_seconds?: number;
}
export interface CredentialProviderUpdateParams {
/**
* New service account token (to rotate credentials)
*/
token?: string;
/**
* How long to cache credential lists
*/
cache_ttl_seconds?: number;
/**
* Whether the provider is enabled for credential lookups
*/
enabled?: boolean;
/**
* Human-readable name for this provider instance
*/
name?: string;
/**
* Priority order for credential lookups (lower numbers are checked first)
*/
priority?: number;
}
export declare namespace CredentialProviders {
export {
type CreateCredentialProviderRequest as CreateCredentialProviderRequest,
type CredentialProvider as CredentialProvider,
type CredentialProviderItem as CredentialProviderItem,
type CredentialProviderTestResult as CredentialProviderTestResult,
type UpdateCredentialProviderRequest as UpdateCredentialProviderRequest,
type CredentialProviderListResponse as CredentialProviderListResponse,
type CredentialProviderListItemsResponse as CredentialProviderListItemsResponse,
type CredentialProviderCreateParams as CredentialProviderCreateParams,
type CredentialProviderUpdateParams as CredentialProviderUpdateParams,
};
}