@scaleway/sdk 3.0.0-alpha.0 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.gen.d.ts +362 -0
- package/dist/index.gen.js +323 -0
- package/package.json +71 -25
- package/README.md +0 -46
- package/dist/api/account/index.js +0 -4
- package/dist/api/account/v2/api.gen.js +0 -147
- package/dist/api/account/v2/index.gen.js +0 -4
- package/dist/api/account/v2/marshalling.gen.js +0 -39
- package/dist/api/account/v3/api.gen.js +0 -129
- package/dist/api/account/v3/index.gen.js +0 -6
- package/dist/api/account/v3/marshalling.gen.js +0 -39
- package/dist/api/account/v3/validation-rules.gen.js +0 -39
- package/dist/api/applesilicon/index.js +0 -2
- package/dist/api/applesilicon/v1alpha1/api.gen.js +0 -220
- package/dist/api/applesilicon/v1alpha1/content.gen.js +0 -7
- package/dist/api/applesilicon/v1alpha1/index.gen.js +0 -5
- package/dist/api/applesilicon/v1alpha1/marshalling.gen.js +0 -113
- package/dist/api/baremetal/index.js +0 -2
- package/dist/api/baremetal/v1/api.gen.js +0 -523
- package/dist/api/baremetal/v1/api.utils.js +0 -27
- package/dist/api/baremetal/v1/content.gen.js +0 -13
- package/dist/api/baremetal/v1/index.js +0 -5
- package/dist/api/baremetal/v1/marshalling.gen.js +0 -395
- package/dist/api/baremetal/v1/validation-rules.gen.js +0 -109
- package/dist/api/billing/index.js +0 -2
- package/dist/api/billing/v2alpha1/api.gen.js +0 -80
- package/dist/api/billing/v2alpha1/index.gen.js +0 -4
- package/dist/api/billing/v2alpha1/marshalling.gen.js +0 -53
- package/dist/api/block/index.js +0 -2
- package/dist/api/block/v1alpha1/api.gen.js +0 -245
- package/dist/api/block/v1alpha1/content.gen.js +0 -13
- package/dist/api/block/v1alpha1/index.gen.js +0 -7
- package/dist/api/block/v1alpha1/marshalling.gen.js +0 -175
- package/dist/api/block/v1alpha1/validation-rules.gen.js +0 -42
- package/dist/api/cockpit/index.js +0 -2
- package/dist/api/cockpit/v1beta1/api.gen.js +0 -448
- package/dist/api/cockpit/v1beta1/content.gen.js +0 -7
- package/dist/api/cockpit/v1beta1/index.gen.js +0 -5
- package/dist/api/cockpit/v1beta1/marshalling.gen.js +0 -220
- package/dist/api/container/index.js +0 -2
- package/dist/api/container/v1beta1/api.gen.js +0 -549
- package/dist/api/container/v1beta1/content.gen.js +0 -22
- package/dist/api/container/v1beta1/index.gen.js +0 -5
- package/dist/api/container/v1beta1/marshalling.gen.js +0 -330
- package/dist/api/document_db/index.js +0 -2
- package/dist/api/document_db/v1beta1/api.gen.js +0 -830
- package/dist/api/document_db/v1beta1/content.gen.js +0 -19
- package/dist/api/document_db/v1beta1/index.gen.js +0 -7
- package/dist/api/document_db/v1beta1/marshalling.gen.js +0 -580
- package/dist/api/document_db/v1beta1/validation-rules.gen.js +0 -10
- package/dist/api/domain/index.js +0 -2
- package/dist/api/domain/v2beta1/api.gen.js +0 -875
- package/dist/api/domain/v2beta1/content.gen.js +0 -28
- package/dist/api/domain/v2beta1/index.gen.js +0 -7
- package/dist/api/domain/v2beta1/marshalling.gen.js +0 -958
- package/dist/api/flexibleip/index.js +0 -2
- package/dist/api/flexibleip/v1alpha1/api.gen.js +0 -203
- package/dist/api/flexibleip/v1alpha1/content.gen.js +0 -10
- package/dist/api/flexibleip/v1alpha1/index.gen.js +0 -7
- package/dist/api/flexibleip/v1alpha1/marshalling.gen.js +0 -97
- package/dist/api/flexibleip/v1alpha1/validation-rules.gen.js +0 -14
- package/dist/api/function/index.js +0 -2
- package/dist/api/function/v1beta1/api.gen.js +0 -560
- package/dist/api/function/v1beta1/content.gen.js +0 -22
- package/dist/api/function/v1beta1/index.gen.js +0 -5
- package/dist/api/function/v1beta1/marshalling.gen.js +0 -368
- package/dist/api/iam/index.js +0 -2
- package/dist/api/iam/v1alpha1/api.gen.js +0 -799
- package/dist/api/iam/v1alpha1/index.gen.js +0 -6
- package/dist/api/iam/v1alpha1/marshalling.gen.js +0 -373
- package/dist/api/iam/v1alpha1/validation-rules.gen.js +0 -207
- package/dist/api/instance/index.js +0 -2
- package/dist/api/instance/v1/api.gen.js +0 -1003
- package/dist/api/instance/v1/api.utils.js +0 -369
- package/dist/api/instance/v1/content.gen.js +0 -31
- package/dist/api/instance/v1/index.js +0 -2
- package/dist/api/instance/v1/marshalling.gen.js +0 -1206
- package/dist/api/instance/v1/marshalling.utils.js +0 -63
- package/dist/api/iot/index.js +0 -2
- package/dist/api/iot/v1/api.gen.js +0 -581
- package/dist/api/iot/v1/content.gen.js +0 -7
- package/dist/api/iot/v1/index.gen.js +0 -5
- package/dist/api/iot/v1/marshalling.gen.js +0 -388
- package/dist/api/ipfs/index.js +0 -2
- package/dist/api/ipfs/v1alpha1/api.gen.js +0 -197
- package/dist/api/ipfs/v1alpha1/content.gen.js +0 -7
- package/dist/api/ipfs/v1alpha1/index.gen.js +0 -5
- package/dist/api/ipfs/v1alpha1/marshalling.gen.js +0 -121
- package/dist/api/k8s/index.js +0 -2
- package/dist/api/k8s/v1/api.gen.js +0 -454
- package/dist/api/k8s/v1/api.utils.js +0 -13
- package/dist/api/k8s/v1/content.gen.js +0 -13
- package/dist/api/k8s/v1/index.js +0 -4
- package/dist/api/k8s/v1/marshalling.gen.js +0 -333
- package/dist/api/k8s/v1/validation-rules.gen.js +0 -101
- package/dist/api/lb/index.js +0 -2
- package/dist/api/lb/v1/api.gen.js +0 -1669
- package/dist/api/lb/v1/api.utils.js +0 -81
- package/dist/api/lb/v1/content.gen.js +0 -16
- package/dist/api/lb/v1/index.js +0 -2
- package/dist/api/lb/v1/marshalling.gen.js +0 -923
- package/dist/api/marketplace/index.js +0 -4
- package/dist/api/marketplace/v1/api.gen.js +0 -60
- package/dist/api/marketplace/v1/index.gen.js +0 -4
- package/dist/api/marketplace/v1/marshalling.gen.js +0 -92
- package/dist/api/marketplace/v2/api.gen.js +0 -162
- package/dist/api/marketplace/v2/index.gen.js +0 -4
- package/dist/api/marketplace/v2/marshalling.gen.js +0 -94
- package/dist/api/mnq/index.js +0 -2
- package/dist/api/mnq/v1alpha1/api.gen.js +0 -205
- package/dist/api/mnq/v1alpha1/index.gen.js +0 -4
- package/dist/api/mnq/v1alpha1/marshalling.gen.js +0 -121
- package/dist/api/rdb/index.js +0 -2
- package/dist/api/rdb/v1/api.gen.js +0 -972
- package/dist/api/rdb/v1/content.gen.js +0 -22
- package/dist/api/rdb/v1/index.gen.js +0 -7
- package/dist/api/rdb/v1/marshalling.gen.js +0 -636
- package/dist/api/rdb/v1/validation-rules.gen.js +0 -10
- package/dist/api/redis/index.js +0 -2
- package/dist/api/redis/v1/api.gen.js +0 -389
- package/dist/api/redis/v1/content.gen.js +0 -7
- package/dist/api/redis/v1/index.gen.js +0 -5
- package/dist/api/redis/v1/marshalling.gen.js +0 -259
- package/dist/api/registry/index.js +0 -2
- package/dist/api/registry/v1/api.gen.js +0 -252
- package/dist/api/registry/v1/content.gen.js +0 -13
- package/dist/api/registry/v1/index.gen.js +0 -5
- package/dist/api/registry/v1/marshalling.gen.js +0 -106
- package/dist/api/secret/index.js +0 -2
- package/dist/api/secret/v1alpha1/api.gen.js +0 -415
- package/dist/api/secret/v1alpha1/index.gen.js +0 -4
- package/dist/api/secret/v1alpha1/marshalling.gen.js +0 -143
- package/dist/api/tem/index.js +0 -2
- package/dist/api/tem/v1alpha1/api.gen.js +0 -229
- package/dist/api/tem/v1alpha1/content.gen.js +0 -10
- package/dist/api/tem/v1alpha1/index.gen.js +0 -5
- package/dist/api/tem/v1alpha1/marshalling.gen.js +0 -159
- package/dist/api/test/index.js +0 -2
- package/dist/api/test/v1/api.gen.js +0 -152
- package/dist/api/test/v1/content.gen.js +0 -7
- package/dist/api/test/v1/index.gen.js +0 -5
- package/dist/api/test/v1/marshalling.gen.js +0 -79
- package/dist/api/vpc/index.js +0 -4
- package/dist/api/vpc/v1/api.gen.js +0 -110
- package/dist/api/vpc/v1/index.gen.js +0 -4
- package/dist/api/vpc/v1/marshalling.gen.js +0 -44
- package/dist/api/vpc/v2/api.gen.js +0 -276
- package/dist/api/vpc/v2/index.gen.js +0 -4
- package/dist/api/vpc/v2/marshalling.gen.js +0 -135
- package/dist/api/vpcgw/index.js +0 -2
- package/dist/api/vpcgw/v1/api.gen.js +0 -669
- package/dist/api/vpcgw/v1/content.gen.js +0 -10
- package/dist/api/vpcgw/v1/index.gen.js +0 -5
- package/dist/api/vpcgw/v1/marshalling.gen.js +0 -336
- package/dist/api/webhosting/index.js +0 -2
- package/dist/api/webhosting/v1alpha1/api.gen.js +0 -210
- package/dist/api/webhosting/v1alpha1/content.gen.js +0 -7
- package/dist/api/webhosting/v1alpha1/index.gen.js +0 -7
- package/dist/api/webhosting/v1alpha1/marshalling.gen.js +0 -173
- package/dist/api/webhosting/v1alpha1/validation-rules.gen.js +0 -23
- package/dist/helpers/is-browser.js +0 -5
- package/dist/helpers/is-response.js +0 -10
- package/dist/helpers/json.js +0 -11
- package/dist/helpers/marshalling.js +0 -130
- package/dist/index.cjs +0 -24364
- package/dist/index.d.ts +0 -27584
- package/dist/index.js +0 -69
- package/dist/internal/async/interval-retrier.js +0 -105
- package/dist/internal/async/sleep.js +0 -13
- package/dist/internal/interceptors/composer.js +0 -46
- package/dist/internal/interceptors/helpers.js +0 -32
- package/dist/internal/logger/console-logger.js +0 -38
- package/dist/internal/logger/index.js +0 -41
- package/dist/internal/logger/level-resolver.js +0 -13
- package/dist/internal/validations/string-validation.js +0 -38
- package/dist/node_modules/.pnpm/@scaleway_random-name@4.0.2/node_modules/@scaleway/random-name/dist/index.js +0 -13
- package/dist/scw/api.js +0 -12
- package/dist/scw/auth.js +0 -68
- package/dist/scw/client-ini-factory.js +0 -174
- package/dist/scw/client-ini-profile.js +0 -54
- package/dist/scw/client-settings.js +0 -78
- package/dist/scw/client.js +0 -98
- package/dist/scw/constants.js +0 -4
- package/dist/scw/custom-marshalling.js +0 -131
- package/dist/scw/errors/error-parser.js +0 -107
- package/dist/scw/errors/non-standard/invalid-request-mapper.js +0 -36
- package/dist/scw/errors/non-standard/unknown-resource-mapper.js +0 -27
- package/dist/scw/errors/scw-error.js +0 -66
- package/dist/scw/errors/standard/already-exists-error.js +0 -26
- package/dist/scw/errors/standard/denied-authentication-error.js +0 -52
- package/dist/scw/errors/standard/index.js +0 -13
- package/dist/scw/errors/standard/invalid-arguments-error.js +0 -67
- package/dist/scw/errors/standard/out-of-stock-error.js +0 -22
- package/dist/scw/errors/standard/permissions-denied-error.js +0 -48
- package/dist/scw/errors/standard/precondition-failed-error.js +0 -42
- package/dist/scw/errors/standard/quotas-exceeded-error.js +0 -68
- package/dist/scw/errors/standard/resource-expired-error.js +0 -26
- package/dist/scw/errors/standard/resource-locked-error.js +0 -25
- package/dist/scw/errors/standard/resource-not-found-error.js +0 -25
- package/dist/scw/errors/standard/too-many-requests-error.js +0 -70
- package/dist/scw/errors/standard/transient-state-error.js +0 -26
- package/dist/scw/errors/types.js +0 -23
- package/dist/scw/fetch/build-fetcher.js +0 -72
- package/dist/scw/fetch/http-dumper.js +0 -54
- package/dist/scw/fetch/http-interceptors.js +0 -99
- package/dist/scw/fetch/resource-paginator.js +0 -84
- package/dist/scw/fetch/response-parser.js +0 -72
- package/node_modules/@scaleway/random-name/.npmignore +0 -4
- package/node_modules/@scaleway/random-name/CHANGELOG.md +0 -129
- package/node_modules/@scaleway/random-name/LICENSE.md +0 -21
- package/node_modules/@scaleway/random-name/README.md +0 -26
- package/node_modules/@scaleway/random-name/dist/index.d.ts +0 -3
- package/node_modules/@scaleway/random-name/dist/index.js +0 -13
- package/node_modules/@scaleway/random-name/package.json +0 -23
|
@@ -1,369 +0,0 @@
|
|
|
1
|
-
import { tryAtIntervals, createExponentialBackoffStrategy } from '../../../internal/async/interval-retrier.js';
|
|
2
|
-
import { validatePathParam } from '../../../helpers/marshalling.js';
|
|
3
|
-
import { API } from './api.gen.js';
|
|
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';
|
|
7
|
-
|
|
8
|
-
const validateNotUndefined = obj => {
|
|
9
|
-
if (obj === undefined) throw new TypeError(`object was found undefined`);
|
|
10
|
-
return obj;
|
|
11
|
-
};
|
|
12
|
-
class InstanceV1UtilsAPI extends API {
|
|
13
|
-
/**
|
|
14
|
-
* Waits for {@link Image} to be in a final state.
|
|
15
|
-
*
|
|
16
|
-
* @param request - The request {@link GetImageRequest}
|
|
17
|
-
* @param options - The waiting options
|
|
18
|
-
* @returns A Promise of Image
|
|
19
|
-
*/
|
|
20
|
-
waitForImage = (request, options) => tryAtIntervals(async () => {
|
|
21
|
-
const value = await this.getImage(request).then(res => res.image);
|
|
22
|
-
return {
|
|
23
|
-
done: !IMAGE_TRANSIENT_STATUSES.includes(value.state),
|
|
24
|
-
value
|
|
25
|
-
};
|
|
26
|
-
}, createExponentialBackoffStrategy(options?.minDelay ?? 1, options?.maxDelay ?? 30), options?.timeout);
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Waits for {@link PrivateNIC} to be in a final state.
|
|
30
|
-
*
|
|
31
|
-
* @param request - The request {@link GetPrivateNICRequest}
|
|
32
|
-
* @param options - The waiting options
|
|
33
|
-
* @returns A Promise of PrivateNIC
|
|
34
|
-
*/
|
|
35
|
-
waitForPrivateNIC = (request, options) => tryAtIntervals(async () => {
|
|
36
|
-
const value = await this.getPrivateNIC(request).then(res => res.privateNic);
|
|
37
|
-
return {
|
|
38
|
-
done: !PRIVATE_NIC_TRANSIENT_STATUSES.includes(value.state),
|
|
39
|
-
value
|
|
40
|
-
};
|
|
41
|
-
}, createExponentialBackoffStrategy(options?.minDelay ?? 1, options?.maxDelay ?? 30), options?.timeout);
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Waits for {@link Server} to be in a final state.
|
|
45
|
-
*
|
|
46
|
-
* @param request - The request {@link GetServerRequest}
|
|
47
|
-
* @param options - The waiting options
|
|
48
|
-
* @returns A Promise of Server
|
|
49
|
-
*/
|
|
50
|
-
waitForServer = (request, options) => tryAtIntervals(async () => {
|
|
51
|
-
const value = await this.getServer(request).then(res => res.server);
|
|
52
|
-
return {
|
|
53
|
-
done: !SERVER_TRANSIENT_STATUSES.includes(value.state),
|
|
54
|
-
value
|
|
55
|
-
};
|
|
56
|
-
}, createExponentialBackoffStrategy(options?.minDelay ?? 1, options?.maxDelay ?? 30), options?.timeout);
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Waits for {@link Server} to be in a final state.
|
|
60
|
-
*
|
|
61
|
-
* @param request - The request {@link GetServerRequest}
|
|
62
|
-
* @param options - The waiting options
|
|
63
|
-
* @returns A Promise of Server
|
|
64
|
-
*/
|
|
65
|
-
waitForSnapshot = (request, options) => tryAtIntervals(async () => {
|
|
66
|
-
const value = await this.getSnapshot(request).then(res => res.snapshot);
|
|
67
|
-
return {
|
|
68
|
-
done: !SNAPSHOT_TRANSIENT_STATUSES.includes(value.state),
|
|
69
|
-
value
|
|
70
|
-
};
|
|
71
|
-
}, createExponentialBackoffStrategy(options?.minDelay ?? 1, options?.maxDelay ?? 30), options?.timeout);
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Waits for {@link Volume} to be in a final state.
|
|
75
|
-
*
|
|
76
|
-
* @param request - The request {@link GetVolumeRequest}
|
|
77
|
-
* @param options - The waiting options
|
|
78
|
-
* @returns A Promise of Volume
|
|
79
|
-
*/
|
|
80
|
-
waitForVolume = (request, options) => tryAtIntervals(async () => {
|
|
81
|
-
const value = await this.getVolume(request).then(res => res.volume);
|
|
82
|
-
return {
|
|
83
|
-
done: !VOLUME_TRANSIENT_STATUSES.includes(value.state),
|
|
84
|
-
value
|
|
85
|
-
};
|
|
86
|
-
}, createExponentialBackoffStrategy(options?.minDelay ?? 1, options?.maxDelay ?? 30), options?.timeout);
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Updates a snapshot.
|
|
90
|
-
*
|
|
91
|
-
* @param request - The request {@link UpdateSnapshotRequest}
|
|
92
|
-
* @returns A Promise of UpdateSnapshotResponse
|
|
93
|
-
*/
|
|
94
|
-
updateSnapshot = request => this.getSnapshot(request).then(res => validateNotUndefined(res.snapshot)).then(snapshot => this._setSnapshot({
|
|
95
|
-
...snapshot,
|
|
96
|
-
name: request.name ?? snapshot.name,
|
|
97
|
-
snapshotId: snapshot.id
|
|
98
|
-
})).then(res => ({
|
|
99
|
-
snapshot: res.snapshot
|
|
100
|
-
}));
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Updates a security group.
|
|
104
|
-
*
|
|
105
|
-
* @param request - The request {@link UpdateSecurityGroupRequest}
|
|
106
|
-
* @returns A Promise of UpdateSecurityGroupResponse
|
|
107
|
-
*/
|
|
108
|
-
updateSecurityGroup = request => this.getSecurityGroup({
|
|
109
|
-
securityGroupId: request.securityGroupId,
|
|
110
|
-
zone: request.zone
|
|
111
|
-
}).then(res => validateNotUndefined(res.securityGroup)).then(securityGroup => this._setSecurityGroup({
|
|
112
|
-
creationDate: securityGroup.creationDate,
|
|
113
|
-
description: request.description ?? securityGroup.description,
|
|
114
|
-
enableDefaultSecurity: request.enableDefaultSecurity ?? securityGroup.enableDefaultSecurity,
|
|
115
|
-
id: securityGroup.id,
|
|
116
|
-
inboundDefaultPolicy: request.inboundDefaultPolicy ?? securityGroup.inboundDefaultPolicy,
|
|
117
|
-
modificationDate: securityGroup.modificationDate,
|
|
118
|
-
name: request.name ?? securityGroup.name,
|
|
119
|
-
organization: securityGroup.organization,
|
|
120
|
-
organizationDefault: request.organizationDefault ?? securityGroup.organizationDefault,
|
|
121
|
-
outboundDefaultPolicy: request.outboundDefaultPolicy ?? securityGroup.outboundDefaultPolicy,
|
|
122
|
-
project: securityGroup.project,
|
|
123
|
-
projectDefault: request.projectDefault ?? securityGroup.projectDefault,
|
|
124
|
-
servers: securityGroup.servers,
|
|
125
|
-
stateful: request.stateful ?? securityGroup.stateful,
|
|
126
|
-
zone: request.zone
|
|
127
|
-
})).then(res => ({
|
|
128
|
-
securityGroup: res.securityGroup
|
|
129
|
-
}));
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Updates a security group rule.
|
|
133
|
-
*
|
|
134
|
-
* @param request - The request {@link UpdateSecurityGroupRuleRequest}
|
|
135
|
-
* @returns A Promise of UpdateSecurityGroupRuleResponse
|
|
136
|
-
*/
|
|
137
|
-
updateSecurityGroupRule = request => this.getSecurityGroupRule({
|
|
138
|
-
securityGroupId: request.securityGroupId,
|
|
139
|
-
securityGroupRuleId: request.securityGroupRuleId,
|
|
140
|
-
zone: request.zone
|
|
141
|
-
}).then(res => validateNotUndefined(res.rule)).then(rule => {
|
|
142
|
-
let sReq = {
|
|
143
|
-
action: request.action ?? rule.action,
|
|
144
|
-
destPortFrom: rule.destPortFrom,
|
|
145
|
-
destPortTo: rule.destPortTo,
|
|
146
|
-
direction: request.direction ?? rule.direction,
|
|
147
|
-
editable: rule.editable,
|
|
148
|
-
id: request.securityGroupRuleId,
|
|
149
|
-
ipRange: request.ipRange ?? rule.ipRange,
|
|
150
|
-
position: request.position ?? rule.position,
|
|
151
|
-
protocol: request.protocol ?? rule.protocol,
|
|
152
|
-
securityGroupId: request.securityGroupId,
|
|
153
|
-
securityGroupRuleId: request.securityGroupRuleId
|
|
154
|
-
};
|
|
155
|
-
if (request.destPortFrom) {
|
|
156
|
-
sReq = {
|
|
157
|
-
...sReq,
|
|
158
|
-
destPortFrom: request.destPortFrom > 0 ? request.destPortFrom : undefined
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
if (request.destPortTo) {
|
|
162
|
-
sReq = {
|
|
163
|
-
...sReq,
|
|
164
|
-
destPortTo: request.destPortTo > 0 ? request.destPortTo : undefined
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
if (sReq.destPortFrom && sReq.destPortTo && sReq.destPortFrom === sReq.destPortTo) {
|
|
168
|
-
sReq = {
|
|
169
|
-
...sReq,
|
|
170
|
-
destPortTo: undefined
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
// When we use ICMP protocol portFrom and portTo should be set to nil
|
|
174
|
-
if (request.protocol === 'ICMP') {
|
|
175
|
-
sReq = {
|
|
176
|
-
...sReq,
|
|
177
|
-
destPortFrom: undefined,
|
|
178
|
-
destPortTo: undefined
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
return this._setSecurityGroupRule(sReq);
|
|
182
|
-
}).then(res => ({
|
|
183
|
-
rule: res.rule
|
|
184
|
-
}));
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* Updates a server.
|
|
188
|
-
*
|
|
189
|
-
* @param request - The request {@link UpdateServerRequest}
|
|
190
|
-
* @returns A Promise of UpdateServerResponse
|
|
191
|
-
*/
|
|
192
|
-
updateServer = request => this._updateServer(request);
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* Creates a server.
|
|
196
|
-
*
|
|
197
|
-
* @param request - The request {@link CreateServerRequest}
|
|
198
|
-
* @returns A Promise of CreateServerResponse
|
|
199
|
-
*/
|
|
200
|
-
createServer = request => this._createServer(request);
|
|
201
|
-
|
|
202
|
-
/**
|
|
203
|
-
* Starts an action and wait for the server to be in the correct "terminal
|
|
204
|
-
* state" expected by this action.
|
|
205
|
-
*
|
|
206
|
-
* @param request - The request {@link ServerActionRequest}
|
|
207
|
-
* @returns A Promise of Server
|
|
208
|
-
*/
|
|
209
|
-
serverActionAndWait = async (request, options) => {
|
|
210
|
-
const finalServer = await this.serverAction(request).then(() => this.waitForServer({
|
|
211
|
-
serverId: request.serverId,
|
|
212
|
-
zone: request.zone
|
|
213
|
-
}, options));
|
|
214
|
-
|
|
215
|
-
// Check the action was properly executed.
|
|
216
|
-
let expectedState;
|
|
217
|
-
switch (request.action) {
|
|
218
|
-
case 'poweron':
|
|
219
|
-
case 'reboot':
|
|
220
|
-
expectedState = 'running';
|
|
221
|
-
break;
|
|
222
|
-
case 'poweroff':
|
|
223
|
-
expectedState = 'stopped';
|
|
224
|
-
break;
|
|
225
|
-
case 'stop_in_place':
|
|
226
|
-
expectedState = 'stopped in place';
|
|
227
|
-
break;
|
|
228
|
-
}
|
|
229
|
-
if (expectedState && finalServer.state !== expectedState) {
|
|
230
|
-
throw new Error(`expected state ${expectedState} but found ${finalServer.state}: ${finalServer.stateDetail}`);
|
|
231
|
-
}
|
|
232
|
-
return finalServer;
|
|
233
|
-
};
|
|
234
|
-
|
|
235
|
-
/**
|
|
236
|
-
* Attaches a volume to a server.
|
|
237
|
-
*
|
|
238
|
-
* @param request - The request {@link AttachVolumeRequest}
|
|
239
|
-
* @returns A Promise of AttachVolumeResponse
|
|
240
|
-
*/
|
|
241
|
-
attachVolume = async request => {
|
|
242
|
-
const volumes = await this.getServer({
|
|
243
|
-
serverId: request.serverId,
|
|
244
|
-
zone: request.zone
|
|
245
|
-
}).then(res => validateNotUndefined(res.server?.volumes));
|
|
246
|
-
const newVolumes = {};
|
|
247
|
-
for (const [key, server] of Object.entries(volumes)) {
|
|
248
|
-
newVolumes[key] = {
|
|
249
|
-
id: server.id,
|
|
250
|
-
name: server.name
|
|
251
|
-
};
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
// We loop through all the possible volume keys (0 to len(volumes))
|
|
255
|
-
// to find a non existing key and assign it to the requested volume.
|
|
256
|
-
// A key should always be found. However we return an error if no keys were found.
|
|
257
|
-
let found = false;
|
|
258
|
-
const volumesLength = Object.keys(volumes).length;
|
|
259
|
-
for (let index = 0; index <= volumesLength; index += 1) {
|
|
260
|
-
const key = index.toString();
|
|
261
|
-
if (!(key in newVolumes)) {
|
|
262
|
-
newVolumes[key] = {
|
|
263
|
-
id: request.volumeId,
|
|
264
|
-
name: request.volumeId // name is ignored on this PATCH
|
|
265
|
-
};
|
|
266
|
-
|
|
267
|
-
found = true;
|
|
268
|
-
break;
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
if (!found) {
|
|
272
|
-
throw new Error(`could not find key to attach volume ${request.volumeId}`);
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
// Update server
|
|
276
|
-
return this.updateServer({
|
|
277
|
-
serverId: request.serverId,
|
|
278
|
-
volumes: newVolumes,
|
|
279
|
-
zone: request.zone
|
|
280
|
-
}).then(obj => obj);
|
|
281
|
-
};
|
|
282
|
-
|
|
283
|
-
/**
|
|
284
|
-
* Detaches a volume from a server.
|
|
285
|
-
*
|
|
286
|
-
* @param request - The request {@link DetachVolumeRequest}
|
|
287
|
-
* @returns A Promise of DetachVolumeResponse
|
|
288
|
-
*/
|
|
289
|
-
detachVolume = async request => {
|
|
290
|
-
// Get server and related volumes.
|
|
291
|
-
const server = await this.getVolume({
|
|
292
|
-
volumeId: request.volumeId,
|
|
293
|
-
zone: request.zone
|
|
294
|
-
}).then(res => validateNotUndefined(res.volume?.server?.id)).then(serverId => this.getServer({
|
|
295
|
-
serverId,
|
|
296
|
-
zone: request.zone
|
|
297
|
-
})).then(res => validateNotUndefined(res.server));
|
|
298
|
-
|
|
299
|
-
// Remove volume.
|
|
300
|
-
const newVolumes = {};
|
|
301
|
-
for (const [key, volume] of Object.entries(server.volumes)) {
|
|
302
|
-
if (volume.id !== request.volumeId) {
|
|
303
|
-
newVolumes[key] = {
|
|
304
|
-
id: volume.id,
|
|
305
|
-
name: volume.name
|
|
306
|
-
};
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
// Update server.
|
|
311
|
-
return this.updateServer({
|
|
312
|
-
serverId: server.id,
|
|
313
|
-
volumes: newVolumes,
|
|
314
|
-
zone: request.zone
|
|
315
|
-
}).then(obj => obj);
|
|
316
|
-
};
|
|
317
|
-
|
|
318
|
-
/**
|
|
319
|
-
* Updates an image.
|
|
320
|
-
*
|
|
321
|
-
* @param request - The request {@link UpdateImageRequest}
|
|
322
|
-
* @returns A Promise of UpdateImageResponse
|
|
323
|
-
*/
|
|
324
|
-
updateImage = request => this.getImage({
|
|
325
|
-
zone: request.zone,
|
|
326
|
-
imageId: request.imageId
|
|
327
|
-
}).then(res => validateNotUndefined(res.image)).then(image => ({
|
|
328
|
-
...image,
|
|
329
|
-
name: request.name ?? image.name,
|
|
330
|
-
tags: request.tags ?? image.tags,
|
|
331
|
-
id: image.id
|
|
332
|
-
})).then(imageReq => this.client.fetch({
|
|
333
|
-
body: JSON.stringify(marshalSetImageRequestWithID(imageReq, this.client.settings)),
|
|
334
|
-
headers: {
|
|
335
|
-
'Content-Type': 'application/json; charset=utf-8'
|
|
336
|
-
},
|
|
337
|
-
method: 'PUT',
|
|
338
|
-
path: `/instance/v1/zones/${validatePathParam('zone', imageReq.zone)}/images/${validatePathParam('id', imageReq.id)}`
|
|
339
|
-
}, unmarshalSetImageResponse)).then(res => ({
|
|
340
|
-
image: res.image
|
|
341
|
-
}));
|
|
342
|
-
|
|
343
|
-
/**
|
|
344
|
-
* Get the content of a user data on a server for the given key.
|
|
345
|
-
*
|
|
346
|
-
* @param request - The request {@link GetServerUserDataRequest}
|
|
347
|
-
* @returns The content of the key
|
|
348
|
-
*/
|
|
349
|
-
getServerUserData = request => this.client.fetch({
|
|
350
|
-
method: 'GET',
|
|
351
|
-
path: `/instance/v1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/servers/${validatePathParam('serverId', request.serverId)}/user_data/${validatePathParam('key', request.key)}`
|
|
352
|
-
});
|
|
353
|
-
|
|
354
|
-
/**
|
|
355
|
-
* Sets the content of a user data on a server for the given key.
|
|
356
|
-
*
|
|
357
|
-
* @param request - The request {@link SetServerUserDataRequest}
|
|
358
|
-
*/
|
|
359
|
-
setServerUserData = request => this.client.fetch({
|
|
360
|
-
body: request.content,
|
|
361
|
-
headers: {
|
|
362
|
-
'Content-Type': 'text/plain'
|
|
363
|
-
},
|
|
364
|
-
method: 'PATCH',
|
|
365
|
-
path: `/instance/v1/zones/${validatePathParam('zone', request.zone ?? this.client.settings.defaultZone)}/servers/${validatePathParam('serverId', request.serverId)}/user_data/${validatePathParam('key', request.key)}`
|
|
366
|
-
});
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
export { InstanceV1UtilsAPI };
|
|
@@ -1,31 +0,0 @@
|
|
|
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 ImageState}. */
|
|
5
|
-
const IMAGE_TRANSIENT_STATUSES = ['creating'];
|
|
6
|
-
|
|
7
|
-
/** Lists transient statutes of the enum {@link IpState}. */
|
|
8
|
-
const IP_TRANSIENT_STATUSES = ['pending'];
|
|
9
|
-
|
|
10
|
-
/** Lists transient statutes of the enum {@link PrivateNICState}. */
|
|
11
|
-
const PRIVATE_NIC_TRANSIENT_STATUSES = ['syncing'];
|
|
12
|
-
|
|
13
|
-
/** Lists transient statutes of the enum {@link SecurityGroupState}. */
|
|
14
|
-
const SECURITY_GROUP_TRANSIENT_STATUSES = ['syncing'];
|
|
15
|
-
|
|
16
|
-
/** Lists transient statutes of the enum {@link ServerState}. */
|
|
17
|
-
const SERVER_TRANSIENT_STATUSES = ['starting', 'stopping'];
|
|
18
|
-
|
|
19
|
-
/** Lists transient statutes of the enum {@link SnapshotState}. */
|
|
20
|
-
const SNAPSHOT_TRANSIENT_STATUSES = ['snapshotting', 'importing', 'exporting'];
|
|
21
|
-
|
|
22
|
-
/** Lists transient statutes of the enum {@link TaskStatus}. */
|
|
23
|
-
const TASK_TRANSIENT_STATUSES = ['pending', 'started', 'retry'];
|
|
24
|
-
|
|
25
|
-
/** Lists transient statutes of the enum {@link VolumeServerState}. */
|
|
26
|
-
const VOLUME_SERVER_TRANSIENT_STATUSES = ['snapshotting', 'fetching', 'resizing', 'saving', 'hotsyncing'];
|
|
27
|
-
|
|
28
|
-
/** Lists transient statutes of the enum {@link VolumeState}. */
|
|
29
|
-
const VOLUME_TRANSIENT_STATUSES = ['snapshotting', 'fetching', 'resizing', 'saving', 'hotsyncing'];
|
|
30
|
-
|
|
31
|
-
export { IMAGE_TRANSIENT_STATUSES, IP_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 };
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
export { InstanceV1UtilsAPI as API } from './api.utils.js';
|
|
2
|
-
export { IMAGE_TRANSIENT_STATUSES, IP_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 } from './content.gen.js';
|