@honeyhive/control-plane-sdk 1.0.0 → 1.2.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.
@@ -1,30 +1,59 @@
1
1
  // AUTO-GENERATED — do not edit manually. Run `pnpm turbo run generate` to regenerate.
2
2
 
3
+ import { type Client as OpenapiFetchClient } from 'openapi-fetch';
4
+
3
5
  import { type paths } from './types.js';
4
6
  import {
5
7
  type ListAlertsRequest,
6
8
  type CreateAlertRequest,
7
9
  type GetAlertRequest,
10
+ type CreateWorkspaceRequest,
11
+ type GetWorkspaceRequest,
12
+ type UpdateWorkspaceRequest,
13
+ type DeleteWorkspaceRequest,
8
14
  type CreateProjectRequest,
9
15
  type GetProjectRequest,
10
16
  type UpdateProjectRequest,
11
17
  type DeleteProjectRequest,
18
+ type CreateVirtualDataplaneRequest,
19
+ type GetVirtualDataplaneRequest,
20
+ type UpdateVirtualDataplaneRequest,
21
+ type DeleteVirtualDataplaneRequest,
12
22
  type ListAlertsResponse,
13
23
  type CreateAlertResponse,
14
24
  type GetAlertResponse,
25
+ type CreateWorkspaceResponse,
26
+ type GetWorkspaceResponse,
27
+ type UpdateWorkspaceResponse,
28
+ type DeleteWorkspaceResponse,
15
29
  type CreateProjectResponse,
16
30
  type GetProjectResponse,
17
31
  type UpdateProjectResponse,
18
32
  type DeleteProjectResponse,
33
+ type CreateVirtualDataplaneResponse,
34
+ type GetVirtualDataplaneResponse,
35
+ type UpdateVirtualDataplaneResponse,
36
+ type DeleteVirtualDataplaneResponse,
19
37
  } from './apiTypes.js';
20
38
  import { type ClientConfig, type FetchOptions, createApiClient, unwrap } from '../util.js';
21
39
 
40
+ /** Every security scheme the API's OpenAPI spec defines. */
41
+ export type SecurityScheme = 'ControlPlaneApiKey';
42
+
43
+ /**
44
+ * What `createApiClient` returns: for every security scheme the spec defines,
45
+ * the openapi-fetch client that carries the credential for it. The hand-written
46
+ * chassis builds this table, so a scheme added to or removed from the spec
47
+ * fails to compile there until the table says which client serves it.
48
+ */
49
+ export type ApiClients = Record<SecurityScheme, OpenapiFetchClient<paths>>;
50
+
22
51
  /** @inline */
23
52
  class AlertsNamespace {
24
- #client: ReturnType<typeof createApiClient<paths>>;
53
+ #clients: ApiClients;
25
54
 
26
- constructor(client: ReturnType<typeof createApiClient<paths>>) {
27
- this.#client = client;
55
+ constructor(clients: ApiClients) {
56
+ this.#clients = clients;
28
57
  }
29
58
 
30
59
  /**
@@ -36,8 +65,9 @@ class AlertsNamespace {
36
65
  */
37
66
  public list(request: ListAlertsRequest, options?: FetchOptions): Promise<ListAlertsResponse> {
38
67
  const { project_id, page, limit, status, sort_by, sort_order } = request;
68
+ const httpClient = this.#clients.ControlPlaneApiKey;
39
69
  return unwrap(
40
- this.#client.GET('/v1/projects/{project_id}/alerts', {
70
+ httpClient.GET('/v1/projects/{project_id}/alerts', {
41
71
  params: { path: { project_id }, query: { page, limit, status, sort_by, sort_order } },
42
72
  ...options,
43
73
  }),
@@ -55,8 +85,9 @@ class AlertsNamespace {
55
85
  */
56
86
  public create(request: CreateAlertRequest, options?: FetchOptions): Promise<CreateAlertResponse> {
57
87
  const { project_id, ...body } = request;
88
+ const httpClient = this.#clients.ControlPlaneApiKey;
58
89
  return unwrap(
59
- this.#client.POST('/v1/projects/{project_id}/alerts', {
90
+ httpClient.POST('/v1/projects/{project_id}/alerts', {
60
91
  params: { path: { project_id } },
61
92
  body,
62
93
  ...options,
@@ -73,8 +104,9 @@ class AlertsNamespace {
73
104
  */
74
105
  public get(request: GetAlertRequest, options?: FetchOptions): Promise<GetAlertResponse> {
75
106
  const { project_id, alert_id } = request;
107
+ const httpClient = this.#clients.ControlPlaneApiKey;
76
108
  return unwrap(
77
- this.#client.GET('/v1/projects/{project_id}/alerts/{alert_id}', {
109
+ httpClient.GET('/v1/projects/{project_id}/alerts/{alert_id}', {
78
110
  params: { path: { project_id, alert_id } },
79
111
  ...options,
80
112
  }),
@@ -82,33 +114,174 @@ class AlertsNamespace {
82
114
  }
83
115
  }
84
116
 
117
+ /** @inline */
118
+ class WorkspacesNamespace {
119
+ #clients: ApiClients;
120
+
121
+ constructor(clients: ApiClients) {
122
+ this.#clients = clients;
123
+ }
124
+
125
+ /**
126
+ * Create a workspace
127
+ *
128
+ * Create a workspace in a virtual data plane. The parent virtual data plane is identified by
129
+ * the `virtual_dataplane_id` path parameter alone; the `x-hh-dataplane-id` header does not
130
+ * participate. Your organization's virtual data plane ids are listed on the API keys page of
131
+ * your organization settings in the HoneyHive app. Most organizations have exactly one.
132
+ *
133
+ * The new workspace contains no projects. Create one with
134
+ * `POST /v1/workspaces/{workspace_id}/projects` if you need it, because a workspace with no
135
+ * projects has nowhere to log events.
136
+ *
137
+ * The optional `workspace_creator` field names the user (by email) who receives the
138
+ * workspace-creator membership on the new workspace. The named user must already be a member
139
+ * of the virtual data plane. When omitted, the workspace is created without any membership.
140
+ * The field is only accepted on API-key-initiated requests. User-initiated creation always
141
+ * makes the calling user the creator, so sending the field returns a 400.
142
+ *
143
+ * The roles that membership carries come from your organization's role configuration. An
144
+ * organization that grants no role on workspace creation is a supported case: the request
145
+ * still succeeds and the named user receives no access. A 200 response is not by itself
146
+ * confirmation that the named user was granted anything.
147
+ *
148
+ * A `workspace_creator` who is already signed in does not see the new workspace immediately.
149
+ * A session captures its scope tree and permission grants when it is created, so a membership
150
+ * granted afterwards is not reflected in it. Creating the workspace marks that user's sessions
151
+ * for refresh, and the refresh takes effect on their next request to the control plane, so an
152
+ * idle browser tab may need a page reload.
153
+ */
154
+ public create(
155
+ request: CreateWorkspaceRequest,
156
+ options?: FetchOptions,
157
+ ): Promise<CreateWorkspaceResponse> {
158
+ const { virtual_dataplane_id, ...body } = request;
159
+ const httpClient = this.#clients.ControlPlaneApiKey;
160
+ return unwrap(
161
+ httpClient.POST('/v1/virtual_dataplanes/{virtual_dataplane_id}/workspaces', {
162
+ params: { path: { virtual_dataplane_id } },
163
+ body,
164
+ ...options,
165
+ }),
166
+ );
167
+ }
168
+
169
+ /**
170
+ * Get a workspace
171
+ *
172
+ * Retrieve a single workspace by id. The workspace is identified by the `workspace_id` path
173
+ * parameter alone; the `x-hh-workspace-id` header does not participate.
174
+ *
175
+ * The returned `name` is the workspace's display name. The globally unique slug the workspace
176
+ * was assigned at creation is an internal detail and is not part of this contract.
177
+ */
178
+ public get(request: GetWorkspaceRequest, options?: FetchOptions): Promise<GetWorkspaceResponse> {
179
+ const { workspace_id } = request;
180
+ const httpClient = this.#clients.ControlPlaneApiKey;
181
+ return unwrap(
182
+ httpClient.GET('/v1/workspaces/{workspace_id}', {
183
+ params: { path: { workspace_id } },
184
+ ...options,
185
+ }),
186
+ );
187
+ }
188
+
189
+ /**
190
+ * Update a workspace
191
+ *
192
+ * Update a workspace's display name and/or description. The workspace is identified by the
193
+ * `workspace_id` path parameter alone; the `x-hh-workspace-id` header does not participate.
194
+ * Only fields included in the request body are modified.
195
+ *
196
+ * The workspace's internal slug is not part of this contract and cannot be changed here.
197
+ */
198
+ public update(
199
+ request: UpdateWorkspaceRequest,
200
+ options?: FetchOptions,
201
+ ): Promise<UpdateWorkspaceResponse> {
202
+ const { workspace_id, ...body } = request;
203
+ const httpClient = this.#clients.ControlPlaneApiKey;
204
+ return unwrap(
205
+ httpClient.PUT('/v1/workspaces/{workspace_id}', {
206
+ params: { path: { workspace_id } },
207
+ body,
208
+ ...options,
209
+ }),
210
+ );
211
+ }
212
+
213
+ /**
214
+ * Delete a workspace
215
+ *
216
+ * Delete a workspace. The workspace is soft-deleted (archived) and no longer appears in reads;
217
+ * the response returns the archived workspace. The workspace is identified by the
218
+ * `workspace_id` path parameter alone; the `x-hh-workspace-id` header does not participate.
219
+ *
220
+ * **Deleting a workspace also archives every project inside it**, so the events, datasets,
221
+ * and evaluations in those projects are no longer reachable. Because that reaches well
222
+ * beyond the resource named in the URL, a workspace that still has active projects is
223
+ * rejected with a 409 unless the request sets `dangerously_delete_child_scopes=true`.
224
+ * Projects that were already archived do not count, so a workspace emptied one project at a
225
+ * time deletes without the flag.
226
+ *
227
+ * The response describes only the workspace. It does not enumerate the projects archived
228
+ * alongside it, so read them first if you need that list.
229
+ */
230
+ public delete(
231
+ request: DeleteWorkspaceRequest,
232
+ options?: FetchOptions,
233
+ ): Promise<DeleteWorkspaceResponse> {
234
+ const { workspace_id, dangerously_delete_child_scopes } = request;
235
+ const httpClient = this.#clients.ControlPlaneApiKey;
236
+ return unwrap(
237
+ httpClient.DELETE('/v1/workspaces/{workspace_id}', {
238
+ params: { path: { workspace_id }, query: { dangerously_delete_child_scopes } },
239
+ ...options,
240
+ }),
241
+ );
242
+ }
243
+ }
244
+
85
245
  /** @inline */
86
246
  class ProjectsNamespace {
87
- #client: ReturnType<typeof createApiClient<paths>>;
247
+ #clients: ApiClients;
88
248
 
89
- constructor(client: ReturnType<typeof createApiClient<paths>>) {
90
- this.#client = client;
249
+ constructor(clients: ApiClients) {
250
+ this.#clients = clients;
91
251
  }
92
252
 
93
253
  /**
94
254
  * Create a project
95
255
  *
96
256
  * Create a project in a workspace. The parent workspace is identified by the `workspace_id`
97
- * path parameter alone; the `x-hh-workspace-id` header does not participate.
257
+ * path parameter alone; the `x-hh-workspace-id` header does not participate. A workspace's id
258
+ * is listed on the API keys page of its workspace settings in the HoneyHive app.
98
259
  *
99
260
  * The optional `project_creator` field names the user (by email) who receives the
100
261
  * project-creator membership on the new project. The named user must already be a member of
101
262
  * the workspace. When omitted, the project is created without any membership. The field is
102
- * only accepted on API-key-initiated requests — user-initiated creation always makes the
103
- * calling user the creator and rejects the field with a 400.
263
+ * only accepted on API-key-initiated requests. User-initiated creation always makes the
264
+ * calling user the creator, so sending the field returns a 400.
265
+ *
266
+ * The roles that membership carries come from your organization's role configuration. An
267
+ * organization that grants no role on project creation is a supported case: the request
268
+ * still succeeds and the named user receives no access. A 200 response is not by itself
269
+ * confirmation that the named user was granted anything.
270
+ *
271
+ * A `project_creator` who is already signed in does not see the new project immediately. A
272
+ * session captures its scope tree and permission grants when it is created, so a membership
273
+ * granted afterwards is not reflected in it. Creating the project marks that user's sessions
274
+ * for refresh, and the refresh takes effect on their next request to the control plane, so
275
+ * an idle browser tab may need a page reload.
104
276
  */
105
277
  public create(
106
278
  request: CreateProjectRequest,
107
279
  options?: FetchOptions,
108
280
  ): Promise<CreateProjectResponse> {
109
281
  const { workspace_id, ...body } = request;
282
+ const httpClient = this.#clients.ControlPlaneApiKey;
110
283
  return unwrap(
111
- this.#client.POST('/v1/workspaces/{workspace_id}/projects', {
284
+ httpClient.POST('/v1/workspaces/{workspace_id}/projects', {
112
285
  params: { path: { workspace_id } },
113
286
  body,
114
287
  ...options,
@@ -124,11 +297,9 @@ class ProjectsNamespace {
124
297
  */
125
298
  public get(request: GetProjectRequest, options?: FetchOptions): Promise<GetProjectResponse> {
126
299
  const { project_id } = request;
300
+ const httpClient = this.#clients.ControlPlaneApiKey;
127
301
  return unwrap(
128
- this.#client.GET('/v1/projects/{project_id}', {
129
- params: { path: { project_id } },
130
- ...options,
131
- }),
302
+ httpClient.GET('/v1/projects/{project_id}', { params: { path: { project_id } }, ...options }),
132
303
  );
133
304
  }
134
305
 
@@ -144,8 +315,9 @@ class ProjectsNamespace {
144
315
  options?: FetchOptions,
145
316
  ): Promise<UpdateProjectResponse> {
146
317
  const { project_id, ...body } = request;
318
+ const httpClient = this.#clients.ControlPlaneApiKey;
147
319
  return unwrap(
148
- this.#client.PUT('/v1/projects/{project_id}', {
320
+ httpClient.PUT('/v1/projects/{project_id}', {
149
321
  params: { path: { project_id } },
150
322
  body,
151
323
  ...options,
@@ -165,8 +337,9 @@ class ProjectsNamespace {
165
337
  options?: FetchOptions,
166
338
  ): Promise<DeleteProjectResponse> {
167
339
  const { project_id } = request;
340
+ const httpClient = this.#clients.ControlPlaneApiKey;
168
341
  return unwrap(
169
- this.#client.DELETE('/v1/projects/{project_id}', {
342
+ httpClient.DELETE('/v1/projects/{project_id}', {
170
343
  params: { path: { project_id } },
171
344
  ...options,
172
345
  }),
@@ -174,14 +347,178 @@ class ProjectsNamespace {
174
347
  }
175
348
  }
176
349
 
350
+ /** @inline */
351
+ class VirtualDataplanesNamespace {
352
+ #clients: ApiClients;
353
+
354
+ constructor(clients: ApiClients) {
355
+ this.#clients = clients;
356
+ }
357
+
358
+ /**
359
+ * Create a virtual data plane
360
+ *
361
+ * Create a virtual data plane in an organization. The parent organization is identified by the
362
+ * `org_id` path parameter alone; the `x-hh-org-id` header does not participate. Your
363
+ * organization's id is listed on the API keys page of your organization settings in the
364
+ * HoneyHive app.
365
+ *
366
+ * A virtual data plane is a logical tenant boundary hosted on a physical cluster, and several
367
+ * of them commonly share one cluster. Workspaces are created inside it.
368
+ *
369
+ * `cluster_id` is optional, and omitting it is the common case: the new virtual data plane is
370
+ * placed on the same cluster as the organization's existing ones. Two situations require it
371
+ * explicitly, and both return a 400 that says so rather than guessing: an organization whose
372
+ * existing virtual data planes span more than one cluster, and an organization that has none
373
+ * yet. Every response includes `cluster_id`, so reading an existing virtual data plane tells
374
+ * you which value to send.
375
+ *
376
+ * A cluster admits an organization only if your control plane administrator configured it to,
377
+ * so a `cluster_id` you can read from a sibling virtual data plane is not necessarily one you
378
+ * may place a new virtual data plane on. A cluster that does not admit this organization
379
+ * returns a 404. When this endpoint inferred the cluster, send an explicit `cluster_id` to
380
+ * place the virtual data plane on another cluster.
381
+ *
382
+ * Deployments differ in who places virtual data planes. Where HoneyHive assigns them to
383
+ * organizations automatically, this endpoint returns a 404 for every request and the
384
+ * placement is not yours to make. Deployments whose administrators own the scope tree are
385
+ * the ones this endpoint serves.
386
+ *
387
+ * The optional `dataplane_creator` field names the user (by email) who receives the
388
+ * dataplane-creator membership on the new virtual data plane. The named user must already be a
389
+ * member of the organization. When omitted, it is created without any membership. The field is
390
+ * only accepted on API-key-initiated requests; user-initiated creation always makes the
391
+ * calling user the creator, so sending the field returns a 400.
392
+ *
393
+ * The roles that membership carries come from your organization's role configuration. An
394
+ * organization that grants no role on dataplane creation is a supported case: the request
395
+ * still succeeds and the named user receives no access. A 200 response is not by itself
396
+ * confirmation that the named user was granted anything.
397
+ *
398
+ * A `dataplane_creator` who is already signed in does not see the new virtual data plane
399
+ * immediately. A session captures its scope tree and permission grants when it is created, so
400
+ * a membership granted afterwards is not reflected in it; the refresh takes effect on their
401
+ * next request to the control plane.
402
+ */
403
+ public create(
404
+ request: CreateVirtualDataplaneRequest,
405
+ options?: FetchOptions,
406
+ ): Promise<CreateVirtualDataplaneResponse> {
407
+ const { org_id, ...body } = request;
408
+ const httpClient = this.#clients.ControlPlaneApiKey;
409
+ return unwrap(
410
+ httpClient.POST('/v1/orgs/{org_id}/virtual_dataplanes', {
411
+ params: { path: { org_id } },
412
+ body,
413
+ ...options,
414
+ }),
415
+ );
416
+ }
417
+
418
+ /**
419
+ * Get a virtual data plane
420
+ *
421
+ * Retrieve a single virtual data plane by id. It is identified by the `virtual_dataplane_id`
422
+ * path parameter alone; the `x-hh-dataplane-id` header does not participate.
423
+ *
424
+ * The returned `name` is the display name. The globally unique slug assigned at creation is
425
+ * an internal detail and is not part of this contract. `cluster_id` is the physical cluster
426
+ * hosting this virtual data plane, and it is the value to send when creating another one
427
+ * beside it.
428
+ *
429
+ * Reads work on every deployment, including those where HoneyHive assigns virtual data
430
+ * planes automatically and the write endpoints are unavailable.
431
+ */
432
+ public get(
433
+ request: GetVirtualDataplaneRequest,
434
+ options?: FetchOptions,
435
+ ): Promise<GetVirtualDataplaneResponse> {
436
+ const { virtual_dataplane_id } = request;
437
+ const httpClient = this.#clients.ControlPlaneApiKey;
438
+ return unwrap(
439
+ httpClient.GET('/v1/virtual_dataplanes/{virtual_dataplane_id}', {
440
+ params: { path: { virtual_dataplane_id } },
441
+ ...options,
442
+ }),
443
+ );
444
+ }
445
+
446
+ /**
447
+ * Update a virtual data plane
448
+ *
449
+ * Update a virtual data plane's display name. It is identified by the `virtual_dataplane_id`
450
+ * path parameter alone; the `x-hh-dataplane-id` header does not participate.
451
+ *
452
+ * `name` is the only field this endpoint changes. `cluster_id` is placement rather than
453
+ * description: the workspaces and projects inside a virtual data plane hold data on the
454
+ * cluster hosting it, so moving one is a migration and not an update. A request that omits
455
+ * `name`, or sends the current one, changes nothing.
456
+ *
457
+ * This endpoint is unavailable where HoneyHive assigns virtual data planes automatically,
458
+ * and returns a 404 there.
459
+ */
460
+ public update(
461
+ request: UpdateVirtualDataplaneRequest,
462
+ options?: FetchOptions,
463
+ ): Promise<UpdateVirtualDataplaneResponse> {
464
+ const { virtual_dataplane_id, ...body } = request;
465
+ const httpClient = this.#clients.ControlPlaneApiKey;
466
+ return unwrap(
467
+ httpClient.PUT('/v1/virtual_dataplanes/{virtual_dataplane_id}', {
468
+ params: { path: { virtual_dataplane_id } },
469
+ body,
470
+ ...options,
471
+ }),
472
+ );
473
+ }
474
+
475
+ /**
476
+ * Delete a virtual data plane
477
+ *
478
+ * Delete a virtual data plane. It is soft-deleted (archived) and no longer appears in reads;
479
+ * the response returns the archived virtual data plane. It is identified by the
480
+ * `virtual_dataplane_id` path parameter alone; the `x-hh-dataplane-id` header does not
481
+ * participate.
482
+ *
483
+ * **Deleting a virtual data plane also archives every workspace inside it and every project
484
+ * inside those workspaces**, so the events, datasets, and evaluations in them are no longer
485
+ * reachable. Because that reaches two levels below the resource named in the URL, a virtual
486
+ * data plane with active workspaces is rejected with a 409 unless the request sets
487
+ * `dangerously_delete_child_scopes=true`. Workspaces that were already archived do not count.
488
+ *
489
+ * The response describes only the virtual data plane. It does not enumerate what the cascade
490
+ * archived, so read that first if you need the list.
491
+ *
492
+ * This endpoint is unavailable where HoneyHive assigns virtual data planes automatically,
493
+ * and returns a 404 there.
494
+ */
495
+ public delete(
496
+ request: DeleteVirtualDataplaneRequest,
497
+ options?: FetchOptions,
498
+ ): Promise<DeleteVirtualDataplaneResponse> {
499
+ const { virtual_dataplane_id, dangerously_delete_child_scopes } = request;
500
+ const httpClient = this.#clients.ControlPlaneApiKey;
501
+ return unwrap(
502
+ httpClient.DELETE('/v1/virtual_dataplanes/{virtual_dataplane_id}', {
503
+ params: { path: { virtual_dataplane_id }, query: { dangerously_delete_child_scopes } },
504
+ ...options,
505
+ }),
506
+ );
507
+ }
508
+ }
509
+
177
510
  export class Client {
178
- #client: ReturnType<typeof createApiClient<paths>>;
511
+ #clients: ApiClients;
179
512
  readonly alerts: AlertsNamespace;
513
+ readonly workspaces: WorkspacesNamespace;
180
514
  readonly projects: ProjectsNamespace;
515
+ readonly virtualDataplanes: VirtualDataplanesNamespace;
181
516
 
182
517
  constructor(options: ClientConfig = {}) {
183
- this.#client = createApiClient<paths>(options);
184
- this.alerts = new AlertsNamespace(this.#client);
185
- this.projects = new ProjectsNamespace(this.#client);
518
+ this.#clients = createApiClient(options);
519
+ this.alerts = new AlertsNamespace(this.#clients);
520
+ this.workspaces = new WorkspacesNamespace(this.#clients);
521
+ this.projects = new ProjectsNamespace(this.#clients);
522
+ this.virtualDataplanes = new VirtualDataplanesNamespace(this.#clients);
186
523
  }
187
524
  }