@scaleway/sdk-autoscaling 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,373 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const sdkClient = require("@scaleway/sdk-client");
4
+ const unmarshalCapacity = (data) => {
5
+ if (!sdkClient.isJSONObject(data)) {
6
+ throw new TypeError(
7
+ `Unmarshalling the type 'Capacity' failed as data isn't a dictionary.`
8
+ );
9
+ }
10
+ return {
11
+ cooldownDelay: data.cooldown_delay,
12
+ maxReplicas: data.max_replicas,
13
+ minReplicas: data.min_replicas
14
+ };
15
+ };
16
+ const unmarshalLoadbalancer = (data) => {
17
+ if (!sdkClient.isJSONObject(data)) {
18
+ throw new TypeError(
19
+ `Unmarshalling the type 'Loadbalancer' failed as data isn't a dictionary.`
20
+ );
21
+ }
22
+ return {
23
+ backendIds: data.backend_ids,
24
+ id: data.id,
25
+ privateNetworkId: data.private_network_id
26
+ };
27
+ };
28
+ const unmarshalInstanceGroup = (data) => {
29
+ if (!sdkClient.isJSONObject(data)) {
30
+ throw new TypeError(
31
+ `Unmarshalling the type 'InstanceGroup' failed as data isn't a dictionary.`
32
+ );
33
+ }
34
+ return {
35
+ capacity: unmarshalCapacity(data.capacity),
36
+ createdAt: sdkClient.unmarshalDate(data.created_at),
37
+ errorMessages: data.error_messages,
38
+ id: data.id,
39
+ instanceTemplateId: data.instance_template_id,
40
+ loadbalancer: unmarshalLoadbalancer(data.loadbalancer),
41
+ name: data.name,
42
+ projectId: data.project_id,
43
+ tags: data.tags,
44
+ updatedAt: sdkClient.unmarshalDate(data.updated_at)
45
+ };
46
+ };
47
+ const unmarshalMetric = (data) => {
48
+ if (!sdkClient.isJSONObject(data)) {
49
+ throw new TypeError(
50
+ `Unmarshalling the type 'Metric' failed as data isn't a dictionary.`
51
+ );
52
+ }
53
+ return {
54
+ aggregate: data.aggregate,
55
+ cockpitMetricName: data.cockpit_metric_name,
56
+ managedMetric: data.managed_metric ? data.managed_metric : void 0,
57
+ name: data.name,
58
+ operator: data.operator,
59
+ samplingRangeMin: data.sampling_range_min,
60
+ threshold: data.threshold
61
+ };
62
+ };
63
+ const unmarshalInstancePolicy = (data) => {
64
+ if (!sdkClient.isJSONObject(data)) {
65
+ throw new TypeError(
66
+ `Unmarshalling the type 'InstancePolicy' failed as data isn't a dictionary.`
67
+ );
68
+ }
69
+ return {
70
+ action: data.action,
71
+ id: data.id,
72
+ instanceGroupId: data.instance_group_id,
73
+ metric: data.metric ? unmarshalMetric(data.metric) : void 0,
74
+ name: data.name,
75
+ priority: data.priority,
76
+ type: data.type,
77
+ value: data.value
78
+ };
79
+ };
80
+ const unmarshalVolumeInstanceTemplateFromEmpty = (data) => {
81
+ if (!sdkClient.isJSONObject(data)) {
82
+ throw new TypeError(
83
+ `Unmarshalling the type 'VolumeInstanceTemplateFromEmpty' failed as data isn't a dictionary.`
84
+ );
85
+ }
86
+ return {
87
+ size: data.size
88
+ };
89
+ };
90
+ const unmarshalVolumeInstanceTemplateFromSnapshot = (data) => {
91
+ if (!sdkClient.isJSONObject(data)) {
92
+ throw new TypeError(
93
+ `Unmarshalling the type 'VolumeInstanceTemplateFromSnapshot' failed as data isn't a dictionary.`
94
+ );
95
+ }
96
+ return {
97
+ size: data.size,
98
+ snapshotId: data.snapshot_id
99
+ };
100
+ };
101
+ const unmarshalVolumeInstanceTemplate = (data) => {
102
+ if (!sdkClient.isJSONObject(data)) {
103
+ throw new TypeError(
104
+ `Unmarshalling the type 'VolumeInstanceTemplate' failed as data isn't a dictionary.`
105
+ );
106
+ }
107
+ return {
108
+ boot: data.boot,
109
+ fromEmpty: data.from_empty ? unmarshalVolumeInstanceTemplateFromEmpty(data.from_empty) : void 0,
110
+ fromSnapshot: data.from_snapshot ? unmarshalVolumeInstanceTemplateFromSnapshot(data.from_snapshot) : void 0,
111
+ name: data.name,
112
+ perfIops: data.perf_iops,
113
+ tags: data.tags,
114
+ volumeType: data.volume_type
115
+ };
116
+ };
117
+ const unmarshalInstanceTemplate = (data) => {
118
+ if (!sdkClient.isJSONObject(data)) {
119
+ throw new TypeError(
120
+ `Unmarshalling the type 'InstanceTemplate' failed as data isn't a dictionary.`
121
+ );
122
+ }
123
+ return {
124
+ cloudInit: data.cloud_init,
125
+ commercialType: data.commercial_type,
126
+ createdAt: sdkClient.unmarshalDate(data.created_at),
127
+ id: data.id,
128
+ imageId: data.image_id,
129
+ name: data.name,
130
+ placementGroupId: data.placement_group_id,
131
+ privateNetworkIds: data.private_network_ids,
132
+ projectId: data.project_id,
133
+ publicIpsV4Count: data.public_ips_v4_count,
134
+ publicIpsV6Count: data.public_ips_v6_count,
135
+ securityGroupId: data.security_group_id,
136
+ status: data.status,
137
+ tags: data.tags,
138
+ updatedAt: sdkClient.unmarshalDate(data.updated_at),
139
+ volumes: sdkClient.unmarshalMapOfObject(
140
+ data.volumes,
141
+ unmarshalVolumeInstanceTemplate
142
+ )
143
+ };
144
+ };
145
+ const unmarshalInstanceGroupEvent = (data) => {
146
+ if (!sdkClient.isJSONObject(data)) {
147
+ throw new TypeError(
148
+ `Unmarshalling the type 'InstanceGroupEvent' failed as data isn't a dictionary.`
149
+ );
150
+ }
151
+ return {
152
+ createdAt: sdkClient.unmarshalDate(data.created_at),
153
+ details: data.details,
154
+ id: data.id,
155
+ level: data.level,
156
+ name: data.name,
157
+ source: data.source
158
+ };
159
+ };
160
+ const unmarshalListInstanceGroupEventsResponse = (data) => {
161
+ if (!sdkClient.isJSONObject(data)) {
162
+ throw new TypeError(
163
+ `Unmarshalling the type 'ListInstanceGroupEventsResponse' failed as data isn't a dictionary.`
164
+ );
165
+ }
166
+ return {
167
+ instanceEvents: sdkClient.unmarshalArrayOfObject(
168
+ data.instance_events,
169
+ unmarshalInstanceGroupEvent
170
+ ),
171
+ totalCount: data.total_count
172
+ };
173
+ };
174
+ const unmarshalListInstanceGroupsResponse = (data) => {
175
+ if (!sdkClient.isJSONObject(data)) {
176
+ throw new TypeError(
177
+ `Unmarshalling the type 'ListInstanceGroupsResponse' failed as data isn't a dictionary.`
178
+ );
179
+ }
180
+ return {
181
+ instanceGroups: sdkClient.unmarshalArrayOfObject(
182
+ data.instance_groups,
183
+ unmarshalInstanceGroup
184
+ ),
185
+ totalCount: data.total_count
186
+ };
187
+ };
188
+ const unmarshalListInstancePoliciesResponse = (data) => {
189
+ if (!sdkClient.isJSONObject(data)) {
190
+ throw new TypeError(
191
+ `Unmarshalling the type 'ListInstancePoliciesResponse' failed as data isn't a dictionary.`
192
+ );
193
+ }
194
+ return {
195
+ policies: sdkClient.unmarshalArrayOfObject(data.policies, unmarshalInstancePolicy),
196
+ totalCount: data.total_count
197
+ };
198
+ };
199
+ const unmarshalListInstanceTemplatesResponse = (data) => {
200
+ if (!sdkClient.isJSONObject(data)) {
201
+ throw new TypeError(
202
+ `Unmarshalling the type 'ListInstanceTemplatesResponse' failed as data isn't a dictionary.`
203
+ );
204
+ }
205
+ return {
206
+ instanceTemplates: sdkClient.unmarshalArrayOfObject(
207
+ data.instance_templates,
208
+ unmarshalInstanceTemplate
209
+ ),
210
+ totalCount: data.total_count
211
+ };
212
+ };
213
+ const marshalCapacity = (request, defaults) => ({
214
+ cooldown_delay: request.cooldownDelay,
215
+ max_replicas: request.maxReplicas,
216
+ min_replicas: request.minReplicas
217
+ });
218
+ const marshalLoadbalancer = (request, defaults) => ({
219
+ backend_ids: request.backendIds,
220
+ id: request.id,
221
+ private_network_id: request.privateNetworkId
222
+ });
223
+ const marshalCreateInstanceGroupRequest = (request, defaults) => ({
224
+ capacity: marshalCapacity(request.capacity),
225
+ loadbalancer: marshalLoadbalancer(request.loadbalancer),
226
+ name: request.name,
227
+ project_id: request.projectId ?? defaults.defaultProjectId,
228
+ tags: request.tags,
229
+ template_id: request.templateId
230
+ });
231
+ const marshalMetric = (request, defaults) => ({
232
+ aggregate: request.aggregate,
233
+ name: request.name,
234
+ operator: request.operator,
235
+ sampling_range_min: request.samplingRangeMin,
236
+ threshold: request.threshold,
237
+ ...sdkClient.resolveOneOf([
238
+ { param: "managed_metric", value: request.managedMetric },
239
+ { param: "cockpit_metric_name", value: request.cockpitMetricName }
240
+ ])
241
+ });
242
+ const marshalCreateInstancePolicyRequest = (request, defaults) => ({
243
+ action: request.action,
244
+ instance_group_id: request.instanceGroupId,
245
+ name: request.name,
246
+ priority: request.priority,
247
+ type: request.type,
248
+ value: request.value,
249
+ ...sdkClient.resolveOneOf([
250
+ {
251
+ param: "metric",
252
+ value: request.metric !== void 0 ? marshalMetric(request.metric) : void 0
253
+ }
254
+ ])
255
+ });
256
+ const marshalVolumeInstanceTemplateFromEmpty = (request, defaults) => ({
257
+ size: request.size
258
+ });
259
+ const marshalVolumeInstanceTemplateFromSnapshot = (request, defaults) => ({
260
+ size: request.size,
261
+ snapshot_id: request.snapshotId
262
+ });
263
+ const marshalVolumeInstanceTemplate = (request, defaults) => ({
264
+ boot: request.boot,
265
+ name: request.name,
266
+ tags: request.tags,
267
+ volume_type: request.volumeType,
268
+ ...sdkClient.resolveOneOf([
269
+ {
270
+ param: "from_empty",
271
+ value: request.fromEmpty !== void 0 ? marshalVolumeInstanceTemplateFromEmpty(request.fromEmpty) : void 0
272
+ },
273
+ {
274
+ param: "from_snapshot",
275
+ value: request.fromSnapshot !== void 0 ? marshalVolumeInstanceTemplateFromSnapshot(
276
+ request.fromSnapshot
277
+ ) : void 0
278
+ }
279
+ ]),
280
+ ...sdkClient.resolveOneOf([{ param: "perf_iops", value: request.perfIops }])
281
+ });
282
+ const marshalCreateInstanceTemplateRequest = (request, defaults) => ({
283
+ cloud_init: request.cloudInit,
284
+ commercial_type: request.commercialType,
285
+ image_id: request.imageId,
286
+ name: request.name,
287
+ placement_group_id: request.placementGroupId,
288
+ private_network_ids: request.privateNetworkIds,
289
+ project_id: request.projectId ?? defaults.defaultProjectId,
290
+ public_ips_v4_count: request.publicIpsV4Count,
291
+ public_ips_v6_count: request.publicIpsV6Count,
292
+ security_group_id: request.securityGroupId,
293
+ tags: request.tags,
294
+ volumes: Object.entries(request.volumes).reduce(
295
+ (acc, [key, value]) => ({
296
+ ...acc,
297
+ [key]: marshalVolumeInstanceTemplate(value)
298
+ }),
299
+ {}
300
+ )
301
+ });
302
+ const marshalUpdateInstanceGroupRequestCapacity = (request, defaults) => ({
303
+ cooldown_delay: request.cooldownDelay,
304
+ max_replicas: request.maxReplicas,
305
+ min_replicas: request.minReplicas
306
+ });
307
+ const marshalUpdateInstanceGroupRequestLoadbalancer = (request, defaults) => ({
308
+ backend_ids: request.backendIds
309
+ });
310
+ const marshalUpdateInstanceGroupRequest = (request, defaults) => ({
311
+ capacity: request.capacity !== void 0 ? marshalUpdateInstanceGroupRequestCapacity(request.capacity) : void 0,
312
+ loadbalancer: request.loadbalancer !== void 0 ? marshalUpdateInstanceGroupRequestLoadbalancer(
313
+ request.loadbalancer
314
+ ) : void 0,
315
+ name: request.name,
316
+ tags: request.tags
317
+ });
318
+ const marshalUpdateInstancePolicyRequestMetric = (request, defaults) => ({
319
+ aggregate: request.aggregate,
320
+ name: request.name,
321
+ operator: request.operator,
322
+ sampling_range_min: request.samplingRangeMin,
323
+ threshold: request.threshold,
324
+ ...sdkClient.resolveOneOf([
325
+ { param: "managed_metric", value: request.managedMetric },
326
+ { param: "cockpit_metric_name", value: request.cockpitMetricName }
327
+ ])
328
+ });
329
+ const marshalUpdateInstancePolicyRequest = (request, defaults) => ({
330
+ action: request.action,
331
+ name: request.name,
332
+ priority: request.priority,
333
+ type: request.type,
334
+ value: request.value,
335
+ ...sdkClient.resolveOneOf([
336
+ {
337
+ param: "metric",
338
+ value: request.metric !== void 0 ? marshalUpdateInstancePolicyRequestMetric(request.metric) : void 0
339
+ }
340
+ ])
341
+ });
342
+ const marshalUpdateInstanceTemplateRequest = (request, defaults) => ({
343
+ cloud_init: request.cloudInit,
344
+ commercial_type: request.commercialType,
345
+ image_id: request.imageId,
346
+ name: request.name,
347
+ placement_group_id: request.placementGroupId,
348
+ private_network_ids: request.privateNetworkIds,
349
+ public_ips_v4_count: request.publicIpsV4Count,
350
+ public_ips_v6_count: request.publicIpsV6Count,
351
+ security_group_id: request.securityGroupId,
352
+ tags: request.tags,
353
+ volumes: request.volumes !== void 0 ? Object.entries(request.volumes).reduce(
354
+ (acc, [key, value]) => ({
355
+ ...acc,
356
+ [key]: marshalVolumeInstanceTemplate(value)
357
+ }),
358
+ {}
359
+ ) : void 0
360
+ });
361
+ exports.marshalCreateInstanceGroupRequest = marshalCreateInstanceGroupRequest;
362
+ exports.marshalCreateInstancePolicyRequest = marshalCreateInstancePolicyRequest;
363
+ exports.marshalCreateInstanceTemplateRequest = marshalCreateInstanceTemplateRequest;
364
+ exports.marshalUpdateInstanceGroupRequest = marshalUpdateInstanceGroupRequest;
365
+ exports.marshalUpdateInstancePolicyRequest = marshalUpdateInstancePolicyRequest;
366
+ exports.marshalUpdateInstanceTemplateRequest = marshalUpdateInstanceTemplateRequest;
367
+ exports.unmarshalInstanceGroup = unmarshalInstanceGroup;
368
+ exports.unmarshalInstancePolicy = unmarshalInstancePolicy;
369
+ exports.unmarshalInstanceTemplate = unmarshalInstanceTemplate;
370
+ exports.unmarshalListInstanceGroupEventsResponse = unmarshalListInstanceGroupEventsResponse;
371
+ exports.unmarshalListInstanceGroupsResponse = unmarshalListInstanceGroupsResponse;
372
+ exports.unmarshalListInstancePoliciesResponse = unmarshalListInstancePoliciesResponse;
373
+ exports.unmarshalListInstanceTemplatesResponse = unmarshalListInstanceTemplatesResponse;
@@ -0,0 +1,15 @@
1
+ import type { DefaultValues } from '@scaleway/sdk-client';
2
+ import type { CreateInstanceGroupRequest, CreateInstancePolicyRequest, CreateInstanceTemplateRequest, InstanceGroup, InstancePolicy, InstanceTemplate, ListInstanceGroupEventsResponse, ListInstanceGroupsResponse, ListInstancePoliciesResponse, ListInstanceTemplatesResponse, UpdateInstanceGroupRequest, UpdateInstancePolicyRequest, UpdateInstanceTemplateRequest } from './types.gen';
3
+ export declare const unmarshalInstanceGroup: (data: unknown) => InstanceGroup;
4
+ export declare const unmarshalInstancePolicy: (data: unknown) => InstancePolicy;
5
+ export declare const unmarshalInstanceTemplate: (data: unknown) => InstanceTemplate;
6
+ export declare const unmarshalListInstanceGroupEventsResponse: (data: unknown) => ListInstanceGroupEventsResponse;
7
+ export declare const unmarshalListInstanceGroupsResponse: (data: unknown) => ListInstanceGroupsResponse;
8
+ export declare const unmarshalListInstancePoliciesResponse: (data: unknown) => ListInstancePoliciesResponse;
9
+ export declare const unmarshalListInstanceTemplatesResponse: (data: unknown) => ListInstanceTemplatesResponse;
10
+ export declare const marshalCreateInstanceGroupRequest: (request: CreateInstanceGroupRequest, defaults: DefaultValues) => Record<string, unknown>;
11
+ export declare const marshalCreateInstancePolicyRequest: (request: CreateInstancePolicyRequest, defaults: DefaultValues) => Record<string, unknown>;
12
+ export declare const marshalCreateInstanceTemplateRequest: (request: CreateInstanceTemplateRequest, defaults: DefaultValues) => Record<string, unknown>;
13
+ export declare const marshalUpdateInstanceGroupRequest: (request: UpdateInstanceGroupRequest, defaults: DefaultValues) => Record<string, unknown>;
14
+ export declare const marshalUpdateInstancePolicyRequest: (request: UpdateInstancePolicyRequest, defaults: DefaultValues) => Record<string, unknown>;
15
+ export declare const marshalUpdateInstanceTemplateRequest: (request: UpdateInstanceTemplateRequest, defaults: DefaultValues) => Record<string, unknown>;