@scaleway/sdk 0.1.0-beta.25 → 0.1.0-beta.26

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.
@@ -3,7 +3,7 @@ import { API } from '../../../scw/api.js';
3
3
  import { validatePathParam, urlParams } from '../../../helpers/marshalling.js';
4
4
  import { enrichForPagination } from '../../../scw/fetch/resource-paginator.js';
5
5
  import { SERVER_TRANSIENT_STATUSES } from './content.gen.js';
6
- import { unmarshalListServersResponse, unmarshalServer, marshalCreateServerRequest, marshalUpdateServerRequest, marshalInstallServerRequest, unmarshalGetServerMetricsResponse, marshalRebootServerRequest, marshalStartServerRequest, unmarshalListServerEventsResponse, marshalStartBMCAccessRequest, unmarshalBMCAccess, marshalUpdateIPRequest, unmarshalIP, marshalAddOptionServerRequest, unmarshalListOffersResponse, unmarshalOffer, unmarshalOption, unmarshalListOptionsResponse, unmarshalListSettingsResponse, marshalUpdateSettingRequest, unmarshalSetting, unmarshalListOSResponse, unmarshalOS, marshalPrivateNetworkApiAddServerPrivateNetworkRequest, unmarshalServerPrivateNetwork, marshalPrivateNetworkApiSetServerPrivateNetworksRequest, unmarshalSetServerPrivateNetworksResponse, unmarshalListServerPrivateNetworksResponse } from './marshalling.gen.js';
6
+ import { marshalPrivateNetworkApiAddServerPrivateNetworkRequest, unmarshalServerPrivateNetwork, marshalPrivateNetworkApiSetServerPrivateNetworksRequest, unmarshalSetServerPrivateNetworksResponse, unmarshalListServerPrivateNetworksResponse, unmarshalListServersResponse, unmarshalServer, marshalCreateServerRequest, marshalUpdateServerRequest, marshalInstallServerRequest, unmarshalGetServerMetricsResponse, marshalRebootServerRequest, marshalStartServerRequest, unmarshalListServerEventsResponse, marshalStartBMCAccessRequest, unmarshalBMCAccess, marshalUpdateIPRequest, unmarshalIP, marshalAddOptionServerRequest, unmarshalListOffersResponse, unmarshalOffer, unmarshalOption, unmarshalListOptionsResponse, unmarshalListSettingsResponse, marshalUpdateSettingRequest, unmarshalSetting, unmarshalListOSResponse, unmarshalOS } from './marshalling.gen.js';
7
7
 
8
8
  // This file was automatically generated. DO NOT EDIT.
9
9
  const jsonContentHeaders = {
@@ -1,2 +1,3 @@
1
1
  export { BaremetalV1UtilsAPI as API } from './api.utils.js';
2
+ export { BaremetalPrivateNetworkV1GenAPI as PrivateNetworkAPI } from './api.gen.js';
2
3
  export { SERVER_INSTALL_TRANSIENT_STATUSES, SERVER_PRIVATE_NETWORK_TRANSIENT_STATUSES, SERVER_TRANSIENT_STATUSES } from './content.gen.js';
@@ -1,6 +1,6 @@
1
1
  import { isJSONObject } from '../../../helpers/json.js';
2
2
  import { unmarshalMoney, unmarshalTimeSeries } from '../../../scw/custom-marshalling.js';
3
- import { unmarshalArrayOfObject, unmarshalDate, resolveOneOf } from '../../../helpers/marshalling.js';
3
+ import { unmarshalDate, unmarshalArrayOfObject, resolveOneOf } from '../../../helpers/marshalling.js';
4
4
 
5
5
  // This file was automatically generated. DO NOT EDIT.
6
6
  const unmarshalCPU = data => {
@@ -1,2 +1,4 @@
1
1
  import * as index$1 from './v1/index.js';
2
2
  export { index$1 as v1 };
3
+ import * as index$2 from './v2/index.js';
4
+ export { index$2 as v2 };
@@ -0,0 +1,82 @@
1
+ import { API } from '../../../scw/api.js';
2
+ import { urlParams, validatePathParam, resolveOneOf } from '../../../helpers/marshalling.js';
3
+ import { enrichForPagination } from '../../../scw/fetch/resource-paginator.js';
4
+ import { unmarshalListImagesResponse, unmarshalImage, unmarshalListVersionsResponse, unmarshalVersion, unmarshalListLocalImagesResponse, unmarshalLocalImage, unmarshalListCategoriesResponse, unmarshalCategory } from './marshalling.gen.js';
5
+
6
+ // This file was automatically generated. DO NOT EDIT.
7
+ /** Marketplace API. */
8
+ class MarketplaceV2GenAPI extends API {
9
+ constructor() {
10
+ var _this;
11
+ super(...arguments);
12
+ _this = this;
13
+ this.pageOfListImages = request => this.client.fetch({
14
+ method: 'GET',
15
+ path: `/marketplace/v2/images`,
16
+ urlParams: urlParams(['arch', request.arch], ['category', request.category], ['include_eol', request.includeEol], ['order_by', request.orderBy ?? 'name_asc'], ['page', request.page], ['page_size', request.pageSize ?? this.client.settings.defaultPageSize])
17
+ }, unmarshalListImagesResponse);
18
+ this.listImages = request => enrichForPagination('images', this.pageOfListImages, request);
19
+ this.getImage = request => this.client.fetch({
20
+ method: 'GET',
21
+ path: `/marketplace/v2/images/${validatePathParam('imageId', request.imageId)}`
22
+ }, unmarshalImage);
23
+ this.pageOfListVersions = request => this.client.fetch({
24
+ method: 'GET',
25
+ path: `/marketplace/v2/versions`,
26
+ urlParams: urlParams(['image_id', request.imageId], ['order_by', request.orderBy ?? 'created_at_asc'], ['page', request.page], ['page_size', request.pageSize ?? this.client.settings.defaultPageSize])
27
+ }, unmarshalListVersionsResponse);
28
+ this.listVersions = request => enrichForPagination('versions', this.pageOfListVersions, request);
29
+ this.getVersion = request => this.client.fetch({
30
+ method: 'GET',
31
+ path: `/marketplace/v2/versions/${validatePathParam('versionId', request.versionId)}`
32
+ }, unmarshalVersion);
33
+ this.pageOfListLocalImages = function (request) {
34
+ if (request === void 0) {
35
+ request = {};
36
+ }
37
+ return _this.client.fetch({
38
+ method: 'GET',
39
+ path: `/marketplace/v2/local-images`,
40
+ urlParams: urlParams(['order_by', request.orderBy ?? 'created_at_asc'], ['page', request.page], ['page_size', request.pageSize ?? _this.client.settings.defaultPageSize], ...Object.entries(resolveOneOf([{
41
+ param: 'image_id',
42
+ value: request.imageId
43
+ }, {
44
+ param: 'version_id',
45
+ value: request.versionId
46
+ }])))
47
+ }, unmarshalListLocalImagesResponse);
48
+ };
49
+ this.listLocalImages = function (request) {
50
+ if (request === void 0) {
51
+ request = {};
52
+ }
53
+ return enrichForPagination('localImages', _this.pageOfListLocalImages, request);
54
+ };
55
+ this.getLocalImage = request => this.client.fetch({
56
+ method: 'GET',
57
+ path: `/marketplace/v2/local-images/${validatePathParam('localImageId', request.localImageId)}`
58
+ }, unmarshalLocalImage);
59
+ this.pageOfListCategories = function (request) {
60
+ if (request === void 0) {
61
+ request = {};
62
+ }
63
+ return _this.client.fetch({
64
+ method: 'GET',
65
+ path: `/marketplace/v2/categories`,
66
+ urlParams: urlParams(['page', request.page], ['page_size', request.pageSize ?? _this.client.settings.defaultPageSize])
67
+ }, unmarshalListCategoriesResponse);
68
+ };
69
+ this.listCategories = function (request) {
70
+ if (request === void 0) {
71
+ request = {};
72
+ }
73
+ return enrichForPagination('categories', _this.pageOfListCategories, request);
74
+ };
75
+ this.getCategory = request => this.client.fetch({
76
+ method: 'GET',
77
+ path: `/marketplace/v2/categories/${validatePathParam('categoryId', request.categoryId)}`
78
+ }, unmarshalCategory);
79
+ }
80
+ }
81
+
82
+ export { MarketplaceV2GenAPI };
@@ -0,0 +1 @@
1
+ export { MarketplaceV2GenAPI as API } from './api.gen.js';
@@ -0,0 +1,91 @@
1
+ import { isJSONObject } from '../../../helpers/json.js';
2
+ import { unmarshalDate, unmarshalArrayOfObject } from '../../../helpers/marshalling.js';
3
+
4
+ // This file was automatically generated. DO NOT EDIT.
5
+ const unmarshalCategory = data => {
6
+ if (!isJSONObject(data)) {
7
+ throw new TypeError(`Unmarshalling the type 'Category' failed as data isn't a dictionary.`);
8
+ }
9
+ return {
10
+ description: data.description,
11
+ id: data.id,
12
+ name: data.name
13
+ };
14
+ };
15
+ const unmarshalImage = data => {
16
+ if (!isJSONObject(data)) {
17
+ throw new TypeError(`Unmarshalling the type 'Image' failed as data isn't a dictionary.`);
18
+ }
19
+ return {
20
+ categories: data.categories,
21
+ createdAt: unmarshalDate(data.created_at),
22
+ description: data.description,
23
+ id: data.id,
24
+ label: data.label,
25
+ logo: data.logo,
26
+ name: data.name,
27
+ updatedAt: unmarshalDate(data.updated_at),
28
+ validUntil: unmarshalDate(data.valid_until)
29
+ };
30
+ };
31
+ const unmarshalLocalImage = data => {
32
+ if (!isJSONObject(data)) {
33
+ throw new TypeError(`Unmarshalling the type 'LocalImage' failed as data isn't a dictionary.`);
34
+ }
35
+ return {
36
+ arch: data.arch,
37
+ compatibleCommercialTypes: data.compatible_commercial_types,
38
+ id: data.id,
39
+ zone: data.zone
40
+ };
41
+ };
42
+ const unmarshalVersion = data => {
43
+ if (!isJSONObject(data)) {
44
+ throw new TypeError(`Unmarshalling the type 'Version' failed as data isn't a dictionary.`);
45
+ }
46
+ return {
47
+ createdAt: unmarshalDate(data.created_at),
48
+ id: data.id,
49
+ name: data.name,
50
+ publishedAt: unmarshalDate(data.published_at),
51
+ updatedAt: unmarshalDate(data.updated_at)
52
+ };
53
+ };
54
+ const unmarshalListCategoriesResponse = data => {
55
+ if (!isJSONObject(data)) {
56
+ throw new TypeError(`Unmarshalling the type 'ListCategoriesResponse' failed as data isn't a dictionary.`);
57
+ }
58
+ return {
59
+ categories: unmarshalArrayOfObject(data.categories, unmarshalCategory),
60
+ totalCount: data.total_count
61
+ };
62
+ };
63
+ const unmarshalListImagesResponse = data => {
64
+ if (!isJSONObject(data)) {
65
+ throw new TypeError(`Unmarshalling the type 'ListImagesResponse' failed as data isn't a dictionary.`);
66
+ }
67
+ return {
68
+ images: unmarshalArrayOfObject(data.images, unmarshalImage),
69
+ totalCount: data.total_count
70
+ };
71
+ };
72
+ const unmarshalListLocalImagesResponse = data => {
73
+ if (!isJSONObject(data)) {
74
+ throw new TypeError(`Unmarshalling the type 'ListLocalImagesResponse' failed as data isn't a dictionary.`);
75
+ }
76
+ return {
77
+ localImages: unmarshalArrayOfObject(data.local_images, unmarshalLocalImage),
78
+ totalCount: data.total_count
79
+ };
80
+ };
81
+ const unmarshalListVersionsResponse = data => {
82
+ if (!isJSONObject(data)) {
83
+ throw new TypeError(`Unmarshalling the type 'ListVersionsResponse' failed as data isn't a dictionary.`);
84
+ }
85
+ return {
86
+ totalCount: data.total_count,
87
+ versions: unmarshalArrayOfObject(data.versions, unmarshalVersion)
88
+ };
89
+ };
90
+
91
+ export { unmarshalCategory, unmarshalImage, unmarshalListCategoriesResponse, unmarshalListImagesResponse, unmarshalListLocalImagesResponse, unmarshalListVersionsResponse, unmarshalLocalImage, unmarshalVersion };
@@ -45,7 +45,7 @@ class TemV1Alpha1GenAPI extends API {
45
45
  return _this.client.fetch({
46
46
  method: 'GET',
47
47
  path: `/transactional-email/v1alpha1/regions/${validatePathParam('region', request.region ?? _this.client.settings.defaultRegion)}/emails`,
48
- urlParams: urlParams(['domain_id', request.domainId], ['mail_from', request.mailFrom], ['mail_to', request.mailTo], ['page', request.page], ['page_size', request.pageSize ?? _this.client.settings.defaultPageSize], ['project_id', request.projectId ?? _this.client.settings.defaultProjectId], ['since', request.since], ['statuses', request.statuses], ['until', request.until])
48
+ urlParams: urlParams(['domain_id', request.domainId], ['mail_from', request.mailFrom], ['mail_to', request.mailTo], ['message_id', request.messageId], ['page', request.page], ['page_size', request.pageSize ?? _this.client.settings.defaultPageSize], ['project_id', request.projectId ?? _this.client.settings.defaultProjectId], ['since', request.since], ['statuses', request.statuses], ['until', request.until])
49
49
  }, unmarshalListEmailsResponse);
50
50
  };
51
51
  this.listEmails = function (request) {
@@ -2,6 +2,17 @@ import { isJSONObject } from '../../../helpers/json.js';
2
2
  import { unmarshalDate, unmarshalArrayOfObject } from '../../../helpers/marshalling.js';
3
3
 
4
4
  // This file was automatically generated. DO NOT EDIT.
5
+ const unmarshalDomainStatistics = data => {
6
+ if (!isJSONObject(data)) {
7
+ throw new TypeError(`Unmarshalling the type 'DomainStatistics' failed as data isn't a dictionary.`);
8
+ }
9
+ return {
10
+ canceledCount: data.canceled_count,
11
+ failedCount: data.failed_count,
12
+ sentCount: data.sent_count,
13
+ totalCount: data.total_count
14
+ };
15
+ };
5
16
  const unmarshalEmailTry = data => {
6
17
  if (!isJSONObject(data)) {
7
18
  throw new TypeError(`Unmarshalling the type 'EmailTry' failed as data isn't a dictionary.`);
@@ -13,19 +24,6 @@ const unmarshalEmailTry = data => {
13
24
  triedAt: unmarshalDate(data.tried_at)
14
25
  };
15
26
  };
16
- const unmarshalStatistics = data => {
17
- if (!isJSONObject(data)) {
18
- throw new TypeError(`Unmarshalling the type 'Statistics' failed as data isn't a dictionary.`);
19
- }
20
- return {
21
- canceledCount: data.canceled_count,
22
- failedCount: data.failed_count,
23
- newCount: data.new_count,
24
- sendingCount: data.sending_count,
25
- sentCount: data.sent_count,
26
- totalCount: data.total_count
27
- };
28
- };
29
27
  const unmarshalDomain = data => {
30
28
  if (!isJSONObject(data)) {
31
29
  throw new TypeError(`Unmarshalling the type 'Domain' failed as data isn't a dictionary.`);
@@ -43,7 +41,7 @@ const unmarshalDomain = data => {
43
41
  region: data.region,
44
42
  revokedAt: unmarshalDate(data.revoked_at),
45
43
  spfConfig: data.spf_config,
46
- statistics: data.statistics ? unmarshalStatistics(data.statistics) : undefined,
44
+ statistics: data.statistics ? unmarshalDomainStatistics(data.statistics) : undefined,
47
45
  status: data.status
48
46
  };
49
47
  };
@@ -92,6 +90,19 @@ const unmarshalListEmailsResponse = data => {
92
90
  totalCount: data.total_count
93
91
  };
94
92
  };
93
+ const unmarshalStatistics = data => {
94
+ if (!isJSONObject(data)) {
95
+ throw new TypeError(`Unmarshalling the type 'Statistics' failed as data isn't a dictionary.`);
96
+ }
97
+ return {
98
+ canceledCount: data.canceled_count,
99
+ failedCount: data.failed_count,
100
+ newCount: data.new_count,
101
+ sendingCount: data.sending_count,
102
+ sentCount: data.sent_count,
103
+ totalCount: data.total_count
104
+ };
105
+ };
95
106
  const marshalCreateEmailRequestAddress = (request, defaults) => ({
96
107
  email: request.email,
97
108
  name: request.name
@@ -113,7 +113,7 @@ const unmarshalMapOfObject = function (data, unmarshaller, emptyFallback) {
113
113
  if (emptyFallback === void 0) {
114
114
  emptyFallback = true;
115
115
  }
116
- if (!data || typeof data !== 'object' || Array.isArray(data)) {
116
+ if (!data || typeof data !== 'object' || !(data instanceof Object) || Array.isArray(data)) {
117
117
  return emptyFallback ? {} : undefined;
118
118
  }
119
119
  return Object.entries(data).reduce((acc, _ref) => {