@scaleway/sdk-qaas 1.1.1

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.
@@ -0,0 +1,510 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const sdkClient = require("@scaleway/sdk-client");
4
+ const content_gen = require("./content.gen.cjs");
5
+ const marshalling_gen = require("./marshalling.gen.cjs");
6
+ const jsonContentHeaders = {
7
+ "Content-Type": "application/json; charset=utf-8"
8
+ };
9
+ class API extends sdkClient.API {
10
+ /**
11
+ * Get job information. Retrieve information about the provided **job ID**, such as status, payload, and result.
12
+ *
13
+ * @param request - The request {@link GetJobRequest}
14
+ * @returns A Promise of Job
15
+ */
16
+ getJob = (request) => this.client.fetch(
17
+ {
18
+ method: "GET",
19
+ path: `/qaas/v1alpha1/jobs/${sdkClient.validatePathParam("jobId", request.jobId)}`
20
+ },
21
+ marshalling_gen.unmarshalJob
22
+ );
23
+ /**
24
+ * Waits for {@link Job} to be in a final state.
25
+ *
26
+ * @param request - The request {@link GetJobRequest}
27
+ * @param options - The waiting options
28
+ * @returns A Promise of Job
29
+ */
30
+ waitForJob = (request, options) => sdkClient.waitForResource(
31
+ options?.stop ?? ((res) => Promise.resolve(!content_gen.JOB_TRANSIENT_STATUSES.includes(res.status))),
32
+ this.getJob,
33
+ request,
34
+ options
35
+ );
36
+ pageOfListJobs = (request = {}) => this.client.fetch(
37
+ {
38
+ method: "GET",
39
+ path: `/qaas/v1alpha1/jobs`,
40
+ urlParams: sdkClient.urlParams(
41
+ ["order_by", request.orderBy],
42
+ ["page", request.page],
43
+ [
44
+ "page_size",
45
+ request.pageSize ?? this.client.settings.defaultPageSize
46
+ ],
47
+ ["tags", request.tags],
48
+ ...Object.entries(
49
+ sdkClient.resolveOneOf([
50
+ { param: "session_id", value: request.sessionId },
51
+ {
52
+ default: this.client.settings.defaultProjectId,
53
+ param: "project_id",
54
+ value: request.projectId
55
+ }
56
+ ])
57
+ )
58
+ )
59
+ },
60
+ marshalling_gen.unmarshalListJobsResponse
61
+ );
62
+ /**
63
+ * List all jobs within a project or session. Retrieve information about all jobs within a given project or session.
64
+ *
65
+ * @param request - The request {@link ListJobsRequest}
66
+ * @returns A Promise of ListJobsResponse
67
+ */
68
+ listJobs = (request = {}) => sdkClient.enrichForPagination("jobs", this.pageOfListJobs, request);
69
+ pageOfListJobResults = (request) => this.client.fetch(
70
+ {
71
+ method: "GET",
72
+ path: `/qaas/v1alpha1/jobs/${sdkClient.validatePathParam("jobId", request.jobId)}/results`,
73
+ urlParams: sdkClient.urlParams(
74
+ ["order_by", request.orderBy],
75
+ ["page", request.page],
76
+ [
77
+ "page_size",
78
+ request.pageSize ?? this.client.settings.defaultPageSize
79
+ ]
80
+ )
81
+ },
82
+ marshalling_gen.unmarshalListJobResultsResponse
83
+ );
84
+ /**
85
+ * List all results of a job. Retrieve all intermediate and final results of a job.
86
+ *
87
+ * @param request - The request {@link ListJobResultsRequest}
88
+ * @returns A Promise of ListJobResultsResponse
89
+ */
90
+ listJobResults = (request) => sdkClient.enrichForPagination("jobResults", this.pageOfListJobResults, request);
91
+ /**
92
+ * Create a job. Create a job to be executed inside a session.
93
+ *
94
+ * @param request - The request {@link CreateJobRequest}
95
+ * @returns A Promise of Job
96
+ */
97
+ createJob = (request) => this.client.fetch(
98
+ {
99
+ body: JSON.stringify(
100
+ marshalling_gen.marshalCreateJobRequest(request, this.client.settings)
101
+ ),
102
+ headers: jsonContentHeaders,
103
+ method: "POST",
104
+ path: `/qaas/v1alpha1/jobs`
105
+ },
106
+ marshalling_gen.unmarshalJob
107
+ );
108
+ /**
109
+ * Update job information. Update job information about the provided **job ID**.
110
+ *
111
+ * @param request - The request {@link UpdateJobRequest}
112
+ * @returns A Promise of Job
113
+ */
114
+ updateJob = (request) => this.client.fetch(
115
+ {
116
+ body: JSON.stringify(
117
+ marshalling_gen.marshalUpdateJobRequest(request, this.client.settings)
118
+ ),
119
+ headers: jsonContentHeaders,
120
+ method: "PATCH",
121
+ path: `/qaas/v1alpha1/jobs/${sdkClient.validatePathParam("jobId", request.jobId)}`
122
+ },
123
+ marshalling_gen.unmarshalJob
124
+ );
125
+ /**
126
+ * Cancel a job. Cancel the job corresponding to the provided **job ID**.
127
+ *
128
+ * @param request - The request {@link CancelJobRequest}
129
+ * @returns A Promise of Job
130
+ */
131
+ cancelJob = (request) => this.client.fetch(
132
+ {
133
+ body: "{}",
134
+ headers: jsonContentHeaders,
135
+ method: "POST",
136
+ path: `/qaas/v1alpha1/jobs/${sdkClient.validatePathParam("jobId", request.jobId)}/cancel`
137
+ },
138
+ marshalling_gen.unmarshalJob
139
+ );
140
+ /**
141
+ * Delete a job. Delete the job corresponding to the provided **job ID**.
142
+ *
143
+ * @param request - The request {@link DeleteJobRequest}
144
+ */
145
+ deleteJob = (request) => this.client.fetch({
146
+ method: "DELETE",
147
+ path: `/qaas/v1alpha1/jobs/${sdkClient.validatePathParam("jobId", request.jobId)}`
148
+ });
149
+ /**
150
+ * Get a job circuit. Retrieve the circuit of the provided **job ID**.
151
+ *
152
+ * @param request - The request {@link GetJobCircuitRequest}
153
+ * @returns A Promise of JobCircuit
154
+ */
155
+ getJobCircuit = (request) => this.client.fetch(
156
+ {
157
+ method: "GET",
158
+ path: `/qaas/v1alpha1/jobs/${sdkClient.validatePathParam("jobId", request.jobId)}/circuit`
159
+ },
160
+ marshalling_gen.unmarshalJobCircuit
161
+ );
162
+ /**
163
+ * Get platform information. Retrieve information about the provided **platform ID**, such as provider name, technology, and type.
164
+ *
165
+ * @param request - The request {@link GetPlatformRequest}
166
+ * @returns A Promise of Platform
167
+ */
168
+ getPlatform = (request) => this.client.fetch(
169
+ {
170
+ method: "GET",
171
+ path: `/qaas/v1alpha1/platforms/${sdkClient.validatePathParam("platformId", request.platformId)}`
172
+ },
173
+ marshalling_gen.unmarshalPlatform
174
+ );
175
+ pageOfListPlatforms = (request = {}) => this.client.fetch(
176
+ {
177
+ method: "GET",
178
+ path: `/qaas/v1alpha1/platforms`,
179
+ urlParams: sdkClient.urlParams(
180
+ ["backend_name", request.backendName],
181
+ ["name", request.name],
182
+ ["order_by", request.orderBy],
183
+ ["page", request.page],
184
+ [
185
+ "page_size",
186
+ request.pageSize ?? this.client.settings.defaultPageSize
187
+ ],
188
+ ["platform_technology", request.platformTechnology],
189
+ ["platform_type", request.platformType],
190
+ ["provider_name", request.providerName]
191
+ )
192
+ },
193
+ marshalling_gen.unmarshalListPlatformsResponse
194
+ );
195
+ /**
196
+ * List all available platforms. Retrieve information about all platforms.
197
+ *
198
+ * @param request - The request {@link ListPlatformsRequest}
199
+ * @returns A Promise of ListPlatformsResponse
200
+ */
201
+ listPlatforms = (request = {}) => sdkClient.enrichForPagination("platforms", this.pageOfListPlatforms, request);
202
+ /**
203
+ * Get session infrormation. Retrieve information about the provided **session ID**, such as name, status, and number of executed jobs.
204
+ *
205
+ * @param request - The request {@link GetSessionRequest}
206
+ * @returns A Promise of Session
207
+ */
208
+ getSession = (request) => this.client.fetch(
209
+ {
210
+ method: "GET",
211
+ path: `/qaas/v1alpha1/sessions/${sdkClient.validatePathParam("sessionId", request.sessionId)}`
212
+ },
213
+ marshalling_gen.unmarshalSession
214
+ );
215
+ /**
216
+ * Waits for {@link Session} to be in a final state.
217
+ *
218
+ * @param request - The request {@link GetSessionRequest}
219
+ * @param options - The waiting options
220
+ * @returns A Promise of Session
221
+ */
222
+ waitForSession = (request, options) => sdkClient.waitForResource(
223
+ options?.stop ?? ((res) => Promise.resolve(
224
+ !content_gen.SESSION_TRANSIENT_STATUSES.includes(res.status)
225
+ )),
226
+ this.getSession,
227
+ request,
228
+ options
229
+ );
230
+ pageOfListSessions = (request = {}) => this.client.fetch(
231
+ {
232
+ method: "GET",
233
+ path: `/qaas/v1alpha1/sessions`,
234
+ urlParams: sdkClient.urlParams(
235
+ ["order_by", request.orderBy],
236
+ ["page", request.page],
237
+ [
238
+ "page_size",
239
+ request.pageSize ?? this.client.settings.defaultPageSize
240
+ ],
241
+ ["platform_id", request.platformId],
242
+ [
243
+ "project_id",
244
+ request.projectId ?? this.client.settings.defaultProjectId
245
+ ],
246
+ ["tags", request.tags]
247
+ )
248
+ },
249
+ marshalling_gen.unmarshalListSessionsResponse
250
+ );
251
+ /**
252
+ * List all sessions. Retrieve information about all sessions.
253
+ *
254
+ * @param request - The request {@link ListSessionsRequest}
255
+ * @returns A Promise of ListSessionsResponse
256
+ */
257
+ listSessions = (request = {}) => sdkClient.enrichForPagination("sessions", this.pageOfListSessions, request);
258
+ /**
259
+ * Create a session. Create a dedicated session for the specified platform.
260
+ *
261
+ * @param request - The request {@link CreateSessionRequest}
262
+ * @returns A Promise of Session
263
+ */
264
+ createSession = (request) => this.client.fetch(
265
+ {
266
+ body: JSON.stringify(
267
+ marshalling_gen.marshalCreateSessionRequest(request, this.client.settings)
268
+ ),
269
+ headers: jsonContentHeaders,
270
+ method: "POST",
271
+ path: `/qaas/v1alpha1/sessions`
272
+ },
273
+ marshalling_gen.unmarshalSession
274
+ );
275
+ /**
276
+ * Update session information. Update session information of the provided **session ID**.
277
+ *
278
+ * @param request - The request {@link UpdateSessionRequest}
279
+ * @returns A Promise of Session
280
+ */
281
+ updateSession = (request) => this.client.fetch(
282
+ {
283
+ body: JSON.stringify(
284
+ marshalling_gen.marshalUpdateSessionRequest(request, this.client.settings)
285
+ ),
286
+ headers: jsonContentHeaders,
287
+ method: "PATCH",
288
+ path: `/qaas/v1alpha1/sessions/${sdkClient.validatePathParam("sessionId", request.sessionId)}`
289
+ },
290
+ marshalling_gen.unmarshalSession
291
+ );
292
+ /**
293
+ * Terminate an existing session. Terminate a session by its unique ID and cancel all its attached jobs.
294
+ *
295
+ * @param request - The request {@link TerminateSessionRequest}
296
+ * @returns A Promise of Session
297
+ */
298
+ terminateSession = (request) => this.client.fetch(
299
+ {
300
+ body: "{}",
301
+ headers: jsonContentHeaders,
302
+ method: "POST",
303
+ path: `/qaas/v1alpha1/sessions/${sdkClient.validatePathParam("sessionId", request.sessionId)}/terminate`
304
+ },
305
+ marshalling_gen.unmarshalSession
306
+ );
307
+ /**
308
+ * Delete an existing session. Delete a session by its unique ID and delete all its attached jobs.
309
+ *
310
+ * @param request - The request {@link DeleteSessionRequest}
311
+ */
312
+ deleteSession = (request) => this.client.fetch({
313
+ method: "DELETE",
314
+ path: `/qaas/v1alpha1/sessions/${sdkClient.validatePathParam("sessionId", request.sessionId)}`
315
+ });
316
+ pageOfListSessionACLs = (request) => this.client.fetch(
317
+ {
318
+ method: "GET",
319
+ path: `/qaas/v1alpha1/sessions/${sdkClient.validatePathParam("sessionId", request.sessionId)}/acls`,
320
+ urlParams: sdkClient.urlParams(
321
+ ["order_by", request.orderBy],
322
+ ["page", request.page],
323
+ [
324
+ "page_size",
325
+ request.pageSize ?? this.client.settings.defaultPageSize
326
+ ]
327
+ )
328
+ },
329
+ marshalling_gen.unmarshalListSessionACLsResponse
330
+ );
331
+ listSessionACLs = (request) => sdkClient.enrichForPagination("acls", this.pageOfListSessionACLs, request);
332
+ /**
333
+ * Create a process. Create a new process for the specified application on a specified platform.
334
+ *
335
+ * @param request - The request {@link CreateProcessRequest}
336
+ * @returns A Promise of Process
337
+ */
338
+ createProcess = (request) => this.client.fetch(
339
+ {
340
+ body: JSON.stringify(
341
+ marshalling_gen.marshalCreateProcessRequest(request, this.client.settings)
342
+ ),
343
+ headers: jsonContentHeaders,
344
+ method: "POST",
345
+ path: `/qaas/v1alpha1/processes`
346
+ },
347
+ marshalling_gen.unmarshalProcess
348
+ );
349
+ /**
350
+ * Get process infrormation. Retrieve information about the provided **process ID**, such as name, status and progress.
351
+ *
352
+ * @param request - The request {@link GetProcessRequest}
353
+ * @returns A Promise of Process
354
+ */
355
+ getProcess = (request) => this.client.fetch(
356
+ {
357
+ method: "GET",
358
+ path: `/qaas/v1alpha1/processes/${sdkClient.validatePathParam("processId", request.processId)}`
359
+ },
360
+ marshalling_gen.unmarshalProcess
361
+ );
362
+ /**
363
+ * Waits for {@link Process} to be in a final state.
364
+ *
365
+ * @param request - The request {@link GetProcessRequest}
366
+ * @param options - The waiting options
367
+ * @returns A Promise of Process
368
+ */
369
+ waitForProcess = (request, options) => sdkClient.waitForResource(
370
+ options?.stop ?? ((res) => Promise.resolve(
371
+ !content_gen.PROCESS_TRANSIENT_STATUSES.includes(res.status)
372
+ )),
373
+ this.getProcess,
374
+ request,
375
+ options
376
+ );
377
+ pageOfListProcesses = (request = {}) => this.client.fetch(
378
+ {
379
+ method: "GET",
380
+ path: `/qaas/v1alpha1/processes`,
381
+ urlParams: sdkClient.urlParams(
382
+ ["application_id", request.applicationId],
383
+ ["order_by", request.orderBy],
384
+ ["page", request.page],
385
+ [
386
+ "page_size",
387
+ request.pageSize ?? this.client.settings.defaultPageSize
388
+ ],
389
+ [
390
+ "project_id",
391
+ request.projectId ?? this.client.settings.defaultProjectId
392
+ ],
393
+ ["tags", request.tags]
394
+ )
395
+ },
396
+ marshalling_gen.unmarshalListProcessesResponse
397
+ );
398
+ /**
399
+ * List all processes. Retrieve information about all processes.
400
+ *
401
+ * @param request - The request {@link ListProcessesRequest}
402
+ * @returns A Promise of ListProcessesResponse
403
+ */
404
+ listProcesses = (request = {}) => sdkClient.enrichForPagination("processes", this.pageOfListProcesses, request);
405
+ /**
406
+ * Update process information. Update process information of the provided **process ID**.
407
+ *
408
+ * @param request - The request {@link UpdateProcessRequest}
409
+ * @returns A Promise of Process
410
+ */
411
+ updateProcess = (request) => this.client.fetch(
412
+ {
413
+ body: JSON.stringify(
414
+ marshalling_gen.marshalUpdateProcessRequest(request, this.client.settings)
415
+ ),
416
+ headers: jsonContentHeaders,
417
+ method: "PATCH",
418
+ path: `/qaas/v1alpha1/processes/${sdkClient.validatePathParam("processId", request.processId)}`
419
+ },
420
+ marshalling_gen.unmarshalProcess
421
+ );
422
+ /**
423
+ * Cancel a running process. Cancel a process by its unique ID. Intermediate results are still available.
424
+ *
425
+ * @param request - The request {@link CancelProcessRequest}
426
+ * @returns A Promise of Process
427
+ */
428
+ cancelProcess = (request) => this.client.fetch(
429
+ {
430
+ body: "{}",
431
+ headers: jsonContentHeaders,
432
+ method: "POST",
433
+ path: `/qaas/v1alpha1/processes/${sdkClient.validatePathParam("processId", request.processId)}/cancel`
434
+ },
435
+ marshalling_gen.unmarshalProcess
436
+ );
437
+ /**
438
+ * Delete an existing process. Delete a process by its unique ID and delete all its data.
439
+ *
440
+ * @param request - The request {@link DeleteProcessRequest}
441
+ */
442
+ deleteProcess = (request) => this.client.fetch({
443
+ method: "DELETE",
444
+ path: `/qaas/v1alpha1/processes/${sdkClient.validatePathParam("processId", request.processId)}`
445
+ });
446
+ pageOfListProcessResults = (request) => this.client.fetch(
447
+ {
448
+ method: "GET",
449
+ path: `/qaas/v1alpha1/processes/${sdkClient.validatePathParam("processId", request.processId)}/results`,
450
+ urlParams: sdkClient.urlParams(
451
+ ["order_by", request.orderBy],
452
+ ["page", request.page],
453
+ [
454
+ "page_size",
455
+ request.pageSize ?? this.client.settings.defaultPageSize
456
+ ]
457
+ )
458
+ },
459
+ marshalling_gen.unmarshalListProcessResultsResponse
460
+ );
461
+ /**
462
+ * List all results of a process. Retrieve all intermediate and final result of a process.
463
+ *
464
+ * @param request - The request {@link ListProcessResultsRequest}
465
+ * @returns A Promise of ListProcessResultsResponse
466
+ */
467
+ listProcessResults = (request) => sdkClient.enrichForPagination(
468
+ "processResults",
469
+ this.pageOfListProcessResults,
470
+ request
471
+ );
472
+ /**
473
+ * Get application information. Retrieve information about the provided **applcation ID**, such as name, type and compatible platforms.
474
+ *
475
+ * @param request - The request {@link GetApplicationRequest}
476
+ * @returns A Promise of Application
477
+ */
478
+ getApplication = (request) => this.client.fetch(
479
+ {
480
+ method: "GET",
481
+ path: `/qaas/v1alpha1/applications/${sdkClient.validatePathParam("applicationId", request.applicationId)}`
482
+ },
483
+ marshalling_gen.unmarshalApplication
484
+ );
485
+ pageOfListApplications = (request = {}) => this.client.fetch(
486
+ {
487
+ method: "GET",
488
+ path: `/qaas/v1alpha1/applications`,
489
+ urlParams: sdkClient.urlParams(
490
+ ["application_type", request.applicationType],
491
+ ["name", request.name],
492
+ ["order_by", request.orderBy],
493
+ ["page", request.page],
494
+ [
495
+ "page_size",
496
+ request.pageSize ?? this.client.settings.defaultPageSize
497
+ ]
498
+ )
499
+ },
500
+ marshalling_gen.unmarshalListApplicationsResponse
501
+ );
502
+ /**
503
+ * List all available applications. Retrieve information about all applications.
504
+ *
505
+ * @param request - The request {@link ListApplicationsRequest}
506
+ * @returns A Promise of ListApplicationsResponse
507
+ */
508
+ listApplications = (request = {}) => sdkClient.enrichForPagination("applications", this.pageOfListApplications, request);
509
+ }
510
+ exports.API = API;