@scaleway/sdk 1.5.0 → 1.6.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.
Files changed (35) hide show
  1. package/dist/api/applesilicon/v1alpha1/api.gen.js +1 -1
  2. package/dist/api/baremetal/v1/api.gen.js +2 -2
  3. package/dist/api/cockpit/v1beta1/api.gen.js +51 -1
  4. package/dist/api/cockpit/v1beta1/marshalling.gen.js +44 -1
  5. package/dist/api/container/v1beta1/api.gen.js +1 -1
  6. package/dist/api/flexibleip/v1alpha1/api.gen.js +1 -1
  7. package/dist/api/function/v1beta1/api.gen.js +1 -1
  8. package/dist/api/function/v1beta1/marshalling.gen.js +0 -20
  9. package/dist/api/iam/v1alpha1/validation-rules.gen.js +10 -10
  10. package/dist/api/instance/v1/api.gen.js +86 -67
  11. package/dist/api/iot/v1/api.gen.js +1 -1
  12. package/dist/api/k8s/v1/api.gen.js +1 -1
  13. package/dist/api/lb/v1/api.gen.js +2 -2
  14. package/dist/api/lb/v1/marshalling.gen.js +33 -19
  15. package/dist/api/mnq/v1alpha1/api.gen.js +1 -1
  16. package/dist/api/rdb/v1/api.gen.js +1 -1
  17. package/dist/api/redis/v1/api.gen.js +1 -1
  18. package/dist/api/redis/v1/marshalling.gen.js +2 -0
  19. package/dist/api/registry/v1/api.gen.js +1 -1
  20. package/dist/api/secret/v1alpha1/api.gen.js +1 -1
  21. package/dist/api/secret/v1alpha1/marshalling.gen.js +14 -2
  22. package/dist/api/tem/v1alpha1/api.gen.js +1 -1
  23. package/dist/api/vpc/v1/api.gen.js +2 -2
  24. package/dist/api/vpcgw/v1/api.gen.js +1 -1
  25. package/dist/api/webhosting/v1alpha1/api.gen.js +1 -1
  26. package/dist/index.cjs +276 -121
  27. package/dist/index.d.ts +669 -504
  28. package/dist/internal/async/interval-retrier.js +6 -0
  29. package/dist/internal/logger/level-resolver.js +3 -3
  30. package/dist/scw/client-ini-factory.js +6 -0
  31. package/dist/scw/client-ini-profile.js +18 -0
  32. package/dist/scw/client-settings.js +12 -0
  33. package/dist/scw/constants.js +1 -1
  34. package/dist/scw/errors/standard/quotas-exceeded-error.js +6 -0
  35. package/package.json +2 -2
@@ -209,8 +209,8 @@ class API extends API$1 {
209
209
  path: `/apple-silicon/v1alpha1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/servers/${validatePathParam('serverId', request.serverId)}/reinstall`
210
210
  }, unmarshalServer);
211
211
  }
212
+ /** Lists the available zones of the API. */
212
213
  }
213
- /** Lists the available zones of the API. */
214
214
  API.LOCALITIES = ['fr-par-3'];
215
215
 
216
216
  export { API };
@@ -389,10 +389,10 @@ class API extends API$1 {
389
389
  path: `/baremetal/v1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/os/${validatePathParam('osId', request.osId)}`
390
390
  }, unmarshalOS);
391
391
  }
392
+ /** Lists the available zones of the API. */
392
393
  }
393
394
 
394
395
  /** Elastic Metal Private Network API. */
395
- /** Lists the available zones of the API. */
396
396
  API.LOCALITIES = ['fr-par-1', 'fr-par-2', 'nl-ams-1'];
397
397
  class PrivateNetworkAPI extends API$1 {
398
398
  constructor() {
@@ -459,8 +459,8 @@ class PrivateNetworkAPI extends API$1 {
459
459
  path: `/baremetal/v1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/servers/${validatePathParam('serverId', request.serverId)}/private-networks/${validatePathParam('privateNetworkId', request.privateNetworkId)}`
460
460
  });
461
461
  }
462
+ /** Lists the available zones of the API. */
462
463
  }
463
- /** Lists the available zones of the API. */
464
464
  PrivateNetworkAPI.LOCALITIES = ['fr-par-2'];
465
465
 
466
466
  export { API, PrivateNetworkAPI };
@@ -3,7 +3,7 @@ import { API as API$1 } from '../../../scw/api.js';
3
3
  import { urlParams, validatePathParam } from '../../../helpers/marshalling.js';
4
4
  import { enrichForPagination } from '../../../scw/fetch/resource-paginator.js';
5
5
  import { COCKPIT_TRANSIENT_STATUSES } from './content.gen.js';
6
- import { marshalActivateCockpitRequest, unmarshalCockpit, marshalDeactivateCockpitRequest, marshalResetCockpitGrafanaRequest, marshalCreateTokenRequest, unmarshalToken, unmarshalListTokensResponse, marshalCreateContactPointRequest, unmarshalContactPoint, unmarshalListContactPointsResponse, marshalDeleteContactPointRequest, marshalEnableManagedAlertsRequest, marshalDisableManagedAlertsRequest, marshalTriggerTestAlertRequest, marshalCreateGrafanaUserRequest, unmarshalGrafanaUser, unmarshalListGrafanaUsersResponse, marshalDeleteGrafanaUserRequest, marshalResetGrafanaUserPasswordRequest } from './marshalling.gen.js';
6
+ import { marshalActivateCockpitRequest, unmarshalCockpit, unmarshalCockpitMetrics, marshalDeactivateCockpitRequest, marshalResetCockpitGrafanaRequest, marshalCreateTokenRequest, unmarshalToken, unmarshalListTokensResponse, marshalCreateContactPointRequest, unmarshalContactPoint, unmarshalListContactPointsResponse, marshalDeleteContactPointRequest, marshalEnableManagedAlertsRequest, marshalDisableManagedAlertsRequest, marshalTriggerTestAlertRequest, marshalCreateGrafanaUserRequest, unmarshalGrafanaUser, unmarshalListGrafanaUsersResponse, marshalDeleteGrafanaUserRequest, marshalResetGrafanaUserPasswordRequest, unmarshalListPlansResponse, marshalSelectPlanRequest, unmarshalSelectPlanResponse } from './marshalling.gen.js';
7
7
 
8
8
  // This file was automatically generated. DO NOT EDIT.
9
9
  const jsonContentHeaders = {
@@ -67,6 +67,22 @@ class API extends API$1 {
67
67
  }
68
68
  return waitForResource((options == null ? void 0 : options.stop) ?? (res => Promise.resolve(!COCKPIT_TRANSIENT_STATUSES.includes(res.status))), _this.getCockpit, request, options);
69
69
  };
70
+ /**
71
+ * Get cockpit metrics. Get the cockpit metrics with the given project ID.
72
+ *
73
+ * @param request - The request {@link GetCockpitMetricsRequest}
74
+ * @returns A Promise of CockpitMetrics
75
+ */
76
+ this.getCockpitMetrics = function (request) {
77
+ if (request === void 0) {
78
+ request = {};
79
+ }
80
+ return _this.client.fetch({
81
+ method: 'GET',
82
+ path: `/cockpit/v1beta1/cockpit/metrics`,
83
+ urlParams: urlParams(['end_date', request.endDate], ['metric_name', request.metricName], ['project_id', request.projectId ?? _this.client.settings.defaultProjectId], ['start_date', request.startDate])
84
+ }, unmarshalCockpitMetrics);
85
+ };
70
86
  /**
71
87
  * Deactivate a cockpit. Deactivate a cockpit associated with the given
72
88
  * project ID.
@@ -326,6 +342,40 @@ class API extends API$1 {
326
342
  method: 'POST',
327
343
  path: `/cockpit/v1beta1/grafana-users/${validatePathParam('grafanaUserId', request.grafanaUserId)}/reset-password`
328
344
  }, unmarshalGrafanaUser);
345
+ this.pageOfListPlans = function (request) {
346
+ if (request === void 0) {
347
+ request = {};
348
+ }
349
+ return _this.client.fetch({
350
+ method: 'GET',
351
+ path: `/cockpit/v1beta1/plans`,
352
+ urlParams: urlParams(['order_by', request.orderBy ?? 'name_asc'], ['page', request.page], ['page_size', request.pageSize ?? _this.client.settings.defaultPageSize])
353
+ }, unmarshalListPlansResponse);
354
+ };
355
+ /**
356
+ * List plans. List all pricing plans.
357
+ *
358
+ * @param request - The request {@link ListPlansRequest}
359
+ * @returns A Promise of ListPlansResponse
360
+ */
361
+ this.listPlans = function (request) {
362
+ if (request === void 0) {
363
+ request = {};
364
+ }
365
+ return enrichForPagination('plans', _this.pageOfListPlans, request);
366
+ };
367
+ /**
368
+ * Select pricing plan. Select the wanted pricing plan.
369
+ *
370
+ * @param request - The request {@link SelectPlanRequest}
371
+ * @returns A Promise of SelectPlanResponse
372
+ */
373
+ this.selectPlan = request => this.client.fetch({
374
+ body: JSON.stringify(marshalSelectPlanRequest(request, this.client.settings)),
375
+ headers: jsonContentHeaders,
376
+ method: 'POST',
377
+ path: `/cockpit/v1beta1/select-plan`
378
+ }, unmarshalSelectPlanResponse);
329
379
  }
330
380
  }
331
381
 
@@ -1,5 +1,6 @@
1
1
  import randomName from '../../../node_modules/.pnpm/@scaleway_random-name@4.0.1/node_modules/@scaleway/random-name/dist/index.js';
2
2
  import { isJSONObject } from '../../../helpers/json.js';
3
+ import { unmarshalTimeSeries } from '../../../scw/custom-marshalling.js';
3
4
  import { unmarshalDate, unmarshalArrayOfObject, resolveOneOf } from '../../../helpers/marshalling.js';
4
5
 
5
6
  // This file was automatically generated. DO NOT EDIT.
@@ -55,6 +56,20 @@ const unmarshalGrafanaUser = data => {
55
56
  role: data.role
56
57
  };
57
58
  };
59
+ const unmarshalPlan = data => {
60
+ if (!isJSONObject(data)) {
61
+ throw new TypeError(`Unmarshalling the type 'Plan' failed as data isn't a dictionary.`);
62
+ }
63
+ return {
64
+ id: data.id,
65
+ logsIngestionPrice: data.logs_ingestion_price,
66
+ name: data.name,
67
+ retentionLogsInterval: data.retention_logs_interval,
68
+ retentionMetricsInterval: data.retention_metrics_interval,
69
+ retentionPrice: data.retention_price,
70
+ sampleIngestionPrice: data.sample_ingestion_price
71
+ };
72
+ };
58
73
  const unmarshalToken = data => {
59
74
  if (!isJSONObject(data)) {
60
75
  throw new TypeError(`Unmarshalling the type 'Token' failed as data isn't a dictionary.`);
@@ -77,11 +92,20 @@ const unmarshalCockpit = data => {
77
92
  createdAt: unmarshalDate(data.created_at),
78
93
  endpoints: data.endpoints ? unmarshalCockpitEndpoints(data.endpoints) : undefined,
79
94
  managedAlertsEnabled: data.managed_alerts_enabled,
95
+ plan: data.plan ? unmarshalPlan(data.plan) : undefined,
80
96
  projectId: data.project_id,
81
97
  status: data.status,
82
98
  updatedAt: unmarshalDate(data.updated_at)
83
99
  };
84
100
  };
101
+ const unmarshalCockpitMetrics = data => {
102
+ if (!isJSONObject(data)) {
103
+ throw new TypeError(`Unmarshalling the type 'CockpitMetrics' failed as data isn't a dictionary.`);
104
+ }
105
+ return {
106
+ timeseries: unmarshalArrayOfObject(data.timeseries, unmarshalTimeSeries)
107
+ };
108
+ };
85
109
  const unmarshalListContactPointsResponse = data => {
86
110
  if (!isJSONObject(data)) {
87
111
  throw new TypeError(`Unmarshalling the type 'ListContactPointsResponse' failed as data isn't a dictionary.`);
@@ -102,6 +126,15 @@ const unmarshalListGrafanaUsersResponse = data => {
102
126
  totalCount: data.total_count
103
127
  };
104
128
  };
129
+ const unmarshalListPlansResponse = data => {
130
+ if (!isJSONObject(data)) {
131
+ throw new TypeError(`Unmarshalling the type 'ListPlansResponse' failed as data isn't a dictionary.`);
132
+ }
133
+ return {
134
+ plans: unmarshalArrayOfObject(data.plans, unmarshalPlan),
135
+ totalCount: data.total_count
136
+ };
137
+ };
105
138
  const unmarshalListTokensResponse = data => {
106
139
  if (!isJSONObject(data)) {
107
140
  throw new TypeError(`Unmarshalling the type 'ListTokensResponse' failed as data isn't a dictionary.`);
@@ -111,6 +144,12 @@ const unmarshalListTokensResponse = data => {
111
144
  totalCount: data.total_count
112
145
  };
113
146
  };
147
+ const unmarshalSelectPlanResponse = data => {
148
+ if (!isJSONObject(data)) {
149
+ throw new TypeError(`Unmarshalling the type 'SelectPlanResponse' failed as data isn't a dictionary.`);
150
+ }
151
+ return {};
152
+ };
114
153
  const marshalContactPointEmail = (request, defaults) => ({
115
154
  to: request.to
116
155
  });
@@ -168,8 +207,12 @@ const marshalResetCockpitGrafanaRequest = (request, defaults) => ({
168
207
  const marshalResetGrafanaUserPasswordRequest = (request, defaults) => ({
169
208
  project_id: request.projectId ?? defaults.defaultProjectId
170
209
  });
210
+ const marshalSelectPlanRequest = (request, defaults) => ({
211
+ plan_id: request.planId,
212
+ project_id: request.projectId ?? defaults.defaultProjectId
213
+ });
171
214
  const marshalTriggerTestAlertRequest = (request, defaults) => ({
172
215
  project_id: request.projectId ?? defaults.defaultProjectId
173
216
  });
174
217
 
175
- export { marshalActivateCockpitRequest, marshalCreateContactPointRequest, marshalCreateGrafanaUserRequest, marshalCreateTokenRequest, marshalDeactivateCockpitRequest, marshalDeleteContactPointRequest, marshalDeleteGrafanaUserRequest, marshalDisableManagedAlertsRequest, marshalEnableManagedAlertsRequest, marshalResetCockpitGrafanaRequest, marshalResetGrafanaUserPasswordRequest, marshalTriggerTestAlertRequest, unmarshalCockpit, unmarshalContactPoint, unmarshalGrafanaUser, unmarshalListContactPointsResponse, unmarshalListGrafanaUsersResponse, unmarshalListTokensResponse, unmarshalToken };
218
+ export { marshalActivateCockpitRequest, marshalCreateContactPointRequest, marshalCreateGrafanaUserRequest, marshalCreateTokenRequest, marshalDeactivateCockpitRequest, marshalDeleteContactPointRequest, marshalDeleteGrafanaUserRequest, marshalDisableManagedAlertsRequest, marshalEnableManagedAlertsRequest, marshalResetCockpitGrafanaRequest, marshalResetGrafanaUserPasswordRequest, marshalSelectPlanRequest, marshalTriggerTestAlertRequest, unmarshalCockpit, unmarshalCockpitMetrics, unmarshalContactPoint, unmarshalGrafanaUser, unmarshalListContactPointsResponse, unmarshalListGrafanaUsersResponse, unmarshalListPlansResponse, unmarshalListTokensResponse, unmarshalSelectPlanResponse, unmarshalToken };
@@ -395,8 +395,8 @@ class API extends API$1 {
395
395
  path: `/containers/v1beta1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/tokens/${validatePathParam('tokenId', request.tokenId)}`
396
396
  }, unmarshalToken);
397
397
  }
398
+ /** Lists the available regions of the API. */
398
399
  }
399
- /** Lists the available regions of the API. */
400
400
  API.LOCALITIES = ['fr-par', 'nl-ams', 'pl-waw'];
401
401
 
402
402
  export { API };
@@ -161,8 +161,8 @@ class API extends API$1 {
161
161
  path: `/flexible-ip/v1alpha1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/fips/${validatePathParam('fipId', request.fipId)}/mac`
162
162
  });
163
163
  }
164
+ /** Lists the available zones of the API. */
164
165
  }
165
- /** Lists the available zones of the API. */
166
166
  API.LOCALITIES = ['fr-par-1', 'fr-par-2', 'nl-ams-1'];
167
167
 
168
168
  export { API };
@@ -487,8 +487,8 @@ class API extends API$1 {
487
487
  path: `/functions/v1beta1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/triggers/${validatePathParam('triggerId', request.triggerId)}`
488
488
  }, unmarshalTrigger);
489
489
  }
490
+ /** Lists the available regions of the API. */
490
491
  }
491
- /** Lists the available regions of the API. */
492
492
  API.LOCALITIES = ['fr-par', 'nl-ams', 'pl-waw'];
493
493
 
494
494
  export { API };
@@ -293,22 +293,8 @@ const marshalSecret = (request, defaults) => ({
293
293
  key: request.key,
294
294
  value: request.value
295
295
  });
296
- const marshalUpdateTriggerRequestMnqNatsClientConfig = (request, defaults) => ({
297
- mnq_namespace_id: request.mnqNamespaceId,
298
- mnq_project_id: request.mnqProjectId,
299
- mnq_region: request.mnqRegion,
300
- subject: request.subject
301
- });
302
- const marshalUpdateTriggerRequestMnqSqsClientConfig = (request, defaults) => ({
303
- mnq_namespace_id: request.mnqNamespaceId,
304
- mnq_project_id: request.mnqProjectId,
305
- mnq_region: request.mnqRegion,
306
- queue: request.queue
307
- });
308
296
  const marshalUpdateTriggerRequestSqsClientConfig = (request, defaults) => ({
309
297
  access_key: request.accessKey,
310
- endpoint: request.endpoint,
311
- queue_url: request.queueUrl,
312
298
  secret_key: request.secretKey
313
299
  });
314
300
  const marshalCreateCronRequest = (request, defaults) => ({
@@ -398,14 +384,8 @@ const marshalUpdateTriggerRequest = (request, defaults) => ({
398
384
  description: request.description,
399
385
  name: request.name,
400
386
  ...resolveOneOf([{
401
- param: 'scw_sqs_config',
402
- value: request.scwSqsConfig ? marshalUpdateTriggerRequestMnqSqsClientConfig(request.scwSqsConfig) : undefined
403
- }, {
404
387
  param: 'sqs_config',
405
388
  value: request.sqsConfig ? marshalUpdateTriggerRequestSqsClientConfig(request.sqsConfig) : undefined
406
- }, {
407
- param: 'scw_nats_config',
408
- value: request.scwNatsConfig ? marshalUpdateTriggerRequestMnqNatsClientConfig(request.scwNatsConfig) : undefined
409
389
  }])
410
390
  });
411
391
 
@@ -60,7 +60,7 @@ const ListAPIKeysRequest = {
60
60
  maxLength: 200
61
61
  },
62
62
  page: {
63
- greaterThanOrEqual: 1
63
+ greaterThan: 0
64
64
  },
65
65
  pageSize: {
66
66
  greaterThanOrEqual: 1,
@@ -74,7 +74,7 @@ const ListApplicationsRequest = {
74
74
  pattern: /^[a-zA-Z0-9\(\)\._\- ]+$/
75
75
  },
76
76
  page: {
77
- greaterThanOrEqual: 1
77
+ greaterThan: 0
78
78
  },
79
79
  pageSize: {
80
80
  greaterThanOrEqual: 1,
@@ -86,7 +86,7 @@ const ListGroupsRequest = {
86
86
  minLength: 1
87
87
  },
88
88
  page: {
89
- greaterThanOrEqual: 1
89
+ greaterThan: 0
90
90
  },
91
91
  pageSize: {
92
92
  greaterThanOrEqual: 1,
@@ -95,7 +95,7 @@ const ListGroupsRequest = {
95
95
  };
96
96
  const ListJWTsRequest = {
97
97
  page: {
98
- greaterThanOrEqual: 1
98
+ greaterThan: 0
99
99
  },
100
100
  pageSize: {
101
101
  greaterThanOrEqual: 1,
@@ -104,7 +104,7 @@ const ListJWTsRequest = {
104
104
  };
105
105
  const ListPermissionSetsRequest = {
106
106
  page: {
107
- greaterThanOrEqual: 1
107
+ greaterThan: 0
108
108
  },
109
109
  pageSize: {
110
110
  greaterThanOrEqual: 1,
@@ -113,7 +113,7 @@ const ListPermissionSetsRequest = {
113
113
  };
114
114
  const ListPoliciesRequest = {
115
115
  page: {
116
- greaterThanOrEqual: 1
116
+ greaterThan: 0
117
117
  },
118
118
  pageSize: {
119
119
  greaterThanOrEqual: 1,
@@ -125,7 +125,7 @@ const ListPoliciesRequest = {
125
125
  };
126
126
  const ListQuotaRequest = {
127
127
  page: {
128
- greaterThanOrEqual: 1
128
+ greaterThan: 0
129
129
  },
130
130
  pageSize: {
131
131
  greaterThanOrEqual: 1,
@@ -134,7 +134,7 @@ const ListQuotaRequest = {
134
134
  };
135
135
  const ListRulesRequest = {
136
136
  page: {
137
- greaterThanOrEqual: 1
137
+ greaterThan: 0
138
138
  },
139
139
  pageSize: {
140
140
  greaterThanOrEqual: 1,
@@ -147,7 +147,7 @@ const ListSSHKeysRequest = {
147
147
  minLength: 1
148
148
  },
149
149
  page: {
150
- greaterThanOrEqual: 1
150
+ greaterThan: 0
151
151
  },
152
152
  pageSize: {
153
153
  greaterThanOrEqual: 1,
@@ -156,7 +156,7 @@ const ListSSHKeysRequest = {
156
156
  };
157
157
  const ListUsersRequest = {
158
158
  page: {
159
- greaterThanOrEqual: 1
159
+ greaterThan: 0
160
160
  },
161
161
  pageSize: {
162
162
  greaterThanOrEqual: 1,