@scaleway/sdk-jobs 2.2.0 → 2.2.2

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,484 @@
1
+ import type { Region as ScwRegion } from '@scaleway/sdk-client';
2
+ export type JobRunReason = 'unknown_reason' | 'invalid_request' | 'timeout' | 'cancellation' | 'technical_error' | 'image_not_found' | 'invalid_image' | 'memory_usage_exceeded' | 'storage_usage_exceeded' | 'exited_with_error' | 'secret_disabled' | 'secret_not_found' | 'quota_exceeded';
3
+ export type JobRunState = 'unknown_state' | 'initialized' | 'validated' | 'queued' | 'running' | 'succeeded' | 'failed' | 'interrupting' | 'interrupted' | 'retrying';
4
+ export type ListJobDefinitionsRequestOrderBy = 'created_at_asc' | 'created_at_desc';
5
+ export type ListJobRunsRequestOrderBy = 'created_at_asc' | 'created_at_desc';
6
+ export interface SecretEnvVar {
7
+ name: string;
8
+ }
9
+ export interface SecretFile {
10
+ path: string;
11
+ }
12
+ export interface CronSchedule {
13
+ /**
14
+ * UNIX cron schedule to run job (e.g., '* * * * *').
15
+ */
16
+ schedule: string;
17
+ /**
18
+ * Timezone for the cron schedule, in tz database format (e.g., 'Europe/Paris').
19
+ */
20
+ timezone: string;
21
+ }
22
+ export interface RetryPolicy {
23
+ /**
24
+ * Maximum number of retries upon a job failure.
25
+ */
26
+ maxRetries: number;
27
+ }
28
+ export interface CreateJobDefinitionRequestCronScheduleConfig {
29
+ schedule: string;
30
+ timezone: string;
31
+ }
32
+ export interface CreateSecretsRequestSecretConfig {
33
+ secretManagerId: string;
34
+ secretManagerVersion: string;
35
+ /**
36
+ *
37
+ * One-of ('pathOrEnvVar'): at most one of 'path', 'envVarName' could be set.
38
+ */
39
+ path?: string;
40
+ /**
41
+ *
42
+ * One-of ('pathOrEnvVar'): at most one of 'path', 'envVarName' could be set.
43
+ */
44
+ envVarName?: string;
45
+ }
46
+ export interface Secret {
47
+ /**
48
+ * UUID of the secret reference within the job.
49
+ */
50
+ secretId: string;
51
+ /**
52
+ * UUID of the secret in Secret Manager.
53
+ */
54
+ secretManagerId: string;
55
+ /**
56
+ * Version of the secret in Secret Manager.
57
+ */
58
+ secretManagerVersion: string;
59
+ /**
60
+ * UUID of the job definition.
61
+ */
62
+ jobDefinitionId: string;
63
+ /**
64
+ * File secret mounted inside the job.
65
+ *
66
+ * One-of ('secretConfig'): at most one of 'file', 'envVar' could be set.
67
+ */
68
+ file?: SecretFile;
69
+ /**
70
+ * Environment variable used to expose the secret.
71
+ *
72
+ * One-of ('secretConfig'): at most one of 'file', 'envVar' could be set.
73
+ */
74
+ envVar?: SecretEnvVar;
75
+ }
76
+ export interface JobDefinition {
77
+ id: string;
78
+ name: string;
79
+ projectId: string;
80
+ createdAt?: Date;
81
+ updatedAt?: Date;
82
+ cpuLimit: number;
83
+ memoryLimit: number;
84
+ localStorageCapacity: number;
85
+ imageUri: string;
86
+ /**
87
+ * @deprecated
88
+ */
89
+ command?: string;
90
+ environmentVariables: Record<string, string>;
91
+ jobTimeout?: string;
92
+ description: string;
93
+ cronSchedule?: CronSchedule;
94
+ startupCommand: string[];
95
+ args: string[];
96
+ retryPolicy?: RetryPolicy;
97
+ /**
98
+ * Region to target. If none is passed will use default region from the config.
99
+ */
100
+ region: ScwRegion;
101
+ }
102
+ export interface Resource {
103
+ computeLimitMvcpu: number;
104
+ memoryLimitBytes: number;
105
+ }
106
+ export interface JobRun {
107
+ id: string;
108
+ jobDefinitionId: string;
109
+ createdAt?: Date;
110
+ updatedAt?: Date;
111
+ startedAt?: Date;
112
+ terminatedAt?: Date;
113
+ runDuration?: string;
114
+ state: JobRunState;
115
+ reason?: JobRunReason;
116
+ exitCode?: number;
117
+ errorMessage?: string;
118
+ cpuLimit: number;
119
+ memoryLimit: number;
120
+ localStorageCapacity: number;
121
+ /**
122
+ * @deprecated
123
+ */
124
+ command?: string;
125
+ environmentVariables: Record<string, string>;
126
+ startupCommand: string[];
127
+ args: string[];
128
+ attempts?: number;
129
+ /**
130
+ * Region to target. If none is passed will use default region from the config.
131
+ */
132
+ region: ScwRegion;
133
+ }
134
+ export interface UpdateJobDefinitionRequestCronScheduleConfig {
135
+ schedule?: string;
136
+ timezone?: string;
137
+ }
138
+ export type CreateJobDefinitionRequest = {
139
+ /**
140
+ * Region to target. If none is passed will use default region from the config.
141
+ */
142
+ region?: ScwRegion;
143
+ /**
144
+ * Name of the job definition.
145
+ */
146
+ name?: string;
147
+ /**
148
+ * CPU limit of the job (in mvCPU).
149
+ */
150
+ cpuLimit: number;
151
+ /**
152
+ * Memory limit of the job (in MiB).
153
+ */
154
+ memoryLimit: number;
155
+ /**
156
+ * Local storage capacity of the job (in MiB).
157
+ */
158
+ localStorageCapacity: number;
159
+ /**
160
+ * Image to use for the job.
161
+ */
162
+ imageUri: string;
163
+ /**
164
+ * @deprecated Deprecated: please use startup_command instead.
165
+ */
166
+ command?: string;
167
+ /**
168
+ * The main executable or entrypoint script to run.
169
+ If both command and startup_command are provided, only startup_command will be used.
170
+ */
171
+ startupCommand?: string[];
172
+ /**
173
+ * Passed to the startup command at runtime.
174
+ Environment variables and secrets can be included, and will be expanded before the arguments are used.
175
+ */
176
+ args?: string[];
177
+ /**
178
+ * UUID of the Scaleway Project containing the job.
179
+ */
180
+ projectId?: string;
181
+ /**
182
+ * Environment variables of the job.
183
+ */
184
+ environmentVariables?: Record<string, string>;
185
+ /**
186
+ * Description of the job.
187
+ */
188
+ description: string;
189
+ /**
190
+ * Timeout of the job in seconds.
191
+ */
192
+ jobTimeout?: string;
193
+ /**
194
+ * Configure a cron for the job.
195
+ */
196
+ cronSchedule?: CreateJobDefinitionRequestCronScheduleConfig;
197
+ /**
198
+ * Retry behaviour in case of job failure.
199
+ */
200
+ retryPolicy?: RetryPolicy;
201
+ };
202
+ export type CreateSecretsRequest = {
203
+ /**
204
+ * Region to target. If none is passed will use default region from the config.
205
+ */
206
+ region?: ScwRegion;
207
+ /**
208
+ * UUID of the job definition.
209
+ */
210
+ jobDefinitionId: string;
211
+ /**
212
+ * List of secrets to inject into the job.
213
+ */
214
+ secrets: CreateSecretsRequestSecretConfig[];
215
+ };
216
+ export interface CreateSecretsResponse {
217
+ /**
218
+ * List of secrets created.
219
+ */
220
+ secrets: Secret[];
221
+ }
222
+ export type DeleteJobDefinitionRequest = {
223
+ /**
224
+ * Region to target. If none is passed will use default region from the config.
225
+ */
226
+ region?: ScwRegion;
227
+ /**
228
+ * UUID of the job definition to delete.
229
+ */
230
+ jobDefinitionId: string;
231
+ };
232
+ export type DeleteSecretRequest = {
233
+ /**
234
+ * Region to target. If none is passed will use default region from the config.
235
+ */
236
+ region?: ScwRegion;
237
+ /**
238
+ * UUID of the secret reference within the job.
239
+ */
240
+ secretId: string;
241
+ };
242
+ export type GetJobDefinitionRequest = {
243
+ /**
244
+ * Region to target. If none is passed will use default region from the config.
245
+ */
246
+ region?: ScwRegion;
247
+ /**
248
+ * UUID of the job definition to get.
249
+ */
250
+ jobDefinitionId: string;
251
+ };
252
+ export type GetJobLimitsRequest = {
253
+ /**
254
+ * Region to target. If none is passed will use default region from the config.
255
+ */
256
+ region?: ScwRegion;
257
+ };
258
+ export type GetJobRunRequest = {
259
+ /**
260
+ * Region to target. If none is passed will use default region from the config.
261
+ */
262
+ region?: ScwRegion;
263
+ /**
264
+ * UUID of the job run to get.
265
+ */
266
+ jobRunId: string;
267
+ };
268
+ export type GetSecretRequest = {
269
+ /**
270
+ * Region to target. If none is passed will use default region from the config.
271
+ */
272
+ region?: ScwRegion;
273
+ /**
274
+ * UUID of the secret reference within the job.
275
+ */
276
+ secretId: string;
277
+ };
278
+ export interface JobLimits {
279
+ secretsPerJobDefinition: number;
280
+ }
281
+ export type ListJobDefinitionsRequest = {
282
+ /**
283
+ * Region to target. If none is passed will use default region from the config.
284
+ */
285
+ region?: ScwRegion;
286
+ page?: number;
287
+ pageSize?: number;
288
+ orderBy?: ListJobDefinitionsRequestOrderBy;
289
+ projectId?: string;
290
+ organizationId?: string;
291
+ };
292
+ export interface ListJobDefinitionsResponse {
293
+ jobDefinitions: JobDefinition[];
294
+ totalCount: number;
295
+ }
296
+ export type ListJobResourcesRequest = {
297
+ /**
298
+ * Region to target. If none is passed will use default region from the config.
299
+ */
300
+ region?: ScwRegion;
301
+ };
302
+ export interface ListJobResourcesResponse {
303
+ resources: Resource[];
304
+ }
305
+ export type ListJobRunsRequest = {
306
+ /**
307
+ * Region to target. If none is passed will use default region from the config.
308
+ */
309
+ region?: ScwRegion;
310
+ page?: number;
311
+ pageSize?: number;
312
+ orderBy?: ListJobRunsRequestOrderBy;
313
+ jobDefinitionId?: string;
314
+ projectId?: string;
315
+ organizationId?: string;
316
+ state?: JobRunState;
317
+ states?: JobRunState[];
318
+ reasons?: JobRunReason[];
319
+ };
320
+ export interface ListJobRunsResponse {
321
+ jobRuns: JobRun[];
322
+ totalCount: number;
323
+ }
324
+ export type ListSecretsRequest = {
325
+ /**
326
+ * Region to target. If none is passed will use default region from the config.
327
+ */
328
+ region?: ScwRegion;
329
+ /**
330
+ * UUID of the job definition.
331
+ */
332
+ jobDefinitionId: string;
333
+ };
334
+ export interface ListSecretsResponse {
335
+ /**
336
+ * List of secret references within a job definition.
337
+ */
338
+ secrets: Secret[];
339
+ /**
340
+ * Total count of secret references within a job definition.
341
+ */
342
+ totalCount: number;
343
+ }
344
+ export type StartJobDefinitionRequest = {
345
+ /**
346
+ * Region to target. If none is passed will use default region from the config.
347
+ */
348
+ region?: ScwRegion;
349
+ /**
350
+ * UUID of the job definition to start.
351
+ */
352
+ jobDefinitionId: string;
353
+ /**
354
+ * @deprecated If empty or not defined, the image's default command is used.
355
+ Deprecated: please use startup_command instead.
356
+ */
357
+ command?: string;
358
+ /**
359
+ * Overrides the default defined in the job image.
360
+ The main executable or entrypoint script to run.
361
+ If both command and startup_command are provided, only startup_command will be used.
362
+ */
363
+ startupCommand?: string[];
364
+ /**
365
+ * Overrides the default arguments defined in the job image.
366
+ Passed to the contextual startup command at runtime.
367
+ Environment variables and secrets can be included, and will be expanded before the arguments are used.
368
+ */
369
+ args?: string[];
370
+ /**
371
+ * Contextual environment variables for this specific job run.
372
+ */
373
+ environmentVariables?: Record<string, string>;
374
+ /**
375
+ * Number of jobs to run.
376
+ */
377
+ replicas?: number;
378
+ };
379
+ export interface StartJobDefinitionResponse {
380
+ /**
381
+ * List of started job runs.
382
+ */
383
+ jobRuns: JobRun[];
384
+ }
385
+ export type StopJobRunRequest = {
386
+ /**
387
+ * Region to target. If none is passed will use default region from the config.
388
+ */
389
+ region?: ScwRegion;
390
+ /**
391
+ * UUID of the job run to stop.
392
+ */
393
+ jobRunId: string;
394
+ };
395
+ export type UpdateJobDefinitionRequest = {
396
+ /**
397
+ * Region to target. If none is passed will use default region from the config.
398
+ */
399
+ region?: ScwRegion;
400
+ /**
401
+ * UUID of the job definition to update.
402
+ */
403
+ jobDefinitionId: string;
404
+ /**
405
+ * Name of the job definition.
406
+ */
407
+ name?: string;
408
+ /**
409
+ * CPU limit of the job (in mvCPU).
410
+ */
411
+ cpuLimit?: number;
412
+ /**
413
+ * Memory limit of the job (in MiB).
414
+ */
415
+ memoryLimit?: number;
416
+ /**
417
+ * Local storage capacity of the job (in MiB).
418
+ */
419
+ localStorageCapacity?: number;
420
+ /**
421
+ * Image to use for the job.
422
+ */
423
+ imageUri?: string;
424
+ /**
425
+ * @deprecated Deprecated: please use startup_command instead.
426
+ */
427
+ command?: string;
428
+ /**
429
+ * The main executable or entrypoint script to run.
430
+ If both command and startup_command are provided, only startup_command will be used.
431
+ */
432
+ startupCommand?: string[];
433
+ /**
434
+ * Passed to the startup command at runtime.
435
+ Environment variables and secrets can be included, and will be expanded before the arguments are used.
436
+ */
437
+ args?: string[];
438
+ /**
439
+ * Environment variables of the job.
440
+ */
441
+ environmentVariables?: Record<string, string>;
442
+ /**
443
+ * Description of the job.
444
+ */
445
+ description?: string;
446
+ /**
447
+ * Timeout of the job in seconds.
448
+ */
449
+ jobTimeout?: string;
450
+ /**
451
+ * Configure a cron for the job.
452
+ */
453
+ cronSchedule?: UpdateJobDefinitionRequestCronScheduleConfig;
454
+ /**
455
+ * Retry behaviour in case of job failure.
456
+ */
457
+ retryPolicy?: RetryPolicy;
458
+ };
459
+ export type UpdateSecretRequest = {
460
+ /**
461
+ * Region to target. If none is passed will use default region from the config.
462
+ */
463
+ region?: ScwRegion;
464
+ /**
465
+ * UUID of the secret reference within the job.
466
+ */
467
+ secretId: string;
468
+ /**
469
+ * Version of the secret in Secret Manager.
470
+ */
471
+ secretManagerVersion?: string;
472
+ /**
473
+ * Path of the secret to mount inside the job (either `path` or `env_var_name` must be set).
474
+ *
475
+ * One-of ('secretConfig'): at most one of 'path', 'envVarName' could be set.
476
+ */
477
+ path?: string;
478
+ /**
479
+ * Environment variable name used to expose the secret inside the job (either `path` or `env_var_name` must be set).
480
+ *
481
+ * One-of ('secretConfig'): at most one of 'path', 'envVarName' could be set.
482
+ */
483
+ envVarName?: string;
484
+ };
@@ -0,0 +1,108 @@
1
+ export declare const CreateJobDefinitionRequest: {
2
+ cpuLimit: {
3
+ greaterThan: number;
4
+ };
5
+ description: {
6
+ maxLength: number;
7
+ };
8
+ imageUri: {
9
+ pattern: RegExp;
10
+ };
11
+ localStorageCapacity: {
12
+ greaterThan: number;
13
+ };
14
+ memoryLimit: {
15
+ greaterThan: number;
16
+ };
17
+ name: {
18
+ pattern: RegExp;
19
+ };
20
+ };
21
+ export declare const CreateJobDefinitionRequestCronScheduleConfig: {
22
+ schedule: {
23
+ maxLength: number;
24
+ minLength: number;
25
+ };
26
+ timezone: {
27
+ maxLength: number;
28
+ minLength: number;
29
+ };
30
+ };
31
+ export declare const CreateSecretsRequestSecretConfig: {
32
+ secretManagerVersion: {
33
+ minLength: number;
34
+ };
35
+ };
36
+ export declare const CronSchedule: {
37
+ schedule: {
38
+ maxLength: number;
39
+ minLength: number;
40
+ };
41
+ timezone: {
42
+ maxLength: number;
43
+ minLength: number;
44
+ };
45
+ };
46
+ export declare const ListJobDefinitionsRequest: {
47
+ page: {
48
+ greaterThanOrEqual: number;
49
+ };
50
+ pageSize: {
51
+ greaterThanOrEqual: number;
52
+ lessThanOrEqual: number;
53
+ };
54
+ };
55
+ export declare const ListJobRunsRequest: {
56
+ page: {
57
+ greaterThanOrEqual: number;
58
+ };
59
+ pageSize: {
60
+ greaterThanOrEqual: number;
61
+ lessThanOrEqual: number;
62
+ };
63
+ };
64
+ export declare const RetryPolicy: {
65
+ maxRetries: {
66
+ lessThanOrEqual: number;
67
+ };
68
+ };
69
+ export declare const StartJobDefinitionRequest: {
70
+ replicas: {
71
+ greaterThan: number;
72
+ };
73
+ };
74
+ export declare const UpdateJobDefinitionRequest: {
75
+ cpuLimit: {
76
+ greaterThan: number;
77
+ };
78
+ description: {
79
+ maxLength: number;
80
+ };
81
+ imageUri: {
82
+ pattern: RegExp;
83
+ };
84
+ localStorageCapacity: {
85
+ greaterThan: number;
86
+ };
87
+ memoryLimit: {
88
+ greaterThan: number;
89
+ };
90
+ name: {
91
+ pattern: RegExp;
92
+ };
93
+ };
94
+ export declare const UpdateJobDefinitionRequestCronScheduleConfig: {
95
+ schedule: {
96
+ maxLength: number;
97
+ minLength: number;
98
+ };
99
+ timezone: {
100
+ maxLength: number;
101
+ minLength: number;
102
+ };
103
+ };
104
+ export declare const UpdateSecretRequest: {
105
+ secretManagerVersion: {
106
+ minLength: number;
107
+ };
108
+ };
@@ -0,0 +1,121 @@
1
+ const CreateJobDefinitionRequest = {
2
+ cpuLimit: {
3
+ greaterThan: 0
4
+ },
5
+ description: {
6
+ maxLength: 255
7
+ },
8
+ imageUri: {
9
+ pattern: /^((?:(?:(?:[a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])(?:\.(?:[a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]))*|\[(?:[a-fA-F0-9:]+)\])(?::[0-9]+)?\/)?[a-z0-9]+(?:(?:[._]|__|[-]+)[a-z0-9]+)*(?:\/[a-z0-9]+(?:(?:[._]|__|[-]+)[a-z0-9]+)*)*)(?::(\w[A-Za-z0-9_.-]{0,127}))?(?:@([A-Za-z][A-Za-z0-9]*(?:[-_+.][A-Za-z][A-Za-z0-9]*)*[:][[:xdigit:]]{32,}))?$/
10
+ },
11
+ localStorageCapacity: {
12
+ greaterThan: 0
13
+ },
14
+ memoryLimit: {
15
+ greaterThan: 0
16
+ },
17
+ name: {
18
+ pattern: /^[A-Za-z0-9-_]{3,50}$/
19
+ }
20
+ };
21
+ const CreateJobDefinitionRequestCronScheduleConfig = {
22
+ schedule: {
23
+ maxLength: 255,
24
+ minLength: 1
25
+ },
26
+ timezone: {
27
+ maxLength: 255,
28
+ minLength: 1
29
+ }
30
+ };
31
+ const CreateSecretsRequestSecretConfig = {
32
+ secretManagerVersion: {
33
+ minLength: 1
34
+ }
35
+ };
36
+ const CronSchedule = {
37
+ schedule: {
38
+ maxLength: 255,
39
+ minLength: 1
40
+ },
41
+ timezone: {
42
+ maxLength: 255,
43
+ minLength: 1
44
+ }
45
+ };
46
+ const ListJobDefinitionsRequest = {
47
+ page: {
48
+ greaterThanOrEqual: 1
49
+ },
50
+ pageSize: {
51
+ greaterThanOrEqual: 1,
52
+ lessThanOrEqual: 1e3
53
+ }
54
+ };
55
+ const ListJobRunsRequest = {
56
+ page: {
57
+ greaterThanOrEqual: 1
58
+ },
59
+ pageSize: {
60
+ greaterThanOrEqual: 1,
61
+ lessThanOrEqual: 1e3
62
+ }
63
+ };
64
+ const RetryPolicy = {
65
+ maxRetries: {
66
+ lessThanOrEqual: 5
67
+ }
68
+ };
69
+ const StartJobDefinitionRequest = {
70
+ replicas: {
71
+ greaterThan: 0
72
+ }
73
+ };
74
+ const UpdateJobDefinitionRequest = {
75
+ cpuLimit: {
76
+ greaterThan: 0
77
+ },
78
+ description: {
79
+ maxLength: 255
80
+ },
81
+ imageUri: {
82
+ pattern: /^((?:(?:(?:[a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])(?:\.(?:[a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]))*|\[(?:[a-fA-F0-9:]+)\])(?::[0-9]+)?\/)?[a-z0-9]+(?:(?:[._]|__|[-]+)[a-z0-9]+)*(?:\/[a-z0-9]+(?:(?:[._]|__|[-]+)[a-z0-9]+)*)*)(?::(\w[A-Za-z0-9_.-]{0,127}))?(?:@([A-Za-z][A-Za-z0-9]*(?:[-_+.][A-Za-z][A-Za-z0-9]*)*[:][[:xdigit:]]{32,}))?$/
83
+ },
84
+ localStorageCapacity: {
85
+ greaterThan: 0
86
+ },
87
+ memoryLimit: {
88
+ greaterThan: 0
89
+ },
90
+ name: {
91
+ pattern: /^[A-Za-z0-9-_]{3,50}$/
92
+ }
93
+ };
94
+ const UpdateJobDefinitionRequestCronScheduleConfig = {
95
+ schedule: {
96
+ maxLength: 255,
97
+ minLength: 1
98
+ },
99
+ timezone: {
100
+ maxLength: 255,
101
+ minLength: 1
102
+ }
103
+ };
104
+ const UpdateSecretRequest = {
105
+ secretManagerVersion: {
106
+ minLength: 1
107
+ }
108
+ };
109
+ export {
110
+ CreateJobDefinitionRequest,
111
+ CreateJobDefinitionRequestCronScheduleConfig,
112
+ CreateSecretsRequestSecretConfig,
113
+ CronSchedule,
114
+ ListJobDefinitionsRequest,
115
+ ListJobRunsRequest,
116
+ RetryPolicy,
117
+ StartJobDefinitionRequest,
118
+ UpdateJobDefinitionRequest,
119
+ UpdateJobDefinitionRequestCronScheduleConfig,
120
+ UpdateSecretRequest
121
+ };