@scaleway/sdk 0.1.0-alpha.9 → 0.1.0-beta.3

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 (153) hide show
  1. package/README.md +14 -58
  2. package/dist/api/account/index.js +4 -0
  3. package/dist/api/account/v2/api.gen.js +88 -0
  4. package/dist/api/account/v2/index.js +1 -0
  5. package/dist/api/account/v2/marshalling.gen.js +39 -0
  6. package/dist/api/account/v2alpha1/api.gen.js +15 -32
  7. package/dist/api/account/v2alpha1/index.js +1 -0
  8. package/dist/api/account/v2alpha1/marshalling.gen.js +62 -0
  9. package/dist/api/applesilicon/index.js +2 -0
  10. package/dist/api/applesilicon/v1alpha1/api.gen.js +40 -24
  11. package/dist/api/applesilicon/v1alpha1/content.gen.js +7 -0
  12. package/dist/api/applesilicon/v1alpha1/index.js +2 -0
  13. package/dist/api/applesilicon/v1alpha1/marshalling.gen.js +125 -0
  14. package/dist/api/baremetal/index.js +2 -0
  15. package/dist/api/baremetal/v1/api.gen.js +68 -91
  16. package/dist/api/baremetal/v1/api.utils.js +31 -0
  17. package/dist/api/baremetal/v1/content.gen.js +10 -0
  18. package/dist/api/baremetal/v1/index.js +2 -0
  19. package/dist/api/baremetal/v1/marshalling.gen.js +402 -0
  20. package/dist/api/container/index.js +2 -0
  21. package/dist/api/container/v1beta1/api.gen.js +111 -106
  22. package/dist/api/container/v1beta1/content.gen.js +19 -0
  23. package/dist/api/container/v1beta1/index.js +2 -0
  24. package/dist/api/container/v1beta1/marshalling.gen.js +261 -0
  25. package/dist/api/domain/index.js +2 -0
  26. package/dist/api/domain/v2beta1/api.gen.js +110 -280
  27. package/dist/api/domain/v2beta1/content.gen.js +7 -0
  28. package/dist/api/domain/v2beta1/index.js +2 -0
  29. package/dist/api/domain/v2beta1/marshalling.gen.js +1228 -0
  30. package/dist/api/flexibleip/index.js +2 -0
  31. package/dist/api/flexibleip/v1alpha1/api.gen.js +45 -48
  32. package/dist/api/flexibleip/v1alpha1/content.gen.js +10 -0
  33. package/dist/api/flexibleip/v1alpha1/index.js +2 -0
  34. package/dist/api/flexibleip/v1alpha1/marshalling.gen.js +103 -0
  35. package/dist/api/function/index.js +2 -0
  36. package/dist/api/function/v1beta1/api.gen.js +114 -103
  37. package/dist/api/function/v1beta1/content.gen.js +19 -0
  38. package/dist/api/function/v1beta1/index.js +2 -0
  39. package/dist/api/function/v1beta1/marshalling.gen.js +305 -0
  40. package/dist/api/iam/index.js +2 -0
  41. package/dist/api/iam/v1alpha1/api.gen.js +131 -212
  42. package/dist/api/iam/v1alpha1/index.js +1 -0
  43. package/dist/api/iam/v1alpha1/marshalling.gen.js +350 -0
  44. package/dist/api/instance/index.js +2 -0
  45. package/dist/api/instance/v1/api.gen.js +218 -414
  46. package/dist/api/instance/v1/api.utils.js +254 -0
  47. package/dist/api/instance/v1/content.gen.js +28 -0
  48. package/dist/api/instance/v1/index.js +2 -0
  49. package/dist/api/instance/v1/marshalling.gen.js +1447 -0
  50. package/dist/api/iot/index.js +2 -0
  51. package/dist/api/iot/v1/api.gen.js +71 -164
  52. package/dist/api/iot/v1/content.gen.js +7 -0
  53. package/dist/api/iot/v1/index.js +2 -0
  54. package/dist/api/iot/v1/marshalling.gen.js +487 -0
  55. package/dist/api/k8s/index.js +2 -0
  56. package/dist/api/k8s/v1/api.gen.js +53 -111
  57. package/dist/api/k8s/v1/content.gen.js +13 -0
  58. package/dist/api/k8s/v1/index.js +2 -0
  59. package/dist/api/k8s/v1/marshalling.gen.js +391 -0
  60. package/dist/api/lb/index.js +2 -0
  61. package/dist/api/lb/v1/api.gen.js +212 -595
  62. package/dist/api/lb/v1/api.utils.js +62 -0
  63. package/dist/api/lb/v1/content.gen.js +16 -0
  64. package/dist/api/lb/v1/index.js +2 -0
  65. package/dist/api/lb/v1/marshalling.gen.js +1020 -0
  66. package/dist/api/marketplace/index.js +2 -0
  67. package/dist/api/marketplace/v1/api.gen.js +8 -10
  68. package/dist/api/marketplace/v1/index.js +1 -0
  69. package/dist/api/marketplace/v1/marshalling.gen.js +104 -0
  70. package/dist/api/mnq/index.js +2 -0
  71. package/dist/api/mnq/v1alpha1/api.gen.js +29 -48
  72. package/dist/api/mnq/v1alpha1/index.js +1 -0
  73. package/dist/api/mnq/v1alpha1/marshalling.gen.js +170 -0
  74. package/dist/api/rdb/index.js +2 -0
  75. package/dist/api/rdb/v1/api.gen.js +113 -202
  76. package/dist/api/rdb/v1/content.gen.js +16 -0
  77. package/dist/api/rdb/v1/index.js +2 -0
  78. package/dist/api/rdb/v1/marshalling.gen.js +687 -0
  79. package/dist/api/redis/index.js +2 -0
  80. package/dist/api/redis/v1alpha1/api.gen.js +75 -91
  81. package/dist/api/redis/v1alpha1/content.gen.js +7 -0
  82. package/dist/api/redis/v1alpha1/index.js +2 -0
  83. package/dist/api/redis/v1alpha1/marshalling.gen.js +296 -0
  84. package/dist/api/registry/index.js +2 -0
  85. package/dist/api/registry/v1/api.gen.js +37 -47
  86. package/dist/api/registry/v1/content.gen.js +13 -0
  87. package/dist/api/registry/v1/index.js +2 -0
  88. package/dist/api/registry/v1/marshalling.gen.js +113 -0
  89. package/dist/api/test/index.js +2 -0
  90. package/dist/api/test/v1/api.gen.js +109 -0
  91. package/dist/api/test/v1/content.gen.js +7 -0
  92. package/dist/api/test/v1/index.js +1 -0
  93. package/dist/api/test/v1/marshalling.gen.js +83 -0
  94. package/dist/api/vpc/index.js +2 -0
  95. package/dist/api/vpc/v1/api.gen.js +43 -32
  96. package/dist/api/vpc/v1/index.js +1 -0
  97. package/dist/api/vpc/v1/marshalling.gen.js +45 -0
  98. package/dist/api/vpcgw/index.js +2 -0
  99. package/dist/api/vpcgw/v1/api.gen.js +107 -174
  100. package/dist/api/vpcgw/v1/content.gen.js +10 -0
  101. package/dist/api/vpcgw/v1/index.js +2 -0
  102. package/dist/api/vpcgw/v1/marshalling.gen.js +357 -0
  103. package/dist/helpers/json.js +6 -0
  104. package/dist/{scw → helpers}/marshalling.js +59 -47
  105. package/dist/index.cjs +12862 -5677
  106. package/dist/index.d.ts +5985 -5510
  107. package/dist/index.js +48 -83
  108. package/dist/internal/async/interval-retrier.js +105 -0
  109. package/dist/internal/async/sleep.js +13 -0
  110. package/dist/internal/interceptors/request.js +5 -1
  111. package/dist/internal/logger/console-logger.js +9 -1
  112. package/dist/internal/{tools → validations}/string-validation.js +0 -7
  113. package/dist/{helpers/API.js → scw/api.js} +1 -1
  114. package/dist/{internal → scw}/auth.js +2 -2
  115. package/dist/scw/client-ini-factory.js +1 -1
  116. package/dist/scw/client-ini-profile.js +1 -1
  117. package/dist/scw/client-settings.js +1 -1
  118. package/dist/scw/constants.js +1 -1
  119. package/dist/scw/custom-marshalling.js +136 -0
  120. package/dist/scw/errors/error-parser.js +5 -0
  121. package/dist/scw/errors/non-standard/unknown-resource-mapper.js +1 -1
  122. package/dist/scw/errors/scw-error.js +14 -1
  123. package/dist/scw/errors/standard/index.js +1 -0
  124. package/dist/scw/errors/standard/too-many-requests-error.js +83 -0
  125. package/dist/scw/fetch/build-fetcher.js +1 -1
  126. package/dist/scw/fetch/http-interceptors.js +4 -0
  127. package/dist/scw/fetch/response-parser.js +33 -3
  128. package/package.json +8 -2
  129. package/dist/api/account/v2alpha1/types.gen.js +0 -1
  130. package/dist/api/applesilicon/v1alpha1/types.gen.js +0 -1
  131. package/dist/api/baremetal/v1/types.gen.js +0 -1
  132. package/dist/api/container/v1beta1/types.gen.js +0 -1
  133. package/dist/api/dedibox/v1/api.gen.js +0 -757
  134. package/dist/api/dedibox/v1/types.gen.js +0 -1
  135. package/dist/api/domain/v2beta1/types.gen.js +0 -1
  136. package/dist/api/flexibleip/v1alpha1/types.gen.js +0 -1
  137. package/dist/api/function/v1beta1/types.gen.js +0 -1
  138. package/dist/api/iam/v1alpha1/types.gen.js +0 -1
  139. package/dist/api/instance/v1/types.gen.js +0 -1
  140. package/dist/api/iot/v1/types.gen.js +0 -1
  141. package/dist/api/k8s/v1/types.gen.js +0 -1
  142. package/dist/api/lb/v1/types.gen.js +0 -1
  143. package/dist/api/marketplace/v1/types.gen.js +0 -1
  144. package/dist/api/mnq/v1alpha1/types.gen.js +0 -1
  145. package/dist/api/rdb/v1/types.gen.js +0 -1
  146. package/dist/api/redis/v1alpha1/types.gen.js +0 -1
  147. package/dist/api/registry/v1/types.gen.js +0 -1
  148. package/dist/api/vpc/v1/types.gen.js +0 -1
  149. package/dist/api/vpcgw/v1/types.gen.js +0 -1
  150. package/dist/helpers/camelize.js +0 -36
  151. package/dist/helpers/for-regions.js +0 -15
  152. package/dist/internals.js +0 -6
  153. package/dist/scw/custom-unmarshallers.js +0 -7
package/README.md CHANGED
@@ -1,33 +1,11 @@
1
1
  # Scaleway SDK
2
2
 
3
- ## ALPHA
4
-
5
- The project is in an **early alpha** phase.
6
-
7
- * The generated code as well as the distribution is subject to change (i.e. we might have one package per product).
8
- * The code will be available on GitHub once it enters beta.
9
-
10
- **List of available APIs:**
11
-
12
- | **Name** | **Version** | **Class** |
13
- |:-------------:|:-----------:|:---------------:|
14
- | Account | v2alpha1 | AccountAPI |
15
- | Apple Silicon | v1alpha1 | ApplesiliconAPI |
16
- | Baremetal | v1 | BaremetalAPI |
17
- | Container | v1beta1 | ContainerAPI |
18
- | Domain | v2beta1 | DomainAPI |
19
- | Flexible IP | v1alpha1 | FlexibleipAPI |
20
- | Function | v1beta1 | FunctionAPI |
21
- | IOT | v1 | IotAPI |
22
- | K8S | v1 | K8SAPI |
23
- | LB | v1 | LbAPI |
24
- | Marketplace | v1 | MarketplaceAPI |
25
- | RDB | v1 | RdbAPI |
26
- | Redis | v1alpha1 | RedisAPI |
27
- | Registry | v1 | RegistryAPI |
28
- | VPC | v1 | VpcAPI |
29
- | VPC Gateway | v1 | VpcgwAPI |
3
+ This SDK enables you to interact with Scaleway APIs.
30
4
 
5
+ **🔗  Important links:**
6
+ * Reference documentation (soon)
7
+ * [Example projects](https://github.com/scaleway/scaleway-sdk-js/tree/master/examples)
8
+ * [Developers website](https://developers.scaleway.com) (API documentation)
31
9
 
32
10
  ## Getting Started
33
11
 
@@ -36,7 +14,7 @@ You'll need a pair of access and secret keys to connect to Scaleway API. Please
36
14
  **A minimal setup** would look like this:
37
15
 
38
16
  ```ts
39
- import { RegistryAPI, createClient } from '@scaleway/sdk'
17
+ import { Registry, createClient } from '@scaleway/sdk'
40
18
 
41
19
  const client = createClient({
42
20
  accessKey: 'SCWXXXXXXXXXXXXXXXXX',
@@ -46,44 +24,22 @@ const client = createClient({
46
24
  defaultZone: 'fr-par-1',
47
25
  })
48
26
 
49
- const registryAPI = new RegistryAPI(client)
27
+ const api = new Registry.v1.API(client)
50
28
  ```
51
29
 
52
- **In case of a NodeJS environment**, you could retrieve the profile from either the configuration file or the environment variables:
30
+ **For a simpler setup**, you could retrieve the profile from either the configuration file or the environment variables:
53
31
 
54
32
  ```ts
55
- import { loadProfileFromConfigurationFile } from '@scaleway/configuration-loader'
56
- // import { loadProfileFromEnvironmentValues } from '@scaleway/configuration-loader'
33
+ import {
34
+ loadProfileFromConfigurationFile,
35
+ // loadProfileFromEnvironmentValues,
36
+ } from '@scaleway/configuration-loader'
57
37
 
58
- const profile = loadProfileFromConfigurationFile()
59
- // const profile = loadProfileFromEnvironmentValues()
38
+ const profile = loadProfileFromConfigurationFile() // loadProfileFromEnvironmentValues()
60
39
  const client = createClient(profile)
61
40
  ```
62
41
 
63
- **For more advanced needs**, please check the examples.
64
-
65
- ## Usage
66
-
67
- This SDK is based on the [fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) API and use `Request`, `Response` & `Headers` interfaces. Those interfaces are native in modern browsers, node >=18 & deno environments.
68
-
69
- For `node` < 18 & `React Native` environments, the commonJS build requires [cross-fetch](https://www.npmjs.com/package/cross-fetch) package, it is listed in `dependencies` but not used in esm build.
70
-
71
- ## Troubleshooting
72
-
73
- In node environment, the commonJS module defined in `dist/index.cjs` entry file is used by default, thanks to the "main" `package.json` field.
74
-
75
- If you want to use the ES module from `dist/index.js` with node < 18 & `React Native` environments, we recommend you to explicitly import [cross-fetch](https://www.npmjs.com/package/cross-fetch) polyfill:
76
-
77
- ```ts
78
- import 'cross-fetch/polyfill'
79
- import {...} from '@scaleway/sdk'
80
- ```
81
-
82
- or
83
-
84
- ```bash
85
- node -r cross-fetch/polyfill ./script-using-sdk.mjs
86
- ```
42
+ **For more information**, please check the [GitHub project](https://github.com/scaleway/scaleway-sdk-js).
87
43
 
88
44
  ## Reach us
89
45
 
@@ -0,0 +1,4 @@
1
+ import * as index$1 from './v2alpha1/index.js';
2
+ export { index$1 as v2alpha1 };
3
+ import * as index$2 from './v2/index.js';
4
+ export { index$2 as v2 };
@@ -0,0 +1,88 @@
1
+ import { API } from '../../../scw/api.js';
2
+ import { urlParams, validatePathParam } from '../../../helpers/marshalling.js';
3
+ import { enrichForPagination } from '../../../scw/fetch/resource-paginator.js';
4
+ import { marshalCreateProjectRequest, unmarshalProject, unmarshalListProjectsResponse, marshalUpdateProjectRequest } from './marshalling.gen.js';
5
+
6
+ // This file was automatically generated. DO NOT EDIT.
7
+ const jsonContentHeaders = {
8
+ 'Content-Type': 'application/json; charset=utf-8'
9
+ };
10
+ /**
11
+ * Account API.
12
+ *
13
+ * This API allows you to manage projects.
14
+ */
15
+
16
+ class AccountV2GenAPI extends API {
17
+ constructor() {
18
+ var _this;
19
+
20
+ super(...arguments);
21
+ _this = this;
22
+
23
+ this.createProject = request => this.client.fetch({
24
+ body: JSON.stringify(marshalCreateProjectRequest(request, this.client.settings)),
25
+ headers: jsonContentHeaders,
26
+ method: 'POST',
27
+ path: `/account/v2/projects`
28
+ }, unmarshalProject);
29
+
30
+ this.pageOfListProjects = function (request) {
31
+ if (request === void 0) {
32
+ request = {};
33
+ }
34
+
35
+ return _this.client.fetch({
36
+ method: 'GET',
37
+ path: `/account/v2/projects`,
38
+ urlParams: urlParams(['name', request.name], ['order_by', request.orderBy ?? 'created_at_asc'], ['organization_id', request.organizationId ?? _this.client.settings.defaultOrganizationId], ['page', request.page], ['page_size', request.pageSize ?? _this.client.settings.defaultPageSize])
39
+ }, unmarshalListProjectsResponse);
40
+ };
41
+
42
+ this.listProjects = function (request) {
43
+ if (request === void 0) {
44
+ request = {};
45
+ }
46
+
47
+ return enrichForPagination('projects', _this.pageOfListProjects, request);
48
+ };
49
+
50
+ this.getProject = function (request) {
51
+ if (request === void 0) {
52
+ request = {};
53
+ }
54
+
55
+ return _this.client.fetch({
56
+ method: 'GET',
57
+ path: `/account/v2/projects/${validatePathParam('projectId', request.projectId ?? _this.client.settings.defaultProjectId)}`
58
+ }, unmarshalProject);
59
+ };
60
+
61
+ this.deleteProject = function (request) {
62
+ if (request === void 0) {
63
+ request = {};
64
+ }
65
+
66
+ return _this.client.fetch({
67
+ method: 'DELETE',
68
+ path: `/account/v2/projects/${validatePathParam('projectId', request.projectId ?? _this.client.settings.defaultProjectId)}`
69
+ });
70
+ };
71
+
72
+ this.updateProject = function (request) {
73
+ if (request === void 0) {
74
+ request = {};
75
+ }
76
+
77
+ return _this.client.fetch({
78
+ body: JSON.stringify(marshalUpdateProjectRequest(request, _this.client.settings)),
79
+ headers: jsonContentHeaders,
80
+ method: 'PATCH',
81
+ path: `/account/v2/projects/${validatePathParam('projectId', request.projectId ?? _this.client.settings.defaultProjectId)}`
82
+ }, unmarshalProject);
83
+ };
84
+ }
85
+
86
+ }
87
+
88
+ export { AccountV2GenAPI };
@@ -0,0 +1 @@
1
+ export { AccountV2GenAPI as API } from './api.gen.js';
@@ -0,0 +1,39 @@
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 unmarshalProject = data => {
6
+ if (!isJSONObject(data)) {
7
+ throw new TypeError(`Unmarshalling the type 'Project' failed as data isn't a dictionary.`);
8
+ }
9
+
10
+ return {
11
+ createdAt: unmarshalDate(data.created_at),
12
+ description: data.description,
13
+ id: data.id,
14
+ name: data.name,
15
+ organizationId: data.organization_id,
16
+ updatedAt: unmarshalDate(data.updated_at)
17
+ };
18
+ };
19
+ const unmarshalListProjectsResponse = data => {
20
+ if (!isJSONObject(data)) {
21
+ throw new TypeError(`Unmarshalling the type 'ListProjectsResponse' failed as data isn't a dictionary.`);
22
+ }
23
+
24
+ return {
25
+ projects: unmarshalArrayOfObject(data.projects, unmarshalProject),
26
+ totalCount: data.total_count
27
+ };
28
+ };
29
+ const marshalCreateProjectRequest = (request, defaults) => ({
30
+ description: request.description,
31
+ name: request.name,
32
+ organization_id: request.organizationId ?? defaults.defaultOrganizationId
33
+ });
34
+ const marshalUpdateProjectRequest = (request, defaults) => ({
35
+ description: request.description,
36
+ name: request.name
37
+ });
38
+
39
+ export { marshalCreateProjectRequest, marshalUpdateProjectRequest, unmarshalListProjectsResponse, unmarshalProject };
@@ -1,14 +1,14 @@
1
- import { API } from '../../../helpers/API.js';
2
- import { urlParams, resolveOneOf, validatePathParam, unmarshalAnyRes } from '../../../scw/marshalling.js';
1
+ import { API } from '../../../scw/api.js';
2
+ import { urlParams, validatePathParam } from '../../../helpers/marshalling.js';
3
3
  import { enrichForPagination } from '../../../scw/fetch/resource-paginator.js';
4
+ import { unmarshalListSSHKeysResponse, marshalCreateSSHKeyRequest, unmarshalSSHKey, marshalUpdateSSHKeyRequest } from './marshalling.gen.js';
4
5
 
5
6
  // This file was automatically generated. DO NOT EDIT.
6
-
7
- const unmarshal0ECB = data => unmarshalAnyRes(data, [], ['created_at', 'updated_at']);
8
-
9
7
  const jsonContentHeaders = {
10
8
  'Content-Type': 'application/json; charset=utf-8'
11
9
  };
10
+ /** Account API. */
11
+
12
12
  class AccountV2Alpha1GenAPI extends API {
13
13
  constructor() {
14
14
  var _this;
@@ -25,7 +25,7 @@ class AccountV2Alpha1GenAPI extends API {
25
25
  method: 'GET',
26
26
  path: `/account/v2alpha1/ssh-keys`,
27
27
  urlParams: urlParams(['name', request.name], ['order_by', request.orderBy ?? 'created_at_asc'], ['organization_id', request.organizationId ?? _this.client.settings.defaultOrganizationId], ['page', request.page], ['page_size', request.pageSize ?? _this.client.settings.defaultPageSize], ['project_id', request.projectId ?? _this.client.settings.defaultProjectId])
28
- }, unmarshal0ECB);
28
+ }, unmarshalListSSHKeysResponse);
29
29
  };
30
30
 
31
31
  this.listSSHKeys = function (request) {
@@ -36,41 +36,24 @@ class AccountV2Alpha1GenAPI extends API {
36
36
  return enrichForPagination('sshKeys', _this.pageOfListSSHKeys, request);
37
37
  };
38
38
 
39
- this.createSSHKey = request => {
40
- const projectIdentifier = resolveOneOf([{
41
- default: this.client.settings.defaultProjectId,
42
- param: 'project_id',
43
- value: request.projectId
44
- }, {
45
- default: this.client.settings.defaultOrganizationId,
46
- param: 'organization_id',
47
- value: request.organizationId
48
- }]);
49
- return this.client.fetch({
50
- body: JSON.stringify({
51
- name: request.name,
52
- public_key: request.publicKey,
53
- ...projectIdentifier
54
- }),
55
- headers: jsonContentHeaders,
56
- method: 'POST',
57
- path: `/account/v2alpha1/ssh-keys`
58
- }, unmarshal0ECB);
59
- };
39
+ this.createSSHKey = request => this.client.fetch({
40
+ body: JSON.stringify(marshalCreateSSHKeyRequest(request, this.client.settings)),
41
+ headers: jsonContentHeaders,
42
+ method: 'POST',
43
+ path: `/account/v2alpha1/ssh-keys`
44
+ }, unmarshalSSHKey);
60
45
 
61
46
  this.getSSHKey = request => this.client.fetch({
62
47
  method: 'GET',
63
48
  path: `/account/v2alpha1/ssh-key/${validatePathParam('sshKeyId', request.sshKeyId)}`
64
- }, unmarshal0ECB);
49
+ }, unmarshalSSHKey);
65
50
 
66
51
  this.updateSSHKey = request => this.client.fetch({
67
- body: JSON.stringify({
68
- name: request.name
69
- }),
52
+ body: JSON.stringify(marshalUpdateSSHKeyRequest(request, this.client.settings)),
70
53
  headers: jsonContentHeaders,
71
54
  method: 'PATCH',
72
55
  path: `/account/v2alpha1/ssh-key/${validatePathParam('sshKeyId', request.sshKeyId)}`
73
- }, unmarshal0ECB);
56
+ }, unmarshalSSHKey);
74
57
 
75
58
  this.deleteSSHKey = request => this.client.fetch({
76
59
  method: 'DELETE',
@@ -0,0 +1 @@
1
+ export { AccountV2Alpha1GenAPI as API } from './api.gen.js';
@@ -0,0 +1,62 @@
1
+ import { isJSONObject } from '../../../helpers/json.js';
2
+ import { resolveOneOf, unmarshalDate, unmarshalArrayOfObject } from '../../../helpers/marshalling.js';
3
+
4
+ // This file was automatically generated. DO NOT EDIT.
5
+
6
+ const unmarshalSSHKeyCreationInfo = data => {
7
+ if (!isJSONObject(data)) {
8
+ throw new TypeError(`Unmarshalling the type 'SSHKeyCreationInfo' failed as data isn't a dictionary.`);
9
+ }
10
+
11
+ return {
12
+ address: data.address,
13
+ countryCode: data.country_code,
14
+ userAgent: data.user_agent
15
+ };
16
+ };
17
+
18
+ const unmarshalSSHKey = data => {
19
+ if (!isJSONObject(data)) {
20
+ throw new TypeError(`Unmarshalling the type 'SSHKey' failed as data isn't a dictionary.`);
21
+ }
22
+
23
+ return {
24
+ createdAt: unmarshalDate(data.created_at),
25
+ creationInfo: data.creation_info ? unmarshalSSHKeyCreationInfo(data.creation_info) : undefined,
26
+ fingerprint: data.fingerprint,
27
+ id: data.id,
28
+ name: data.name,
29
+ organizationId: data.organization_id,
30
+ projectId: data.project_id,
31
+ publicKey: data.public_key,
32
+ updatedAt: unmarshalDate(data.updated_at)
33
+ };
34
+ };
35
+ const unmarshalListSSHKeysResponse = data => {
36
+ if (!isJSONObject(data)) {
37
+ throw new TypeError(`Unmarshalling the type 'ListSSHKeysResponse' failed as data isn't a dictionary.`);
38
+ }
39
+
40
+ return {
41
+ sshKeys: unmarshalArrayOfObject(data.ssh_keys, unmarshalSSHKey),
42
+ totalCount: data.total_count
43
+ };
44
+ };
45
+ const marshalCreateSSHKeyRequest = (request, defaults) => ({
46
+ name: request.name,
47
+ public_key: request.publicKey,
48
+ ...resolveOneOf([{
49
+ default: defaults.defaultProjectId,
50
+ param: 'project_id',
51
+ value: request.projectId
52
+ }, {
53
+ default: defaults.defaultOrganizationId,
54
+ param: 'organization_id',
55
+ value: request.organizationId
56
+ }])
57
+ });
58
+ const marshalUpdateSSHKeyRequest = (request, defaults) => ({
59
+ name: request.name
60
+ });
61
+
62
+ export { marshalCreateSSHKeyRequest, marshalUpdateSSHKeyRequest, unmarshalListSSHKeysResponse, unmarshalSSHKey };
@@ -0,0 +1,2 @@
1
+ import * as index$1 from './v1alpha1/index.js';
2
+ export { index$1 as v1alpha1 };
@@ -1,15 +1,35 @@
1
- import randomName from '../../../node_modules/.pnpm/@scaleway_random-name@3.0.2/node_modules/@scaleway/random-name/dist/index.js';
2
- import { API } from '../../../helpers/API.js';
3
- import { validatePathParam, unmarshalAnyRes, urlParams } from '../../../scw/marshalling.js';
1
+ import { waitForResource } from '../../../internal/async/interval-retrier.js';
2
+ import { API } from '../../../scw/api.js';
3
+ import { validatePathParam, urlParams } from '../../../helpers/marshalling.js';
4
4
  import { enrichForPagination } from '../../../scw/fetch/resource-paginator.js';
5
+ import { SERVER_TRANSIENT_STATUSES } from './content.gen.js';
6
+ import { unmarshalListServerTypesResponse, unmarshalServerType, marshalCreateServerRequest, unmarshalServer, unmarshalListServersResponse, unmarshalListOSResponse, unmarshalOS, marshalUpdateServerRequest } from './marshalling.gen.js';
5
7
 
6
8
  // This file was automatically generated. DO NOT EDIT.
7
-
8
- const unmarshalA4C1 = data => unmarshalAnyRes(data, [], ['created_at', 'deletable_at', 'updated_at']);
9
-
10
9
  const jsonContentHeaders = {
11
10
  'Content-Type': 'application/json; charset=utf-8'
12
11
  };
12
+ /**
13
+ * Apple silicon.
14
+ *
15
+ * Scaleway Apple silicon M1 as-a-Service is built using the latest generation
16
+ * of Apple Mac mini hardware (fifth generation).
17
+ *
18
+ * These dedicated Mac mini M1s are designed for developing, building, testing,
19
+ * and signing applications for Apple devices, including iPhones, iPads, Mac
20
+ * computers and much more.
21
+ *
22
+ * Get set to explore, learn and build on a dedicated Mac mini M1 with more
23
+ * performance and speed than you ever thought possible.
24
+ *
25
+ * _Apple silicon as a Service comes with a minimum allocation period of 24 hours_*.
26
+ *
27
+ * Mac mini and macOS are trademarks of Apple Inc., registered in the U.S. and
28
+ * other countries and regions. IOS is a trademark or registered trademark of
29
+ * Cisco in the U.S. and other countries and is used by Apple under license.
30
+ * Scaleway is not affiliated with Apple Inc.
31
+ */
32
+
13
33
  class ApplesiliconV1Alpha1GenAPI extends API {
14
34
  constructor() {
15
35
  var _this;
@@ -25,24 +45,20 @@ class ApplesiliconV1Alpha1GenAPI extends API {
25
45
  return _this.client.fetch({
26
46
  method: 'GET',
27
47
  path: `/apple-silicon/v1alpha1/zones/${validatePathParam('zone', request.zone ?? _this.client.settings.defaultZone)}/server-types`
28
- }, unmarshalAnyRes);
48
+ }, unmarshalListServerTypesResponse);
29
49
  };
30
50
 
31
51
  this.getServerType = request => this.client.fetch({
32
52
  method: 'GET',
33
53
  path: `/apple-silicon/v1alpha1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/server-type/${validatePathParam('serverType', request.serverType)}`
34
- }, unmarshalAnyRes);
54
+ }, unmarshalServerType);
35
55
 
36
56
  this.createServer = request => this.client.fetch({
37
- body: JSON.stringify({
38
- name: request.name || randomName('as'),
39
- project_id: request.projectId ?? this.client.settings.defaultProjectId,
40
- type: request.type
41
- }),
57
+ body: JSON.stringify(marshalCreateServerRequest(request, this.client.settings)),
42
58
  headers: jsonContentHeaders,
43
59
  method: 'POST',
44
60
  path: `/apple-silicon/v1alpha1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/servers`
45
- }, unmarshalA4C1);
61
+ }, unmarshalServer);
46
62
 
47
63
  this.pageOfListServers = function (request) {
48
64
  if (request === void 0) {
@@ -53,7 +69,7 @@ class ApplesiliconV1Alpha1GenAPI extends API {
53
69
  method: 'GET',
54
70
  path: `/apple-silicon/v1alpha1/zones/${validatePathParam('zone', request.zone ?? _this.client.settings.defaultZone)}/servers`,
55
71
  urlParams: urlParams(['order_by', request.orderBy ?? 'created_at_asc'], ['organization_id', request.organizationId ?? _this.client.settings.defaultOrganizationId], ['page', request.page], ['page_size', request.pageSize ?? _this.client.settings.defaultPageSize], ['project_id', request.projectId ?? _this.client.settings.defaultProjectId])
56
- }, unmarshalA4C1);
72
+ }, unmarshalListServersResponse);
57
73
  };
58
74
 
59
75
  this.listServers = function (request) {
@@ -73,7 +89,7 @@ class ApplesiliconV1Alpha1GenAPI extends API {
73
89
  method: 'GET',
74
90
  path: `/apple-silicon/v1alpha1/zones/${validatePathParam('zone', request.zone ?? _this.client.settings.defaultZone)}/os`,
75
91
  urlParams: urlParams(['name', request.name], ['page', request.page], ['page_size', request.pageSize ?? _this.client.settings.defaultPageSize], ['server_type', request.serverType])
76
- }, unmarshalAnyRes);
92
+ }, unmarshalListOSResponse);
77
93
  };
78
94
 
79
95
  this.listOS = function (request) {
@@ -87,21 +103,21 @@ class ApplesiliconV1Alpha1GenAPI extends API {
87
103
  this.getOS = request => this.client.fetch({
88
104
  method: 'GET',
89
105
  path: `/apple-silicon/v1alpha1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/os/${validatePathParam('osId', request.osId)}`
90
- }, unmarshalAnyRes);
106
+ }, unmarshalOS);
91
107
 
92
108
  this.getServer = request => this.client.fetch({
93
109
  method: 'GET',
94
110
  path: `/apple-silicon/v1alpha1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/servers/${validatePathParam('serverId', request.serverId)}`
95
- }, unmarshalA4C1);
111
+ }, unmarshalServer);
112
+
113
+ this.waitForServer = (request, options) => waitForResource((options == null ? void 0 : options.stop) ?? (res => Promise.resolve(!SERVER_TRANSIENT_STATUSES.includes(res.status))), this.getServer, request, options);
96
114
 
97
115
  this.updateServer = request => this.client.fetch({
98
- body: JSON.stringify({
99
- name: request.name
100
- }),
116
+ body: JSON.stringify(marshalUpdateServerRequest(request, this.client.settings)),
101
117
  headers: jsonContentHeaders,
102
118
  method: 'PATCH',
103
119
  path: `/apple-silicon/v1alpha1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/servers/${validatePathParam('serverId', request.serverId)}`
104
- }, unmarshalA4C1);
120
+ }, unmarshalServer);
105
121
 
106
122
  this.deleteServer = request => this.client.fetch({
107
123
  method: 'DELETE',
@@ -113,14 +129,14 @@ class ApplesiliconV1Alpha1GenAPI extends API {
113
129
  headers: jsonContentHeaders,
114
130
  method: 'POST',
115
131
  path: `/apple-silicon/v1alpha1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/servers/${validatePathParam('serverId', request.serverId)}/reboot`
116
- }, unmarshalA4C1);
132
+ }, unmarshalServer);
117
133
 
118
134
  this.reinstallServer = request => this.client.fetch({
119
135
  body: '{}',
120
136
  headers: jsonContentHeaders,
121
137
  method: 'POST',
122
138
  path: `/apple-silicon/v1alpha1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/servers/${validatePathParam('serverId', request.serverId)}/reinstall`
123
- }, unmarshalA4C1);
139
+ }, unmarshalServer);
124
140
  }
125
141
 
126
142
  }
@@ -0,0 +1,7 @@
1
+ // This file was automatically generated. DO NOT EDIT.
2
+ // If you have any remark or suggestion do not hesitate to open an issue.
3
+
4
+ /** Lists transient statutes of the enum {@link ServerStatus}. */
5
+ const SERVER_TRANSIENT_STATUSES = ['starting', 'rebooting', 'updating', 'locking', 'unlocking', 'reinstalling'];
6
+
7
+ export { SERVER_TRANSIENT_STATUSES };
@@ -0,0 +1,2 @@
1
+ export { ApplesiliconV1Alpha1GenAPI as API } from './api.gen.js';
2
+ export { SERVER_TRANSIENT_STATUSES } from './content.gen.js';
@@ -0,0 +1,125 @@
1
+ import randomName from '../../../node_modules/.pnpm/@scaleway_random-name@3.0.2/node_modules/@scaleway/random-name/dist/index.js';
2
+ import { isJSONObject } from '../../../helpers/json.js';
3
+ import { unmarshalDate, unmarshalArrayOfObject } from '../../../helpers/marshalling.js';
4
+
5
+ // This file was automatically generated. DO NOT EDIT.
6
+
7
+ const unmarshalServerTypeCPU = data => {
8
+ if (!isJSONObject(data)) {
9
+ throw new TypeError(`Unmarshalling the type 'ServerTypeCPU' failed as data isn't a dictionary.`);
10
+ }
11
+
12
+ return {
13
+ coreCount: data.core_count,
14
+ name: data.name
15
+ };
16
+ };
17
+
18
+ const unmarshalServerTypeDisk = data => {
19
+ if (!isJSONObject(data)) {
20
+ throw new TypeError(`Unmarshalling the type 'ServerTypeDisk' failed as data isn't a dictionary.`);
21
+ }
22
+
23
+ return {
24
+ capacity: data.capacity,
25
+ type: data.type
26
+ };
27
+ };
28
+
29
+ const unmarshalServerTypeMemory = data => {
30
+ if (!isJSONObject(data)) {
31
+ throw new TypeError(`Unmarshalling the type 'ServerTypeMemory' failed as data isn't a dictionary.`);
32
+ }
33
+
34
+ return {
35
+ capacity: data.capacity,
36
+ type: data.type
37
+ };
38
+ };
39
+
40
+ const unmarshalOS = data => {
41
+ if (!isJSONObject(data)) {
42
+ throw new TypeError(`Unmarshalling the type 'OS' failed as data isn't a dictionary.`);
43
+ }
44
+
45
+ return {
46
+ compatibleServerTypes: data.compatible_server_types,
47
+ id: data.id,
48
+ imageUrl: data.image_url,
49
+ label: data.label,
50
+ name: data.name
51
+ };
52
+ };
53
+ const unmarshalServer = data => {
54
+ if (!isJSONObject(data)) {
55
+ throw new TypeError(`Unmarshalling the type 'Server' failed as data isn't a dictionary.`);
56
+ }
57
+
58
+ return {
59
+ createdAt: unmarshalDate(data.created_at),
60
+ deletableAt: unmarshalDate(data.deletable_at),
61
+ id: data.id,
62
+ ip: data.ip,
63
+ name: data.name,
64
+ organizationId: data.organization_id,
65
+ projectId: data.project_id,
66
+ status: data.status,
67
+ type: data.type,
68
+ updatedAt: unmarshalDate(data.updated_at),
69
+ vncUrl: data.vnc_url,
70
+ zone: data.zone
71
+ };
72
+ };
73
+ const unmarshalServerType = data => {
74
+ if (!isJSONObject(data)) {
75
+ throw new TypeError(`Unmarshalling the type 'ServerType' failed as data isn't a dictionary.`);
76
+ }
77
+
78
+ return {
79
+ cpu: data.cpu ? unmarshalServerTypeCPU(data.cpu) : undefined,
80
+ disk: data.disk ? unmarshalServerTypeDisk(data.disk) : undefined,
81
+ memory: data.memory ? unmarshalServerTypeMemory(data.memory) : undefined,
82
+ minimumLeaseDuration: data.minimum_lease_duration,
83
+ name: data.name,
84
+ stock: data.stock
85
+ };
86
+ };
87
+ const unmarshalListOSResponse = data => {
88
+ if (!isJSONObject(data)) {
89
+ throw new TypeError(`Unmarshalling the type 'ListOSResponse' failed as data isn't a dictionary.`);
90
+ }
91
+
92
+ return {
93
+ os: unmarshalArrayOfObject(data.os, unmarshalOS),
94
+ totalCount: data.total_count
95
+ };
96
+ };
97
+ const unmarshalListServerTypesResponse = data => {
98
+ if (!isJSONObject(data)) {
99
+ throw new TypeError(`Unmarshalling the type 'ListServerTypesResponse' failed as data isn't a dictionary.`);
100
+ }
101
+
102
+ return {
103
+ serverTypes: unmarshalArrayOfObject(data.server_types, unmarshalServerType)
104
+ };
105
+ };
106
+ const unmarshalListServersResponse = data => {
107
+ if (!isJSONObject(data)) {
108
+ throw new TypeError(`Unmarshalling the type 'ListServersResponse' failed as data isn't a dictionary.`);
109
+ }
110
+
111
+ return {
112
+ servers: unmarshalArrayOfObject(data.servers, unmarshalServer),
113
+ totalCount: data.total_count
114
+ };
115
+ };
116
+ const marshalCreateServerRequest = (request, defaults) => ({
117
+ name: request.name || randomName('as'),
118
+ project_id: request.projectId ?? defaults.defaultProjectId,
119
+ type: request.type
120
+ });
121
+ const marshalUpdateServerRequest = (request, defaults) => ({
122
+ name: request.name
123
+ });
124
+
125
+ export { marshalCreateServerRequest, marshalUpdateServerRequest, unmarshalListOSResponse, unmarshalListServerTypesResponse, unmarshalListServersResponse, unmarshalOS, unmarshalServer, unmarshalServerType };
@@ -0,0 +1,2 @@
1
+ import * as index$1 from './v1/index.js';
2
+ export { index$1 as v1 };