openai 6.46.0 → 6.48.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (236) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/README.md +9 -2
  3. package/client.d.mts +1 -0
  4. package/client.d.mts.map +1 -1
  5. package/client.d.ts +1 -0
  6. package/client.d.ts.map +1 -1
  7. package/client.js +11 -5
  8. package/client.js.map +1 -1
  9. package/client.mjs +11 -5
  10. package/client.mjs.map +1 -1
  11. package/core/streaming.d.mts.map +1 -1
  12. package/core/streaming.d.ts.map +1 -1
  13. package/core/streaming.js +38 -6
  14. package/core/streaming.js.map +1 -1
  15. package/core/streaming.mjs +38 -6
  16. package/core/streaming.mjs.map +1 -1
  17. package/core/uploads.d.mts +1 -1
  18. package/core/uploads.d.mts.map +1 -1
  19. package/core/uploads.d.ts +1 -1
  20. package/core/uploads.d.ts.map +1 -1
  21. package/core/uploads.js +3 -1
  22. package/core/uploads.js.map +1 -1
  23. package/core/uploads.mjs +1 -0
  24. package/core/uploads.mjs.map +1 -1
  25. package/helpers/zod.d.mts +20 -7
  26. package/helpers/zod.d.mts.map +1 -1
  27. package/helpers/zod.d.ts +20 -7
  28. package/helpers/zod.d.ts.map +1 -1
  29. package/helpers/zod.js +24 -12
  30. package/helpers/zod.js.map +1 -1
  31. package/helpers/zod.mjs +24 -12
  32. package/helpers/zod.mjs.map +1 -1
  33. package/index.d.mts +1 -1
  34. package/index.d.mts.map +1 -1
  35. package/index.d.ts +1 -1
  36. package/index.d.ts.map +1 -1
  37. package/index.js +2 -1
  38. package/index.js.map +1 -1
  39. package/index.mjs +1 -1
  40. package/index.mjs.map +1 -1
  41. package/internal/headers.d.mts.map +1 -1
  42. package/internal/headers.d.ts.map +1 -1
  43. package/internal/headers.js +7 -3
  44. package/internal/headers.js.map +1 -1
  45. package/internal/headers.mjs +7 -3
  46. package/internal/headers.mjs.map +1 -1
  47. package/internal/uploads.d.mts +26 -1
  48. package/internal/uploads.d.mts.map +1 -1
  49. package/internal/uploads.d.ts +26 -1
  50. package/internal/uploads.d.ts.map +1 -1
  51. package/internal/uploads.js +169 -1
  52. package/internal/uploads.js.map +1 -1
  53. package/internal/uploads.mjs +169 -2
  54. package/internal/uploads.mjs.map +1 -1
  55. package/lib/AbstractChatCompletionRunner.d.mts +3 -3
  56. package/lib/AbstractChatCompletionRunner.d.mts.map +1 -1
  57. package/lib/AbstractChatCompletionRunner.d.ts +3 -3
  58. package/lib/AbstractChatCompletionRunner.d.ts.map +1 -1
  59. package/lib/AbstractChatCompletionRunner.js +4 -3
  60. package/lib/AbstractChatCompletionRunner.js.map +1 -1
  61. package/lib/AbstractChatCompletionRunner.mjs +4 -3
  62. package/lib/AbstractChatCompletionRunner.mjs.map +1 -1
  63. package/lib/AssistantStream.d.mts.map +1 -1
  64. package/lib/AssistantStream.d.ts.map +1 -1
  65. package/lib/AssistantStream.js +3 -2
  66. package/lib/AssistantStream.js.map +1 -1
  67. package/lib/AssistantStream.mjs +3 -2
  68. package/lib/AssistantStream.mjs.map +1 -1
  69. package/lib/ChatCompletionRunner.d.mts +26 -2
  70. package/lib/ChatCompletionRunner.d.mts.map +1 -1
  71. package/lib/ChatCompletionRunner.d.ts +26 -2
  72. package/lib/ChatCompletionRunner.d.ts.map +1 -1
  73. package/lib/ChatCompletionRunner.js.map +1 -1
  74. package/lib/ChatCompletionRunner.mjs.map +1 -1
  75. package/lib/ChatCompletionStream.d.mts +14 -1
  76. package/lib/ChatCompletionStream.d.mts.map +1 -1
  77. package/lib/ChatCompletionStream.d.ts +14 -1
  78. package/lib/ChatCompletionStream.d.ts.map +1 -1
  79. package/lib/ChatCompletionStream.js +68 -12
  80. package/lib/ChatCompletionStream.js.map +1 -1
  81. package/lib/ChatCompletionStream.mjs +67 -12
  82. package/lib/ChatCompletionStream.mjs.map +1 -1
  83. package/lib/ChatCompletionStreamingRunner.d.mts +25 -2
  84. package/lib/ChatCompletionStreamingRunner.d.mts.map +1 -1
  85. package/lib/ChatCompletionStreamingRunner.d.ts +25 -2
  86. package/lib/ChatCompletionStreamingRunner.d.ts.map +1 -1
  87. package/lib/ChatCompletionStreamingRunner.js +77 -0
  88. package/lib/ChatCompletionStreamingRunner.js.map +1 -1
  89. package/lib/ChatCompletionStreamingRunner.mjs +78 -1
  90. package/lib/ChatCompletionStreamingRunner.mjs.map +1 -1
  91. package/lib/EventStream.d.mts +13 -0
  92. package/lib/EventStream.d.mts.map +1 -1
  93. package/lib/EventStream.d.ts +13 -0
  94. package/lib/EventStream.d.ts.map +1 -1
  95. package/lib/EventStream.js +107 -2
  96. package/lib/EventStream.js.map +1 -1
  97. package/lib/EventStream.mjs +107 -2
  98. package/lib/EventStream.mjs.map +1 -1
  99. package/lib/RunnableFunction.d.mts +38 -21
  100. package/lib/RunnableFunction.d.mts.map +1 -1
  101. package/lib/RunnableFunction.d.ts +38 -21
  102. package/lib/RunnableFunction.d.ts.map +1 -1
  103. package/lib/RunnableFunction.js.map +1 -1
  104. package/lib/RunnableFunction.mjs.map +1 -1
  105. package/lib/parser.d.mts +2 -2
  106. package/lib/parser.d.mts.map +1 -1
  107. package/lib/parser.d.ts +2 -2
  108. package/lib/parser.d.ts.map +1 -1
  109. package/lib/parser.js.map +1 -1
  110. package/lib/parser.mjs.map +1 -1
  111. package/lib/responses/ResponseStream.d.mts +6 -1
  112. package/lib/responses/ResponseStream.d.mts.map +1 -1
  113. package/lib/responses/ResponseStream.d.ts +6 -1
  114. package/lib/responses/ResponseStream.d.ts.map +1 -1
  115. package/lib/responses/ResponseStream.js +21 -0
  116. package/lib/responses/ResponseStream.js.map +1 -1
  117. package/lib/responses/ResponseStream.mjs +21 -0
  118. package/lib/responses/ResponseStream.mjs.map +1 -1
  119. package/package.json +1 -1
  120. package/resources/admin/organization/audit-logs.d.mts +2 -2
  121. package/resources/admin/organization/audit-logs.d.mts.map +1 -1
  122. package/resources/admin/organization/audit-logs.d.ts +2 -2
  123. package/resources/admin/organization/audit-logs.d.ts.map +1 -1
  124. package/resources/admin/organization/projects/api-keys.d.mts +12 -0
  125. package/resources/admin/organization/projects/api-keys.d.mts.map +1 -1
  126. package/resources/admin/organization/projects/api-keys.d.ts +12 -0
  127. package/resources/admin/organization/projects/api-keys.d.ts.map +1 -1
  128. package/resources/admin/organization/projects/index.d.mts +1 -1
  129. package/resources/admin/organization/projects/index.d.mts.map +1 -1
  130. package/resources/admin/organization/projects/index.d.ts +1 -1
  131. package/resources/admin/organization/projects/index.d.ts.map +1 -1
  132. package/resources/admin/organization/projects/index.js +4 -4
  133. package/resources/admin/organization/projects/index.js.map +1 -1
  134. package/resources/admin/organization/projects/index.mjs +1 -1
  135. package/resources/admin/organization/projects/index.mjs.map +1 -1
  136. package/resources/admin/organization/projects/projects.d.mts +2 -2
  137. package/resources/admin/organization/projects/projects.d.mts.map +1 -1
  138. package/resources/admin/organization/projects/projects.d.ts +2 -2
  139. package/resources/admin/organization/projects/projects.d.ts.map +1 -1
  140. package/resources/admin/organization/projects/projects.js +2 -2
  141. package/resources/admin/organization/projects/projects.js.map +1 -1
  142. package/resources/admin/organization/projects/projects.mjs +2 -2
  143. package/resources/admin/organization/projects/projects.mjs.map +1 -1
  144. package/resources/admin/organization/projects/service-accounts/api-keys.d.mts +58 -0
  145. package/resources/admin/organization/projects/service-accounts/api-keys.d.mts.map +1 -0
  146. package/resources/admin/organization/projects/service-accounts/api-keys.d.ts +58 -0
  147. package/resources/admin/organization/projects/service-accounts/api-keys.d.ts.map +1 -0
  148. package/resources/admin/organization/projects/service-accounts/api-keys.js +26 -0
  149. package/resources/admin/organization/projects/service-accounts/api-keys.js.map +1 -0
  150. package/resources/admin/organization/projects/service-accounts/api-keys.mjs +22 -0
  151. package/resources/admin/organization/projects/service-accounts/api-keys.mjs.map +1 -0
  152. package/resources/admin/organization/projects/service-accounts/index.d.mts +3 -0
  153. package/resources/admin/organization/projects/service-accounts/index.d.mts.map +1 -0
  154. package/resources/admin/organization/projects/service-accounts/index.d.ts +3 -0
  155. package/resources/admin/organization/projects/service-accounts/index.d.ts.map +1 -0
  156. package/resources/admin/organization/projects/service-accounts/index.js +9 -0
  157. package/resources/admin/organization/projects/service-accounts/index.js.map +1 -0
  158. package/resources/admin/organization/projects/service-accounts/index.mjs +4 -0
  159. package/resources/admin/organization/projects/service-accounts/index.mjs.map +1 -0
  160. package/resources/admin/organization/projects/service-accounts/service-accounts.d.mts +177 -0
  161. package/resources/admin/organization/projects/service-accounts/service-accounts.d.mts.map +1 -0
  162. package/resources/admin/organization/projects/service-accounts/service-accounts.d.ts +177 -0
  163. package/resources/admin/organization/projects/service-accounts/service-accounts.d.ts.map +1 -0
  164. package/resources/admin/organization/projects/service-accounts/service-accounts.js +109 -0
  165. package/resources/admin/organization/projects/service-accounts/service-accounts.js.map +1 -0
  166. package/resources/admin/organization/projects/service-accounts/service-accounts.mjs +104 -0
  167. package/resources/admin/organization/projects/service-accounts/service-accounts.mjs.map +1 -0
  168. package/resources/admin/organization/projects/service-accounts.d.mts +1 -167
  169. package/resources/admin/organization/projects/service-accounts.d.mts.map +1 -1
  170. package/resources/admin/organization/projects/service-accounts.d.ts +1 -167
  171. package/resources/admin/organization/projects/service-accounts.d.ts.map +1 -1
  172. package/resources/admin/organization/projects/service-accounts.js +2 -97
  173. package/resources/admin/organization/projects/service-accounts.js.map +1 -1
  174. package/resources/admin/organization/projects/service-accounts.mjs +1 -95
  175. package/resources/admin/organization/projects/service-accounts.mjs.map +1 -1
  176. package/resources/admin/organization/usage.d.mts +517 -88
  177. package/resources/admin/organization/usage.d.mts.map +1 -1
  178. package/resources/admin/organization/usage.d.ts +517 -88
  179. package/resources/admin/organization/usage.d.ts.map +1 -1
  180. package/resources/beta/responses/responses.d.mts +7 -6
  181. package/resources/beta/responses/responses.d.mts.map +1 -1
  182. package/resources/beta/responses/responses.d.ts +7 -6
  183. package/resources/beta/responses/responses.d.ts.map +1 -1
  184. package/resources/beta/responses/responses.js.map +1 -1
  185. package/resources/beta/responses/responses.mjs.map +1 -1
  186. package/resources/chat/completions/completions.d.mts +15 -6
  187. package/resources/chat/completions/completions.d.mts.map +1 -1
  188. package/resources/chat/completions/completions.d.ts +15 -6
  189. package/resources/chat/completions/completions.d.ts.map +1 -1
  190. package/resources/chat/completions/completions.js.map +1 -1
  191. package/resources/chat/completions/completions.mjs.map +1 -1
  192. package/resources/responses/responses.d.mts +3 -2
  193. package/resources/responses/responses.d.mts.map +1 -1
  194. package/resources/responses/responses.d.ts +3 -2
  195. package/resources/responses/responses.d.ts.map +1 -1
  196. package/resources/responses/responses.js.map +1 -1
  197. package/resources/responses/responses.mjs.map +1 -1
  198. package/resources/webhooks/webhooks.d.mts +2 -54
  199. package/resources/webhooks/webhooks.d.mts.map +1 -1
  200. package/resources/webhooks/webhooks.d.ts +2 -54
  201. package/resources/webhooks/webhooks.d.ts.map +1 -1
  202. package/src/client.ts +13 -5
  203. package/src/core/streaming.ts +36 -8
  204. package/src/core/uploads.ts +6 -1
  205. package/src/helpers/zod.ts +62 -23
  206. package/src/index.ts +1 -1
  207. package/src/internal/headers.ts +7 -3
  208. package/src/internal/uploads.ts +214 -4
  209. package/src/lib/AbstractChatCompletionRunner.ts +17 -9
  210. package/src/lib/AssistantStream.ts +3 -2
  211. package/src/lib/ChatCompletionRunner.ts +46 -6
  212. package/src/lib/ChatCompletionStream.ts +108 -13
  213. package/src/lib/ChatCompletionStreamingRunner.ts +144 -7
  214. package/src/lib/EventStream.ts +114 -4
  215. package/src/lib/RunnableFunction.ts +60 -31
  216. package/src/lib/parser.ts +4 -0
  217. package/src/lib/responses/ResponseStream.ts +29 -1
  218. package/src/resources/admin/organization/audit-logs.ts +169 -1
  219. package/src/resources/admin/organization/projects/api-keys.ts +15 -1
  220. package/src/resources/admin/organization/projects/index.ts +1 -1
  221. package/src/resources/admin/organization/projects/projects.ts +13 -13
  222. package/src/resources/admin/organization/projects/service-accounts/api-keys.ts +80 -0
  223. package/src/resources/admin/organization/projects/service-accounts/index.ts +15 -0
  224. package/src/resources/admin/organization/projects/service-accounts/service-accounts.ts +284 -0
  225. package/src/resources/admin/organization/projects/service-accounts.ts +1 -264
  226. package/src/resources/admin/organization/usage.ts +616 -88
  227. package/src/resources/beta/responses/responses.ts +7 -6
  228. package/src/resources/chat/completions/completions.ts +66 -9
  229. package/src/resources/responses/responses.ts +3 -2
  230. package/src/resources/webhooks/api.md +0 -1
  231. package/src/resources/webhooks/webhooks.ts +1 -65
  232. package/src/version.ts +1 -1
  233. package/version.d.mts +1 -1
  234. package/version.d.ts +1 -1
  235. package/version.js +1 -1
  236. package/version.mjs +1 -1
@@ -0,0 +1,284 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../../../../../core/resource';
4
+ import * as APIKeysAPI from './api-keys';
5
+ import { APIKeyCreateParams, APIKeyCreateResponse, APIKeys } from './api-keys';
6
+ import { APIPromise } from '../../../../../core/api-promise';
7
+ import {
8
+ ConversationCursorPage,
9
+ type ConversationCursorPageParams,
10
+ PagePromise,
11
+ } from '../../../../../core/pagination';
12
+ import { RequestOptions } from '../../../../../internal/request-options';
13
+ import { path } from '../../../../../internal/utils/path';
14
+
15
+ export class ServiceAccounts extends APIResource {
16
+ apiKeys: APIKeysAPI.APIKeys = new APIKeysAPI.APIKeys(this._client);
17
+
18
+ /**
19
+ * Creates a new service account in the project. By default, this also returns an
20
+ * unredacted API key for the service account.
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * const serviceAccount =
25
+ * await client.admin.organization.projects.serviceAccounts.create(
26
+ * 'project_id',
27
+ * { name: 'name' },
28
+ * );
29
+ * ```
30
+ */
31
+ create(
32
+ projectID: string,
33
+ body: ServiceAccountCreateParams,
34
+ options?: RequestOptions,
35
+ ): APIPromise<ServiceAccountCreateResponse> {
36
+ return this._client.post(path`/organization/projects/${projectID}/service_accounts`, {
37
+ body,
38
+ ...options,
39
+ __security: { adminAPIKeyAuth: true },
40
+ });
41
+ }
42
+
43
+ /**
44
+ * Retrieves a service account in the project.
45
+ *
46
+ * @example
47
+ * ```ts
48
+ * const projectServiceAccount =
49
+ * await client.admin.organization.projects.serviceAccounts.retrieve(
50
+ * 'service_account_id',
51
+ * { project_id: 'project_id' },
52
+ * );
53
+ * ```
54
+ */
55
+ retrieve(
56
+ serviceAccountID: string,
57
+ params: ServiceAccountRetrieveParams,
58
+ options?: RequestOptions,
59
+ ): APIPromise<ProjectServiceAccount> {
60
+ const { project_id } = params;
61
+ return this._client.get(path`/organization/projects/${project_id}/service_accounts/${serviceAccountID}`, {
62
+ ...options,
63
+ __security: { adminAPIKeyAuth: true },
64
+ });
65
+ }
66
+
67
+ /**
68
+ * Updates a service account in the project.
69
+ *
70
+ * @example
71
+ * ```ts
72
+ * const projectServiceAccount =
73
+ * await client.admin.organization.projects.serviceAccounts.update(
74
+ * 'service_account_id',
75
+ * { project_id: 'project_id' },
76
+ * );
77
+ * ```
78
+ */
79
+ update(
80
+ serviceAccountID: string,
81
+ params: ServiceAccountUpdateParams,
82
+ options?: RequestOptions,
83
+ ): APIPromise<ProjectServiceAccount> {
84
+ const { project_id, ...body } = params;
85
+ return this._client.post(
86
+ path`/organization/projects/${project_id}/service_accounts/${serviceAccountID}`,
87
+ { body, ...options, __security: { adminAPIKeyAuth: true } },
88
+ );
89
+ }
90
+
91
+ /**
92
+ * Returns a list of service accounts in the project.
93
+ *
94
+ * @example
95
+ * ```ts
96
+ * // Automatically fetches more pages as needed.
97
+ * for await (const projectServiceAccount of client.admin.organization.projects.serviceAccounts.list(
98
+ * 'project_id',
99
+ * )) {
100
+ * // ...
101
+ * }
102
+ * ```
103
+ */
104
+ list(
105
+ projectID: string,
106
+ query: ServiceAccountListParams | null | undefined = {},
107
+ options?: RequestOptions,
108
+ ): PagePromise<ProjectServiceAccountsPage, ProjectServiceAccount> {
109
+ return this._client.getAPIList(
110
+ path`/organization/projects/${projectID}/service_accounts`,
111
+ ConversationCursorPage<ProjectServiceAccount>,
112
+ { query, ...options, __security: { adminAPIKeyAuth: true } },
113
+ );
114
+ }
115
+
116
+ /**
117
+ * Deletes a service account from the project.
118
+ *
119
+ * Returns confirmation of service account deletion, or an error if the project is
120
+ * archived (archived projects have no service accounts).
121
+ *
122
+ * @example
123
+ * ```ts
124
+ * const serviceAccount =
125
+ * await client.admin.organization.projects.serviceAccounts.delete(
126
+ * 'service_account_id',
127
+ * { project_id: 'project_id' },
128
+ * );
129
+ * ```
130
+ */
131
+ delete(
132
+ serviceAccountID: string,
133
+ params: ServiceAccountDeleteParams,
134
+ options?: RequestOptions,
135
+ ): APIPromise<ServiceAccountDeleteResponse> {
136
+ const { project_id } = params;
137
+ return this._client.delete(
138
+ path`/organization/projects/${project_id}/service_accounts/${serviceAccountID}`,
139
+ { ...options, __security: { adminAPIKeyAuth: true } },
140
+ );
141
+ }
142
+ }
143
+
144
+ export type ProjectServiceAccountsPage = ConversationCursorPage<ProjectServiceAccount>;
145
+
146
+ /**
147
+ * Represents an individual service account in a project.
148
+ */
149
+ export interface ProjectServiceAccount {
150
+ /**
151
+ * The identifier, which can be referenced in API endpoints
152
+ */
153
+ id: string;
154
+
155
+ /**
156
+ * The Unix timestamp (in seconds) of when the service account was created
157
+ */
158
+ created_at: number;
159
+
160
+ /**
161
+ * The name of the service account
162
+ */
163
+ name: string;
164
+
165
+ /**
166
+ * The object type, which is always `organization.project.service_account`
167
+ */
168
+ object: 'organization.project.service_account';
169
+
170
+ /**
171
+ * `owner`, `member`, or `none`
172
+ */
173
+ role: 'owner' | 'member' | 'none';
174
+ }
175
+
176
+ export interface ServiceAccountCreateResponse {
177
+ id: string;
178
+
179
+ api_key: ServiceAccountCreateResponse.APIKey | null;
180
+
181
+ created_at: number;
182
+
183
+ name: string;
184
+
185
+ object: 'organization.project.service_account';
186
+
187
+ /**
188
+ * Service accounts created with default project membership have role `member`.
189
+ * Accounts created with `create_service_account_only` have role `none`.
190
+ */
191
+ role: 'member' | 'none';
192
+ }
193
+
194
+ export namespace ServiceAccountCreateResponse {
195
+ export interface APIKey {
196
+ id: string;
197
+
198
+ created_at: number;
199
+
200
+ name: string;
201
+
202
+ /**
203
+ * The object type, which is always `organization.project.service_account.api_key`
204
+ */
205
+ object: 'organization.project.service_account.api_key';
206
+
207
+ value: string;
208
+ }
209
+ }
210
+
211
+ export interface ServiceAccountDeleteResponse {
212
+ id: string;
213
+
214
+ deleted: boolean;
215
+
216
+ object: 'organization.project.service_account.deleted';
217
+ }
218
+
219
+ export interface ServiceAccountCreateParams {
220
+ /**
221
+ * The name of the service account being created.
222
+ */
223
+ name: string;
224
+
225
+ /**
226
+ * Create the service account without default roles or an API key.
227
+ */
228
+ create_service_account_only?: boolean | null;
229
+ }
230
+
231
+ export interface ServiceAccountRetrieveParams {
232
+ /**
233
+ * The ID of the project.
234
+ */
235
+ project_id: string;
236
+ }
237
+
238
+ export interface ServiceAccountUpdateParams {
239
+ /**
240
+ * Path param: The ID of the project.
241
+ */
242
+ project_id: string;
243
+
244
+ /**
245
+ * Body param: The updated service account name.
246
+ */
247
+ name?: string;
248
+
249
+ /**
250
+ * Body param: The updated service account role.
251
+ */
252
+ role?: 'member' | 'owner';
253
+ }
254
+
255
+ export interface ServiceAccountListParams extends ConversationCursorPageParams {}
256
+
257
+ export interface ServiceAccountDeleteParams {
258
+ /**
259
+ * The ID of the project.
260
+ */
261
+ project_id: string;
262
+ }
263
+
264
+ ServiceAccounts.APIKeys = APIKeys;
265
+
266
+ export declare namespace ServiceAccounts {
267
+ export {
268
+ type ProjectServiceAccount as ProjectServiceAccount,
269
+ type ServiceAccountCreateResponse as ServiceAccountCreateResponse,
270
+ type ServiceAccountDeleteResponse as ServiceAccountDeleteResponse,
271
+ type ProjectServiceAccountsPage as ProjectServiceAccountsPage,
272
+ type ServiceAccountCreateParams as ServiceAccountCreateParams,
273
+ type ServiceAccountRetrieveParams as ServiceAccountRetrieveParams,
274
+ type ServiceAccountUpdateParams as ServiceAccountUpdateParams,
275
+ type ServiceAccountListParams as ServiceAccountListParams,
276
+ type ServiceAccountDeleteParams as ServiceAccountDeleteParams,
277
+ };
278
+
279
+ export {
280
+ APIKeys as APIKeys,
281
+ type APIKeyCreateResponse as APIKeyCreateResponse,
282
+ type APIKeyCreateParams as APIKeyCreateParams,
283
+ };
284
+ }
@@ -1,266 +1,3 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
- import { APIResource } from '../../../../core/resource';
4
- import { APIPromise } from '../../../../core/api-promise';
5
- import {
6
- ConversationCursorPage,
7
- type ConversationCursorPageParams,
8
- PagePromise,
9
- } from '../../../../core/pagination';
10
- import { RequestOptions } from '../../../../internal/request-options';
11
- import { path } from '../../../../internal/utils/path';
12
-
13
- export class ServiceAccounts extends APIResource {
14
- /**
15
- * Creates a new service account in the project. This also returns an unredacted
16
- * API key for the service account.
17
- *
18
- * @example
19
- * ```ts
20
- * const serviceAccount =
21
- * await client.admin.organization.projects.serviceAccounts.create(
22
- * 'project_id',
23
- * { name: 'name' },
24
- * );
25
- * ```
26
- */
27
- create(
28
- projectID: string,
29
- body: ServiceAccountCreateParams,
30
- options?: RequestOptions,
31
- ): APIPromise<ServiceAccountCreateResponse> {
32
- return this._client.post(path`/organization/projects/${projectID}/service_accounts`, {
33
- body,
34
- ...options,
35
- __security: { adminAPIKeyAuth: true },
36
- });
37
- }
38
-
39
- /**
40
- * Retrieves a service account in the project.
41
- *
42
- * @example
43
- * ```ts
44
- * const projectServiceAccount =
45
- * await client.admin.organization.projects.serviceAccounts.retrieve(
46
- * 'service_account_id',
47
- * { project_id: 'project_id' },
48
- * );
49
- * ```
50
- */
51
- retrieve(
52
- serviceAccountID: string,
53
- params: ServiceAccountRetrieveParams,
54
- options?: RequestOptions,
55
- ): APIPromise<ProjectServiceAccount> {
56
- const { project_id } = params;
57
- return this._client.get(path`/organization/projects/${project_id}/service_accounts/${serviceAccountID}`, {
58
- ...options,
59
- __security: { adminAPIKeyAuth: true },
60
- });
61
- }
62
-
63
- /**
64
- * Updates a service account in the project.
65
- *
66
- * @example
67
- * ```ts
68
- * const projectServiceAccount =
69
- * await client.admin.organization.projects.serviceAccounts.update(
70
- * 'service_account_id',
71
- * { project_id: 'project_id' },
72
- * );
73
- * ```
74
- */
75
- update(
76
- serviceAccountID: string,
77
- params: ServiceAccountUpdateParams,
78
- options?: RequestOptions,
79
- ): APIPromise<ProjectServiceAccount> {
80
- const { project_id, ...body } = params;
81
- return this._client.post(
82
- path`/organization/projects/${project_id}/service_accounts/${serviceAccountID}`,
83
- { body, ...options, __security: { adminAPIKeyAuth: true } },
84
- );
85
- }
86
-
87
- /**
88
- * Returns a list of service accounts in the project.
89
- *
90
- * @example
91
- * ```ts
92
- * // Automatically fetches more pages as needed.
93
- * for await (const projectServiceAccount of client.admin.organization.projects.serviceAccounts.list(
94
- * 'project_id',
95
- * )) {
96
- * // ...
97
- * }
98
- * ```
99
- */
100
- list(
101
- projectID: string,
102
- query: ServiceAccountListParams | null | undefined = {},
103
- options?: RequestOptions,
104
- ): PagePromise<ProjectServiceAccountsPage, ProjectServiceAccount> {
105
- return this._client.getAPIList(
106
- path`/organization/projects/${projectID}/service_accounts`,
107
- ConversationCursorPage<ProjectServiceAccount>,
108
- { query, ...options, __security: { adminAPIKeyAuth: true } },
109
- );
110
- }
111
-
112
- /**
113
- * Deletes a service account from the project.
114
- *
115
- * Returns confirmation of service account deletion, or an error if the project is
116
- * archived (archived projects have no service accounts).
117
- *
118
- * @example
119
- * ```ts
120
- * const serviceAccount =
121
- * await client.admin.organization.projects.serviceAccounts.delete(
122
- * 'service_account_id',
123
- * { project_id: 'project_id' },
124
- * );
125
- * ```
126
- */
127
- delete(
128
- serviceAccountID: string,
129
- params: ServiceAccountDeleteParams,
130
- options?: RequestOptions,
131
- ): APIPromise<ServiceAccountDeleteResponse> {
132
- const { project_id } = params;
133
- return this._client.delete(
134
- path`/organization/projects/${project_id}/service_accounts/${serviceAccountID}`,
135
- { ...options, __security: { adminAPIKeyAuth: true } },
136
- );
137
- }
138
- }
139
-
140
- export type ProjectServiceAccountsPage = ConversationCursorPage<ProjectServiceAccount>;
141
-
142
- /**
143
- * Represents an individual service account in a project.
144
- */
145
- export interface ProjectServiceAccount {
146
- /**
147
- * The identifier, which can be referenced in API endpoints
148
- */
149
- id: string;
150
-
151
- /**
152
- * The Unix timestamp (in seconds) of when the service account was created
153
- */
154
- created_at: number;
155
-
156
- /**
157
- * The name of the service account
158
- */
159
- name: string;
160
-
161
- /**
162
- * The object type, which is always `organization.project.service_account`
163
- */
164
- object: 'organization.project.service_account';
165
-
166
- /**
167
- * `owner` or `member`
168
- */
169
- role: 'owner' | 'member';
170
- }
171
-
172
- export interface ServiceAccountCreateResponse {
173
- id: string;
174
-
175
- api_key: ServiceAccountCreateResponse.APIKey | null;
176
-
177
- created_at: number;
178
-
179
- name: string;
180
-
181
- object: 'organization.project.service_account';
182
-
183
- /**
184
- * Service accounts can only have one role of type `member`
185
- */
186
- role: 'member';
187
- }
188
-
189
- export namespace ServiceAccountCreateResponse {
190
- export interface APIKey {
191
- id: string;
192
-
193
- created_at: number;
194
-
195
- name: string;
196
-
197
- /**
198
- * The object type, which is always `organization.project.service_account.api_key`
199
- */
200
- object: 'organization.project.service_account.api_key';
201
-
202
- value: string;
203
- }
204
- }
205
-
206
- export interface ServiceAccountDeleteResponse {
207
- id: string;
208
-
209
- deleted: boolean;
210
-
211
- object: 'organization.project.service_account.deleted';
212
- }
213
-
214
- export interface ServiceAccountCreateParams {
215
- /**
216
- * The name of the service account being created.
217
- */
218
- name: string;
219
- }
220
-
221
- export interface ServiceAccountRetrieveParams {
222
- /**
223
- * The ID of the project.
224
- */
225
- project_id: string;
226
- }
227
-
228
- export interface ServiceAccountUpdateParams {
229
- /**
230
- * Path param: The ID of the project.
231
- */
232
- project_id: string;
233
-
234
- /**
235
- * Body param: The updated service account name.
236
- */
237
- name?: string;
238
-
239
- /**
240
- * Body param: The updated service account role.
241
- */
242
- role?: 'member' | 'owner';
243
- }
244
-
245
- export interface ServiceAccountListParams extends ConversationCursorPageParams {}
246
-
247
- export interface ServiceAccountDeleteParams {
248
- /**
249
- * The ID of the project.
250
- */
251
- project_id: string;
252
- }
253
-
254
- export declare namespace ServiceAccounts {
255
- export {
256
- type ProjectServiceAccount as ProjectServiceAccount,
257
- type ServiceAccountCreateResponse as ServiceAccountCreateResponse,
258
- type ServiceAccountDeleteResponse as ServiceAccountDeleteResponse,
259
- type ProjectServiceAccountsPage as ProjectServiceAccountsPage,
260
- type ServiceAccountCreateParams as ServiceAccountCreateParams,
261
- type ServiceAccountRetrieveParams as ServiceAccountRetrieveParams,
262
- type ServiceAccountUpdateParams as ServiceAccountUpdateParams,
263
- type ServiceAccountListParams as ServiceAccountListParams,
264
- type ServiceAccountDeleteParams as ServiceAccountDeleteParams,
265
- };
266
- }
3
+ export * from './service-accounts/index';