@scaleway/sdk-jobs 1.0.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,272 @@
1
+ import { API as API$1, validatePathParam, urlParams, enrichForPagination } from "@scaleway/sdk-client";
2
+ import { marshalCreateJobDefinitionRequest, unmarshalJobDefinition, unmarshalListJobDefinitionsResponse, marshalUpdateJobDefinitionRequest, marshalStartJobDefinitionRequest, unmarshalStartJobDefinitionResponse, marshalCreateJobDefinitionSecretsRequest, unmarshalCreateJobDefinitionSecretsResponse, unmarshalSecret, unmarshalListJobDefinitionSecretsResponse, marshalUpdateJobDefinitionSecretRequest, unmarshalJobRun, unmarshalListJobRunsResponse, unmarshalListJobsResourcesResponse, unmarshalJobsLimits } from "./marshalling.gen.js";
3
+ const jsonContentHeaders = {
4
+ "Content-Type": "application/json; charset=utf-8"
5
+ };
6
+ class API extends API$1 {
7
+ /** Lists the available regions of the API. */
8
+ static LOCALITIES = [
9
+ "fr-par",
10
+ "nl-ams",
11
+ "pl-waw"
12
+ ];
13
+ /**
14
+ * Create a new job definition in a specified Project.
15
+ *
16
+ * @param request - The request {@link CreateJobDefinitionRequest}
17
+ * @returns A Promise of JobDefinition
18
+ */
19
+ createJobDefinition = (request) => this.client.fetch(
20
+ {
21
+ body: JSON.stringify(
22
+ marshalCreateJobDefinitionRequest(request, this.client.settings)
23
+ ),
24
+ headers: jsonContentHeaders,
25
+ method: "POST",
26
+ path: `/serverless-jobs/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/job-definitions`
27
+ },
28
+ unmarshalJobDefinition
29
+ );
30
+ /**
31
+ * Get a job definition by its unique identifier.
32
+ *
33
+ * @param request - The request {@link GetJobDefinitionRequest}
34
+ * @returns A Promise of JobDefinition
35
+ */
36
+ getJobDefinition = (request) => this.client.fetch(
37
+ {
38
+ method: "GET",
39
+ path: `/serverless-jobs/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/job-definitions/${validatePathParam("jobDefinitionId", request.jobDefinitionId)}`
40
+ },
41
+ unmarshalJobDefinition
42
+ );
43
+ pageOfListJobDefinitions = (request = {}) => this.client.fetch(
44
+ {
45
+ method: "GET",
46
+ path: `/serverless-jobs/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/job-definitions`,
47
+ urlParams: urlParams(
48
+ ["order_by", request.orderBy],
49
+ ["organization_id", request.organizationId],
50
+ ["page", request.page],
51
+ [
52
+ "page_size",
53
+ request.pageSize ?? this.client.settings.defaultPageSize
54
+ ],
55
+ ["project_id", request.projectId]
56
+ )
57
+ },
58
+ unmarshalListJobDefinitionsResponse
59
+ );
60
+ /**
61
+ * List all your job definitions with filters.
62
+ *
63
+ * @param request - The request {@link ListJobDefinitionsRequest}
64
+ * @returns A Promise of ListJobDefinitionsResponse
65
+ */
66
+ listJobDefinitions = (request = {}) => enrichForPagination(
67
+ "jobDefinitions",
68
+ this.pageOfListJobDefinitions,
69
+ request
70
+ );
71
+ /**
72
+ * Update an existing job definition associated with the specified unique identifier.
73
+ *
74
+ * @param request - The request {@link UpdateJobDefinitionRequest}
75
+ * @returns A Promise of JobDefinition
76
+ */
77
+ updateJobDefinition = (request) => this.client.fetch(
78
+ {
79
+ body: JSON.stringify(
80
+ marshalUpdateJobDefinitionRequest(request, this.client.settings)
81
+ ),
82
+ headers: jsonContentHeaders,
83
+ method: "PATCH",
84
+ path: `/serverless-jobs/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/job-definitions/${validatePathParam("jobDefinitionId", request.jobDefinitionId)}`
85
+ },
86
+ unmarshalJobDefinition
87
+ );
88
+ /**
89
+ * Delete an exsisting job definition by its unique identifier.
90
+ *
91
+ * @param request - The request {@link DeleteJobDefinitionRequest}
92
+ */
93
+ deleteJobDefinition = (request) => this.client.fetch({
94
+ method: "DELETE",
95
+ path: `/serverless-jobs/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/job-definitions/${validatePathParam("jobDefinitionId", request.jobDefinitionId)}`
96
+ });
97
+ /**
98
+ * Run an existing job definition by its unique identifier. This will create a new job run.
99
+ *
100
+ * @param request - The request {@link StartJobDefinitionRequest}
101
+ * @returns A Promise of StartJobDefinitionResponse
102
+ */
103
+ startJobDefinition = (request) => this.client.fetch(
104
+ {
105
+ body: JSON.stringify(
106
+ marshalStartJobDefinitionRequest(request, this.client.settings)
107
+ ),
108
+ headers: jsonContentHeaders,
109
+ method: "POST",
110
+ path: `/serverless-jobs/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/job-definitions/${validatePathParam("jobDefinitionId", request.jobDefinitionId)}/start`
111
+ },
112
+ unmarshalStartJobDefinitionResponse
113
+ );
114
+ /**
115
+ * Create a secret reference within a job definition.
116
+ *
117
+ * @param request - The request {@link CreateJobDefinitionSecretsRequest}
118
+ * @returns A Promise of CreateJobDefinitionSecretsResponse
119
+ */
120
+ createJobDefinitionSecrets = (request) => this.client.fetch(
121
+ {
122
+ body: JSON.stringify(
123
+ marshalCreateJobDefinitionSecretsRequest(
124
+ request,
125
+ this.client.settings
126
+ )
127
+ ),
128
+ headers: jsonContentHeaders,
129
+ method: "POST",
130
+ path: `/serverless-jobs/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/job-definitions/${validatePathParam("jobDefinitionId", request.jobDefinitionId)}/secrets`
131
+ },
132
+ unmarshalCreateJobDefinitionSecretsResponse
133
+ );
134
+ /**
135
+ * Get a secret references within a job definition.
136
+ *
137
+ * @param request - The request {@link GetJobDefinitionSecretRequest}
138
+ * @returns A Promise of Secret
139
+ */
140
+ getJobDefinitionSecret = (request) => this.client.fetch(
141
+ {
142
+ method: "GET",
143
+ path: `/serverless-jobs/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/job-definitions/${validatePathParam("jobDefinitionId", request.jobDefinitionId)}/secrets/${validatePathParam("secretId", request.secretId)}`
144
+ },
145
+ unmarshalSecret
146
+ );
147
+ /**
148
+ * List secrets references within a job definition.
149
+ *
150
+ * @param request - The request {@link ListJobDefinitionSecretsRequest}
151
+ * @returns A Promise of ListJobDefinitionSecretsResponse
152
+ */
153
+ listJobDefinitionSecrets = (request) => this.client.fetch(
154
+ {
155
+ method: "GET",
156
+ path: `/serverless-jobs/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/job-definitions/${validatePathParam("jobDefinitionId", request.jobDefinitionId)}/secrets`
157
+ },
158
+ unmarshalListJobDefinitionSecretsResponse
159
+ );
160
+ /**
161
+ * Update a secret reference within a job definition.
162
+ *
163
+ * @param request - The request {@link UpdateJobDefinitionSecretRequest}
164
+ * @returns A Promise of Secret
165
+ */
166
+ updateJobDefinitionSecret = (request) => this.client.fetch(
167
+ {
168
+ body: JSON.stringify(
169
+ marshalUpdateJobDefinitionSecretRequest(
170
+ request,
171
+ this.client.settings
172
+ )
173
+ ),
174
+ headers: jsonContentHeaders,
175
+ method: "PATCH",
176
+ path: `/serverless-jobs/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/job-definitions/${validatePathParam("jobDefinitionId", request.jobDefinitionId)}/secrets/${validatePathParam("secretId", request.secretId)}`
177
+ },
178
+ unmarshalSecret
179
+ );
180
+ /**
181
+ * Delete a secret reference within a job definition.
182
+ *
183
+ * @param request - The request {@link DeleteJobDefinitionSecretRequest}
184
+ */
185
+ deleteJobDefinitionSecret = (request) => this.client.fetch({
186
+ method: "DELETE",
187
+ path: `/serverless-jobs/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/job-definitions/${validatePathParam("jobDefinitionId", request.jobDefinitionId)}/secrets/${validatePathParam("secretId", request.secretId)}`
188
+ });
189
+ /**
190
+ * Get a job run by its unique identifier.
191
+ *
192
+ * @param request - The request {@link GetJobRunRequest}
193
+ * @returns A Promise of JobRun
194
+ */
195
+ getJobRun = (request) => this.client.fetch(
196
+ {
197
+ method: "GET",
198
+ path: `/serverless-jobs/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/job-runs/${validatePathParam("jobRunId", request.jobRunId)}`
199
+ },
200
+ unmarshalJobRun
201
+ );
202
+ /**
203
+ * Stop a job run by its unique identifier.
204
+ *
205
+ * @param request - The request {@link StopJobRunRequest}
206
+ * @returns A Promise of JobRun
207
+ */
208
+ stopJobRun = (request) => this.client.fetch(
209
+ {
210
+ body: "{}",
211
+ headers: jsonContentHeaders,
212
+ method: "POST",
213
+ path: `/serverless-jobs/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/job-runs/${validatePathParam("jobRunId", request.jobRunId)}/stop`
214
+ },
215
+ unmarshalJobRun
216
+ );
217
+ pageOfListJobRuns = (request = {}) => this.client.fetch(
218
+ {
219
+ method: "GET",
220
+ path: `/serverless-jobs/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/job-runs`,
221
+ urlParams: urlParams(
222
+ ["job_definition_id", request.jobDefinitionId],
223
+ ["order_by", request.orderBy],
224
+ ["organization_id", request.organizationId],
225
+ ["page", request.page],
226
+ [
227
+ "page_size",
228
+ request.pageSize ?? this.client.settings.defaultPageSize
229
+ ],
230
+ ["project_id", request.projectId],
231
+ ["state", request.state]
232
+ )
233
+ },
234
+ unmarshalListJobRunsResponse
235
+ );
236
+ /**
237
+ * List all job runs with filters.
238
+ *
239
+ * @param request - The request {@link ListJobRunsRequest}
240
+ * @returns A Promise of ListJobRunsResponse
241
+ */
242
+ listJobRuns = (request = {}) => enrichForPagination("jobRuns", this.pageOfListJobRuns, request);
243
+ /**
244
+ * List jobs resources for the console.
245
+ *
246
+ * @param request - The request {@link ListJobsResourcesRequest}
247
+ * @returns A Promise of ListJobsResourcesResponse
248
+ */
249
+ listJobsResources = (request = {}) => this.client.fetch(
250
+ {
251
+ method: "GET",
252
+ path: `/serverless-jobs/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/jobs-resources`
253
+ },
254
+ unmarshalListJobsResourcesResponse
255
+ );
256
+ /**
257
+ * Get jobs limits for the console.
258
+ *
259
+ * @param request - The request {@link GetJobsLimitsRequest}
260
+ * @returns A Promise of JobsLimits
261
+ */
262
+ getJobsLimits = (request = {}) => this.client.fetch(
263
+ {
264
+ method: "GET",
265
+ path: `/serverless-jobs/v1alpha1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/jobs-limits`
266
+ },
267
+ unmarshalJobsLimits
268
+ );
269
+ }
270
+ export {
271
+ API
272
+ };
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const JOB_RUN_TRANSIENT_STATUSES = [
4
+ "queued",
5
+ "scheduled",
6
+ "running"
7
+ ];
8
+ exports.JOB_RUN_TRANSIENT_STATUSES = JOB_RUN_TRANSIENT_STATUSES;
@@ -0,0 +1,3 @@
1
+ import type { JobRunState } from './types.gen';
2
+ /** Lists transient statutes of the enum {@link JobRunState}. */
3
+ export declare const JOB_RUN_TRANSIENT_STATUSES: JobRunState[];
@@ -0,0 +1,8 @@
1
+ const JOB_RUN_TRANSIENT_STATUSES = [
2
+ "queued",
3
+ "scheduled",
4
+ "running"
5
+ ];
6
+ export {
7
+ JOB_RUN_TRANSIENT_STATUSES
8
+ };
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const api_gen = require("./api.gen.cjs");
4
+ const content_gen = require("./content.gen.cjs");
5
+ const marshalling_gen = require("./marshalling.gen.cjs");
6
+ const validationRules_gen = require("./validation-rules.gen.cjs");
7
+ exports.API = api_gen.API;
8
+ exports.JOB_RUN_TRANSIENT_STATUSES = content_gen.JOB_RUN_TRANSIENT_STATUSES;
9
+ exports.marshalCreateJobDefinitionRequest = marshalling_gen.marshalCreateJobDefinitionRequest;
10
+ exports.marshalCreateJobDefinitionSecretsRequest = marshalling_gen.marshalCreateJobDefinitionSecretsRequest;
11
+ exports.marshalStartJobDefinitionRequest = marshalling_gen.marshalStartJobDefinitionRequest;
12
+ exports.marshalUpdateJobDefinitionRequest = marshalling_gen.marshalUpdateJobDefinitionRequest;
13
+ exports.marshalUpdateJobDefinitionSecretRequest = marshalling_gen.marshalUpdateJobDefinitionSecretRequest;
14
+ exports.unmarshalCreateJobDefinitionSecretsResponse = marshalling_gen.unmarshalCreateJobDefinitionSecretsResponse;
15
+ exports.unmarshalJobDefinition = marshalling_gen.unmarshalJobDefinition;
16
+ exports.unmarshalJobRun = marshalling_gen.unmarshalJobRun;
17
+ exports.unmarshalJobsLimits = marshalling_gen.unmarshalJobsLimits;
18
+ exports.unmarshalListJobDefinitionSecretsResponse = marshalling_gen.unmarshalListJobDefinitionSecretsResponse;
19
+ exports.unmarshalListJobDefinitionsResponse = marshalling_gen.unmarshalListJobDefinitionsResponse;
20
+ exports.unmarshalListJobRunsResponse = marshalling_gen.unmarshalListJobRunsResponse;
21
+ exports.unmarshalListJobsResourcesResponse = marshalling_gen.unmarshalListJobsResourcesResponse;
22
+ exports.unmarshalSecret = marshalling_gen.unmarshalSecret;
23
+ exports.unmarshalStartJobDefinitionResponse = marshalling_gen.unmarshalStartJobDefinitionResponse;
24
+ exports.ValidationRules = validationRules_gen;
@@ -0,0 +1,5 @@
1
+ export { API } from './api.gen';
2
+ export * from './content.gen';
3
+ export * from './marshalling.gen';
4
+ export type { CreateJobDefinitionRequest, CreateJobDefinitionRequestCronScheduleConfig, CreateJobDefinitionSecretsRequest, CreateJobDefinitionSecretsRequestSecretConfig, CreateJobDefinitionSecretsResponse, CronSchedule, DeleteJobDefinitionRequest, DeleteJobDefinitionSecretRequest, GetJobDefinitionRequest, GetJobDefinitionSecretRequest, GetJobRunRequest, GetJobsLimitsRequest, JobDefinition, JobRun, JobRunState, JobsLimits, ListJobDefinitionSecretsRequest, ListJobDefinitionSecretsResponse, ListJobDefinitionsRequest, ListJobDefinitionsRequestOrderBy, ListJobDefinitionsResponse, ListJobRunsRequest, ListJobRunsRequestOrderBy, ListJobRunsResponse, ListJobsResourcesRequest, ListJobsResourcesResponse, Resource, Secret, SecretEnvVar, SecretFile, StartJobDefinitionRequest, StartJobDefinitionResponse, StopJobRunRequest, UpdateJobDefinitionRequest, UpdateJobDefinitionRequestCronScheduleConfig, UpdateJobDefinitionSecretRequest, } from './types.gen';
5
+ export * as ValidationRules from './validation-rules.gen';
@@ -0,0 +1,24 @@
1
+ import { API } from "./api.gen.js";
2
+ import { JOB_RUN_TRANSIENT_STATUSES } from "./content.gen.js";
3
+ import { marshalCreateJobDefinitionRequest, marshalCreateJobDefinitionSecretsRequest, marshalStartJobDefinitionRequest, marshalUpdateJobDefinitionRequest, marshalUpdateJobDefinitionSecretRequest, unmarshalCreateJobDefinitionSecretsResponse, unmarshalJobDefinition, unmarshalJobRun, unmarshalJobsLimits, unmarshalListJobDefinitionSecretsResponse, unmarshalListJobDefinitionsResponse, unmarshalListJobRunsResponse, unmarshalListJobsResourcesResponse, unmarshalSecret, unmarshalStartJobDefinitionResponse } from "./marshalling.gen.js";
4
+ import * as validationRules_gen from "./validation-rules.gen.js";
5
+ export {
6
+ API,
7
+ JOB_RUN_TRANSIENT_STATUSES,
8
+ validationRules_gen as ValidationRules,
9
+ marshalCreateJobDefinitionRequest,
10
+ marshalCreateJobDefinitionSecretsRequest,
11
+ marshalStartJobDefinitionRequest,
12
+ marshalUpdateJobDefinitionRequest,
13
+ marshalUpdateJobDefinitionSecretRequest,
14
+ unmarshalCreateJobDefinitionSecretsResponse,
15
+ unmarshalJobDefinition,
16
+ unmarshalJobRun,
17
+ unmarshalJobsLimits,
18
+ unmarshalListJobDefinitionSecretsResponse,
19
+ unmarshalListJobDefinitionsResponse,
20
+ unmarshalListJobRunsResponse,
21
+ unmarshalListJobsResourcesResponse,
22
+ unmarshalSecret,
23
+ unmarshalStartJobDefinitionResponse
24
+ };
@@ -0,0 +1,262 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const randomName = require("@scaleway/random-name");
4
+ const sdkClient = require("@scaleway/sdk-client");
5
+ const unmarshalSecretEnvVar = (data) => {
6
+ if (!sdkClient.isJSONObject(data)) {
7
+ throw new TypeError(
8
+ `Unmarshalling the type 'SecretEnvVar' failed as data isn't a dictionary.`
9
+ );
10
+ }
11
+ return {
12
+ name: data.name
13
+ };
14
+ };
15
+ const unmarshalSecretFile = (data) => {
16
+ if (!sdkClient.isJSONObject(data)) {
17
+ throw new TypeError(
18
+ `Unmarshalling the type 'SecretFile' failed as data isn't a dictionary.`
19
+ );
20
+ }
21
+ return {
22
+ path: data.path
23
+ };
24
+ };
25
+ const unmarshalSecret = (data) => {
26
+ if (!sdkClient.isJSONObject(data)) {
27
+ throw new TypeError(
28
+ `Unmarshalling the type 'Secret' failed as data isn't a dictionary.`
29
+ );
30
+ }
31
+ return {
32
+ envVar: data.env_var ? unmarshalSecretEnvVar(data.env_var) : void 0,
33
+ file: data.file ? unmarshalSecretFile(data.file) : void 0,
34
+ secretId: data.secret_id,
35
+ secretManagerId: data.secret_manager_id,
36
+ secretManagerVersion: data.secret_manager_version
37
+ };
38
+ };
39
+ const unmarshalCronSchedule = (data) => {
40
+ if (!sdkClient.isJSONObject(data)) {
41
+ throw new TypeError(
42
+ `Unmarshalling the type 'CronSchedule' failed as data isn't a dictionary.`
43
+ );
44
+ }
45
+ return {
46
+ schedule: data.schedule,
47
+ timezone: data.timezone
48
+ };
49
+ };
50
+ const unmarshalJobDefinition = (data) => {
51
+ if (!sdkClient.isJSONObject(data)) {
52
+ throw new TypeError(
53
+ `Unmarshalling the type 'JobDefinition' failed as data isn't a dictionary.`
54
+ );
55
+ }
56
+ return {
57
+ command: data.command,
58
+ cpuLimit: data.cpu_limit,
59
+ createdAt: sdkClient.unmarshalDate(data.created_at),
60
+ cronSchedule: data.cron_schedule ? unmarshalCronSchedule(data.cron_schedule) : void 0,
61
+ description: data.description,
62
+ environmentVariables: data.environment_variables,
63
+ id: data.id,
64
+ imageUri: data.image_uri,
65
+ jobTimeout: data.job_timeout,
66
+ localStorageCapacity: data.local_storage_capacity,
67
+ memoryLimit: data.memory_limit,
68
+ name: data.name,
69
+ projectId: data.project_id,
70
+ region: data.region,
71
+ updatedAt: sdkClient.unmarshalDate(data.updated_at)
72
+ };
73
+ };
74
+ const unmarshalJobRun = (data) => {
75
+ if (!sdkClient.isJSONObject(data)) {
76
+ throw new TypeError(
77
+ `Unmarshalling the type 'JobRun' failed as data isn't a dictionary.`
78
+ );
79
+ }
80
+ return {
81
+ command: data.command,
82
+ cpuLimit: data.cpu_limit,
83
+ createdAt: sdkClient.unmarshalDate(data.created_at),
84
+ environmentVariables: data.environment_variables,
85
+ errorMessage: data.error_message,
86
+ exitCode: data.exit_code,
87
+ id: data.id,
88
+ jobDefinitionId: data.job_definition_id,
89
+ localStorageCapacity: data.local_storage_capacity,
90
+ memoryLimit: data.memory_limit,
91
+ region: data.region,
92
+ runDuration: data.run_duration,
93
+ startedAt: sdkClient.unmarshalDate(data.started_at),
94
+ state: data.state,
95
+ terminatedAt: sdkClient.unmarshalDate(data.terminated_at),
96
+ updatedAt: sdkClient.unmarshalDate(data.updated_at)
97
+ };
98
+ };
99
+ const unmarshalCreateJobDefinitionSecretsResponse = (data) => {
100
+ if (!sdkClient.isJSONObject(data)) {
101
+ throw new TypeError(
102
+ `Unmarshalling the type 'CreateJobDefinitionSecretsResponse' failed as data isn't a dictionary.`
103
+ );
104
+ }
105
+ return {
106
+ secrets: sdkClient.unmarshalArrayOfObject(data.secrets, unmarshalSecret)
107
+ };
108
+ };
109
+ const unmarshalJobsLimits = (data) => {
110
+ if (!sdkClient.isJSONObject(data)) {
111
+ throw new TypeError(
112
+ `Unmarshalling the type 'JobsLimits' failed as data isn't a dictionary.`
113
+ );
114
+ }
115
+ return {
116
+ secretsPerJobDefinition: data.secrets_per_job_definition
117
+ };
118
+ };
119
+ const unmarshalListJobDefinitionSecretsResponse = (data) => {
120
+ if (!sdkClient.isJSONObject(data)) {
121
+ throw new TypeError(
122
+ `Unmarshalling the type 'ListJobDefinitionSecretsResponse' failed as data isn't a dictionary.`
123
+ );
124
+ }
125
+ return {
126
+ secrets: sdkClient.unmarshalArrayOfObject(data.secrets, unmarshalSecret),
127
+ totalCount: data.total_count
128
+ };
129
+ };
130
+ const unmarshalListJobDefinitionsResponse = (data) => {
131
+ if (!sdkClient.isJSONObject(data)) {
132
+ throw new TypeError(
133
+ `Unmarshalling the type 'ListJobDefinitionsResponse' failed as data isn't a dictionary.`
134
+ );
135
+ }
136
+ return {
137
+ jobDefinitions: sdkClient.unmarshalArrayOfObject(
138
+ data.job_definitions,
139
+ unmarshalJobDefinition
140
+ ),
141
+ totalCount: data.total_count
142
+ };
143
+ };
144
+ const unmarshalListJobRunsResponse = (data) => {
145
+ if (!sdkClient.isJSONObject(data)) {
146
+ throw new TypeError(
147
+ `Unmarshalling the type 'ListJobRunsResponse' failed as data isn't a dictionary.`
148
+ );
149
+ }
150
+ return {
151
+ jobRuns: sdkClient.unmarshalArrayOfObject(data.job_runs, unmarshalJobRun),
152
+ totalCount: data.total_count
153
+ };
154
+ };
155
+ const unmarshalResource = (data) => {
156
+ if (!sdkClient.isJSONObject(data)) {
157
+ throw new TypeError(
158
+ `Unmarshalling the type 'Resource' failed as data isn't a dictionary.`
159
+ );
160
+ }
161
+ return {
162
+ cpuLimit: data.cpu_limit,
163
+ memoryLimit: data.memory_limit
164
+ };
165
+ };
166
+ const unmarshalListJobsResourcesResponse = (data) => {
167
+ if (!sdkClient.isJSONObject(data)) {
168
+ throw new TypeError(
169
+ `Unmarshalling the type 'ListJobsResourcesResponse' failed as data isn't a dictionary.`
170
+ );
171
+ }
172
+ return {
173
+ resources: sdkClient.unmarshalArrayOfObject(data.resources, unmarshalResource)
174
+ };
175
+ };
176
+ const unmarshalStartJobDefinitionResponse = (data) => {
177
+ if (!sdkClient.isJSONObject(data)) {
178
+ throw new TypeError(
179
+ `Unmarshalling the type 'StartJobDefinitionResponse' failed as data isn't a dictionary.`
180
+ );
181
+ }
182
+ return {
183
+ jobRuns: sdkClient.unmarshalArrayOfObject(data.job_runs, unmarshalJobRun)
184
+ };
185
+ };
186
+ const marshalCreateJobDefinitionRequestCronScheduleConfig = (request, defaults) => ({
187
+ schedule: request.schedule,
188
+ timezone: request.timezone
189
+ });
190
+ const marshalCreateJobDefinitionRequest = (request, defaults) => ({
191
+ command: request.command,
192
+ cpu_limit: request.cpuLimit,
193
+ cron_schedule: request.cronSchedule !== void 0 ? marshalCreateJobDefinitionRequestCronScheduleConfig(
194
+ request.cronSchedule
195
+ ) : void 0,
196
+ description: request.description,
197
+ environment_variables: request.environmentVariables !== void 0 ? request.environmentVariables : void 0,
198
+ image_uri: request.imageUri,
199
+ job_timeout: request.jobTimeout,
200
+ local_storage_capacity: request.localStorageCapacity,
201
+ memory_limit: request.memoryLimit,
202
+ name: request.name || randomName("job"),
203
+ project_id: request.projectId ?? defaults.defaultProjectId
204
+ });
205
+ const marshalCreateJobDefinitionSecretsRequestSecretConfig = (request, defaults) => ({
206
+ secret_manager_id: request.secretManagerId,
207
+ secret_manager_version: request.secretManagerVersion,
208
+ ...sdkClient.resolveOneOf([
209
+ { param: "path", value: request.path },
210
+ { param: "env_var_name", value: request.envVarName }
211
+ ])
212
+ });
213
+ const marshalCreateJobDefinitionSecretsRequest = (request, defaults) => ({
214
+ secrets: request.secrets.map(
215
+ (elt) => marshalCreateJobDefinitionSecretsRequestSecretConfig(elt)
216
+ )
217
+ });
218
+ const marshalStartJobDefinitionRequest = (request, defaults) => ({
219
+ command: request.command,
220
+ environment_variables: request.environmentVariables,
221
+ replicas: request.replicas
222
+ });
223
+ const marshalUpdateJobDefinitionRequestCronScheduleConfig = (request, defaults) => ({
224
+ schedule: request.schedule,
225
+ timezone: request.timezone
226
+ });
227
+ const marshalUpdateJobDefinitionRequest = (request, defaults) => ({
228
+ command: request.command,
229
+ cpu_limit: request.cpuLimit,
230
+ cron_schedule: request.cronSchedule !== void 0 ? marshalUpdateJobDefinitionRequestCronScheduleConfig(
231
+ request.cronSchedule
232
+ ) : void 0,
233
+ description: request.description,
234
+ environment_variables: request.environmentVariables,
235
+ image_uri: request.imageUri,
236
+ job_timeout: request.jobTimeout,
237
+ local_storage_capacity: request.localStorageCapacity,
238
+ memory_limit: request.memoryLimit,
239
+ name: request.name
240
+ });
241
+ const marshalUpdateJobDefinitionSecretRequest = (request, defaults) => ({
242
+ secret_manager_version: request.secretManagerVersion,
243
+ ...sdkClient.resolveOneOf([
244
+ { param: "path", value: request.path },
245
+ { param: "env_var_name", value: request.envVarName }
246
+ ])
247
+ });
248
+ exports.marshalCreateJobDefinitionRequest = marshalCreateJobDefinitionRequest;
249
+ exports.marshalCreateJobDefinitionSecretsRequest = marshalCreateJobDefinitionSecretsRequest;
250
+ exports.marshalStartJobDefinitionRequest = marshalStartJobDefinitionRequest;
251
+ exports.marshalUpdateJobDefinitionRequest = marshalUpdateJobDefinitionRequest;
252
+ exports.marshalUpdateJobDefinitionSecretRequest = marshalUpdateJobDefinitionSecretRequest;
253
+ exports.unmarshalCreateJobDefinitionSecretsResponse = unmarshalCreateJobDefinitionSecretsResponse;
254
+ exports.unmarshalJobDefinition = unmarshalJobDefinition;
255
+ exports.unmarshalJobRun = unmarshalJobRun;
256
+ exports.unmarshalJobsLimits = unmarshalJobsLimits;
257
+ exports.unmarshalListJobDefinitionSecretsResponse = unmarshalListJobDefinitionSecretsResponse;
258
+ exports.unmarshalListJobDefinitionsResponse = unmarshalListJobDefinitionsResponse;
259
+ exports.unmarshalListJobRunsResponse = unmarshalListJobRunsResponse;
260
+ exports.unmarshalListJobsResourcesResponse = unmarshalListJobsResourcesResponse;
261
+ exports.unmarshalSecret = unmarshalSecret;
262
+ exports.unmarshalStartJobDefinitionResponse = unmarshalStartJobDefinitionResponse;
@@ -0,0 +1,17 @@
1
+ import type { DefaultValues } from '@scaleway/sdk-client';
2
+ import type { CreateJobDefinitionRequest, CreateJobDefinitionSecretsRequest, CreateJobDefinitionSecretsResponse, JobDefinition, JobRun, JobsLimits, ListJobDefinitionSecretsResponse, ListJobDefinitionsResponse, ListJobRunsResponse, ListJobsResourcesResponse, Secret, StartJobDefinitionRequest, StartJobDefinitionResponse, UpdateJobDefinitionRequest, UpdateJobDefinitionSecretRequest } from './types.gen';
3
+ export declare const unmarshalSecret: (data: unknown) => Secret;
4
+ export declare const unmarshalJobDefinition: (data: unknown) => JobDefinition;
5
+ export declare const unmarshalJobRun: (data: unknown) => JobRun;
6
+ export declare const unmarshalCreateJobDefinitionSecretsResponse: (data: unknown) => CreateJobDefinitionSecretsResponse;
7
+ export declare const unmarshalJobsLimits: (data: unknown) => JobsLimits;
8
+ export declare const unmarshalListJobDefinitionSecretsResponse: (data: unknown) => ListJobDefinitionSecretsResponse;
9
+ export declare const unmarshalListJobDefinitionsResponse: (data: unknown) => ListJobDefinitionsResponse;
10
+ export declare const unmarshalListJobRunsResponse: (data: unknown) => ListJobRunsResponse;
11
+ export declare const unmarshalListJobsResourcesResponse: (data: unknown) => ListJobsResourcesResponse;
12
+ export declare const unmarshalStartJobDefinitionResponse: (data: unknown) => StartJobDefinitionResponse;
13
+ export declare const marshalCreateJobDefinitionRequest: (request: CreateJobDefinitionRequest, defaults: DefaultValues) => Record<string, unknown>;
14
+ export declare const marshalCreateJobDefinitionSecretsRequest: (request: CreateJobDefinitionSecretsRequest, defaults: DefaultValues) => Record<string, unknown>;
15
+ export declare const marshalStartJobDefinitionRequest: (request: StartJobDefinitionRequest, defaults: DefaultValues) => Record<string, unknown>;
16
+ export declare const marshalUpdateJobDefinitionRequest: (request: UpdateJobDefinitionRequest, defaults: DefaultValues) => Record<string, unknown>;
17
+ export declare const marshalUpdateJobDefinitionSecretRequest: (request: UpdateJobDefinitionSecretRequest, defaults: DefaultValues) => Record<string, unknown>;