@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,13 +0,0 @@
|
|
|
1
|
-
export { ScalewayError } from '../scw-error.js';
|
|
2
|
-
export { AlreadyExistsError } from './already-exists-error.js';
|
|
3
|
-
export { DeniedAuthenticationError } from './denied-authentication-error.js';
|
|
4
|
-
export { InvalidArgumentsError } from './invalid-arguments-error.js';
|
|
5
|
-
export { OutOfStockError } from './out-of-stock-error.js';
|
|
6
|
-
export { PermissionsDeniedError } from './permissions-denied-error.js';
|
|
7
|
-
export { PreconditionFailedError } from './precondition-failed-error.js';
|
|
8
|
-
export { QuotasExceededError } from './quotas-exceeded-error.js';
|
|
9
|
-
export { ResourceExpiredError } from './resource-expired-error.js';
|
|
10
|
-
export { ResourceLockedError } from './resource-locked-error.js';
|
|
11
|
-
export { ResourceNotFoundError } from './resource-not-found-error.js';
|
|
12
|
-
export { TooManyRequestsError } from './too-many-requests-error.js';
|
|
13
|
-
export { TransientStateError } from './transient-state-error.js';
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { isJSONObject } from '../../../helpers/json.js';
|
|
2
|
-
import { ScalewayError } from '../scw-error.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Details of an {@link InvalidArgumentsError} error.
|
|
6
|
-
*
|
|
7
|
-
* @public
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Build the default message for {@link InvalidArgumentsError}.
|
|
12
|
-
*
|
|
13
|
-
* @param list - The list of {@link InvalidArgumentsErrorDetails}
|
|
14
|
-
* @returns The error message
|
|
15
|
-
*
|
|
16
|
-
* @internal
|
|
17
|
-
*/
|
|
18
|
-
const buildMessage = list => {
|
|
19
|
-
const invalidArgs = list.reduce((acc, details) => {
|
|
20
|
-
let readableReason = '';
|
|
21
|
-
switch (details.reason) {
|
|
22
|
-
case 'required':
|
|
23
|
-
readableReason = `is required`;
|
|
24
|
-
break;
|
|
25
|
-
case 'format':
|
|
26
|
-
readableReason = `is wrongly formatted`;
|
|
27
|
-
break;
|
|
28
|
-
case 'constraint':
|
|
29
|
-
readableReason = `does not respect constraint`;
|
|
30
|
-
break;
|
|
31
|
-
default:
|
|
32
|
-
readableReason = `is invalid for unexpected reason`;
|
|
33
|
-
break;
|
|
34
|
-
}
|
|
35
|
-
if (details.helpMessage && details.helpMessage.length > 0) {
|
|
36
|
-
readableReason = readableReason.concat(`, `, details.helpMessage);
|
|
37
|
-
}
|
|
38
|
-
acc.push(`${details.argumentName} ${readableReason}`);
|
|
39
|
-
return acc;
|
|
40
|
-
}, []);
|
|
41
|
-
return `invalid argument(s): ${invalidArgs.join('; ')}`;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* InvalidArguments error happens when one or many fields are invalid in the request message.
|
|
46
|
-
*
|
|
47
|
-
* @public
|
|
48
|
-
*/
|
|
49
|
-
class InvalidArgumentsError extends ScalewayError {
|
|
50
|
-
constructor(status, body, details) {
|
|
51
|
-
super(status, body, buildMessage(details));
|
|
52
|
-
this.status = status;
|
|
53
|
-
this.body = body;
|
|
54
|
-
this.details = details;
|
|
55
|
-
this.name = 'InvalidArgumentsError';
|
|
56
|
-
}
|
|
57
|
-
static fromJSON(status, obj) {
|
|
58
|
-
if (!Array.isArray(obj.details)) return null;
|
|
59
|
-
return new InvalidArgumentsError(status, obj, obj.details.reduce((list, detail) => isJSONObject(detail) && typeof detail.argument_name === 'string' && typeof detail.reason === 'string' ? list.concat({
|
|
60
|
-
argumentName: detail.argument_name,
|
|
61
|
-
helpMessage: typeof detail.help_message === 'string' ? detail.help_message : undefined,
|
|
62
|
-
reason: detail.reason
|
|
63
|
-
}) : list, []));
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export { InvalidArgumentsError };
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { ScalewayError } from '../scw-error.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* OutOfStock error happens when stocks are empty for the resource.
|
|
5
|
-
*
|
|
6
|
-
* @public
|
|
7
|
-
*/
|
|
8
|
-
class OutOfStockError extends ScalewayError {
|
|
9
|
-
constructor(status, body, resource) {
|
|
10
|
-
super(status, body, `resource ${resource} is out of stock`);
|
|
11
|
-
this.status = status;
|
|
12
|
-
this.body = body;
|
|
13
|
-
this.resource = resource;
|
|
14
|
-
this.name = 'OutOfStockError';
|
|
15
|
-
}
|
|
16
|
-
static fromJSON(status, obj) {
|
|
17
|
-
if (typeof obj.resource !== 'string') return null;
|
|
18
|
-
return new OutOfStockError(status, obj, obj.resource);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export { OutOfStockError };
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { isJSONObject } from '../../../helpers/json.js';
|
|
2
|
-
import { ScalewayError } from '../scw-error.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Details of an {@link PermissionsDeniedError} error.
|
|
6
|
-
*
|
|
7
|
-
* @public
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Build the default message for {@link PermissionsDeniedError}.
|
|
12
|
-
*
|
|
13
|
-
* @param list - The list of {@link PermissionsDeniedErrorDetails}
|
|
14
|
-
* @returns The error message
|
|
15
|
-
*
|
|
16
|
-
* @internal
|
|
17
|
-
*/
|
|
18
|
-
const buildMessage = list => `insufficient permissions: ${list.map(_ref => {
|
|
19
|
-
let {
|
|
20
|
-
action,
|
|
21
|
-
resource
|
|
22
|
-
} = _ref;
|
|
23
|
-
return `${action} ${resource}`;
|
|
24
|
-
}).join('; ')}`;
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* PermissionsDenied error happens when one or many permissions are not accorded to the user making the request.
|
|
28
|
-
*
|
|
29
|
-
* @public
|
|
30
|
-
*/
|
|
31
|
-
class PermissionsDeniedError extends ScalewayError {
|
|
32
|
-
constructor(status, body, list) {
|
|
33
|
-
super(status, body, buildMessage(list));
|
|
34
|
-
this.status = status;
|
|
35
|
-
this.body = body;
|
|
36
|
-
this.list = list;
|
|
37
|
-
this.name = 'PermissionsDeniedError';
|
|
38
|
-
}
|
|
39
|
-
static fromJSON(status, obj) {
|
|
40
|
-
if (!Array.isArray(obj.details)) return null;
|
|
41
|
-
return new PermissionsDeniedError(status, obj, obj.details.reduce((list, detail) => isJSONObject(detail) && typeof detail.resource === 'string' && typeof detail.action === 'string' ? list.concat({
|
|
42
|
-
action: detail.action,
|
|
43
|
-
resource: detail.resource
|
|
44
|
-
}) : list, []));
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export { PermissionsDeniedError };
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { ScalewayError } from '../scw-error.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Build the default message for {@link PreconditionFailedError}.
|
|
5
|
-
*
|
|
6
|
-
* @param precondition - The precondition
|
|
7
|
-
* @param helpMessage - The message which should help the user to fix the root cause
|
|
8
|
-
* @returns The error message
|
|
9
|
-
*
|
|
10
|
-
* @internal
|
|
11
|
-
*/
|
|
12
|
-
const buildMessage = (precondition, helpMessage) => {
|
|
13
|
-
let message = `precondition failed: ${precondition}`;
|
|
14
|
-
if (typeof helpMessage === 'string' && helpMessage.length > 0) {
|
|
15
|
-
message = message.concat(', ', helpMessage);
|
|
16
|
-
}
|
|
17
|
-
return message;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* PreconditionFailed error is used when a precondition is not respected.
|
|
22
|
-
*
|
|
23
|
-
* @public
|
|
24
|
-
*/
|
|
25
|
-
class PreconditionFailedError extends ScalewayError {
|
|
26
|
-
constructor(status, body, precondition, helpMessage) {
|
|
27
|
-
super(status, body, buildMessage(precondition, helpMessage));
|
|
28
|
-
this.status = status;
|
|
29
|
-
this.body = body;
|
|
30
|
-
this.precondition = precondition;
|
|
31
|
-
this.helpMessage = helpMessage;
|
|
32
|
-
this.name = 'PreconditionFailedError';
|
|
33
|
-
}
|
|
34
|
-
static fromJSON(status, obj) {
|
|
35
|
-
if (typeof obj.precondition !== 'string' || typeof obj.help_message !== 'string') {
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
|
-
return new PreconditionFailedError(status, obj, obj.precondition, obj.help_message);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export { PreconditionFailedError };
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { isJSONObject } from '../../../helpers/json.js';
|
|
2
|
-
import { ScalewayError } from '../scw-error.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Scope of an {@link QuotasExceededErrorDetails} error.
|
|
6
|
-
*
|
|
7
|
-
* @public
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Details of an {@link QuotasExceededError} error.
|
|
12
|
-
*
|
|
13
|
-
* @public
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Build the default message for {@link QuotasExceededError}.
|
|
18
|
-
*
|
|
19
|
-
* @param list - The list of {@link QuotasExceededErrorDetails}
|
|
20
|
-
* @returns The error message
|
|
21
|
-
*
|
|
22
|
-
* @internal
|
|
23
|
-
*/
|
|
24
|
-
const buildMessage = list => `quota(s) exceeded: ${list.map(details => {
|
|
25
|
-
const message = `${details.resource} has reached its quota (${details.current}/${details.quota})`;
|
|
26
|
-
return details.scope ? `${message} for ${details.scope.kind} '${details.scope.id}'` : message;
|
|
27
|
-
}).join('; ')}`;
|
|
28
|
-
const buildScope = detail => {
|
|
29
|
-
if (typeof detail.organization_id === 'string' && detail.organization_id.length) {
|
|
30
|
-
return {
|
|
31
|
-
id: detail.organization_id,
|
|
32
|
-
kind: 'organization'
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
if (typeof detail.project_id === 'string' && detail.project_id.length) {
|
|
36
|
-
return {
|
|
37
|
-
id: detail.project_id,
|
|
38
|
-
kind: 'project'
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
return undefined;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* QuotasExceeded error happens when one or many resource exceed quotas during the creation of a resource.
|
|
46
|
-
*
|
|
47
|
-
* @public
|
|
48
|
-
*/
|
|
49
|
-
class QuotasExceededError extends ScalewayError {
|
|
50
|
-
constructor(status, body, list) {
|
|
51
|
-
super(status, body, buildMessage(list));
|
|
52
|
-
this.status = status;
|
|
53
|
-
this.body = body;
|
|
54
|
-
this.list = list;
|
|
55
|
-
this.name = 'QuotasExceededError';
|
|
56
|
-
}
|
|
57
|
-
static fromJSON(status, obj) {
|
|
58
|
-
if (!Array.isArray(obj.details)) return null;
|
|
59
|
-
return new QuotasExceededError(status, obj, obj.details.reduce((list, detail) => isJSONObject(detail) && typeof detail.resource === 'string' && typeof detail.quota === 'number' && typeof detail.current === 'number' ? list.concat({
|
|
60
|
-
current: detail.current,
|
|
61
|
-
quota: detail.quota,
|
|
62
|
-
resource: detail.resource,
|
|
63
|
-
scope: buildScope(detail)
|
|
64
|
-
}) : list, []));
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export { QuotasExceededError };
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { ScalewayError } from '../scw-error.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* ResourceExpired error happens when trying to access a resource that has expired.
|
|
5
|
-
*
|
|
6
|
-
* @public
|
|
7
|
-
*/
|
|
8
|
-
class ResourceExpiredError extends ScalewayError {
|
|
9
|
-
constructor(status, body, resource, resourceId, expiredSince) {
|
|
10
|
-
super(status, body, `resource ${resource} with ID ${resourceId} expired since ${expiredSince.toISOString()}`);
|
|
11
|
-
this.status = status;
|
|
12
|
-
this.body = body;
|
|
13
|
-
this.resource = resource;
|
|
14
|
-
this.resourceId = resourceId;
|
|
15
|
-
this.expiredSince = expiredSince;
|
|
16
|
-
this.name = 'ResourceExpiredError';
|
|
17
|
-
}
|
|
18
|
-
static fromJSON(status, obj) {
|
|
19
|
-
if (typeof obj.resource !== 'string' || typeof obj.resource_id !== 'string' || typeof obj.expired_since !== 'string') {
|
|
20
|
-
return null;
|
|
21
|
-
}
|
|
22
|
-
return new ResourceExpiredError(status, obj, obj.resource, obj.resource_id, new Date(obj.expired_since));
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export { ResourceExpiredError };
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { ScalewayError } from '../scw-error.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* ResourceLocked error happens when a resource is locked by trust and safety.
|
|
5
|
-
*
|
|
6
|
-
* @public
|
|
7
|
-
*/
|
|
8
|
-
class ResourceLockedError extends ScalewayError {
|
|
9
|
-
constructor(status, body, resource, resourceId) {
|
|
10
|
-
super(status, body, `resource ${resource} with ID ${resourceId} is locked`);
|
|
11
|
-
this.status = status;
|
|
12
|
-
this.body = body;
|
|
13
|
-
this.resource = resource;
|
|
14
|
-
this.resourceId = resourceId;
|
|
15
|
-
this.name = 'ResourceLockedError';
|
|
16
|
-
}
|
|
17
|
-
static fromJSON(status, obj) {
|
|
18
|
-
if (typeof obj.resource !== 'string' || typeof obj.resource_id !== 'string') {
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
return new ResourceLockedError(status, obj, obj.resource, obj.resource_id);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export { ResourceLockedError };
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { ScalewayError } from '../scw-error.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* ResourceNotFound error happens when getting a resource that does not exist anymore.
|
|
5
|
-
*
|
|
6
|
-
* @public
|
|
7
|
-
*/
|
|
8
|
-
class ResourceNotFoundError extends ScalewayError {
|
|
9
|
-
constructor(status, body, resource, resourceId) {
|
|
10
|
-
super(status, body, `resource ${resource} with ID ${resourceId} is not found`);
|
|
11
|
-
this.status = status;
|
|
12
|
-
this.body = body;
|
|
13
|
-
this.resource = resource;
|
|
14
|
-
this.resourceId = resourceId;
|
|
15
|
-
this.name = 'ResourceNotFoundError';
|
|
16
|
-
}
|
|
17
|
-
static fromJSON(status, obj) {
|
|
18
|
-
if (typeof obj.resource !== 'string' || typeof obj.resource_id !== 'string') {
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
return new ResourceNotFoundError(status, obj, obj.resource, obj.resource_id);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export { ResourceNotFoundError };
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { isJSONObject } from '../../../helpers/json.js';
|
|
2
|
-
import { ScalewayError } from '../scw-error.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Quota policy of {@link TooManyRequestsError}.
|
|
6
|
-
*
|
|
7
|
-
* @public
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Build the default message for {@link TooManyRequestsError}.
|
|
12
|
-
*
|
|
13
|
-
* @internal
|
|
14
|
-
*/
|
|
15
|
-
const buildMessage = (helpMessage, limit, resetSeconds, resetAt) => {
|
|
16
|
-
const details = [];
|
|
17
|
-
if (limit) {
|
|
18
|
-
if (limit.windowSeconds) {
|
|
19
|
-
details.push(`quota is ${limit.quota} for ${limit.windowSeconds}s`);
|
|
20
|
-
} else {
|
|
21
|
-
details.push(`quota is ${limit.quota}`);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
if (resetSeconds) {
|
|
25
|
-
details.push(`resets in ${resetSeconds}s`);
|
|
26
|
-
} else if (resetAt) {
|
|
27
|
-
details.push(`resets at ${resetAt.toISOString()}`);
|
|
28
|
-
}
|
|
29
|
-
let output = `too many requests`;
|
|
30
|
-
if (details.length > 0) {
|
|
31
|
-
output += ` (${details.join(', ')})`;
|
|
32
|
-
}
|
|
33
|
-
if (helpMessage.length > 0) {
|
|
34
|
-
output += `: ${helpMessage}`;
|
|
35
|
-
}
|
|
36
|
-
return output;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* TooManyRequestsError error happens when fetching too many times a resource.
|
|
41
|
-
*
|
|
42
|
-
* @public
|
|
43
|
-
*/
|
|
44
|
-
class TooManyRequestsError extends ScalewayError {
|
|
45
|
-
constructor(status, body, helpMessage, limit, /** The number of seconds until the quota resets */
|
|
46
|
-
resetSeconds, /** The timestamp when the quota resets */
|
|
47
|
-
resetAt) {
|
|
48
|
-
super(status, body, buildMessage(helpMessage, limit, resetSeconds, resetAt));
|
|
49
|
-
this.status = status;
|
|
50
|
-
this.body = body;
|
|
51
|
-
this.helpMessage = helpMessage;
|
|
52
|
-
this.limit = limit;
|
|
53
|
-
this.resetSeconds = resetSeconds;
|
|
54
|
-
this.resetAt = resetAt;
|
|
55
|
-
this.name = 'TooManyRequestsError';
|
|
56
|
-
}
|
|
57
|
-
static fromJSON(status, obj) {
|
|
58
|
-
if (typeof obj.help_message !== 'string') return null;
|
|
59
|
-
let limit;
|
|
60
|
-
if (isJSONObject(obj.limit) && typeof obj.limit.quota === 'number') {
|
|
61
|
-
limit = {
|
|
62
|
-
quota: obj.limit.quota,
|
|
63
|
-
windowSeconds: typeof obj.limit.window_seconds === 'number' ? obj.limit.window_seconds : undefined
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
return new TooManyRequestsError(status, obj, obj.help_message, limit, typeof obj.reset_seconds === 'number' ? obj.reset_seconds : undefined, typeof obj.reset_at === 'string' ? new Date(obj.reset_at) : undefined);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export { TooManyRequestsError };
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { ScalewayError } from '../scw-error.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* TransientState error happens when trying to perform an action on a resource in a transient state.
|
|
5
|
-
*
|
|
6
|
-
* @public
|
|
7
|
-
*/
|
|
8
|
-
class TransientStateError extends ScalewayError {
|
|
9
|
-
constructor(status, body, resource, resourceId, currentState) {
|
|
10
|
-
super(status, body, `resource ${resource} with ID ${resourceId} is in a transient state: ${currentState}`);
|
|
11
|
-
this.status = status;
|
|
12
|
-
this.body = body;
|
|
13
|
-
this.resource = resource;
|
|
14
|
-
this.resourceId = resourceId;
|
|
15
|
-
this.currentState = currentState;
|
|
16
|
-
this.name = 'TransientStateError';
|
|
17
|
-
}
|
|
18
|
-
static fromJSON(status, obj) {
|
|
19
|
-
if (typeof obj.resource !== 'string' || typeof obj.resource_id !== 'string' || typeof obj.current_state !== 'string') {
|
|
20
|
-
return null;
|
|
21
|
-
}
|
|
22
|
-
return new TransientStateError(status, obj, obj.resource, obj.resource_id, obj.current_state);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export { TransientStateError };
|
package/dist/scw/errors/types.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { isJSONObject } from '../../helpers/json.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Verifies the object is a record of string to string[].
|
|
5
|
-
*
|
|
6
|
-
* @param obj - The object
|
|
7
|
-
* @returns Whether the object is of the expected type
|
|
8
|
-
*
|
|
9
|
-
* @internal
|
|
10
|
-
*/
|
|
11
|
-
const isRecordOfStringArray = obj => {
|
|
12
|
-
if (!isJSONObject(obj)) {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
for (const elt of Object.values(obj)) {
|
|
16
|
-
if (!Array.isArray(elt) || Object.values(elt).find(x => typeof x !== 'string') !== undefined) {
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return true;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export { isRecordOfStringArray };
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { isBrowser } from '../../helpers/is-browser.js';
|
|
2
|
-
import { composeRequestInterceptors, composeResponseInterceptors, composeResponseErrorInterceptors } from '../../internal/interceptors/composer.js';
|
|
3
|
-
import { obfuscateAuthHeadersEntry } from '../auth.js';
|
|
4
|
-
import { logRequest, logResponse, obfuscateInterceptor } from './http-interceptors.js';
|
|
5
|
-
import { responseParser } from './response-parser.js';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Builds Request from {@link ScwRequest} & {@link Settings}.
|
|
9
|
-
*
|
|
10
|
-
* @param request - A scaleway request
|
|
11
|
-
* @param settings - The settings
|
|
12
|
-
* @returns A fetch Request
|
|
13
|
-
*
|
|
14
|
-
* @internal
|
|
15
|
-
*/
|
|
16
|
-
const buildRequest = (request, settings) => {
|
|
17
|
-
let {
|
|
18
|
-
path
|
|
19
|
-
} = request;
|
|
20
|
-
if (request.urlParams instanceof URLSearchParams) {
|
|
21
|
-
path = path.concat(`?${request.urlParams.toString()}`);
|
|
22
|
-
}
|
|
23
|
-
return new Request(`${settings.apiURL}${path}`, {
|
|
24
|
-
body: request.body,
|
|
25
|
-
headers: {
|
|
26
|
-
Accept: 'application/json',
|
|
27
|
-
...( /* istanbul ignore next */!isBrowser() ? {
|
|
28
|
-
'User-Agent': settings.userAgent
|
|
29
|
-
} : {}),
|
|
30
|
-
...request.headers
|
|
31
|
-
},
|
|
32
|
-
method: request.method
|
|
33
|
-
});
|
|
34
|
-
};
|
|
35
|
-
const asIs = response => response;
|
|
36
|
-
/**
|
|
37
|
-
* Builds a resource fetcher.
|
|
38
|
-
*
|
|
39
|
-
* @param settings - The {@link Settings} object
|
|
40
|
-
* @param httpClient - The HTTP client that should be used to call the API
|
|
41
|
-
* @returns The fetcher
|
|
42
|
-
*
|
|
43
|
-
* @internal
|
|
44
|
-
*/
|
|
45
|
-
const buildFetcher = (settings, httpClient) => {
|
|
46
|
-
let requestNumber = 0;
|
|
47
|
-
const prepareRequest = requestId => composeRequestInterceptors([...settings.interceptors.map(obj => obj.request).filter(obj => obj), logRequest(requestId, obfuscateInterceptor(obfuscateAuthHeadersEntry))]);
|
|
48
|
-
const prepareResponse = requestId => composeResponseInterceptors([...settings.interceptors.map(obj => obj.response).filter(obj => obj), logResponse(requestId)]);
|
|
49
|
-
const prepareResponseErrors = () => composeResponseErrorInterceptors(settings.interceptors.map(obj => obj.responseError).filter(obj => obj));
|
|
50
|
-
return async function (request, unwrapper) {
|
|
51
|
-
if (unwrapper === void 0) {
|
|
52
|
-
unwrapper = asIs;
|
|
53
|
-
}
|
|
54
|
-
const requestId = `${requestNumber += 1}`;
|
|
55
|
-
const reqInterceptors = prepareRequest(requestId);
|
|
56
|
-
const finalRequest = await reqInterceptors(buildRequest(request, settings));
|
|
57
|
-
try {
|
|
58
|
-
const response = await httpClient(finalRequest);
|
|
59
|
-
const resInterceptors = prepareResponse(requestId);
|
|
60
|
-
const finalResponse = await resInterceptors(response);
|
|
61
|
-
const resUnmarshaller = responseParser(unwrapper, request.responseType ?? 'json');
|
|
62
|
-
const unmarshaledResponse = await resUnmarshaller(finalResponse);
|
|
63
|
-
return unmarshaledResponse;
|
|
64
|
-
} catch (err) {
|
|
65
|
-
const resErrorInterceptors = prepareResponseErrors();
|
|
66
|
-
const handledError = await resErrorInterceptors(finalRequest, err);
|
|
67
|
-
return unwrapper(handledError);
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
export { buildFetcher, buildRequest };
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Converts a string to PascalCase.
|
|
3
|
-
*
|
|
4
|
-
* @param str - The input string
|
|
5
|
-
* @returns The string in PascalCase
|
|
6
|
-
*
|
|
7
|
-
* @internal
|
|
8
|
-
*/
|
|
9
|
-
const toPascalCase = str => str.replace(/\w+/g, word => `${word[0].toUpperCase()}${word.slice(1).toLowerCase()}`);
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Converts a Headers entry to string.
|
|
13
|
-
*
|
|
14
|
-
* @param entry - The header entry as a string tuple
|
|
15
|
-
* @returns A serialized string
|
|
16
|
-
*
|
|
17
|
-
* @internal
|
|
18
|
-
*/
|
|
19
|
-
const serializeHeadersEntry = _ref => {
|
|
20
|
-
let [name, value] = _ref;
|
|
21
|
-
return `${toPascalCase(name)}: ${value}`;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Converts Headers to safe to log strings (with obfuscated auth secrets).
|
|
26
|
-
*
|
|
27
|
-
* @param headers - The Headers
|
|
28
|
-
* @returns Serialized headers strings
|
|
29
|
-
*
|
|
30
|
-
* @internal
|
|
31
|
-
*/
|
|
32
|
-
const serializeHeaders = headers => Array.from(headers.entries(), serializeHeadersEntry);
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Dumps a Request into a readable string.
|
|
36
|
-
*
|
|
37
|
-
* @param request - The request
|
|
38
|
-
* @returns The readable string
|
|
39
|
-
*
|
|
40
|
-
* @internal
|
|
41
|
-
*/
|
|
42
|
-
const dumpRequest = async request => [`${request.method.toUpperCase()}: ${request.url}`, ...serializeHeaders(request.headers), await request.clone().text()].join('\r\n');
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Dumps a Response into a readable string.
|
|
46
|
-
*
|
|
47
|
-
* @param response - The response
|
|
48
|
-
* @returns The readable string
|
|
49
|
-
*
|
|
50
|
-
* @internal
|
|
51
|
-
*/
|
|
52
|
-
const dumpResponse = async response => [`HTTP ${response.status} ${response.ok ? 'OK' : 'NOK'}`, ...serializeHeaders(response.headers), await response.clone().text()].join('\r\n');
|
|
53
|
-
|
|
54
|
-
export { dumpRequest, dumpResponse };
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { getLogger } from '../../internal/logger/index.js';
|
|
2
|
-
import { shouldLog, LevelResolver } from '../../internal/logger/level-resolver.js';
|
|
3
|
-
import { dumpRequest, dumpResponse } from './http-dumper.js';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Mapper of an header entry.
|
|
7
|
-
*
|
|
8
|
-
* @internal
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* HTTP Request with obfuscated secrets.
|
|
13
|
-
*
|
|
14
|
-
* @internal
|
|
15
|
-
*/
|
|
16
|
-
class ObfuscatedRequest extends Request {
|
|
17
|
-
constructor(request, obfuscate) {
|
|
18
|
-
super(request);
|
|
19
|
-
this.request = request;
|
|
20
|
-
this.obfuscate = obfuscate;
|
|
21
|
-
}
|
|
22
|
-
get headers() {
|
|
23
|
-
return new Headers(Array.from(this.request.headers, this.obfuscate));
|
|
24
|
-
}
|
|
25
|
-
clone() {
|
|
26
|
-
return new ObfuscatedRequest(this.request, this.obfuscate);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Creates an interceptor to obfuscate the requests.
|
|
32
|
-
*
|
|
33
|
-
* @param obfuscate - The Header entries obfuscator mapper
|
|
34
|
-
* @returns The obfuscated Request
|
|
35
|
-
*
|
|
36
|
-
* @internal
|
|
37
|
-
*/
|
|
38
|
-
const obfuscateInterceptor = obfuscate => _ref => {
|
|
39
|
-
let {
|
|
40
|
-
request
|
|
41
|
-
} = _ref;
|
|
42
|
-
return new ObfuscatedRequest(request, obfuscate);
|
|
43
|
-
};
|
|
44
|
-
const identity = _ref2 => {
|
|
45
|
-
let {
|
|
46
|
-
request
|
|
47
|
-
} = _ref2;
|
|
48
|
-
return request;
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Creates an interceptor to log the requests.
|
|
53
|
-
*
|
|
54
|
-
* @param identifier - The request identifier
|
|
55
|
-
* @param obfuscate - The obfuscation interceptor
|
|
56
|
-
* @returns The interceptor
|
|
57
|
-
*
|
|
58
|
-
* @internal
|
|
59
|
-
*/
|
|
60
|
-
const logRequest = function (identifier, obfuscate) {
|
|
61
|
-
if (obfuscate === void 0) {
|
|
62
|
-
obfuscate = identity;
|
|
63
|
-
}
|
|
64
|
-
return async _ref3 => {
|
|
65
|
-
let {
|
|
66
|
-
request
|
|
67
|
-
} = _ref3;
|
|
68
|
-
if (shouldLog(LevelResolver[getLogger().logLevel], 'debug')) {
|
|
69
|
-
getLogger().debug(`--------------- Scaleway SDK REQUEST ${identifier} ---------------
|
|
70
|
-
${await dumpRequest(await obfuscate({
|
|
71
|
-
request
|
|
72
|
-
}))}
|
|
73
|
-
---------------------------------------------------------`);
|
|
74
|
-
}
|
|
75
|
-
return request;
|
|
76
|
-
};
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Creates an interceptor to log the responses.
|
|
81
|
-
*
|
|
82
|
-
* @param identifier - The request identifier
|
|
83
|
-
* @returns The interceptor
|
|
84
|
-
*
|
|
85
|
-
* @internal
|
|
86
|
-
*/
|
|
87
|
-
const logResponse = identifier => async _ref4 => {
|
|
88
|
-
let {
|
|
89
|
-
response
|
|
90
|
-
} = _ref4;
|
|
91
|
-
if (shouldLog(LevelResolver[getLogger().logLevel], 'debug')) {
|
|
92
|
-
getLogger().debug(`--------------- Scaleway SDK RESPONSE ${identifier} ---------------
|
|
93
|
-
${await dumpResponse(response)}
|
|
94
|
-
---------------------------------------------------------`);
|
|
95
|
-
}
|
|
96
|
-
return response;
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
export { logRequest, logResponse, obfuscateInterceptor };
|