@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,54 +0,0 @@
|
|
|
1
|
-
import { isAccessKey, isSecretKey } from '../internal/validations/string-validation.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Holds access key and secret key.
|
|
5
|
-
*
|
|
6
|
-
* @public
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Holds default values of a Scaleway profile.
|
|
11
|
-
*
|
|
12
|
-
* @public
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Holds values of a Scaleway profile.
|
|
17
|
-
*
|
|
18
|
-
* @public
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Verifies that the payload contains both the accessKey and the secretKey.
|
|
23
|
-
*
|
|
24
|
-
* @param obj - The secrets
|
|
25
|
-
* @returns Whether the secrets are not empty.
|
|
26
|
-
*
|
|
27
|
-
* @internal
|
|
28
|
-
*/
|
|
29
|
-
const hasAuthenticationSecrets = obj => typeof obj.accessKey === 'string' && obj.accessKey !== '' && typeof obj.secretKey === 'string' && obj.secretKey !== '';
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Asserts the format of secrets.
|
|
33
|
-
*
|
|
34
|
-
* @param obj - The secrets
|
|
35
|
-
* @returns Whether the secrets use a valid format
|
|
36
|
-
*
|
|
37
|
-
* @throws Error
|
|
38
|
-
* Thrown if either the accessKey or the secretKey has en invalid format.
|
|
39
|
-
*
|
|
40
|
-
* @internal
|
|
41
|
-
*/
|
|
42
|
-
function assertValidAuthenticationSecrets(obj) {
|
|
43
|
-
if (!(obj.accessKey && obj.secretKey)) {
|
|
44
|
-
throw new Error(`Invalid secrets, accessKey & secretKey must be defined. See https://www.scaleway.com/en/docs/identity-and-access-management/iam/how-to/create-api-keys/`);
|
|
45
|
-
}
|
|
46
|
-
if (!isAccessKey(obj.accessKey)) {
|
|
47
|
-
throw new Error(`Invalid access key format '${obj.accessKey}', expected SCWXXXXXXXXXXXXXXXXX format. See https://www.scaleway.com/en/docs/identity-and-access-management/iam/how-to/create-api-keys/`);
|
|
48
|
-
}
|
|
49
|
-
if (!isSecretKey(obj.secretKey)) {
|
|
50
|
-
throw new Error(`Invalid secret key format '${obj.secretKey}', expected a UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx. See https://www.scaleway.com/en/docs/identity-and-access-management/iam/how-to/create-api-keys/`);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export { assertValidAuthenticationSecrets, hasAuthenticationSecrets };
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { isOrganizationId, isProjectId, isRegion, isZone, isURL } from '../internal/validations/string-validation.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Holds default values of settings.
|
|
5
|
-
*
|
|
6
|
-
* @public
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Settings hold the values of all client options.
|
|
11
|
-
*
|
|
12
|
-
* @public
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Validates the content of a {@link Settings} object.
|
|
17
|
-
*
|
|
18
|
-
* @throws Error
|
|
19
|
-
* Thrown if {@link Settings} aren't valid.
|
|
20
|
-
*
|
|
21
|
-
* @internal
|
|
22
|
-
*/
|
|
23
|
-
const assertValidSettings = obj => {
|
|
24
|
-
// Default Organization ID.
|
|
25
|
-
if (obj.defaultOrganizationId !== undefined) {
|
|
26
|
-
if (typeof obj.defaultOrganizationId !== 'string' || obj.defaultOrganizationId.length === 0) {
|
|
27
|
-
throw new Error('Default organization ID cannot be empty');
|
|
28
|
-
}
|
|
29
|
-
if (!isOrganizationId(obj.defaultOrganizationId)) {
|
|
30
|
-
throw new Error(`Invalid organization ID format '${obj.defaultOrganizationId}', expected a UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// Default Project ID.
|
|
35
|
-
if (obj.defaultProjectId !== undefined) {
|
|
36
|
-
if (typeof obj.defaultProjectId !== 'string' || obj.defaultProjectId.length === 0) {
|
|
37
|
-
throw new Error('Default project ID cannot be empty');
|
|
38
|
-
}
|
|
39
|
-
if (!isProjectId(obj.defaultProjectId)) {
|
|
40
|
-
throw new Error(`Invalid project ID format '${obj.defaultProjectId}', expected a UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// Default Region.
|
|
45
|
-
if (obj.defaultRegion && !isRegion(obj.defaultRegion)) {
|
|
46
|
-
throw new Error(`Invalid default region format '${obj.defaultRegion}'`);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// Default Zone.
|
|
50
|
-
if (obj.defaultZone && !isZone(obj.defaultZone)) {
|
|
51
|
-
throw new Error(`Invalid default zone format '${obj.defaultZone}'`);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// API URL.
|
|
55
|
-
if (!isURL(obj.apiURL)) {
|
|
56
|
-
throw new Error(`Invalid URL ${obj.apiURL}`);
|
|
57
|
-
}
|
|
58
|
-
if (obj.apiURL.endsWith('/')) {
|
|
59
|
-
throw new Error(`Invalid URL ${obj.apiURL}: it should not have a trailing slash`);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// HTTP Client.
|
|
63
|
-
if (typeof obj.httpClient !== typeof fetch) {
|
|
64
|
-
throw new Error(`Invalid HTTP Client`);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// Default Page Size.
|
|
68
|
-
if (obj.defaultPageSize !== undefined && (typeof obj.defaultPageSize !== 'number' || Number.isNaN(obj.defaultPageSize) || obj.defaultPageSize <= 0)) {
|
|
69
|
-
throw new Error(`Invalid defaultPageSize ${obj.defaultPageSize}: it should be a number above 0`);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// User Agent.
|
|
73
|
-
if (typeof obj.userAgent !== 'string') {
|
|
74
|
-
throw new Error(`Invalid User-Agent`);
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
export { assertValidSettings };
|
package/dist/scw/client.js
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { getLogger } from '../internal/logger/index.js';
|
|
2
|
-
import { withLegacyInterceptors, withProfile } from './client-ini-factory.js';
|
|
3
|
-
import { assertValidSettings } from './client-settings.js';
|
|
4
|
-
import { version, userAgent } from './constants.js';
|
|
5
|
-
import { buildFetcher } from './fetch/build-fetcher.js';
|
|
6
|
-
|
|
7
|
-
/** Default {@link Settings} values. */
|
|
8
|
-
const DEFAULT_SETTINGS = {
|
|
9
|
-
apiURL: 'https://api.scaleway.com',
|
|
10
|
-
httpClient: fetch,
|
|
11
|
-
interceptors: [],
|
|
12
|
-
userAgent
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Scaleway client.
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Creates a Scaleway client with advanced options.
|
|
21
|
-
* You can either use existing factories
|
|
22
|
-
* (like `withProfile`, `withUserAgentSuffix`, etc)
|
|
23
|
-
* or write your own using the interface `ClientConfig`.
|
|
24
|
-
*
|
|
25
|
-
* @example
|
|
26
|
-
* Creates a client with factories:
|
|
27
|
-
* ```
|
|
28
|
-
* createAdvancedClient(
|
|
29
|
-
* (obj: Settings) => ({
|
|
30
|
-
* ...obj,
|
|
31
|
-
* defaultPageSize: 100 ,
|
|
32
|
-
* httpClient: myFetchWrapper,
|
|
33
|
-
* }),
|
|
34
|
-
* withUserAgentSuffix('bot-name/1.0'),
|
|
35
|
-
* )
|
|
36
|
-
* ```
|
|
37
|
-
*
|
|
38
|
-
* @throws Error
|
|
39
|
-
* Thrown if the setup fails.
|
|
40
|
-
*
|
|
41
|
-
* @public
|
|
42
|
-
*/
|
|
43
|
-
const createAdvancedClient = function () {
|
|
44
|
-
for (var _len = arguments.length, configs = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
45
|
-
configs[_key] = arguments[_key];
|
|
46
|
-
}
|
|
47
|
-
const settings = configs.concat([withLegacyInterceptors()]).reduce((currentSettings, config) => config(currentSettings), DEFAULT_SETTINGS);
|
|
48
|
-
assertValidSettings(settings);
|
|
49
|
-
getLogger().info(`init Scaleway SDK version ${version}`);
|
|
50
|
-
return {
|
|
51
|
-
fetch: buildFetcher(settings, settings.httpClient),
|
|
52
|
-
settings
|
|
53
|
-
};
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Creates a Scaleway client with a profile.
|
|
58
|
-
*
|
|
59
|
-
* @example
|
|
60
|
-
* Creates a client with credentials & default values (see https://www.scaleway.com/en/docs/identity-and-access-management/iam/how-to/create-api-keys/):
|
|
61
|
-
* ```
|
|
62
|
-
* import { createClient } from '@scaleway/sdk'
|
|
63
|
-
*
|
|
64
|
-
* createClient({
|
|
65
|
-
* accessKey: 'SCWXXXXXXXXXXXXXXXXX',
|
|
66
|
-
* secretKey: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
|
|
67
|
-
* defaultProjectId: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
|
|
68
|
-
* defaultRegion: 'fr-par',
|
|
69
|
-
* defaultZone: 'fr-par-1',
|
|
70
|
-
* })
|
|
71
|
-
* ```
|
|
72
|
-
*
|
|
73
|
-
* @example
|
|
74
|
-
* Creates a client by loading values from the environment (see https://www.scaleway.com/en/docs/identity-and-access-management/iam/how-to/create-api-keys/)
|
|
75
|
-
* or the config file created by CLI `scw init` (see https://www.scaleway.com/en/cli/):
|
|
76
|
-
* ```
|
|
77
|
-
* import { loadProfileFromConfigurationFile } from '@scaleway/configuration-loader'
|
|
78
|
-
* import { createClient } from '@scaleway/sdk'
|
|
79
|
-
*
|
|
80
|
-
* createClient({
|
|
81
|
-
* ...await loadProfileFromConfigurationFile(),
|
|
82
|
-
* defaultZone: 'fr-par-3',
|
|
83
|
-
* })
|
|
84
|
-
* ```
|
|
85
|
-
*
|
|
86
|
-
* @throws Error
|
|
87
|
-
* Thrown if the setup fails.
|
|
88
|
-
*
|
|
89
|
-
* @public
|
|
90
|
-
*/
|
|
91
|
-
const createClient = function (profile) {
|
|
92
|
-
if (profile === void 0) {
|
|
93
|
-
profile = {};
|
|
94
|
-
}
|
|
95
|
-
return createAdvancedClient(withProfile(profile));
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
export { createAdvancedClient, createClient };
|
package/dist/scw/constants.js
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import { isJSONObject } from '../helpers/json.js';
|
|
2
|
-
import { unmarshalDate, unmarshalArrayOfObject } from '../helpers/marshalling.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Unmarshals {@link Money}
|
|
6
|
-
*
|
|
7
|
-
* @internal
|
|
8
|
-
*/
|
|
9
|
-
const unmarshalMoney = data => {
|
|
10
|
-
if (!isJSONObject(data)) {
|
|
11
|
-
throw new TypeError(`Unmarshalling the type 'Money' failed as data isn't a dictionary.`);
|
|
12
|
-
}
|
|
13
|
-
return {
|
|
14
|
-
currencyCode: data.currency_code,
|
|
15
|
-
nanos: data.nanos,
|
|
16
|
-
units: data.units
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Unmarshals {@link ServiceInfo}.
|
|
22
|
-
*
|
|
23
|
-
* @internal
|
|
24
|
-
*/
|
|
25
|
-
const unmarshalServiceInfo = data => {
|
|
26
|
-
if (!isJSONObject(data)) {
|
|
27
|
-
throw new TypeError(`Unmarshalling the type 'ServiceInfo' failed as data isn't a dictionary.`);
|
|
28
|
-
}
|
|
29
|
-
return {
|
|
30
|
-
description: data.description,
|
|
31
|
-
documentationUrl: data.documentation_url,
|
|
32
|
-
name: data.name,
|
|
33
|
-
version: data.version
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Unmarshals {@link ScwFile}.
|
|
39
|
-
*
|
|
40
|
-
* @internal
|
|
41
|
-
*/
|
|
42
|
-
const unmarshalScwFile = data => {
|
|
43
|
-
if (!isJSONObject(data)) {
|
|
44
|
-
throw new TypeError(`Unmarshalling the type 'ScwFile' failed as data isn't a dictionary.`);
|
|
45
|
-
}
|
|
46
|
-
return {
|
|
47
|
-
content: data.content,
|
|
48
|
-
contentType: data.content_type,
|
|
49
|
-
name: data.name
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Unmarshals {@link TimeSeriesPoint}
|
|
55
|
-
*
|
|
56
|
-
* @remarks To optimize the size of this message,
|
|
57
|
-
* the JSON is compressed in an array instead of a dictionary.
|
|
58
|
-
* Example: `["2019-08-08T15:00:00Z", 0.2]`.
|
|
59
|
-
*
|
|
60
|
-
* @internal
|
|
61
|
-
*/
|
|
62
|
-
const unmarshalTimeSeriesPoint = data => {
|
|
63
|
-
if (!Array.isArray(data)) {
|
|
64
|
-
throw new TypeError(`Unmarshalling the type 'TimeSeriesPoint' failed as data isn't an array.`);
|
|
65
|
-
}
|
|
66
|
-
return {
|
|
67
|
-
timestamp: unmarshalDate(data[0]),
|
|
68
|
-
value: data[1]
|
|
69
|
-
};
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Unmarshals {@link TimeSeries}
|
|
74
|
-
*
|
|
75
|
-
* @internal
|
|
76
|
-
*/
|
|
77
|
-
const unmarshalTimeSeries = data => {
|
|
78
|
-
if (!isJSONObject(data)) {
|
|
79
|
-
throw new TypeError(`Unmarshalling the type 'TimeSeries' failed as data isn't a dictionary.`);
|
|
80
|
-
}
|
|
81
|
-
return {
|
|
82
|
-
metadata: data.metadata,
|
|
83
|
-
name: data.name,
|
|
84
|
-
points: unmarshalArrayOfObject(data.points, unmarshalTimeSeriesPoint)
|
|
85
|
-
};
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Marshals {@link ScwFile}.
|
|
90
|
-
*
|
|
91
|
-
* @internal
|
|
92
|
-
*/
|
|
93
|
-
const marshalScwFile = obj => ({
|
|
94
|
-
content: obj.content,
|
|
95
|
-
content_type: obj.contentType,
|
|
96
|
-
name: obj.name
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Marshals {@link Money}
|
|
101
|
-
*
|
|
102
|
-
* @internal
|
|
103
|
-
*/
|
|
104
|
-
const marshalMoney = obj => ({
|
|
105
|
-
currency_code: obj.currencyCode,
|
|
106
|
-
nanos: obj.nanos,
|
|
107
|
-
units: obj.units
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Marshals {@link TimeSeriesPoint}
|
|
112
|
-
*
|
|
113
|
-
* @internal
|
|
114
|
-
*/
|
|
115
|
-
const marshalTimeSeriesPoint = obj => ({
|
|
116
|
-
timestamp: obj.timestamp?.toISOString(),
|
|
117
|
-
value: obj.value
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Marshals {@link TimeSeries}
|
|
122
|
-
*
|
|
123
|
-
* @internal
|
|
124
|
-
*/
|
|
125
|
-
const marshalTimeSeries = obj => ({
|
|
126
|
-
metadata: obj.metadata,
|
|
127
|
-
name: obj.name,
|
|
128
|
-
points: obj.points.map(elt => marshalTimeSeriesPoint(elt))
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
export { marshalMoney, marshalScwFile, marshalTimeSeries, marshalTimeSeriesPoint, unmarshalMoney, unmarshalScwFile, unmarshalServiceInfo, unmarshalTimeSeries, unmarshalTimeSeriesPoint };
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { InvalidRequestMapper } from './non-standard/invalid-request-mapper.js';
|
|
2
|
-
import { UnknownResourceMapper } from './non-standard/unknown-resource-mapper.js';
|
|
3
|
-
import { ScalewayError } from './scw-error.js';
|
|
4
|
-
import { AlreadyExistsError } from './standard/already-exists-error.js';
|
|
5
|
-
import { DeniedAuthenticationError } from './standard/denied-authentication-error.js';
|
|
6
|
-
import { InvalidArgumentsError } from './standard/invalid-arguments-error.js';
|
|
7
|
-
import { OutOfStockError } from './standard/out-of-stock-error.js';
|
|
8
|
-
import { PermissionsDeniedError } from './standard/permissions-denied-error.js';
|
|
9
|
-
import { PreconditionFailedError } from './standard/precondition-failed-error.js';
|
|
10
|
-
import { QuotasExceededError } from './standard/quotas-exceeded-error.js';
|
|
11
|
-
import { ResourceExpiredError } from './standard/resource-expired-error.js';
|
|
12
|
-
import { ResourceLockedError } from './standard/resource-locked-error.js';
|
|
13
|
-
import { ResourceNotFoundError } from './standard/resource-not-found-error.js';
|
|
14
|
-
import { TooManyRequestsError } from './standard/too-many-requests-error.js';
|
|
15
|
-
import { TransientStateError } from './standard/transient-state-error.js';
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Unmarshals a standard error from raw body.
|
|
19
|
-
*
|
|
20
|
-
* @param type - The error type
|
|
21
|
-
* @param status - The status code
|
|
22
|
-
* @param body - The error response
|
|
23
|
-
* @returns The standard error if found
|
|
24
|
-
*
|
|
25
|
-
* @internal
|
|
26
|
-
*/
|
|
27
|
-
const unmarshalStandardError = (type, status, body) => {
|
|
28
|
-
let error;
|
|
29
|
-
switch (type) {
|
|
30
|
-
case 'denied_authentication':
|
|
31
|
-
error = DeniedAuthenticationError;
|
|
32
|
-
break;
|
|
33
|
-
case 'invalid_arguments':
|
|
34
|
-
error = InvalidArgumentsError;
|
|
35
|
-
break;
|
|
36
|
-
case 'out_of_stock':
|
|
37
|
-
error = OutOfStockError;
|
|
38
|
-
break;
|
|
39
|
-
case 'permissions_denied':
|
|
40
|
-
error = PermissionsDeniedError;
|
|
41
|
-
break;
|
|
42
|
-
case 'precondition_failed':
|
|
43
|
-
error = PreconditionFailedError;
|
|
44
|
-
break;
|
|
45
|
-
case 'quotas_exceeded':
|
|
46
|
-
error = QuotasExceededError;
|
|
47
|
-
break;
|
|
48
|
-
case 'expired':
|
|
49
|
-
error = ResourceExpiredError;
|
|
50
|
-
break;
|
|
51
|
-
case 'not_found':
|
|
52
|
-
error = ResourceNotFoundError;
|
|
53
|
-
break;
|
|
54
|
-
case 'locked':
|
|
55
|
-
error = ResourceLockedError;
|
|
56
|
-
break;
|
|
57
|
-
case 'transient_state':
|
|
58
|
-
error = TransientStateError;
|
|
59
|
-
break;
|
|
60
|
-
case 'already_exists':
|
|
61
|
-
error = AlreadyExistsError;
|
|
62
|
-
break;
|
|
63
|
-
case 'too_many_requests':
|
|
64
|
-
error = TooManyRequestsError;
|
|
65
|
-
break;
|
|
66
|
-
default:
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
|
-
return error.fromJSON(status, body);
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Unmarshals a non-standard error from raw body.
|
|
74
|
-
*
|
|
75
|
-
* @param type - The error type
|
|
76
|
-
* @param status - The status code
|
|
77
|
-
* @param body - The error response
|
|
78
|
-
* @returns The non-standard error if found
|
|
79
|
-
*
|
|
80
|
-
* @internal
|
|
81
|
-
*/
|
|
82
|
-
const unmarshalNonStandardError = (type, status, body) => {
|
|
83
|
-
switch (type) {
|
|
84
|
-
case 'unknown_resource':
|
|
85
|
-
return UnknownResourceMapper.fromJSON(status, body);
|
|
86
|
-
case 'invalid_request_error':
|
|
87
|
-
return InvalidRequestMapper.fromJSON(status, body);
|
|
88
|
-
default:
|
|
89
|
-
return null;
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Parses Scaleway error from raw body.
|
|
95
|
-
*
|
|
96
|
-
* @param status - The status code
|
|
97
|
-
* @param body - The error response
|
|
98
|
-
* @returns The resolved error
|
|
99
|
-
*
|
|
100
|
-
* @internal
|
|
101
|
-
*/
|
|
102
|
-
const parseScalewayError = (status, body) => {
|
|
103
|
-
const parsableError = typeof body.type === 'string' && (unmarshalStandardError(body.type, status, body) ?? unmarshalNonStandardError(body.type, status, body));
|
|
104
|
-
return parsableError || new ScalewayError(status, body);
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
export { parseScalewayError };
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { ScalewayError } from '../scw-error.js';
|
|
2
|
-
import { InvalidArgumentsError } from '../standard/invalid-arguments-error.js';
|
|
3
|
-
import { QuotasExceededError } from '../standard/quotas-exceeded-error.js';
|
|
4
|
-
import { isRecordOfStringArray } from '../types.js';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* InvalidRequest error is only returned by the instance API.
|
|
8
|
-
*
|
|
9
|
-
* @public
|
|
10
|
-
*/
|
|
11
|
-
class InvalidRequestMapper {
|
|
12
|
-
static fromJSON(status, obj) {
|
|
13
|
-
if (typeof obj.message === 'string' && obj.message.toLowerCase().includes('quota exceeded for this resource')) {
|
|
14
|
-
return new QuotasExceededError(status, obj, [{
|
|
15
|
-
current: 0,
|
|
16
|
-
quota: 0,
|
|
17
|
-
resource: typeof obj.resource === 'string' ? obj.resource : ''
|
|
18
|
-
}]);
|
|
19
|
-
}
|
|
20
|
-
const fields = obj.fields && isRecordOfStringArray(obj.fields) ? obj.fields : {};
|
|
21
|
-
const fieldsMessages = Object.entries(fields);
|
|
22
|
-
if (fieldsMessages.length) {
|
|
23
|
-
return new InvalidArgumentsError(status, obj, fieldsMessages.map(_ref => {
|
|
24
|
-
let [argumentName, messages] = _ref;
|
|
25
|
-
return messages.map(helpMessage => ({
|
|
26
|
-
argumentName,
|
|
27
|
-
helpMessage,
|
|
28
|
-
reason: 'constraint'
|
|
29
|
-
}));
|
|
30
|
-
}).flat());
|
|
31
|
-
}
|
|
32
|
-
return new ScalewayError(status, obj);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export { InvalidRequestMapper };
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { isUUID } from '../../../internal/validations/string-validation.js';
|
|
2
|
-
import { ScalewayError } from '../scw-error.js';
|
|
3
|
-
import { ResourceNotFoundError } from '../standard/resource-not-found-error.js';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* UnknownResource error is only returned by the instance API.
|
|
7
|
-
*
|
|
8
|
-
* @public
|
|
9
|
-
*/
|
|
10
|
-
class UnknownResourceMapper {
|
|
11
|
-
static fromJSON(status, obj) {
|
|
12
|
-
// Split the message
|
|
13
|
-
// Note: some errors uses ' and not "
|
|
14
|
-
// Examples: `"111..." not found` or `Security Group '111...' not found`
|
|
15
|
-
const messageParts = typeof obj.message === 'string' ? obj.message.split(/"|'/) : [];
|
|
16
|
-
if (messageParts.length === 3 && isUUID(messageParts[1])) {
|
|
17
|
-
return new ResourceNotFoundError(status, obj,
|
|
18
|
-
// transform `Security group ` to `security_group`
|
|
19
|
-
// `.replaceAll()` may be too recent to use yet.
|
|
20
|
-
// that's why we're using `.split(' ').join('_')` for now.
|
|
21
|
-
messageParts[0].trim().toLowerCase().split(' ').join('_'), messageParts[1]);
|
|
22
|
-
}
|
|
23
|
-
return new ScalewayError(status, obj);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export { UnknownResourceMapper };
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { isJSONObject } from '../../helpers/json.js';
|
|
2
|
-
import { isRecordOfStringArray } from './types.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Builds the default message for {@link ScalewayError}.
|
|
6
|
-
*
|
|
7
|
-
* @param status - The response code
|
|
8
|
-
* @param body - The response body
|
|
9
|
-
* @returns The error message
|
|
10
|
-
*
|
|
11
|
-
* @internal
|
|
12
|
-
*/
|
|
13
|
-
const buildDefaultMessage = (status, body) => {
|
|
14
|
-
const message = [`http error ${status}`];
|
|
15
|
-
if (typeof body === 'string') {
|
|
16
|
-
message.push(body);
|
|
17
|
-
} else if (isJSONObject(body)) {
|
|
18
|
-
if (typeof body.resource === 'string') {
|
|
19
|
-
message.push(`resource ${body.resource}`);
|
|
20
|
-
}
|
|
21
|
-
if (typeof body.message === 'string') {
|
|
22
|
-
message.push(body.message);
|
|
23
|
-
}
|
|
24
|
-
if (body.fields && isRecordOfStringArray(body.fields)) {
|
|
25
|
-
message.push(Object.entries(body.fields).map(_ref => {
|
|
26
|
-
let [name, list] = _ref;
|
|
27
|
-
return `${name} (${list.join(', ')})`;
|
|
28
|
-
}).join(', '));
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return message.join(': ');
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Scaleway error.
|
|
36
|
-
*
|
|
37
|
-
* @public
|
|
38
|
-
*/
|
|
39
|
-
class ScalewayError extends Error {
|
|
40
|
-
/** The message originating from the payload. */
|
|
41
|
-
|
|
42
|
-
constructor( /** The response status. */
|
|
43
|
-
status, /** The response payload. */
|
|
44
|
-
body, /** The augmented message. */
|
|
45
|
-
message) {
|
|
46
|
-
if (message === void 0) {
|
|
47
|
-
message = buildDefaultMessage(status, body);
|
|
48
|
-
}
|
|
49
|
-
super(message); // 'Error' breaks prototype chain here
|
|
50
|
-
this.status = status;
|
|
51
|
-
this.body = body;
|
|
52
|
-
this.message = message;
|
|
53
|
-
this.name = 'ScalewayError';
|
|
54
|
-
this.rawMessage = typeof body === 'object' && typeof body.message === 'string' ? body.message : undefined;
|
|
55
|
-
Object.setPrototypeOf(this, new.target.prototype); // restore prototype chain
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
static fromJSON(status, obj) {
|
|
59
|
-
return new ScalewayError(status, obj);
|
|
60
|
-
}
|
|
61
|
-
toString() {
|
|
62
|
-
return `${this.name}: ${this.message}`;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export { ScalewayError };
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { ScalewayError } from '../scw-error.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* AlreadyExists error is used when a resource already exists.
|
|
5
|
-
*
|
|
6
|
-
* @public
|
|
7
|
-
*/
|
|
8
|
-
class AlreadyExistsError extends ScalewayError {
|
|
9
|
-
constructor(status, body, resource, resourceId, helpMessage) {
|
|
10
|
-
super(status, body, `resource ${resource} with ID ${resourceId} already exists: ${helpMessage}`);
|
|
11
|
-
this.status = status;
|
|
12
|
-
this.body = body;
|
|
13
|
-
this.resource = resource;
|
|
14
|
-
this.resourceId = resourceId;
|
|
15
|
-
this.helpMessage = helpMessage;
|
|
16
|
-
this.name = 'AlreadyExistsError';
|
|
17
|
-
}
|
|
18
|
-
static fromJSON(status, obj) {
|
|
19
|
-
if (typeof obj.resource !== 'string' || typeof obj.resource_id !== 'string' || typeof obj.help_message !== 'string') {
|
|
20
|
-
return null;
|
|
21
|
-
}
|
|
22
|
-
return new AlreadyExistsError(status, obj, obj.resource, obj.resource_id, obj.help_message);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export { AlreadyExistsError };
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { ScalewayError } from '../scw-error.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Build the default message for {@link DeniedAuthenticationError}.
|
|
5
|
-
*
|
|
6
|
-
* @param method - The authentication method
|
|
7
|
-
* @param reason - The deny reason
|
|
8
|
-
* @returns The error message
|
|
9
|
-
*
|
|
10
|
-
* @internal
|
|
11
|
-
*/
|
|
12
|
-
const buildMessage = (method, reason) => {
|
|
13
|
-
let reasonDesc;
|
|
14
|
-
switch (reason) {
|
|
15
|
-
case 'invalid_argument':
|
|
16
|
-
reasonDesc = `invalid ${method} format or empty value`;
|
|
17
|
-
break;
|
|
18
|
-
case 'not_found':
|
|
19
|
-
reasonDesc = `${method} does not exist`;
|
|
20
|
-
break;
|
|
21
|
-
case 'expired':
|
|
22
|
-
reasonDesc = `${method} is expired`;
|
|
23
|
-
break;
|
|
24
|
-
default:
|
|
25
|
-
reasonDesc = `unknown reason for ${method}`;
|
|
26
|
-
}
|
|
27
|
-
return `denied authentication: ${reasonDesc}`;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* DeniedAuthentication error is used by the API Gateway auth service to deny a request.
|
|
32
|
-
*
|
|
33
|
-
* @public
|
|
34
|
-
*/
|
|
35
|
-
class DeniedAuthenticationError extends ScalewayError {
|
|
36
|
-
constructor(status, body, method, reason) {
|
|
37
|
-
super(status, body, buildMessage(method, reason));
|
|
38
|
-
this.status = status;
|
|
39
|
-
this.body = body;
|
|
40
|
-
this.method = method;
|
|
41
|
-
this.reason = reason;
|
|
42
|
-
this.name = 'DeniedAuthenticationError';
|
|
43
|
-
}
|
|
44
|
-
static fromJSON(status, obj) {
|
|
45
|
-
if (typeof obj.method !== 'string' || typeof obj.reason !== 'string') {
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
48
|
-
return new DeniedAuthenticationError(status, obj, obj.method, obj.reason);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export { DeniedAuthenticationError };
|