@toshicloud/sdk 0.5.1 → 0.6.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.
package/README.md CHANGED
@@ -147,9 +147,16 @@ method for each call (`create`, `get`, `list`, `update`, `delete`, `wait`,
147
147
  `watch`, and `cancel` on a job, `execute`, `start` and `stop` on a sandbox,
148
148
  `start`, `stop`, `setMode`, `listRuns`, `wake`, `hold`, `release`,
149
149
  `listRevisions`, `getRevision`, `rollback` and `listActivations` on a
150
- service). The calls that
150
+ service). A service's alarms are `setAlarm`, `getAlarm`, `listAlarms`
151
+ (every alarm in one answer, with no page token), `deleteAlarm`,
152
+ `pauseAlarm`, `resumeAlarm` and `runAlarmNow`, and its sign-ins are
153
+ `startSignIn`, which hands back the sign-in's stream as the server sends
154
+ it, `answerSignIn`, `cancelSignIn` and `getSignInStatus`. The calls that
151
155
  span the three types sit on `workload` itself: `listEvents`, `watchEvents`,
152
- `getOperation` and `waitOperation`. `run` sits at the top of the client, as
156
+ `emitEvent`, `holdWorkload`, `releaseWorkload`, `getOperation` and
157
+ `waitOperation`. `holdWorkload` and `releaseWorkload` are operator-only and
158
+ need the operator's headers, which the caller adds with an interceptor
159
+ (see Operator calls). `run` sits at the top of the client, as
153
160
  `toshi run` sits at the top of the CLI.
154
161
 
155
162
  <!-- examples/client-shape.ts -->
@@ -160,6 +167,49 @@ const { job } = await toshi.workload.jobs.get({ id: jobs[0].id });
160
167
  console.log(job?.id);
161
168
  ```
162
169
 
170
+ ### Operator calls
171
+
172
+ An operator's token sends its reason in `Toshi-Operator-Reason` and the
173
+ workspace it acts on in `Toshi-Workspace` on every Workspace API call; the
174
+ server refuses one without them. Both belong to the client rather than to a
175
+ call, so the caller sets them with an interceptor of its own: the `transport`
176
+ option receives the client's interceptors, and the caller adds the one that
177
+ writes the headers. `workload.holdWorkload` places an operator's hold on a
178
+ sandbox or service, stopping it if it runs, and `workload.releaseWorkload`
179
+ lifts the hold and starts nothing; only an operator may make either call.
180
+
181
+ <!-- examples/operator-reason.ts -->
182
+
183
+ ```ts
184
+ import type { Interceptor } from "@connectrpc/connect";
185
+ import { createConnectTransport } from "@connectrpc/connect-node";
186
+
187
+ import { createToshiClient } from "@toshicloud/sdk/node";
188
+
189
+ const baseUrl = "https://toshi.example.com";
190
+
191
+ // An operator's token, the reason its calls carry and the workspace they
192
+ // act on.
193
+ declare const token: string;
194
+
195
+ const operator: Interceptor = (next) => (req) => {
196
+ req.header.set("Toshi-Operator-Reason", "investigating a report");
197
+ req.header.set("Toshi-Workspace", "acme");
198
+ return next(req);
199
+ };
200
+
201
+ export const toshi = createToshiClient({
202
+ transport: (interceptors) =>
203
+ createConnectTransport({
204
+ baseUrl,
205
+ httpVersion: "2",
206
+ interceptors: [...interceptors, operator],
207
+ }),
208
+ token,
209
+ project: "default",
210
+ });
211
+ ```
212
+
163
213
  ### Lists
164
214
 
165
215
  `workload.jobs.all`, `workload.sandboxes.all`,
@@ -407,6 +457,10 @@ for await (const chunk of run) {
407
457
  await run.wait();
408
458
  ```
409
459
 
460
+ The fake also keeps a service's alarms: `setAlarm`, `getAlarm`, `listAlarms`,
461
+ `deleteAlarm`, `pauseAlarm`, `resumeAlarm` and `runAlarmNow` answer from its
462
+ state machine.
463
+
410
464
  `fake.on(method, impl)` replaces the state machine for one method with a hook
411
465
  typed by that method: one call for unary, server-stream and bidirectional
412
466
  methods alike. `fake.calls()` returns every call the fake received, oldest
@@ -423,8 +477,9 @@ in `proto/toshi/workspace/v1` of the
423
477
  only `@bufbuild/protobuf`, so installing the package needs no generator.
424
478
 
425
479
  `pin.env` names the toshi-api commit the code is generated from:
426
- `2184ae8440834bb5b91991b3e4d62d14ce9dd15a` today, the commit of the
427
- release tag `v0.4.1`. `mise.toml` pins the versions of Node, pnpm and `buf`;
480
+ `5474559e89f7faf4b718fd5f1d64ff7457657477` today, the commit of the
481
+ release tag `v0.5.0`.
482
+ `mise.toml` pins the versions of Node, pnpm and `buf`;
428
483
  `package.json` pins `protoc-gen-es` at the same version as the
429
484
  `@bufbuild/protobuf` development dependency.
430
485
 
package/dist/client.d.ts CHANGED
@@ -26,10 +26,10 @@ import { WebhookService } from "./gen/toshi/workspace/v1/webhook_pb.js";
26
26
  import { WorkspaceService } from "./gen/toshi/workspace/v1/workspace_service_pb.js";
27
27
  import { CreatePreviewShareLinkRequestSchema, ListPreviewShareLinksRequestSchema, RevokePreviewShareLinkRequestSchema, StartSandboxRequestSchema, StopSandboxRequestSchema } from "./gen/toshi/workspace/v1/workspace_pb.js";
28
28
  import type { CreatePreviewShareLinkResponse, ListPreviewShareLinksResponse, RevokePreviewShareLinkResponse, StartSandboxResponse, StopSandboxResponse } from "./gen/toshi/workspace/v1/workspace_pb.js";
29
- import { CancelJobRequestSchema, CreateJobRequestSchema, CreateSandboxRequestSchema, CreateServiceRequestSchema, DeleteJobRequestSchema, DeleteSandboxRequestSchema, DeleteServiceRequestSchema, GetJobRequestSchema, GetSandboxRequestSchema, GetServiceRequestSchema, ListJobsRequestSchema, ListSandboxesRequestSchema, ListServicesRequestSchema, UpdateJobRequestSchema, UpdateSandboxRequestSchema, UpdateServiceRequestSchema, WaitJobRequestSchema, WaitSandboxRequestSchema, WaitServiceRequestSchema, WatchJobsRequestSchema, WatchSandboxesRequestSchema, WatchServicesRequestSchema } from "./gen/toshi/workspace/v1/workloads_pb.js";
30
- import type { CancelJobResponse, CreateJobResponse, CreateSandboxResponse, CreateServiceResponse, DeleteJobResponse, DeleteSandboxResponse, DeleteServiceResponse, GetJobResponse, GetSandboxResponse, GetServiceResponse, ListJobsResponse, ListSandboxesResponse, ListServicesResponse, UpdateJobResponse, UpdateSandboxResponse, UpdateServiceResponse, WaitJobResponse, WaitSandboxResponse, WaitServiceResponse, WatchJobsResponse, WatchSandboxesResponse, WatchServicesResponse } from "./gen/toshi/workspace/v1/workloads_pb.js";
31
- import { ExecuteStartSchema, GetOperationRequestSchema, GetServiceRevisionRequestSchema, HoldServiceRequestSchema, ListEventsRequestSchema, ListServiceActivationsRequestSchema, ListServiceRevisionsRequestSchema, ListServiceRunsRequestSchema, ReleaseServiceRequestSchema, RollbackServiceRequestSchema, SetServiceModeRequestSchema, StartServiceRequestSchema, StopServiceRequestSchema, WaitOperationRequestSchema, WakeServiceRequestSchema, WatchEventsRequestSchema, WatchOutputRequestSchema } from "./gen/toshi/workspace/v1/workspace_pb.js";
32
- import type { Event, GetOperationResponse, GetServiceRevisionResponse, HoldServiceResponse, Job, ListEventsResponse, ListServiceActivationsResponse, ListServiceRevisionsResponse, ListServiceRunsResponse, Operation, PreviewShareLink, ReleaseServiceResponse, RollbackServiceResponse, Sandbox, Service, ServiceRun, SetServiceModeResponse, StartServiceResponse, StopServiceResponse, WakeServiceResponse, WatchEventsResponse, WatchOutputResponse } from "./gen/toshi/workspace/v1/workspace_pb.js";
29
+ import { CancelJobRequestSchema, CreateJobRequestSchema, CreateSandboxRequestSchema, CreateServiceRequestSchema, DeleteJobRequestSchema, DeleteSandboxRequestSchema, DeleteServiceAlarmRequestSchema, DeleteServiceRequestSchema, EmitWorkloadEventRequestSchema, GetJobRequestSchema, GetSandboxRequestSchema, GetServiceAlarmRequestSchema, GetServiceRequestSchema, ListJobsRequestSchema, ListSandboxesRequestSchema, ListServiceAlarmsRequestSchema, ListServicesRequestSchema, PauseServiceAlarmRequestSchema, ResumeServiceAlarmRequestSchema, RunServiceAlarmNowRequestSchema, SetServiceAlarmRequestSchema, UpdateJobRequestSchema, UpdateSandboxRequestSchema, UpdateServiceRequestSchema, WaitJobRequestSchema, WaitSandboxRequestSchema, WaitServiceRequestSchema, WatchJobsRequestSchema, WatchSandboxesRequestSchema, WatchServicesRequestSchema } from "./gen/toshi/workspace/v1/workloads_pb.js";
30
+ import type { CancelJobResponse, CreateJobResponse, CreateSandboxResponse, CreateServiceResponse, DeleteJobResponse, DeleteSandboxResponse, DeleteServiceAlarmResponse, DeleteServiceResponse, EmitWorkloadEventResponse, GetJobResponse, GetSandboxResponse, GetServiceAlarmResponse, GetServiceResponse, ListJobsResponse, ListSandboxesResponse, ListServiceAlarmsResponse, ListServicesResponse, PauseServiceAlarmResponse, ResumeServiceAlarmResponse, RunServiceAlarmNowResponse, SetServiceAlarmResponse, UpdateJobResponse, UpdateSandboxResponse, UpdateServiceResponse, WaitJobResponse, WaitSandboxResponse, WaitServiceResponse, WatchJobsResponse, WatchSandboxesResponse, WatchServicesResponse } from "./gen/toshi/workspace/v1/workloads_pb.js";
31
+ import { AnswerServiceSignInRequestSchema, CancelServiceSignInRequestSchema, ExecuteStartSchema, GetOperationRequestSchema, GetServiceRevisionRequestSchema, GetServiceSignInStatusRequestSchema, HoldServiceRequestSchema, HoldWorkloadRequestSchema, ListEventsRequestSchema, ListServiceActivationsRequestSchema, ListServiceRevisionsRequestSchema, ListServiceRunsRequestSchema, ReleaseServiceRequestSchema, ReleaseWorkloadRequestSchema, RollbackServiceRequestSchema, SetServiceModeRequestSchema, StartServiceRequestSchema, StartServiceSignInRequestSchema, StopServiceRequestSchema, WaitOperationRequestSchema, WakeServiceRequestSchema, WatchEventsRequestSchema, WatchOutputRequestSchema } from "./gen/toshi/workspace/v1/workspace_pb.js";
32
+ import type { AnswerServiceSignInResponse, CancelServiceSignInResponse, Event, GetOperationResponse, GetServiceRevisionResponse, GetServiceSignInStatusResponse, HoldServiceResponse, HoldWorkloadResponse, Job, ListEventsResponse, ListServiceActivationsResponse, ListServiceRevisionsResponse, ListServiceRunsResponse, Operation, PreviewShareLink, ReleaseServiceResponse, ReleaseWorkloadResponse, RollbackServiceResponse, Sandbox, Service, ServiceRun, SetServiceModeResponse, StartServiceResponse, StartServiceSignInResponse, StopServiceResponse, WakeServiceResponse, WatchEventsResponse, WatchOutputResponse } from "./gen/toshi/workspace/v1/workspace_pb.js";
33
33
  import type { RetryPolicy } from "./retry.js";
34
34
  /** How the client is configured; the caller builds the transport. */
35
35
  export interface ToshiOptions {
@@ -97,6 +97,22 @@ export interface WorkloadClient {
97
97
  /** Yields every event listEvents lists, following the page token from one page to the next. */
98
98
  allEvents(req: MessageInitShape<typeof ListEventsRequestSchema>, opts?: CallOptions): AsyncIterable<Event>;
99
99
  watchEvents(req: MessageInitShape<typeof WatchEventsRequestSchema>, opts?: CallOptions): Promise<EventWatch>;
100
+ /**
101
+ * Appends an event of type EMITTED, with the name and data given, to a job's, sandbox's or
102
+ * service's event log, as its guest emits one, and returns it; the workload need not be running.
103
+ */
104
+ emitEvent(req: MessageInitShape<typeof EmitWorkloadEventRequestSchema>, opts?: CallOptions): Promise<EmitWorkloadEventResponse>;
105
+ /**
106
+ * Places an operator's hold on a sandbox or service, stopping it if it runs. Only an
107
+ * operator may call it; the caller sets the operator's reason in the Toshi-Operator-Reason
108
+ * header with an interceptor, since the client sends none itself.
109
+ */
110
+ holdWorkload(req: MessageInitShape<typeof HoldWorkloadRequestSchema>, opts?: CallOptions): Promise<HoldWorkloadResponse>;
111
+ /**
112
+ * Lifts an operator's hold and starts nothing. Only an operator may call it; the caller
113
+ * sets the operator's reason in the Toshi-Operator-Reason header with an interceptor.
114
+ */
115
+ releaseWorkload(req: MessageInitShape<typeof ReleaseWorkloadRequestSchema>, opts?: CallOptions): Promise<ReleaseWorkloadResponse>;
100
116
  /** Returns one operation: the id a long call hands back, asked for again. */
101
117
  getOperation(req: MessageInitShape<typeof GetOperationRequestSchema>, opts?: CallOptions): Promise<GetOperationResponse>;
102
118
  }
@@ -162,6 +178,58 @@ export interface ServicesClient {
162
178
  rollback(req: MessageInitShape<typeof RollbackServiceRequestSchema>, opts?: CallOptions): Promise<RollbackServiceResponse>;
163
179
  /** Returns a service's activations, oldest first. */
164
180
  listActivations(req: MessageInitShape<typeof ListServiceActivationsRequestSchema>, opts?: CallOptions): Promise<ListServiceActivationsResponse>;
181
+ /**
182
+ * Creates or replaces the service's alarm with this name and returns it: at each instant of its
183
+ * schedule the alarm publishes its event, with its data, on one of the service's event channels.
184
+ */
185
+ setAlarm(req: MessageInitShape<typeof SetServiceAlarmRequestSchema>, opts?: CallOptions): Promise<SetServiceAlarmResponse>;
186
+ /** Returns one alarm and its most recent occurrences, newest first. */
187
+ getAlarm(req: MessageInitShape<typeof GetServiceAlarmRequestSchema>, opts?: CallOptions): Promise<GetServiceAlarmResponse>;
188
+ /**
189
+ * Returns all of a service's alarms, by name, in one answer: the call has no page token, so
190
+ * there is no `allAlarms`.
191
+ */
192
+ listAlarms(req: MessageInitShape<typeof ListServiceAlarmsRequestSchema>, opts?: CallOptions): Promise<ListServiceAlarmsResponse>;
193
+ /** Removes an alarm and its occurrences; messages it already published stay on the channel. */
194
+ deleteAlarm(req: MessageInitShape<typeof DeleteServiceAlarmRequestSchema>, opts?: CallOptions): Promise<DeleteServiceAlarmResponse>;
195
+ /** Stops an alarm publishing until it is resumed; pausing a paused alarm changes nothing. */
196
+ pauseAlarm(req: MessageInitShape<typeof PauseServiceAlarmRequestSchema>, opts?: CallOptions): Promise<PauseServiceAlarmResponse>;
197
+ /**
198
+ * Starts a paused alarm again from the next instant of its schedule; instants that passed while
199
+ * it was paused are not published.
200
+ */
201
+ resumeAlarm(req: MessageInitShape<typeof ResumeServiceAlarmRequestSchema>, opts?: CallOptions): Promise<ResumeServiceAlarmResponse>;
202
+ /**
203
+ * Publishes the alarm's event once, now, paused or not, and returns the occurrence; it does not
204
+ * move the alarm's next instant. It takes a request key, so a retried call is applied once.
205
+ */
206
+ runAlarmNow(req: MessageInitShape<typeof RunServiceAlarmNowRequestSchema>, opts?: CallOptions): Promise<RunServiceAlarmNowResponse>;
207
+ /**
208
+ * Runs one of the service's recipe's sign_in programs and hands back its stream as the server
209
+ * sends it. The caller reads the started message first, which names the sign-in; then the
210
+ * output messages, the program's standard output and standard error; answers the program with
211
+ * `answerSignIn` or ends it early with `cancelSignIn`; and reads the ended message last, which
212
+ * says how it ended. A sign-in may run for 15 minutes.
213
+ *
214
+ * The stream is not retried or resumed: a sign-in has no cursor. Its stream ending for another
215
+ * reason, as a client that leaves, also ends it, cancelled; the caller starts a new one.
216
+ */
217
+ startSignIn(req: MessageInitShape<typeof StartServiceSignInRequestSchema>, opts?: CallOptions): AsyncIterable<StartServiceSignInResponse>;
218
+ /**
219
+ * Writes one line, of at most 4 KiB and with no newline in it, to a running sign-in's standard
220
+ * input; the sign-in's program reads it.
221
+ */
222
+ answerSignIn(req: MessageInitShape<typeof AnswerServiceSignInRequestSchema>, opts?: CallOptions): Promise<AnswerServiceSignInResponse>;
223
+ /**
224
+ * Ends a running sign-in: its program is cancelled and its stream ends CANCELLED. It returns
225
+ * once the cancel is asked for, not once the sign-in has ended.
226
+ */
227
+ cancelSignIn(req: MessageInitShape<typeof CancelServiceSignInRequestSchema>, opts?: CallOptions): Promise<CancelServiceSignInResponse>;
228
+ /**
229
+ * Runs the status commands of the service's recipe and reports, for each sign_in program,
230
+ * whether it is signed in and what its status command wrote.
231
+ */
232
+ getSignInStatus(req: MessageInitShape<typeof GetServiceSignInStatusRequestSchema>, opts?: CallOptions): Promise<GetServiceSignInStatusResponse>;
165
233
  }
166
234
  /** A live stream of a job's changes. */
167
235
  export interface JobWatch extends AsyncIterable<WatchJobsResponse> {
package/dist/client.js CHANGED
@@ -26,8 +26,8 @@ import { VolumeService } from "./gen/toshi/workspace/v1/volumes_pb.js";
26
26
  import { WebhookService } from "./gen/toshi/workspace/v1/webhook_pb.js";
27
27
  import { WorkspaceService } from "./gen/toshi/workspace/v1/workspace_service_pb.js";
28
28
  import { CreatePreviewShareLinkRequestSchema, ListPreviewShareLinksRequestSchema, RevokePreviewShareLinkRequestSchema, StartSandboxRequestSchema, StopSandboxRequestSchema, } from "./gen/toshi/workspace/v1/workspace_pb.js";
29
- import { CancelJobRequestSchema, CreateJobRequestSchema, CreateSandboxRequestSchema, CreateServiceRequestSchema, DeleteJobRequestSchema, DeleteSandboxRequestSchema, DeleteServiceRequestSchema, GetJobRequestSchema, GetSandboxRequestSchema, GetServiceRequestSchema, ListJobsRequestSchema, ListSandboxesRequestSchema, ListServicesRequestSchema, UpdateJobRequestSchema, UpdateSandboxRequestSchema, UpdateServiceRequestSchema, WaitJobRequestSchema, WaitSandboxRequestSchema, WaitServiceRequestSchema, WatchJobsRequestSchema, WatchSandboxesRequestSchema, WatchServicesRequestSchema, WorkloadService, } from "./gen/toshi/workspace/v1/workloads_pb.js";
30
- import { ExecuteStartSchema, GetOperationRequestSchema, GetServiceRevisionRequestSchema, HoldServiceRequestSchema, ListEventsRequestSchema, ListServiceActivationsRequestSchema, ListServiceRevisionsRequestSchema, ListServiceRunsRequestSchema, ReleaseServiceRequestSchema, RollbackServiceRequestSchema, SetServiceModeRequestSchema, StartServiceRequestSchema, StopServiceRequestSchema, WaitOperationRequestSchema, WakeServiceRequestSchema, WatchEventsRequestSchema, WatchOutputRequestSchema, } from "./gen/toshi/workspace/v1/workspace_pb.js";
29
+ import { CancelJobRequestSchema, CreateJobRequestSchema, CreateSandboxRequestSchema, CreateServiceRequestSchema, DeleteJobRequestSchema, DeleteSandboxRequestSchema, DeleteServiceAlarmRequestSchema, DeleteServiceRequestSchema, EmitWorkloadEventRequestSchema, GetJobRequestSchema, GetSandboxRequestSchema, GetServiceAlarmRequestSchema, GetServiceRequestSchema, ListJobsRequestSchema, ListSandboxesRequestSchema, ListServiceAlarmsRequestSchema, ListServicesRequestSchema, PauseServiceAlarmRequestSchema, ResumeServiceAlarmRequestSchema, RunServiceAlarmNowRequestSchema, SetServiceAlarmRequestSchema, UpdateJobRequestSchema, UpdateSandboxRequestSchema, UpdateServiceRequestSchema, WaitJobRequestSchema, WaitSandboxRequestSchema, WaitServiceRequestSchema, WatchJobsRequestSchema, WatchSandboxesRequestSchema, WatchServicesRequestSchema, WorkloadService, } from "./gen/toshi/workspace/v1/workloads_pb.js";
30
+ import { AnswerServiceSignInRequestSchema, CancelServiceSignInRequestSchema, ExecuteStartSchema, GetOperationRequestSchema, GetServiceRevisionRequestSchema, GetServiceSignInStatusRequestSchema, HoldServiceRequestSchema, HoldWorkloadRequestSchema, ListEventsRequestSchema, ListServiceActivationsRequestSchema, ListServiceRevisionsRequestSchema, ListServiceRunsRequestSchema, ReleaseServiceRequestSchema, ReleaseWorkloadRequestSchema, RollbackServiceRequestSchema, SetServiceModeRequestSchema, StartServiceRequestSchema, StartServiceSignInRequestSchema, StopServiceRequestSchema, WaitOperationRequestSchema, WakeServiceRequestSchema, WatchEventsRequestSchema, WatchOutputRequestSchema, } from "./gen/toshi/workspace/v1/workspace_pb.js";
31
31
  import { openOutputWatch } from "./output.js";
32
32
  import { paginate } from "./paginate.js";
33
33
  import { authInterceptor, keyInterceptor, refusalInterceptor, retryInterceptor, scopeInterceptor, } from "./interceptors.js";
@@ -118,11 +118,25 @@ export function createToshiClient(options) {
118
118
  getRevision: (req, opts) => workloadService.getServiceRevision(req, opts),
119
119
  rollback: (req, opts) => workloadService.rollbackService(req, opts),
120
120
  listActivations: (req, opts) => workloadService.listServiceActivations(req, opts),
121
+ setAlarm: (req, opts) => workloadService.setServiceAlarm(req, opts),
122
+ getAlarm: (req, opts) => workloadService.getServiceAlarm(req, opts),
123
+ listAlarms: (req, opts) => workloadService.listServiceAlarms(req, opts),
124
+ deleteAlarm: (req, opts) => workloadService.deleteServiceAlarm(req, opts),
125
+ pauseAlarm: (req, opts) => workloadService.pauseServiceAlarm(req, opts),
126
+ resumeAlarm: (req, opts) => workloadService.resumeServiceAlarm(req, opts),
127
+ runAlarmNow: (req, opts) => workloadService.runServiceAlarmNow(req, opts),
128
+ startSignIn: (req, opts) => workloadService.startServiceSignIn(req, opts),
129
+ answerSignIn: (req, opts) => workloadService.answerServiceSignIn(req, opts),
130
+ cancelSignIn: (req, opts) => workloadService.cancelServiceSignIn(req, opts),
131
+ getSignInStatus: (req, opts) => workloadService.getServiceSignInStatus(req, opts),
121
132
  },
122
133
  waitOperation: (req, opts) => waitOperation(workloadService, create(WaitOperationRequestSchema, req), opts),
123
134
  listEvents: (req, opts) => workloadService.listEvents(req, opts),
124
135
  allEvents: (req, opts) => paginate(req, workloadService.listEvents, (resp) => resp.events, opts),
125
136
  watchEvents: (req, opts) => openEventWatch(workloadService, retry, create(WatchEventsRequestSchema, req), opts),
137
+ emitEvent: (req, opts) => workloadService.emitWorkloadEvent(req, opts),
138
+ holdWorkload: (req, opts) => workloadService.holdWorkload(req, opts),
139
+ releaseWorkload: (req, opts) => workloadService.releaseWorkload(req, opts),
126
140
  getOperation: (req, opts) => workloadService.getOperation(req, opts),
127
141
  },
128
142
  run: (req, opts) => runJob(workloadService, retry, create(CreateJobRequestSchema, req), opts),
@@ -20,15 +20,15 @@ export type Connection = Message<"toshi.workspace.v1.Connection"> & {
20
20
  */
21
21
  kind: ConnectionKind;
22
22
  /**
23
- * Unique among the workspace's WEBHOOK connections; for GITHUB, the
24
- * login of the account the App is installed on.
23
+ * Unique among the workspace's live connections of its kind, WEBHOOK or
24
+ * MAIL; for GITHUB, the login of the account the App is installed on.
25
25
  *
26
26
  * @generated from field: string name = 3;
27
27
  */
28
28
  name: string;
29
29
  /**
30
- * The project and environment a WEBHOOK connection's events belong to;
31
- * empty for GITHUB, whose events belong to their repository's project.
30
+ * The project and environment a WEBHOOK or MAIL connection's events belong
31
+ * to; empty for GITHUB, whose events belong to their repository's project.
32
32
  *
33
33
  * @generated from field: string project = 4;
34
34
  */
@@ -64,8 +64,8 @@ export type Connection = Message<"toshi.workspace.v1.Connection"> & {
64
64
  /**
65
65
  * The inbound address a WEBHOOK connection's sender POSTs to: the
66
66
  * deployment's public address and /ingress/ with the connection's
67
- * address token. Empty for GITHUB, and when the deployment names no
68
- * public address.
67
+ * address token. Empty for GITHUB and MAIL, and when the deployment names
68
+ * no public address.
69
69
  *
70
70
  * @generated from field: string ingress_url = 11;
71
71
  */
@@ -100,6 +100,13 @@ export type Connection = Message<"toshi.workspace.v1.Connection"> & {
100
100
  * @generated from field: string manifest_origin = 15;
101
101
  */
102
102
  manifestOrigin: string;
103
+ /**
104
+ * Where a MAIL connection receives mail and where it sends it; unset for
105
+ * the other kinds.
106
+ *
107
+ * @generated from field: toshi.workspace.v1.MailConnection mail = 16;
108
+ */
109
+ mail?: MailConnection | undefined;
103
110
  };
104
111
  /**
105
112
  * Connection is one source of a workspace's events.
@@ -116,15 +123,15 @@ export type ConnectionJson = {
116
123
  */
117
124
  kind?: ConnectionKindJson;
118
125
  /**
119
- * Unique among the workspace's WEBHOOK connections; for GITHUB, the
120
- * login of the account the App is installed on.
126
+ * Unique among the workspace's live connections of its kind, WEBHOOK or
127
+ * MAIL; for GITHUB, the login of the account the App is installed on.
121
128
  *
122
129
  * @generated from field: string name = 3;
123
130
  */
124
131
  name?: string;
125
132
  /**
126
- * The project and environment a WEBHOOK connection's events belong to;
127
- * empty for GITHUB, whose events belong to their repository's project.
133
+ * The project and environment a WEBHOOK or MAIL connection's events belong
134
+ * to; empty for GITHUB, whose events belong to their repository's project.
128
135
  *
129
136
  * @generated from field: string project = 4;
130
137
  */
@@ -160,8 +167,8 @@ export type ConnectionJson = {
160
167
  /**
161
168
  * The inbound address a WEBHOOK connection's sender POSTs to: the
162
169
  * deployment's public address and /ingress/ with the connection's
163
- * address token. Empty for GITHUB, and when the deployment names no
164
- * public address.
170
+ * address token. Empty for GITHUB and MAIL, and when the deployment names
171
+ * no public address.
165
172
  *
166
173
  * @generated from field: string ingress_url = 11;
167
174
  */
@@ -196,6 +203,13 @@ export type ConnectionJson = {
196
203
  * @generated from field: string manifest_origin = 15;
197
204
  */
198
205
  manifestOrigin?: string;
206
+ /**
207
+ * Where a MAIL connection receives mail and where it sends it; unset for
208
+ * the other kinds.
209
+ *
210
+ * @generated from field: toshi.workspace.v1.MailConnection mail = 16;
211
+ */
212
+ mail?: MailConnectionJson;
199
213
  };
200
214
  /**
201
215
  * Describes the message toshi.workspace.v1.Connection.
@@ -204,6 +218,83 @@ export type ConnectionJson = {
204
218
  export declare const ConnectionSchema: GenMessage<Connection, {
205
219
  jsonType: ConnectionJson;
206
220
  }>;
221
+ /**
222
+ * MailConnection is where a MAIL connection receives mail and where it
223
+ * sends it.
224
+ *
225
+ * @generated from message toshi.workspace.v1.MailConnection
226
+ */
227
+ export type MailConnection = Message<"toshi.workspace.v1.MailConnection"> & {
228
+ /**
229
+ * Output only. The address mail is received at: the connection's name,
230
+ * "@", the workspace's ID and the deployment's inbound mail domain, all
231
+ * lowercase.
232
+ *
233
+ * @generated from field: string address = 1;
234
+ */
235
+ address: string;
236
+ /**
237
+ * The service, by its ID, whose event channel the mail goes to.
238
+ *
239
+ * @generated from field: string service = 2;
240
+ */
241
+ service: string;
242
+ /**
243
+ * The name of that service's event channel.
244
+ *
245
+ * @generated from field: string channel = 3;
246
+ */
247
+ channel: string;
248
+ /**
249
+ * Output only. The mail provider that receives for the address, such as
250
+ * "ses".
251
+ *
252
+ * @generated from field: string provider = 4;
253
+ */
254
+ provider: string;
255
+ };
256
+ /**
257
+ * MailConnection is where a MAIL connection receives mail and where it
258
+ * sends it.
259
+ *
260
+ * @generated from message toshi.workspace.v1.MailConnection
261
+ */
262
+ export type MailConnectionJson = {
263
+ /**
264
+ * Output only. The address mail is received at: the connection's name,
265
+ * "@", the workspace's ID and the deployment's inbound mail domain, all
266
+ * lowercase.
267
+ *
268
+ * @generated from field: string address = 1;
269
+ */
270
+ address?: string;
271
+ /**
272
+ * The service, by its ID, whose event channel the mail goes to.
273
+ *
274
+ * @generated from field: string service = 2;
275
+ */
276
+ service?: string;
277
+ /**
278
+ * The name of that service's event channel.
279
+ *
280
+ * @generated from field: string channel = 3;
281
+ */
282
+ channel?: string;
283
+ /**
284
+ * Output only. The mail provider that receives for the address, such as
285
+ * "ses".
286
+ *
287
+ * @generated from field: string provider = 4;
288
+ */
289
+ provider?: string;
290
+ };
291
+ /**
292
+ * Describes the message toshi.workspace.v1.MailConnection.
293
+ * Use `create(MailConnectionSchema)` to create a new message.
294
+ */
295
+ export declare const MailConnectionSchema: GenMessage<MailConnection, {
296
+ jsonType: MailConnectionJson;
297
+ }>;
207
298
  /**
208
299
  * ConnectionTarget is the URL a WEBHOOK connection's deliveries are posted
209
300
  * to: each delivery's event, as the event log would hold it, signed as
@@ -410,7 +501,8 @@ export declare const GetConnectionResponseSchema: GenMessage<GetConnectionRespon
410
501
  */
411
502
  export type CreateConnectionRequest = Message<"toshi.workspace.v1.CreateConnectionRequest"> & {
412
503
  /**
413
- * WEBHOOK; no other kind is created here.
504
+ * The kind to create: WEBHOOK or MAIL. Installing the GitHub App creates
505
+ * a GITHUB connection.
414
506
  *
415
507
  * @generated from field: toshi.workspace.v1.ConnectionKind kind = 1;
416
508
  */
@@ -422,6 +514,10 @@ export type CreateConnectionRequest = Message<"toshi.workspace.v1.CreateConnecti
422
514
  */
423
515
  name: string;
424
516
  /**
517
+ * The project and environment the connection's events belong to. Both
518
+ * are required for WEBHOOK. For MAIL they are optional, and when set must
519
+ * be the service's.
520
+ *
425
521
  * @generated from field: string project = 3;
426
522
  */
427
523
  project: string;
@@ -433,13 +529,22 @@ export type CreateConnectionRequest = Message<"toshi.workspace.v1.CreateConnecti
433
529
  * @generated from field: string request_key = 5;
434
530
  */
435
531
  requestKey: string;
532
+ /**
533
+ * The mail address and where its mail goes, for a MAIL connection; unset
534
+ * for WEBHOOK. service and channel are required; address and provider are
535
+ * output only, and ignored on input.
536
+ *
537
+ * @generated from field: toshi.workspace.v1.MailConnection mail = 6;
538
+ */
539
+ mail?: MailConnection | undefined;
436
540
  };
437
541
  /**
438
542
  * @generated from message toshi.workspace.v1.CreateConnectionRequest
439
543
  */
440
544
  export type CreateConnectionRequestJson = {
441
545
  /**
442
- * WEBHOOK; no other kind is created here.
546
+ * The kind to create: WEBHOOK or MAIL. Installing the GitHub App creates
547
+ * a GITHUB connection.
443
548
  *
444
549
  * @generated from field: toshi.workspace.v1.ConnectionKind kind = 1;
445
550
  */
@@ -451,6 +556,10 @@ export type CreateConnectionRequestJson = {
451
556
  */
452
557
  name?: string;
453
558
  /**
559
+ * The project and environment the connection's events belong to. Both
560
+ * are required for WEBHOOK. For MAIL they are optional, and when set must
561
+ * be the service's.
562
+ *
454
563
  * @generated from field: string project = 3;
455
564
  */
456
565
  project?: string;
@@ -462,6 +571,14 @@ export type CreateConnectionRequestJson = {
462
571
  * @generated from field: string request_key = 5;
463
572
  */
464
573
  requestKey?: string;
574
+ /**
575
+ * The mail address and where its mail goes, for a MAIL connection; unset
576
+ * for WEBHOOK. service and channel are required; address and provider are
577
+ * output only, and ignored on input.
578
+ *
579
+ * @generated from field: toshi.workspace.v1.MailConnection mail = 6;
580
+ */
581
+ mail?: MailConnectionJson;
465
582
  };
466
583
  /**
467
584
  * Describes the message toshi.workspace.v1.CreateConnectionRequest.
@@ -480,7 +597,8 @@ export type CreateConnectionResponse = Message<"toshi.workspace.v1.CreateConnect
480
597
  connection?: Connection | undefined;
481
598
  /**
482
599
  * The signing secret in its whsec_ form, for the sender to sign its
483
- * requests with. Shown only in this answer and an identical retry's.
600
+ * requests with; empty for a MAIL connection. Shown only in this answer
601
+ * and an identical retry's.
484
602
  *
485
603
  * @generated from field: string secret = 2;
486
604
  */
@@ -496,7 +614,8 @@ export type CreateConnectionResponseJson = {
496
614
  connection?: ConnectionJson;
497
615
  /**
498
616
  * The signing secret in its whsec_ form, for the sender to sign its
499
- * requests with. Shown only in this answer and an identical retry's.
617
+ * requests with; empty for a MAIL connection. Shown only in this answer
618
+ * and an identical retry's.
500
619
  *
501
620
  * @generated from field: string secret = 2;
502
621
  */
@@ -1266,14 +1385,22 @@ export declare enum ConnectionKind {
1266
1385
  *
1267
1386
  * @generated from enum value: CONNECTION_KIND_WEBHOOK = 2;
1268
1387
  */
1269
- WEBHOOK = 2
1388
+ WEBHOOK = 2,
1389
+ /**
1390
+ * An inbound mail address. The deployment's mail provider receives the
1391
+ * messages; each is stored as a receipt before it goes to a service's
1392
+ * event channel.
1393
+ *
1394
+ * @generated from enum value: CONNECTION_KIND_MAIL = 3;
1395
+ */
1396
+ MAIL = 3
1270
1397
  }
1271
1398
  /**
1272
1399
  * ConnectionKind is the kind of source a connection receives events from.
1273
1400
  *
1274
1401
  * @generated from enum toshi.workspace.v1.ConnectionKind
1275
1402
  */
1276
- export type ConnectionKindJson = "CONNECTION_KIND_UNSPECIFIED" | "CONNECTION_KIND_GITHUB" | "CONNECTION_KIND_WEBHOOK";
1403
+ export type ConnectionKindJson = "CONNECTION_KIND_UNSPECIFIED" | "CONNECTION_KIND_GITHUB" | "CONNECTION_KIND_WEBHOOK" | "CONNECTION_KIND_MAIL";
1277
1404
  /**
1278
1405
  * Describes the enum toshi.workspace.v1.ConnectionKind.
1279
1406
  */
@@ -1330,7 +1457,10 @@ export declare const ConnectionDeliveryStateSchema: GenEnum<ConnectionDeliverySt
1330
1457
  * GITHUB, which installing the App creates and removing it deletes; the
1331
1458
  * calls here list it and cannot create or delete it. A WEBHOOK connection
1332
1459
  * receives events from a sender that signs its requests as Standard
1333
- * Webhooks does, with a secret the connection keeps.
1460
+ * Webhooks does, with a secret the connection keeps. A MAIL connection
1461
+ * receives mail at an address the deployment's inbound mail provider
1462
+ * serves; each message is stored as a receipt before it goes to a
1463
+ * service's event channel.
1334
1464
  *
1335
1465
  * The caller's credential names the workspace, as for WorkloadService.
1336
1466
  * CreateConnection and RotateConnectionSecret require a request_key, which
@@ -1367,11 +1497,15 @@ export declare const ConnectionService: GenService<{
1367
1497
  output: typeof GetConnectionResponseSchema;
1368
1498
  };
1369
1499
  /**
1370
- * CreateConnection creates a WEBHOOK connection whose events belong to a
1371
- * project's environment, and returns it with its signing secret. A kind
1372
- * other than WEBHOOK fails with INVALID_ARGUMENT, a name a live
1373
- * connection of the workspace has with ALREADY_EXISTS, and an
1374
- * environment the project does not have with NOT_FOUND.
1500
+ * CreateConnection creates a WEBHOOK or MAIL connection. A WEBHOOK
1501
+ * connection's events belong to a project's environment, and the call
1502
+ * returns it with its signing secret. A MAIL connection receives mail at
1503
+ * an address the deployment's inbound mail provider serves and sends each
1504
+ * message to a service's event channel; it has no secret. A kind other
1505
+ * than WEBHOOK or MAIL fails with INVALID_ARGUMENT, as does a missing
1506
+ * required field, a name a live connection of the workspace has with
1507
+ * ALREADY_EXISTS, and an environment the project does not have with
1508
+ * NOT_FOUND.
1375
1509
  *
1376
1510
  * @generated from rpc toshi.workspace.v1.ConnectionService.CreateConnection
1377
1511
  */
@@ -1381,11 +1515,12 @@ export declare const ConnectionService: GenService<{
1381
1515
  output: typeof CreateConnectionResponseSchema;
1382
1516
  };
1383
1517
  /**
1384
- * DeleteConnection deletes a WEBHOOK connection: its events are no longer
1385
- * received. A GITHUB connection fails with FAILED_PRECONDITION, as only
1386
- * removing the GitHub App deletes it, as does one that live triggers match
1387
- * events from, naming them as project/name, and one the workspace does
1388
- * not have with NOT_FOUND.
1518
+ * DeleteConnection deletes a WEBHOOK or MAIL connection: its events are no
1519
+ * longer received, and a mail connection's address takes no more mail. A
1520
+ * GITHUB connection fails with FAILED_PRECONDITION, as only removing the
1521
+ * GitHub App deletes it, as does one that live triggers match events from,
1522
+ * naming them as project/name, and one the workspace does not have with
1523
+ * NOT_FOUND.
1389
1524
  *
1390
1525
  * @generated from rpc toshi.workspace.v1.ConnectionService.DeleteConnection
1391
1526
  */