@scaleway/sdk 0.1.0-beta.9 → 1.0.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.
- package/README.md +1 -1
- package/dist/api/account/index.js +2 -2
- package/dist/api/account/v2/api.gen.js +5 -18
- package/dist/api/account/v2/index.gen.js +3 -0
- package/dist/api/account/v2/marshalling.gen.js +0 -2
- package/dist/api/account/v2alpha1/api.gen.js +3 -13
- package/dist/api/account/v2alpha1/marshalling.gen.js +0 -5
- package/dist/api/applesilicon/index.js +2 -2
- package/dist/api/applesilicon/v1alpha1/api.gen.js +7 -27
- package/dist/api/applesilicon/v1alpha1/index.gen.js +4 -0
- package/dist/api/applesilicon/v1alpha1/marshalling.gen.js +1 -14
- package/dist/api/baremetal/v1/api.gen.js +47 -49
- package/dist/api/baremetal/v1/api.utils.js +2 -10
- package/dist/api/baremetal/v1/content.gen.js +6 -3
- package/dist/api/baremetal/v1/index.js +4 -1
- package/dist/api/baremetal/v1/marshalling.gen.js +44 -45
- package/dist/api/baremetal/v1/validation-rules.gen.js +109 -0
- package/dist/api/container/index.js +2 -2
- package/dist/api/container/v1beta1/api.gen.js +5 -51
- package/dist/api/container/v1beta1/content.gen.js +4 -4
- package/dist/api/container/v1beta1/{index.js → index.gen.js} +3 -1
- package/dist/api/container/v1beta1/marshalling.gen.js +12 -26
- package/dist/api/domain/index.js +2 -2
- package/dist/api/domain/v2beta1/api.gen.js +55 -85
- package/dist/api/domain/v2beta1/content.gen.js +22 -1
- package/dist/api/domain/v2beta1/index.gen.js +4 -0
- package/dist/api/domain/v2beta1/marshalling.gen.js +47 -165
- package/dist/api/flexibleip/index.js +2 -2
- package/dist/api/flexibleip/v1alpha1/api.gen.js +5 -22
- package/dist/api/flexibleip/v1alpha1/content.gen.js +1 -1
- package/dist/api/flexibleip/v1alpha1/index.gen.js +6 -0
- package/dist/api/flexibleip/v1alpha1/marshalling.gen.js +0 -7
- package/dist/api/flexibleip/v1alpha1/validation-rules.gen.js +14 -0
- package/dist/api/function/index.js +2 -2
- package/dist/api/function/v1beta1/api.gen.js +54 -57
- package/dist/api/function/v1beta1/content.gen.js +8 -5
- package/dist/api/function/v1beta1/index.gen.js +4 -0
- package/dist/api/function/v1beta1/marshalling.gen.js +125 -33
- package/dist/api/iam/index.js +2 -2
- package/dist/api/iam/v1alpha1/api.gen.js +15 -62
- package/dist/api/iam/v1alpha1/index.gen.js +5 -0
- package/dist/api/iam/v1alpha1/marshalling.gen.js +7 -29
- package/dist/api/iam/v1alpha1/validation-rules.gen.js +184 -0
- package/dist/api/instance/v1/api.gen.js +38 -118
- package/dist/api/instance/v1/api.utils.js +59 -51
- package/dist/api/instance/v1/content.gen.js +7 -7
- package/dist/api/instance/v1/marshalling.gen.js +46 -168
- package/dist/api/instance/v1/marshalling.utils.js +63 -0
- package/dist/api/iot/index.js +2 -2
- package/dist/api/iot/v1/api.gen.js +5 -56
- package/dist/api/iot/v1/index.gen.js +4 -0
- package/dist/api/iot/v1/marshalling.gen.js +2 -51
- package/dist/api/k8s/index.js +2 -2
- package/dist/api/k8s/v1/api.gen.js +17 -43
- package/dist/api/k8s/v1/content.gen.js +2 -2
- package/dist/api/k8s/v1/index.gen.js +6 -0
- package/dist/api/k8s/v1/marshalling.gen.js +18 -36
- package/dist/api/k8s/v1/validation-rules.gen.js +92 -0
- package/dist/api/lb/v1/api.gen.js +8 -163
- package/dist/api/lb/v1/api.utils.js +3 -9
- package/dist/api/lb/v1/content.gen.js +3 -3
- package/dist/api/lb/v1/marshalling.gen.js +74 -101
- package/dist/api/marketplace/index.js +4 -2
- package/dist/api/marketplace/v1/api.gen.js +3 -13
- package/dist/api/marketplace/v1/index.gen.js +3 -0
- package/dist/api/marketplace/v1/marshalling.gen.js +0 -13
- package/dist/api/marketplace/v2/api.gen.js +85 -0
- package/dist/api/marketplace/v2/index.gen.js +3 -0
- package/dist/api/marketplace/v2/marshalling.gen.js +92 -0
- package/dist/api/mnq/index.js +2 -2
- package/dist/api/mnq/v1alpha1/api.gen.js +7 -25
- package/dist/api/mnq/v1alpha1/index.gen.js +3 -0
- package/dist/api/mnq/v1alpha1/marshalling.gen.js +7 -46
- package/dist/api/rdb/index.js +2 -2
- package/dist/api/rdb/v1/api.gen.js +15 -89
- package/dist/api/rdb/v1/content.gen.js +10 -4
- package/dist/api/rdb/v1/index.gen.js +4 -0
- package/dist/api/rdb/v1/marshalling.gen.js +25 -81
- package/dist/api/redis/index.js +2 -2
- package/dist/api/redis/{v1alpha1 → v1}/api.gen.js +45 -77
- package/dist/api/redis/{v1alpha1 → v1}/content.gen.js +1 -1
- package/dist/api/redis/v1/index.gen.js +4 -0
- package/dist/api/redis/{v1alpha1 → v1}/marshalling.gen.js +42 -59
- package/dist/api/registry/index.js +2 -2
- package/dist/api/registry/v1/api.gen.js +5 -29
- package/dist/api/registry/v1/content.gen.js +2 -2
- package/dist/api/registry/v1/{index.js → index.gen.js} +3 -1
- package/dist/api/registry/v1/marshalling.gen.js +2 -8
- package/dist/api/secret/index.js +2 -0
- package/dist/api/secret/v1alpha1/api.gen.js +135 -0
- package/dist/api/secret/v1alpha1/index.gen.js +3 -0
- package/dist/api/secret/v1alpha1/marshalling.gen.js +82 -0
- package/dist/api/tem/index.js +2 -0
- package/dist/api/tem/v1alpha1/api.gen.js +109 -0
- package/dist/api/tem/v1alpha1/content.gen.js +10 -0
- package/dist/api/tem/v1alpha1/index.gen.js +4 -0
- package/dist/api/tem/v1alpha1/marshalling.gen.js +132 -0
- package/dist/api/test/index.js +2 -2
- package/dist/api/test/v1/api.gen.js +6 -20
- package/dist/api/test/v1/index.gen.js +4 -0
- package/dist/api/test/v1/marshalling.gen.js +2 -5
- package/dist/api/vpc/index.js +2 -2
- package/dist/api/vpc/v1/api.gen.js +6 -17
- package/dist/api/vpc/v1/index.gen.js +3 -0
- package/dist/api/vpc/v1/marshalling.gen.js +1 -3
- package/dist/api/vpcgw/index.js +2 -2
- package/dist/api/vpcgw/v1/api.gen.js +5 -64
- package/dist/api/vpcgw/v1/content.gen.js +2 -2
- package/dist/api/vpcgw/v1/{index.js → index.gen.js} +3 -1
- package/dist/api/vpcgw/v1/marshalling.gen.js +3 -24
- package/dist/helpers/json.js +1 -2
- package/dist/helpers/marshalling.js +7 -20
- package/dist/index.cjs +3864 -2945
- package/dist/index.d.ts +7212 -4332
- package/dist/index.js +10 -6
- package/dist/internal/async/interval-retrier.js +10 -16
- package/dist/internal/interceptors/interceptor.js +3 -1
- package/dist/internal/interceptors/request.js +1 -3
- package/dist/internal/logger/console-logger.js +3 -5
- package/dist/internal/logger/index.js +3 -5
- package/dist/internal/logger/level-resolver.js +0 -3
- package/dist/internal/validations/string-validation.js +8 -10
- package/dist/node_modules/.pnpm/@scaleway_random-name@4.0.1/node_modules/@scaleway/random-name/dist/index.js +13 -0
- package/dist/scw/api.js +3 -4
- package/dist/scw/auth.js +3 -5
- package/dist/scw/client-ini-factory.js +32 -15
- package/dist/scw/client-ini-profile.js +10 -4
- package/dist/scw/client-settings.js +32 -15
- package/dist/scw/client.js +5 -6
- package/dist/scw/constants.js +1 -1
- package/dist/scw/custom-marshalling.js +8 -14
- package/dist/scw/errors/error-parser.js +2 -21
- package/dist/scw/errors/non-standard/invalid-request-mapper.js +17 -15
- package/dist/scw/errors/non-standard/unknown-resource-mapper.js +7 -6
- package/dist/scw/errors/scw-error.js +20 -20
- package/dist/scw/errors/standard/already-exists-error.js +3 -4
- package/dist/scw/errors/standard/denied-authentication-error.js +4 -11
- package/dist/scw/errors/standard/invalid-arguments-error.js +1 -10
- package/dist/scw/errors/standard/out-of-stock-error.js +0 -3
- package/dist/scw/errors/standard/permissions-denied-error.js +1 -4
- package/dist/scw/errors/standard/precondition-failed-error.js +4 -8
- package/dist/scw/errors/standard/quotas-exceeded-error.js +14 -14
- package/dist/scw/errors/standard/resource-expired-error.js +3 -4
- package/dist/scw/errors/standard/resource-locked-error.js +3 -4
- package/dist/scw/errors/standard/resource-not-found-error.js +3 -4
- package/dist/scw/errors/standard/too-many-requests-error.js +3 -16
- package/dist/scw/errors/standard/transient-state-error.js +3 -4
- package/dist/scw/errors/types.js +0 -3
- package/dist/scw/fetch/build-fetcher.js +1 -9
- package/dist/scw/fetch/http-dumper.js +4 -7
- package/dist/scw/fetch/http-interceptors.js +9 -12
- package/dist/scw/fetch/resource-paginator.js +18 -16
- package/dist/scw/fetch/response-parser.js +17 -23
- package/node_modules/@scaleway/random-name/CHANGELOG.md +42 -63
- package/node_modules/@scaleway/random-name/dist/index.js +5 -246
- package/node_modules/@scaleway/random-name/package.json +6 -5
- package/package.json +4 -5
- package/dist/api/account/v2/index.js +0 -1
- package/dist/api/applesilicon/v1alpha1/index.js +0 -2
- package/dist/api/domain/v2beta1/index.js +0 -2
- package/dist/api/flexibleip/v1alpha1/index.js +0 -2
- package/dist/api/function/v1beta1/index.js +0 -2
- package/dist/api/iam/v1alpha1/index.js +0 -1
- package/dist/api/iot/v1/index.js +0 -2
- package/dist/api/k8s/v1/index.js +0 -2
- package/dist/api/marketplace/v1/index.js +0 -1
- package/dist/api/mnq/v1alpha1/index.js +0 -1
- package/dist/api/rdb/v1/index.js +0 -2
- package/dist/api/redis/v1alpha1/index.js +0 -2
- package/dist/api/test/v1/index.js +0 -1
- package/dist/api/vpc/v1/index.js +0 -1
- package/dist/node_modules/.pnpm/@scaleway_random-name@3.0.2/node_modules/@scaleway/random-name/dist/index.js +0 -254
- package/node_modules/@scaleway/random-name/dist/index.browser.js +0 -256
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { tryAtIntervals, createExponentialBackoffStrategy } from '../../../internal/async/interval-retrier.js';
|
|
2
|
-
import {
|
|
2
|
+
import { validatePathParam } from '../../../helpers/marshalling.js';
|
|
3
|
+
import { API } from './api.gen.js';
|
|
3
4
|
import { IMAGE_TRANSIENT_STATUSES, PRIVATE_NIC_TRANSIENT_STATUSES, SERVER_TRANSIENT_STATUSES, SNAPSHOT_TRANSIENT_STATUSES, VOLUME_TRANSIENT_STATUSES } from './content.gen.js';
|
|
5
|
+
import { unmarshalSetImageResponse } from './marshalling.gen.js';
|
|
6
|
+
import { marshalSetImageRequestWithID } from './marshalling.utils.js';
|
|
4
7
|
|
|
5
8
|
const validateNotUndefined = obj => {
|
|
6
9
|
if (obj === undefined) throw new TypeError(`object was found undefined`);
|
|
7
10
|
return obj;
|
|
8
11
|
};
|
|
9
|
-
|
|
10
|
-
class InstanceV1UtilsAPI extends InstanceV1GenAPI {
|
|
12
|
+
class InstanceV1UtilsAPI extends API {
|
|
11
13
|
constructor() {
|
|
12
14
|
super(...arguments);
|
|
13
|
-
|
|
14
15
|
this.waitForImage = (request, options) => tryAtIntervals(async () => {
|
|
15
16
|
const value = await this.getImage(request).then(res => res.image);
|
|
16
17
|
return {
|
|
@@ -18,7 +19,6 @@ class InstanceV1UtilsAPI extends InstanceV1GenAPI {
|
|
|
18
19
|
value
|
|
19
20
|
};
|
|
20
21
|
}, createExponentialBackoffStrategy((options == null ? void 0 : options.minDelay) ?? 1, (options == null ? void 0 : options.maxDelay) ?? 30), options == null ? void 0 : options.timeout);
|
|
21
|
-
|
|
22
22
|
this.waitForPrivateNIC = (request, options) => tryAtIntervals(async () => {
|
|
23
23
|
const value = await this.getPrivateNIC(request).then(res => res.privateNic);
|
|
24
24
|
return {
|
|
@@ -26,7 +26,6 @@ class InstanceV1UtilsAPI extends InstanceV1GenAPI {
|
|
|
26
26
|
value
|
|
27
27
|
};
|
|
28
28
|
}, createExponentialBackoffStrategy((options == null ? void 0 : options.minDelay) ?? 1, (options == null ? void 0 : options.maxDelay) ?? 30), options == null ? void 0 : options.timeout);
|
|
29
|
-
|
|
30
29
|
this.waitForServer = (request, options) => tryAtIntervals(async () => {
|
|
31
30
|
const value = await this.getServer(request).then(res => res.server);
|
|
32
31
|
return {
|
|
@@ -34,7 +33,6 @@ class InstanceV1UtilsAPI extends InstanceV1GenAPI {
|
|
|
34
33
|
value
|
|
35
34
|
};
|
|
36
35
|
}, createExponentialBackoffStrategy((options == null ? void 0 : options.minDelay) ?? 1, (options == null ? void 0 : options.maxDelay) ?? 30), options == null ? void 0 : options.timeout);
|
|
37
|
-
|
|
38
36
|
this.waitForSnapshot = (request, options) => tryAtIntervals(async () => {
|
|
39
37
|
const value = await this.getSnapshot(request).then(res => res.snapshot);
|
|
40
38
|
return {
|
|
@@ -42,7 +40,6 @@ class InstanceV1UtilsAPI extends InstanceV1GenAPI {
|
|
|
42
40
|
value
|
|
43
41
|
};
|
|
44
42
|
}, createExponentialBackoffStrategy((options == null ? void 0 : options.minDelay) ?? 1, (options == null ? void 0 : options.maxDelay) ?? 30), options == null ? void 0 : options.timeout);
|
|
45
|
-
|
|
46
43
|
this.waitForVolume = (request, options) => tryAtIntervals(async () => {
|
|
47
44
|
const value = await this.getVolume(request).then(res => res.volume);
|
|
48
45
|
return {
|
|
@@ -50,14 +47,13 @@ class InstanceV1UtilsAPI extends InstanceV1GenAPI {
|
|
|
50
47
|
value
|
|
51
48
|
};
|
|
52
49
|
}, createExponentialBackoffStrategy((options == null ? void 0 : options.minDelay) ?? 1, (options == null ? void 0 : options.maxDelay) ?? 30), options == null ? void 0 : options.timeout);
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
this.updateSnapshot = request => this.getSnapshot(request).then(res => validateNotUndefined(res.snapshot)).then(snapshot => this._setSnapshot({
|
|
51
|
+
...snapshot,
|
|
55
52
|
name: request.name ?? snapshot.name,
|
|
56
53
|
snapshotId: snapshot.id
|
|
57
54
|
})).then(res => ({
|
|
58
55
|
snapshot: res.snapshot
|
|
59
56
|
}));
|
|
60
|
-
|
|
61
57
|
this.updateSecurityGroup = request => this.getSecurityGroup({
|
|
62
58
|
securityGroupId: request.securityGroupId,
|
|
63
59
|
zone: request.zone
|
|
@@ -80,7 +76,6 @@ class InstanceV1UtilsAPI extends InstanceV1GenAPI {
|
|
|
80
76
|
})).then(res => ({
|
|
81
77
|
securityGroup: res.securityGroup
|
|
82
78
|
}));
|
|
83
|
-
|
|
84
79
|
this.updateSecurityGroupRule = request => this.getSecurityGroupRule({
|
|
85
80
|
securityGroupId: request.securityGroupId,
|
|
86
81
|
securityGroupRuleId: request.securityGroupRuleId,
|
|
@@ -99,122 +94,107 @@ class InstanceV1UtilsAPI extends InstanceV1GenAPI {
|
|
|
99
94
|
securityGroupId: request.securityGroupId,
|
|
100
95
|
securityGroupRuleId: request.securityGroupRuleId
|
|
101
96
|
};
|
|
102
|
-
|
|
103
97
|
if (request.destPortFrom) {
|
|
104
|
-
sReq = {
|
|
98
|
+
sReq = {
|
|
99
|
+
...sReq,
|
|
105
100
|
destPortFrom: request.destPortFrom > 0 ? request.destPortFrom : undefined
|
|
106
101
|
};
|
|
107
102
|
}
|
|
108
|
-
|
|
109
103
|
if (request.destPortTo) {
|
|
110
|
-
sReq = {
|
|
104
|
+
sReq = {
|
|
105
|
+
...sReq,
|
|
111
106
|
destPortTo: request.destPortTo > 0 ? request.destPortTo : undefined
|
|
112
107
|
};
|
|
113
108
|
}
|
|
114
|
-
|
|
115
109
|
if (sReq.destPortFrom && sReq.destPortTo && sReq.destPortFrom === sReq.destPortTo) {
|
|
116
|
-
sReq = {
|
|
110
|
+
sReq = {
|
|
111
|
+
...sReq,
|
|
117
112
|
destPortTo: undefined
|
|
118
113
|
};
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
|
|
114
|
+
}
|
|
115
|
+
// When we use ICMP protocol portFrom and portTo should be set to nil
|
|
122
116
|
if (request.protocol === 'ICMP') {
|
|
123
|
-
sReq = {
|
|
117
|
+
sReq = {
|
|
118
|
+
...sReq,
|
|
124
119
|
destPortFrom: undefined,
|
|
125
120
|
destPortTo: undefined
|
|
126
121
|
};
|
|
127
122
|
}
|
|
128
|
-
|
|
129
123
|
return this._setSecurityGroupRule(sReq);
|
|
130
124
|
}).then(res => ({
|
|
131
125
|
rule: res.rule
|
|
132
126
|
}));
|
|
133
|
-
|
|
134
127
|
this.updateServer = request => this._updateServer(request);
|
|
135
|
-
|
|
136
128
|
this.createServer = request => this._createServer(request);
|
|
137
|
-
|
|
138
129
|
this.serverActionAndWait = async (request, options) => {
|
|
139
130
|
const finalServer = await this.serverAction(request).then(() => this.waitForServer({
|
|
140
131
|
serverId: request.serverId,
|
|
141
132
|
zone: request.zone
|
|
142
|
-
}, options));
|
|
133
|
+
}, options));
|
|
143
134
|
|
|
135
|
+
// Check the action was properly executed.
|
|
144
136
|
let expectedState;
|
|
145
|
-
|
|
146
137
|
switch (request.action) {
|
|
147
138
|
case 'poweron':
|
|
148
139
|
case 'reboot':
|
|
149
140
|
expectedState = 'running';
|
|
150
141
|
break;
|
|
151
|
-
|
|
152
142
|
case 'poweroff':
|
|
153
143
|
expectedState = 'stopped';
|
|
154
144
|
break;
|
|
155
|
-
|
|
156
145
|
case 'stop_in_place':
|
|
157
146
|
expectedState = 'stopped in place';
|
|
158
147
|
break;
|
|
159
148
|
}
|
|
160
|
-
|
|
161
149
|
if (expectedState && finalServer.state !== expectedState) {
|
|
162
150
|
throw new Error(`expected state ${expectedState} but found ${finalServer.state}: ${finalServer.stateDetail}`);
|
|
163
151
|
}
|
|
164
|
-
|
|
165
152
|
return finalServer;
|
|
166
153
|
};
|
|
167
|
-
|
|
168
154
|
this.attachVolume = async request => {
|
|
169
155
|
const volumes = await this.getServer({
|
|
170
156
|
serverId: request.serverId,
|
|
171
157
|
zone: request.zone
|
|
172
158
|
}).then(res => {
|
|
173
159
|
var _res$server;
|
|
174
|
-
|
|
175
160
|
return validateNotUndefined((_res$server = res.server) == null ? void 0 : _res$server.volumes);
|
|
176
161
|
});
|
|
177
162
|
const newVolumes = {};
|
|
178
|
-
|
|
179
163
|
for (const [key, server] of Object.entries(volumes)) {
|
|
180
164
|
newVolumes[key] = {
|
|
181
165
|
id: server.id,
|
|
182
166
|
name: server.name
|
|
183
167
|
};
|
|
184
|
-
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// We loop through all the possible volume keys (0 to len(volumes))
|
|
185
171
|
// to find a non existing key and assign it to the requested volume.
|
|
186
172
|
// A key should always be found. However we return an error if no keys were found.
|
|
187
|
-
|
|
188
|
-
|
|
189
173
|
let found = false;
|
|
190
174
|
const volumesLength = Object.keys(volumes).length;
|
|
191
|
-
|
|
192
175
|
for (let index = 0; index <= volumesLength; index += 1) {
|
|
193
176
|
const key = index.toString();
|
|
194
|
-
|
|
195
177
|
if (!(key in newVolumes)) {
|
|
196
178
|
newVolumes[key] = {
|
|
197
179
|
id: request.volumeId,
|
|
198
180
|
name: request.volumeId // name is ignored on this PATCH
|
|
199
|
-
|
|
200
181
|
};
|
|
182
|
+
|
|
201
183
|
found = true;
|
|
202
184
|
break;
|
|
203
185
|
}
|
|
204
186
|
}
|
|
205
|
-
|
|
206
187
|
if (!found) {
|
|
207
188
|
throw new Error(`could not find key to attach volume ${request.volumeId}`);
|
|
208
|
-
}
|
|
209
|
-
|
|
189
|
+
}
|
|
210
190
|
|
|
191
|
+
// Update server
|
|
211
192
|
return this.updateServer({
|
|
212
193
|
serverId: request.serverId,
|
|
213
194
|
volumes: newVolumes,
|
|
214
195
|
zone: request.zone
|
|
215
196
|
}).then(obj => obj);
|
|
216
197
|
};
|
|
217
|
-
|
|
218
198
|
this.detachVolume = async request => {
|
|
219
199
|
// Get server and related volumes.
|
|
220
200
|
const server = await this.getVolume({
|
|
@@ -222,15 +202,14 @@ class InstanceV1UtilsAPI extends InstanceV1GenAPI {
|
|
|
222
202
|
zone: request.zone
|
|
223
203
|
}).then(res => {
|
|
224
204
|
var _res$volume, _res$volume$server;
|
|
225
|
-
|
|
226
205
|
return validateNotUndefined((_res$volume = res.volume) == null ? void 0 : (_res$volume$server = _res$volume.server) == null ? void 0 : _res$volume$server.id);
|
|
227
206
|
}).then(serverId => this.getServer({
|
|
228
207
|
serverId,
|
|
229
208
|
zone: request.zone
|
|
230
|
-
})).then(res => validateNotUndefined(res.server));
|
|
209
|
+
})).then(res => validateNotUndefined(res.server));
|
|
231
210
|
|
|
211
|
+
// Remove volume.
|
|
232
212
|
const newVolumes = {};
|
|
233
|
-
|
|
234
213
|
for (const [key, volume] of Object.entries(server.volumes)) {
|
|
235
214
|
if (volume.id !== request.volumeId) {
|
|
236
215
|
newVolumes[key] = {
|
|
@@ -238,17 +217,46 @@ class InstanceV1UtilsAPI extends InstanceV1GenAPI {
|
|
|
238
217
|
name: volume.name
|
|
239
218
|
};
|
|
240
219
|
}
|
|
241
|
-
}
|
|
242
|
-
|
|
220
|
+
}
|
|
243
221
|
|
|
222
|
+
// Update server.
|
|
244
223
|
return this.updateServer({
|
|
245
224
|
serverId: server.id,
|
|
246
225
|
volumes: newVolumes,
|
|
247
226
|
zone: request.zone
|
|
248
227
|
}).then(obj => obj);
|
|
249
228
|
};
|
|
229
|
+
this.updateImage = request => this.getImage({
|
|
230
|
+
zone: request.zone,
|
|
231
|
+
imageId: request.imageId
|
|
232
|
+
}).then(res => validateNotUndefined(res.image)).then(image => ({
|
|
233
|
+
...image,
|
|
234
|
+
name: request.name ?? image.name,
|
|
235
|
+
tags: request.tags ?? image.tags,
|
|
236
|
+
id: image.id
|
|
237
|
+
})).then(imageReq => this.client.fetch({
|
|
238
|
+
body: JSON.stringify(marshalSetImageRequestWithID(imageReq, this.client.settings)),
|
|
239
|
+
headers: {
|
|
240
|
+
'Content-Type': 'application/json; charset=utf-8'
|
|
241
|
+
},
|
|
242
|
+
method: 'PUT',
|
|
243
|
+
path: `/instance/v1/zones/${validatePathParam('zone', imageReq.zone)}/images/${validatePathParam('id', imageReq.id)}`
|
|
244
|
+
}, unmarshalSetImageResponse)).then(res => ({
|
|
245
|
+
image: res.image
|
|
246
|
+
}));
|
|
247
|
+
this.getServerUserData = request => this.client.fetch({
|
|
248
|
+
method: 'GET',
|
|
249
|
+
path: `/instance/v1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/servers/${validatePathParam('serverId', request.serverId)}/user_data/${validatePathParam('key', request.key)}`
|
|
250
|
+
});
|
|
251
|
+
this.setServerUserData = request => this.client.fetch({
|
|
252
|
+
body: request.content,
|
|
253
|
+
headers: {
|
|
254
|
+
'Content-Type': 'text/plain'
|
|
255
|
+
},
|
|
256
|
+
method: 'PATCH',
|
|
257
|
+
path: `/instance/v1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/servers/${validatePathParam('serverId', request.serverId)}/user_data/${validatePathParam('key', request.key)}`
|
|
258
|
+
});
|
|
250
259
|
}
|
|
251
|
-
|
|
252
260
|
}
|
|
253
261
|
|
|
254
262
|
export { InstanceV1UtilsAPI };
|
|
@@ -3,26 +3,26 @@
|
|
|
3
3
|
|
|
4
4
|
/** Lists transient statutes of the enum {@link ImageState}. */
|
|
5
5
|
const IMAGE_TRANSIENT_STATUSES = ['creating'];
|
|
6
|
-
/** Lists transient statutes of the enum {@link PrivateNICState}. */
|
|
7
6
|
|
|
7
|
+
/** Lists transient statutes of the enum {@link PrivateNICState}. */
|
|
8
8
|
const PRIVATE_NIC_TRANSIENT_STATUSES = ['syncing'];
|
|
9
|
-
/** Lists transient statutes of the enum {@link SecurityGroupState}. */
|
|
10
9
|
|
|
10
|
+
/** Lists transient statutes of the enum {@link SecurityGroupState}. */
|
|
11
11
|
const SECURITY_GROUP_TRANSIENT_STATUSES = ['syncing'];
|
|
12
|
-
/** Lists transient statutes of the enum {@link ServerState}. */
|
|
13
12
|
|
|
13
|
+
/** Lists transient statutes of the enum {@link ServerState}. */
|
|
14
14
|
const SERVER_TRANSIENT_STATUSES = ['starting', 'stopping'];
|
|
15
|
+
|
|
15
16
|
/** Lists transient statutes of the enum {@link SnapshotState}. */
|
|
17
|
+
const SNAPSHOT_TRANSIENT_STATUSES = ['snapshotting', 'importing', 'exporting'];
|
|
16
18
|
|
|
17
|
-
const SNAPSHOT_TRANSIENT_STATUSES = ['snapshotting'];
|
|
18
19
|
/** Lists transient statutes of the enum {@link TaskStatus}. */
|
|
19
|
-
|
|
20
20
|
const TASK_TRANSIENT_STATUSES = ['pending', 'started', 'retry'];
|
|
21
|
-
/** Lists transient statutes of the enum {@link VolumeServerState}. */
|
|
22
21
|
|
|
22
|
+
/** Lists transient statutes of the enum {@link VolumeServerState}. */
|
|
23
23
|
const VOLUME_SERVER_TRANSIENT_STATUSES = ['snapshotting', 'fetching', 'resizing', 'saving', 'hotsyncing'];
|
|
24
|
-
/** Lists transient statutes of the enum {@link VolumeState}. */
|
|
25
24
|
|
|
25
|
+
/** Lists transient statutes of the enum {@link VolumeState}. */
|
|
26
26
|
const VOLUME_TRANSIENT_STATUSES = ['snapshotting', 'fetching', 'resizing', 'saving', 'hotsyncing'];
|
|
27
27
|
|
|
28
28
|
export { IMAGE_TRANSIENT_STATUSES, PRIVATE_NIC_TRANSIENT_STATUSES, SECURITY_GROUP_TRANSIENT_STATUSES, SERVER_TRANSIENT_STATUSES, SNAPSHOT_TRANSIENT_STATUSES, TASK_TRANSIENT_STATUSES, VOLUME_SERVER_TRANSIENT_STATUSES, VOLUME_TRANSIENT_STATUSES };
|