@scaleway/sdk-jobs 2.3.0 → 2.4.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,6 +1,6 @@
1
1
  import type { ApiLocality } from '@scaleway/sdk-client';
2
2
  import { API as ParentAPI } from '@scaleway/sdk-client';
3
- import type { CreateJobDefinitionRequest, CreateSecretsRequest, CreateSecretsResponse, DeleteJobDefinitionRequest, DeleteSecretRequest, GetJobDefinitionRequest, GetJobLimitsRequest, GetJobRunRequest, GetSecretRequest, JobDefinition, JobLimits, JobRun, ListJobDefinitionsRequest, ListJobDefinitionsResponse, ListJobResourcesRequest, ListJobResourcesResponse, ListJobRunsRequest, ListJobRunsResponse, ListSecretsRequest, ListSecretsResponse, Secret, StartJobDefinitionRequest, StartJobDefinitionResponse, StopJobRunRequest, UpdateJobDefinitionRequest, UpdateSecretRequest } from './types.gen.js';
3
+ import type { CreateJobDefinitionRequest, CreateSecretsRequest, CreateSecretsResponse, CreateTriggerRequest, DeleteJobDefinitionRequest, DeleteSecretRequest, DeleteTriggerRequest, GetJobDefinitionRequest, GetJobLimitsRequest, GetJobRunRequest, GetSecretRequest, GetTriggerRequest, JobDefinition, JobLimits, JobRun, ListJobDefinitionsRequest, ListJobDefinitionsResponse, ListJobResourcesRequest, ListJobResourcesResponse, ListJobRunsRequest, ListJobRunsResponse, ListSecretsRequest, ListSecretsResponse, ListTriggersRequest, ListTriggersResponse, Secret, StartJobDefinitionRequest, StartJobDefinitionResponse, StopJobRunRequest, Trigger, UpdateJobDefinitionRequest, UpdateSecretRequest, UpdateTriggerRequest } from './types.gen.js';
4
4
  /**
5
5
  * Serverless Jobs API.
6
6
 
@@ -116,6 +116,44 @@ export declare class API extends ParentAPI {
116
116
  * @param request - The request {@link DeleteSecretRequest}
117
117
  */
118
118
  deleteSecret: (request: Readonly<DeleteSecretRequest>) => Promise<void>;
119
+ /**
120
+ * Create a trigger.
121
+ *
122
+ * @param request - The request {@link CreateTriggerRequest}
123
+ * @returns A Promise of Trigger
124
+ */
125
+ createTrigger: (request: Readonly<CreateTriggerRequest>) => Promise<Trigger>;
126
+ /**
127
+ * Get a trigger.
128
+ *
129
+ * @param request - The request {@link GetTriggerRequest}
130
+ * @returns A Promise of Trigger
131
+ */
132
+ getTrigger: (request: Readonly<GetTriggerRequest>) => Promise<Trigger>;
133
+ protected pageOfListTriggers: (request: Readonly<ListTriggersRequest>) => Promise<ListTriggersResponse>;
134
+ /**
135
+ * List triggers of a job definition.
136
+ *
137
+ * @param request - The request {@link ListTriggersRequest}
138
+ * @returns A Promise of ListTriggersResponse
139
+ */
140
+ listTriggers: (request: Readonly<ListTriggersRequest>) => Promise<ListTriggersResponse> & {
141
+ all: () => Promise<Trigger[]>;
142
+ [Symbol.asyncIterator]: () => AsyncGenerator<Trigger[], void, void>;
143
+ };
144
+ /**
145
+ * Update a trigger.
146
+ *
147
+ * @param request - The request {@link UpdateTriggerRequest}
148
+ * @returns A Promise of Trigger
149
+ */
150
+ updateTrigger: (request: Readonly<UpdateTriggerRequest>) => Promise<Trigger>;
151
+ /**
152
+ * Delete a trigger.
153
+ *
154
+ * @param request - The request {@link DeleteTriggerRequest}
155
+ */
156
+ deleteTrigger: (request: Readonly<DeleteTriggerRequest>) => Promise<void>;
119
157
  /**
120
158
  * List job resources for the console.
121
159
  *
@@ -1,4 +1,4 @@
1
- import { marshalCreateJobDefinitionRequest, marshalCreateSecretsRequest, marshalStartJobDefinitionRequest, marshalUpdateJobDefinitionRequest, marshalUpdateSecretRequest, unmarshalCreateSecretsResponse, unmarshalJobDefinition, unmarshalJobLimits, unmarshalJobRun, unmarshalListJobDefinitionsResponse, unmarshalListJobResourcesResponse, unmarshalListJobRunsResponse, unmarshalListSecretsResponse, unmarshalSecret, unmarshalStartJobDefinitionResponse } from "./marshalling.gen.js";
1
+ import { marshalCreateJobDefinitionRequest, marshalCreateSecretsRequest, marshalCreateTriggerRequest, marshalStartJobDefinitionRequest, marshalUpdateJobDefinitionRequest, marshalUpdateSecretRequest, marshalUpdateTriggerRequest, unmarshalCreateSecretsResponse, unmarshalJobDefinition, unmarshalJobLimits, unmarshalJobRun, unmarshalListJobDefinitionsResponse, unmarshalListJobResourcesResponse, unmarshalListJobRunsResponse, unmarshalListSecretsResponse, unmarshalListTriggersResponse, unmarshalSecret, unmarshalStartJobDefinitionResponse, unmarshalTrigger } from "./marshalling.gen.js";
2
2
  import { API, enrichForPagination, toApiLocality, urlParams, validatePathParam } from "@scaleway/sdk-client";
3
3
  var jsonContentHeaders = { "Content-Type": "application/json; charset=utf-8" };
4
4
  /**
@@ -172,6 +172,61 @@ var API$1 = class extends API {
172
172
  path: `/serverless-jobs/v1alpha2/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/secrets/${validatePathParam("secretId", request.secretId)}`
173
173
  });
174
174
  /**
175
+ * Create a trigger.
176
+ *
177
+ * @param request - The request {@link CreateTriggerRequest}
178
+ * @returns A Promise of Trigger
179
+ */
180
+ createTrigger = (request) => this.client.fetch({
181
+ body: JSON.stringify(marshalCreateTriggerRequest(request, this.client.settings)),
182
+ headers: jsonContentHeaders,
183
+ method: "POST",
184
+ path: `/serverless-jobs/v1alpha2/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/triggers`
185
+ }, unmarshalTrigger);
186
+ /**
187
+ * Get a trigger.
188
+ *
189
+ * @param request - The request {@link GetTriggerRequest}
190
+ * @returns A Promise of Trigger
191
+ */
192
+ getTrigger = (request) => this.client.fetch({
193
+ method: "GET",
194
+ path: `/serverless-jobs/v1alpha2/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/triggers/${validatePathParam("triggerId", request.triggerId)}`
195
+ }, unmarshalTrigger);
196
+ pageOfListTriggers = (request) => this.client.fetch({
197
+ method: "GET",
198
+ path: `/serverless-jobs/v1alpha2/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/triggers`,
199
+ urlParams: urlParams(["job_definition_id", request.jobDefinitionId], ["order_by", request.orderBy], ["page", request.page], ["page_size", request.pageSize ?? this.client.settings.defaultPageSize])
200
+ }, unmarshalListTriggersResponse);
201
+ /**
202
+ * List triggers of a job definition.
203
+ *
204
+ * @param request - The request {@link ListTriggersRequest}
205
+ * @returns A Promise of ListTriggersResponse
206
+ */
207
+ listTriggers = (request) => enrichForPagination("triggers", this.pageOfListTriggers, request);
208
+ /**
209
+ * Update a trigger.
210
+ *
211
+ * @param request - The request {@link UpdateTriggerRequest}
212
+ * @returns A Promise of Trigger
213
+ */
214
+ updateTrigger = (request) => this.client.fetch({
215
+ body: JSON.stringify(marshalUpdateTriggerRequest(request, this.client.settings)),
216
+ headers: jsonContentHeaders,
217
+ method: "PATCH",
218
+ path: `/serverless-jobs/v1alpha2/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/triggers/${validatePathParam("triggerId", request.triggerId)}`
219
+ }, unmarshalTrigger);
220
+ /**
221
+ * Delete a trigger.
222
+ *
223
+ * @param request - The request {@link DeleteTriggerRequest}
224
+ */
225
+ deleteTrigger = (request) => this.client.fetch({
226
+ method: "DELETE",
227
+ path: `/serverless-jobs/v1alpha2/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/triggers/${validatePathParam("triggerId", request.triggerId)}`
228
+ });
229
+ /**
175
230
  * List job resources for the console.
176
231
  *
177
232
  * @param request - The request {@link ListJobResourcesRequest}
@@ -1,5 +1,5 @@
1
1
  export { API, } from './api.gen.js';
2
2
  export * from './content.gen.js';
3
3
  export * from './marshalling.gen.js';
4
- export type { CreateJobDefinitionRequest, CreateJobDefinitionRequestCronScheduleConfig, CreateSecretsRequest, CreateSecretsRequestSecretConfig, CreateSecretsResponse, CronSchedule, DeleteJobDefinitionRequest, DeleteSecretRequest, GetJobDefinitionRequest, GetJobLimitsRequest, GetJobRunRequest, GetSecretRequest, JobDefinition, JobLimits, JobRun, JobRunReason, JobRunState, ListJobDefinitionsRequest, ListJobDefinitionsRequestOrderBy, ListJobDefinitionsResponse, ListJobResourcesRequest, ListJobResourcesResponse, ListJobRunsRequest, ListJobRunsRequestOrderBy, ListJobRunsResponse, ListSecretsRequest, ListSecretsResponse, Resource, RetryPolicy, Secret, SecretEnvVar, SecretFile, StartJobDefinitionRequest, StartJobDefinitionResponse, StopJobRunRequest, UpdateJobDefinitionRequest, UpdateJobDefinitionRequestCronScheduleConfig, UpdateSecretRequest, } from './types.gen.js';
4
+ export type { CreateJobDefinitionRequest, CreateJobDefinitionRequestCronScheduleConfig, CreateSecretsRequest, CreateSecretsRequestSecretConfig, CreateSecretsResponse, CreateTriggerRequest, CreateTriggerRequestCronConfig, CronSchedule, DeleteJobDefinitionRequest, DeleteSecretRequest, DeleteTriggerRequest, GetJobDefinitionRequest, GetJobLimitsRequest, GetJobRunRequest, GetSecretRequest, GetTriggerRequest, JobDefinition, JobLimits, JobRun, JobRunReason, JobRunState, ListJobDefinitionsRequest, ListJobDefinitionsRequestOrderBy, ListJobDefinitionsResponse, ListJobResourcesRequest, ListJobResourcesResponse, ListJobRunsRequest, ListJobRunsRequestOrderBy, ListJobRunsResponse, ListSecretsRequest, ListSecretsResponse, ListTriggersRequest, ListTriggersRequestOrderBy, ListTriggersResponse, Resource, RetryPolicy, Secret, SecretEnvVar, SecretFile, StartJobDefinitionRequest, StartJobDefinitionResponse, StopJobRunRequest, Trigger, TriggerCronConfig, UpdateJobDefinitionRequest, UpdateJobDefinitionRequestCronScheduleConfig, UpdateSecretRequest, UpdateTriggerRequest, UpdateTriggerRequestCronConfig, } from './types.gen.js';
5
5
  export * as ValidationRules from './validation-rules.gen.js';
@@ -1,5 +1,5 @@
1
1
  import { __exportAll } from "../_virtual/_rolldown/runtime.js";
2
- import { marshalCreateJobDefinitionRequest, marshalCreateSecretsRequest, marshalStartJobDefinitionRequest, marshalUpdateJobDefinitionRequest, marshalUpdateSecretRequest, unmarshalCreateSecretsResponse, unmarshalJobDefinition, unmarshalJobLimits, unmarshalJobRun, unmarshalListJobDefinitionsResponse, unmarshalListJobResourcesResponse, unmarshalListJobRunsResponse, unmarshalListSecretsResponse, unmarshalSecret, unmarshalStartJobDefinitionResponse } from "./marshalling.gen.js";
2
+ import { marshalCreateJobDefinitionRequest, marshalCreateSecretsRequest, marshalCreateTriggerRequest, marshalStartJobDefinitionRequest, marshalUpdateJobDefinitionRequest, marshalUpdateSecretRequest, marshalUpdateTriggerRequest, unmarshalCreateSecretsResponse, unmarshalJobDefinition, unmarshalJobLimits, unmarshalJobRun, unmarshalListJobDefinitionsResponse, unmarshalListJobResourcesResponse, unmarshalListJobRunsResponse, unmarshalListSecretsResponse, unmarshalListTriggersResponse, unmarshalSecret, unmarshalStartJobDefinitionResponse, unmarshalTrigger } from "./marshalling.gen.js";
3
3
  import { API } from "./api.gen.js";
4
4
  import { JOB_RUN_TRANSIENT_STATUSES } from "./content.gen.js";
5
5
  import { validation_rules_gen_exports } from "./validation-rules.gen.js";
@@ -9,9 +9,11 @@ var index_gen_exports = /* @__PURE__ */ __exportAll({
9
9
  ValidationRules: () => validation_rules_gen_exports,
10
10
  marshalCreateJobDefinitionRequest: () => marshalCreateJobDefinitionRequest,
11
11
  marshalCreateSecretsRequest: () => marshalCreateSecretsRequest,
12
+ marshalCreateTriggerRequest: () => marshalCreateTriggerRequest,
12
13
  marshalStartJobDefinitionRequest: () => marshalStartJobDefinitionRequest,
13
14
  marshalUpdateJobDefinitionRequest: () => marshalUpdateJobDefinitionRequest,
14
15
  marshalUpdateSecretRequest: () => marshalUpdateSecretRequest,
16
+ marshalUpdateTriggerRequest: () => marshalUpdateTriggerRequest,
15
17
  unmarshalCreateSecretsResponse: () => unmarshalCreateSecretsResponse,
16
18
  unmarshalJobDefinition: () => unmarshalJobDefinition,
17
19
  unmarshalJobLimits: () => unmarshalJobLimits,
@@ -20,7 +22,9 @@ var index_gen_exports = /* @__PURE__ */ __exportAll({
20
22
  unmarshalListJobResourcesResponse: () => unmarshalListJobResourcesResponse,
21
23
  unmarshalListJobRunsResponse: () => unmarshalListJobRunsResponse,
22
24
  unmarshalListSecretsResponse: () => unmarshalListSecretsResponse,
25
+ unmarshalListTriggersResponse: () => unmarshalListTriggersResponse,
23
26
  unmarshalSecret: () => unmarshalSecret,
24
- unmarshalStartJobDefinitionResponse: () => unmarshalStartJobDefinitionResponse
27
+ unmarshalStartJobDefinitionResponse: () => unmarshalStartJobDefinitionResponse,
28
+ unmarshalTrigger: () => unmarshalTrigger
25
29
  });
26
30
  export { index_gen_exports };
@@ -1,17 +1,21 @@
1
1
  import type { DefaultValues } from '@scaleway/sdk-client';
2
- import type { CreateJobDefinitionRequest, CreateSecretsRequest, CreateSecretsResponse, JobDefinition, JobLimits, JobRun, ListJobDefinitionsResponse, ListJobResourcesResponse, ListJobRunsResponse, ListSecretsResponse, Secret, StartJobDefinitionRequest, StartJobDefinitionResponse, UpdateJobDefinitionRequest, UpdateSecretRequest } from './types.gen.js';
2
+ import type { CreateJobDefinitionRequest, CreateSecretsRequest, CreateSecretsResponse, CreateTriggerRequest, JobDefinition, JobLimits, JobRun, ListJobDefinitionsResponse, ListJobResourcesResponse, ListJobRunsResponse, ListSecretsResponse, ListTriggersResponse, Secret, StartJobDefinitionRequest, StartJobDefinitionResponse, Trigger, UpdateJobDefinitionRequest, UpdateSecretRequest, UpdateTriggerRequest } from './types.gen.js';
3
3
  export declare const unmarshalSecret: (data: unknown) => Secret;
4
4
  export declare const unmarshalJobDefinition: (data: unknown) => JobDefinition;
5
5
  export declare const unmarshalJobRun: (data: unknown) => JobRun;
6
+ export declare const unmarshalTrigger: (data: unknown) => Trigger;
6
7
  export declare const unmarshalCreateSecretsResponse: (data: unknown) => CreateSecretsResponse;
7
8
  export declare const unmarshalJobLimits: (data: unknown) => JobLimits;
8
9
  export declare const unmarshalListJobDefinitionsResponse: (data: unknown) => ListJobDefinitionsResponse;
9
10
  export declare const unmarshalListJobResourcesResponse: (data: unknown) => ListJobResourcesResponse;
10
11
  export declare const unmarshalListJobRunsResponse: (data: unknown) => ListJobRunsResponse;
11
12
  export declare const unmarshalListSecretsResponse: (data: unknown) => ListSecretsResponse;
13
+ export declare const unmarshalListTriggersResponse: (data: unknown) => ListTriggersResponse;
12
14
  export declare const unmarshalStartJobDefinitionResponse: (data: unknown) => StartJobDefinitionResponse;
13
15
  export declare const marshalCreateJobDefinitionRequest: (request: CreateJobDefinitionRequest, defaults: DefaultValues) => Record<string, unknown>;
14
16
  export declare const marshalCreateSecretsRequest: (request: CreateSecretsRequest, defaults: DefaultValues) => Record<string, unknown>;
17
+ export declare const marshalCreateTriggerRequest: (request: CreateTriggerRequest, defaults: DefaultValues) => Record<string, unknown>;
15
18
  export declare const marshalStartJobDefinitionRequest: (request: StartJobDefinitionRequest, defaults: DefaultValues) => Record<string, unknown>;
16
19
  export declare const marshalUpdateJobDefinitionRequest: (request: UpdateJobDefinitionRequest, defaults: DefaultValues) => Record<string, unknown>;
17
20
  export declare const marshalUpdateSecretRequest: (request: UpdateSecretRequest, defaults: DefaultValues) => Record<string, unknown>;
21
+ export declare const marshalUpdateTriggerRequest: (request: UpdateTriggerRequest, defaults: DefaultValues) => Record<string, unknown>;
@@ -68,7 +68,7 @@ const unmarshalJobRun = (data) => {
68
68
  jobDefinitionId: data.job_definition_id,
69
69
  localStorageCapacity: data.local_storage_capacity,
70
70
  memoryLimit: data.memory_limit,
71
- reason: data.reason ? data.reason : void 0,
71
+ reason: data.reason,
72
72
  region: data.region,
73
73
  runDuration: data.run_duration,
74
74
  startedAt: unmarshalDate(data.started_at),
@@ -78,6 +78,26 @@ const unmarshalJobRun = (data) => {
78
78
  updatedAt: unmarshalDate(data.updated_at)
79
79
  };
80
80
  };
81
+ var unmarshalTriggerCronConfig = (data) => {
82
+ if (!isJSONObject(data)) throw new TypeError(`Unmarshalling the type 'TriggerCronConfig' failed as data isn't a dictionary.`);
83
+ return {
84
+ args: data.args,
85
+ schedule: data.schedule,
86
+ startupCommand: data.startup_command,
87
+ timezone: data.timezone
88
+ };
89
+ };
90
+ const unmarshalTrigger = (data) => {
91
+ if (!isJSONObject(data)) throw new TypeError(`Unmarshalling the type 'Trigger' failed as data isn't a dictionary.`);
92
+ return {
93
+ createdAt: unmarshalDate(data.created_at),
94
+ cronConfig: data.cron_config ? unmarshalTriggerCronConfig(data.cron_config) : void 0,
95
+ id: data.id,
96
+ jobDefinitionId: data.job_definition_id,
97
+ name: data.name,
98
+ updatedAt: unmarshalDate(data.updated_at)
99
+ };
100
+ };
81
101
  const unmarshalCreateSecretsResponse = (data) => {
82
102
  if (!isJSONObject(data)) throw new TypeError(`Unmarshalling the type 'CreateSecretsResponse' failed as data isn't a dictionary.`);
83
103
  return { secrets: unmarshalArrayOfObject(data.secrets, unmarshalSecret) };
@@ -118,6 +138,13 @@ const unmarshalListSecretsResponse = (data) => {
118
138
  totalCount: data.total_count
119
139
  };
120
140
  };
141
+ const unmarshalListTriggersResponse = (data) => {
142
+ if (!isJSONObject(data)) throw new TypeError(`Unmarshalling the type 'ListTriggersResponse' failed as data isn't a dictionary.`);
143
+ return {
144
+ totalCount: data.total_count,
145
+ triggers: unmarshalArrayOfObject(data.triggers, unmarshalTrigger)
146
+ };
147
+ };
121
148
  const unmarshalStartJobDefinitionResponse = (data) => {
122
149
  if (!isJSONObject(data)) throw new TypeError(`Unmarshalling the type 'StartJobDefinitionResponse' failed as data isn't a dictionary.`);
123
150
  return { jobRuns: unmarshalArrayOfObject(data.job_runs, unmarshalJobRun) };
@@ -158,6 +185,20 @@ const marshalCreateSecretsRequest = (request, defaults) => ({
158
185
  job_definition_id: request.jobDefinitionId,
159
186
  secrets: request.secrets.map((elt) => marshalCreateSecretsRequestSecretConfig(elt, defaults))
160
187
  });
188
+ var marshalCreateTriggerRequestCronConfig = (request, defaults) => ({
189
+ args: request.args,
190
+ schedule: request.schedule,
191
+ startup_command: request.startupCommand,
192
+ timezone: request.timezone
193
+ });
194
+ const marshalCreateTriggerRequest = (request, defaults) => ({
195
+ job_definition_id: request.jobDefinitionId,
196
+ name: request.name,
197
+ ...resolveOneOf([{
198
+ param: "cron_config",
199
+ value: request.cronConfig !== void 0 ? marshalCreateTriggerRequestCronConfig(request.cronConfig, defaults) : void 0
200
+ }])
201
+ });
161
202
  const marshalStartJobDefinitionRequest = (request, defaults) => ({
162
203
  args: request.args,
163
204
  command: request.command,
@@ -194,4 +235,17 @@ const marshalUpdateSecretRequest = (request, defaults) => ({
194
235
  value: request.envVarName
195
236
  }])
196
237
  });
197
- export { marshalCreateJobDefinitionRequest, marshalCreateSecretsRequest, marshalStartJobDefinitionRequest, marshalUpdateJobDefinitionRequest, marshalUpdateSecretRequest, unmarshalCreateSecretsResponse, unmarshalJobDefinition, unmarshalJobLimits, unmarshalJobRun, unmarshalListJobDefinitionsResponse, unmarshalListJobResourcesResponse, unmarshalListJobRunsResponse, unmarshalListSecretsResponse, unmarshalSecret, unmarshalStartJobDefinitionResponse };
238
+ var marshalUpdateTriggerRequestCronConfig = (request, defaults) => ({
239
+ args: request.args,
240
+ schedule: request.schedule,
241
+ startup_command: request.startupCommand,
242
+ timezone: request.timezone
243
+ });
244
+ const marshalUpdateTriggerRequest = (request, defaults) => ({
245
+ name: request.name,
246
+ ...resolveOneOf([{
247
+ param: "cron_config",
248
+ value: request.cronConfig !== void 0 ? marshalUpdateTriggerRequestCronConfig(request.cronConfig, defaults) : void 0
249
+ }])
250
+ });
251
+ export { marshalCreateJobDefinitionRequest, marshalCreateSecretsRequest, marshalCreateTriggerRequest, marshalStartJobDefinitionRequest, marshalUpdateJobDefinitionRequest, marshalUpdateSecretRequest, marshalUpdateTriggerRequest, unmarshalCreateSecretsResponse, unmarshalJobDefinition, unmarshalJobLimits, unmarshalJobRun, unmarshalListJobDefinitionsResponse, unmarshalListJobResourcesResponse, unmarshalListJobRunsResponse, unmarshalListSecretsResponse, unmarshalListTriggersResponse, unmarshalSecret, unmarshalStartJobDefinitionResponse, unmarshalTrigger };
@@ -3,6 +3,7 @@ export type JobRunReason = 'unknown_reason' | 'invalid_request' | 'timeout' | 'c
3
3
  export type JobRunState = 'unknown_state' | 'initialized' | 'validated' | 'queued' | 'running' | 'succeeded' | 'failed' | 'interrupting' | 'interrupted' | 'retrying';
4
4
  export type ListJobDefinitionsRequestOrderBy = 'created_at_asc' | 'created_at_desc';
5
5
  export type ListJobRunsRequestOrderBy = 'created_at_asc' | 'created_at_desc';
6
+ export type ListTriggersRequestOrderBy = 'created_at_asc' | 'created_at_desc';
6
7
  export interface SecretEnvVar {
7
8
  name: string;
8
9
  }
@@ -25,6 +26,24 @@ export interface RetryPolicy {
25
26
  */
26
27
  maxRetries: number;
27
28
  }
29
+ export interface TriggerCronConfig {
30
+ /**
31
+ * CRON schedule in UNIX format.
32
+ */
33
+ schedule: string;
34
+ /**
35
+ * Time zone for the CRON schedule.
36
+ */
37
+ timezone: string;
38
+ /**
39
+ * Startup command that will be used by the triggered job.
40
+ */
41
+ startupCommand: string[];
42
+ /**
43
+ * Arguments passed to the startup command used by the triggered job.
44
+ */
45
+ args: string[];
46
+ }
28
47
  export interface CreateJobDefinitionRequestCronScheduleConfig {
29
48
  schedule: string;
30
49
  timezone: string;
@@ -73,26 +92,92 @@ export interface Secret {
73
92
  */
74
93
  envVar?: SecretEnvVar;
75
94
  }
95
+ export interface CreateTriggerRequestCronConfig {
96
+ /**
97
+ * CRON schedule in UNIX format.
98
+ */
99
+ schedule: string;
100
+ /**
101
+ * Time zone for the CRON schedule.
102
+ */
103
+ timezone: string;
104
+ /**
105
+ * Startup command that will be used by the triggered job.
106
+ */
107
+ startupCommand: string[];
108
+ /**
109
+ * Arguments passed to the startup command used by the triggered job.
110
+ */
111
+ args: string[];
112
+ }
76
113
  export interface JobDefinition {
114
+ /**
115
+ * UUID of the job definition.
116
+ */
77
117
  id: string;
118
+ /**
119
+ * Name of the job definition.
120
+ */
78
121
  name: string;
122
+ /**
123
+ * UUID of the Scaleway Project containing the job.
124
+ */
79
125
  projectId: string;
126
+ /**
127
+ * Creation date of the job definition.
128
+ */
80
129
  createdAt?: Date;
130
+ /**
131
+ * Last update date of the job definition.
132
+ */
81
133
  updatedAt?: Date;
134
+ /**
135
+ * CPU limit of the job (in mvCPU).
136
+ */
82
137
  cpuLimit: number;
138
+ /**
139
+ * Memory limit of the job (in MiB).
140
+ */
83
141
  memoryLimit: number;
142
+ /**
143
+ * Local storage capacity of the job (in MiB).
144
+ */
84
145
  localStorageCapacity: number;
146
+ /**
147
+ * Image to use for the job.
148
+ */
85
149
  imageUri: string;
86
150
  /**
87
- * @deprecated
151
+ * @deprecated Deprecated, please use startup_command instead.
152
+ */
153
+ command: string;
154
+ /**
155
+ * Environment variables of the job.
88
156
  */
89
- command?: string;
90
157
  environmentVariables: Record<string, string>;
158
+ /**
159
+ * Timeout of the job in seconds.
160
+ */
91
161
  jobTimeout?: string;
162
+ /**
163
+ * Description of the job.
164
+ */
92
165
  description: string;
166
+ /**
167
+ * Configure a cron for the job.
168
+ */
93
169
  cronSchedule?: CronSchedule;
170
+ /**
171
+ * Job startup command.
172
+ */
94
173
  startupCommand: string[];
174
+ /**
175
+ * Job arguments passed to the startup command at runtime.
176
+ */
95
177
  args: string[];
178
+ /**
179
+ * Retry behaviour in case of job failure.
180
+ */
96
181
  retryPolicy?: RetryPolicy;
97
182
  /**
98
183
  * Region to target. If none is passed will use default region from the config.
@@ -104,37 +189,137 @@ export interface Resource {
104
189
  memoryLimitBytes: number;
105
190
  }
106
191
  export interface JobRun {
192
+ /**
193
+ * UUID of the job run.
194
+ */
107
195
  id: string;
196
+ /**
197
+ * UUID of the job definition.
198
+ */
108
199
  jobDefinitionId: string;
200
+ /**
201
+ * Creation date of the job run.
202
+ */
109
203
  createdAt?: Date;
204
+ /**
205
+ * Last update date of the job run.
206
+ */
110
207
  updatedAt?: Date;
208
+ /**
209
+ * Start date of the job run.
210
+ */
111
211
  startedAt?: Date;
212
+ /**
213
+ * Termination date of the job run.
214
+ */
112
215
  terminatedAt?: Date;
216
+ /**
217
+ * Duration of the job run.
218
+ */
113
219
  runDuration?: string;
220
+ /**
221
+ * State of the job run.
222
+ */
114
223
  state: JobRunState;
224
+ /**
225
+ * Reason for failure if the job failed.
226
+ */
115
227
  reason?: JobRunReason;
228
+ /**
229
+ * Exit code of the job.
230
+ */
116
231
  exitCode?: number;
232
+ /**
233
+ * Error message if the job failed.
234
+ */
117
235
  errorMessage?: string;
236
+ /**
237
+ * CPU limit of the job (in mvCPU).
238
+ */
118
239
  cpuLimit: number;
240
+ /**
241
+ * Memory limit of the job (in MiB).
242
+ */
119
243
  memoryLimit: number;
244
+ /**
245
+ * Local storage capacity of the job (in MiB).
246
+ */
120
247
  localStorageCapacity: number;
121
248
  /**
122
- * @deprecated
249
+ * @deprecated Deprecated, please use startup_command instead.
250
+ */
251
+ command: string;
252
+ /**
253
+ * Environment variables of the job run.
123
254
  */
124
- command?: string;
125
255
  environmentVariables: Record<string, string>;
256
+ /**
257
+ * Job startup command.
258
+ */
126
259
  startupCommand: string[];
260
+ /**
261
+ * Job arguments passed to the startup command at runtime.
262
+ */
127
263
  args: string[];
264
+ /**
265
+ * Number of retry attempts.
266
+ */
128
267
  attempts?: number;
129
268
  /**
130
269
  * Region to target. If none is passed will use default region from the config.
131
270
  */
132
271
  region: ScwRegion;
133
272
  }
273
+ export interface Trigger {
274
+ /**
275
+ * UUID of the trigger.
276
+ */
277
+ id: string;
278
+ /**
279
+ * UUID of the job definition.
280
+ */
281
+ jobDefinitionId: string;
282
+ /**
283
+ * Human readable name of the trigger.
284
+ */
285
+ name: string;
286
+ /**
287
+ * Creation time of the trigger.
288
+ */
289
+ createdAt?: Date;
290
+ /**
291
+ * Last update time of the trigger.
292
+ */
293
+ updatedAt?: Date;
294
+ /**
295
+ * Configuration of the CRON trigger.
296
+ *
297
+ * One-of ('config'): at most one of 'cronConfig' could be set.
298
+ */
299
+ cronConfig?: TriggerCronConfig;
300
+ }
134
301
  export interface UpdateJobDefinitionRequestCronScheduleConfig {
135
302
  schedule?: string;
136
303
  timezone?: string;
137
304
  }
305
+ export interface UpdateTriggerRequestCronConfig {
306
+ /**
307
+ * CRON schedule in UNIX format.
308
+ */
309
+ schedule?: string;
310
+ /**
311
+ * Time zone for the CRON schedule.
312
+ */
313
+ timezone?: string;
314
+ /**
315
+ * Startup command that will be used by the triggered job.
316
+ */
317
+ startupCommand?: string[];
318
+ /**
319
+ * Arguments passed to the startup command used by the triggered job.
320
+ */
321
+ args?: string[];
322
+ }
138
323
  export type CreateJobDefinitionRequest = {
139
324
  /**
140
325
  * Region to target. If none is passed will use default region from the config.
@@ -163,7 +348,7 @@ export type CreateJobDefinitionRequest = {
163
348
  /**
164
349
  * @deprecated Deprecated: please use startup_command instead.
165
350
  */
166
- command?: string;
351
+ command: string;
167
352
  /**
168
353
  * The main executable or entrypoint script to run.
169
354
  If both command and startup_command are provided, only startup_command will be used.
@@ -219,6 +404,26 @@ export interface CreateSecretsResponse {
219
404
  */
220
405
  secrets: Secret[];
221
406
  }
407
+ export type CreateTriggerRequest = {
408
+ /**
409
+ * Region to target. If none is passed will use default region from the config.
410
+ */
411
+ region?: ScwRegion;
412
+ /**
413
+ * UUID of the job definition.
414
+ */
415
+ jobDefinitionId: string;
416
+ /**
417
+ * Name of the trigger.
418
+ */
419
+ name: string;
420
+ /**
421
+ * Configuration of the CRON trigger.
422
+ *
423
+ * One-of ('config'): at most one of 'cronConfig' could be set.
424
+ */
425
+ cronConfig?: CreateTriggerRequestCronConfig;
426
+ };
222
427
  export type DeleteJobDefinitionRequest = {
223
428
  /**
224
429
  * Region to target. If none is passed will use default region from the config.
@@ -239,6 +444,16 @@ export type DeleteSecretRequest = {
239
444
  */
240
445
  secretId: string;
241
446
  };
447
+ export type DeleteTriggerRequest = {
448
+ /**
449
+ * Region to target. If none is passed will use default region from the config.
450
+ */
451
+ region?: ScwRegion;
452
+ /**
453
+ * UUID of the trigger.
454
+ */
455
+ triggerId: string;
456
+ };
242
457
  export type GetJobDefinitionRequest = {
243
458
  /**
244
459
  * Region to target. If none is passed will use default region from the config.
@@ -275,6 +490,16 @@ export type GetSecretRequest = {
275
490
  */
276
491
  secretId: string;
277
492
  };
493
+ export type GetTriggerRequest = {
494
+ /**
495
+ * Region to target. If none is passed will use default region from the config.
496
+ */
497
+ region?: ScwRegion;
498
+ /**
499
+ * UUID of the trigger.
500
+ */
501
+ triggerId: string;
502
+ };
278
503
  export interface JobLimits {
279
504
  secretsPerJobDefinition: number;
280
505
  }
@@ -341,6 +566,38 @@ export interface ListSecretsResponse {
341
566
  */
342
567
  totalCount: number;
343
568
  }
569
+ export type ListTriggersRequest = {
570
+ /**
571
+ * Region to target. If none is passed will use default region from the config.
572
+ */
573
+ region?: ScwRegion;
574
+ /**
575
+ * UUID of the job definition.
576
+ */
577
+ jobDefinitionId: string;
578
+ /**
579
+ * Page number from paginated list of triggers.
580
+ */
581
+ page?: number;
582
+ /**
583
+ * Number of triggers per page.
584
+ */
585
+ pageSize?: number;
586
+ /**
587
+ * Sorting order of triggers.
588
+ */
589
+ orderBy?: ListTriggersRequestOrderBy;
590
+ };
591
+ export interface ListTriggersResponse {
592
+ /**
593
+ * List of triggers.
594
+ */
595
+ triggers: Trigger[];
596
+ /**
597
+ * Total count of triggers.
598
+ */
599
+ totalCount: number;
600
+ }
344
601
  export type StartJobDefinitionRequest = {
345
602
  /**
346
603
  * Region to target. If none is passed will use default region from the config.
@@ -482,3 +739,23 @@ export type UpdateSecretRequest = {
482
739
  */
483
740
  envVarName?: string;
484
741
  };
742
+ export type UpdateTriggerRequest = {
743
+ /**
744
+ * Region to target. If none is passed will use default region from the config.
745
+ */
746
+ region?: ScwRegion;
747
+ /**
748
+ * UUID of the trigger.
749
+ */
750
+ triggerId: string;
751
+ /**
752
+ * Name of the trigger.
753
+ */
754
+ name?: string;
755
+ /**
756
+ * Configuration of the CRON trigger.
757
+ *
758
+ * One-of ('config'): at most one of 'cronConfig' could be set.
759
+ */
760
+ cronConfig?: UpdateTriggerRequestCronConfig;
761
+ };
@@ -33,6 +33,23 @@ export declare const CreateSecretsRequestSecretConfig: {
33
33
  minLength: number;
34
34
  };
35
35
  };
36
+ export declare const CreateTriggerRequest: {
37
+ name: {
38
+ maxLength: number;
39
+ minLength: number;
40
+ pattern: RegExp;
41
+ };
42
+ };
43
+ export declare const CreateTriggerRequestCronConfig: {
44
+ schedule: {
45
+ maxLength: number;
46
+ minLength: number;
47
+ };
48
+ timezone: {
49
+ maxLength: number;
50
+ minLength: number;
51
+ };
52
+ };
36
53
  export declare const CronSchedule: {
37
54
  schedule: {
38
55
  maxLength: number;
@@ -61,6 +78,15 @@ export declare const ListJobRunsRequest: {
61
78
  lessThanOrEqual: number;
62
79
  };
63
80
  };
81
+ export declare const ListTriggersRequest: {
82
+ page: {
83
+ greaterThanOrEqual: number;
84
+ };
85
+ pageSize: {
86
+ greaterThanOrEqual: number;
87
+ lessThanOrEqual: number;
88
+ };
89
+ };
64
90
  export declare const RetryPolicy: {
65
91
  maxRetries: {
66
92
  lessThanOrEqual: number;
@@ -106,3 +132,20 @@ export declare const UpdateSecretRequest: {
106
132
  minLength: number;
107
133
  };
108
134
  };
135
+ export declare const UpdateTriggerRequest: {
136
+ name: {
137
+ maxLength: number;
138
+ minLength: number;
139
+ pattern: RegExp;
140
+ };
141
+ };
142
+ export declare const UpdateTriggerRequestCronConfig: {
143
+ schedule: {
144
+ maxLength: number;
145
+ minLength: number;
146
+ };
147
+ timezone: {
148
+ maxLength: number;
149
+ minLength: number;
150
+ };
151
+ };
@@ -3,14 +3,19 @@ var validation_rules_gen_exports = /* @__PURE__ */ __exportAll({
3
3
  CreateJobDefinitionRequest: () => CreateJobDefinitionRequest,
4
4
  CreateJobDefinitionRequestCronScheduleConfig: () => CreateJobDefinitionRequestCronScheduleConfig,
5
5
  CreateSecretsRequestSecretConfig: () => CreateSecretsRequestSecretConfig,
6
+ CreateTriggerRequest: () => CreateTriggerRequest,
7
+ CreateTriggerRequestCronConfig: () => CreateTriggerRequestCronConfig,
6
8
  CronSchedule: () => CronSchedule,
7
9
  ListJobDefinitionsRequest: () => ListJobDefinitionsRequest,
8
10
  ListJobRunsRequest: () => ListJobRunsRequest,
11
+ ListTriggersRequest: () => ListTriggersRequest,
9
12
  RetryPolicy: () => RetryPolicy,
10
13
  StartJobDefinitionRequest: () => StartJobDefinitionRequest,
11
14
  UpdateJobDefinitionRequest: () => UpdateJobDefinitionRequest,
12
15
  UpdateJobDefinitionRequestCronScheduleConfig: () => UpdateJobDefinitionRequestCronScheduleConfig,
13
- UpdateSecretRequest: () => UpdateSecretRequest
16
+ UpdateSecretRequest: () => UpdateSecretRequest,
17
+ UpdateTriggerRequest: () => UpdateTriggerRequest,
18
+ UpdateTriggerRequestCronConfig: () => UpdateTriggerRequestCronConfig
14
19
  });
15
20
  const CreateJobDefinitionRequest = {
16
21
  cpuLimit: { greaterThan: 0 },
@@ -31,6 +36,21 @@ const CreateJobDefinitionRequestCronScheduleConfig = {
31
36
  }
32
37
  };
33
38
  const CreateSecretsRequestSecretConfig = { secretManagerVersion: { minLength: 1 } };
39
+ const CreateTriggerRequest = { name: {
40
+ maxLength: 50,
41
+ minLength: 1,
42
+ pattern: /^[A-Za-z0-9-_]*$/
43
+ } };
44
+ const CreateTriggerRequestCronConfig = {
45
+ schedule: {
46
+ maxLength: 255,
47
+ minLength: 1
48
+ },
49
+ timezone: {
50
+ maxLength: 255,
51
+ minLength: 1
52
+ }
53
+ };
34
54
  const CronSchedule = {
35
55
  schedule: {
36
56
  maxLength: 255,
@@ -55,6 +75,13 @@ const ListJobRunsRequest = {
55
75
  lessThanOrEqual: 1e3
56
76
  }
57
77
  };
78
+ const ListTriggersRequest = {
79
+ page: { greaterThanOrEqual: 1 },
80
+ pageSize: {
81
+ greaterThanOrEqual: 1,
82
+ lessThanOrEqual: 1e3
83
+ }
84
+ };
58
85
  const RetryPolicy = { maxRetries: { lessThanOrEqual: 5 } };
59
86
  const StartJobDefinitionRequest = { replicas: { greaterThan: 0 } };
60
87
  const UpdateJobDefinitionRequest = {
@@ -76,4 +103,19 @@ const UpdateJobDefinitionRequestCronScheduleConfig = {
76
103
  }
77
104
  };
78
105
  const UpdateSecretRequest = { secretManagerVersion: { minLength: 1 } };
106
+ const UpdateTriggerRequest = { name: {
107
+ maxLength: 50,
108
+ minLength: 1,
109
+ pattern: /^[A-Za-z0-9-_]*$/
110
+ } };
111
+ const UpdateTriggerRequestCronConfig = {
112
+ schedule: {
113
+ maxLength: 255,
114
+ minLength: 1
115
+ },
116
+ timezone: {
117
+ maxLength: 255,
118
+ minLength: 1
119
+ }
120
+ };
79
121
  export { validation_rules_gen_exports };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scaleway/sdk-jobs",
3
- "version": "2.3.0",
3
+ "version": "2.4.0",
4
4
  "description": "Scaleway SDK jobs",
5
5
  "license": "Apache-2.0",
6
6
  "files": [
@@ -27,13 +27,13 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "@scaleway/random-name": "5.1.2",
30
- "@scaleway/sdk-std": "2.2.0"
30
+ "@scaleway/sdk-std": "2.2.1"
31
31
  },
32
32
  "peerDependencies": {
33
- "@scaleway/sdk-client": "^2.2.0"
33
+ "@scaleway/sdk-client": "^2.2.1"
34
34
  },
35
35
  "devDependencies": {
36
- "@scaleway/sdk-client": "^2.2.0"
36
+ "@scaleway/sdk-client": "^2.2.1"
37
37
  },
38
38
  "scripts": {
39
39
  "package:check": "pnpm publint",