@scaleway/sdk-std 1.0.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/LICENSE +191 -0
- package/dist/index.gen.cjs +1 -0
- package/dist/index.gen.d.ts +1 -0
- package/dist/index.gen.js +1 -0
- package/dist/types.gen.d.ts +2 -0
- package/node_modules/@scaleway/sdk-client/README.md +36 -0
- package/node_modules/@scaleway/sdk-client/dist/bridge.d.ts +12 -0
- package/node_modules/@scaleway/sdk-client/dist/helpers/is-browser.cjs +4 -0
- package/node_modules/@scaleway/sdk-client/dist/helpers/is-browser.d.ts +1 -0
- package/node_modules/@scaleway/sdk-client/dist/helpers/is-browser.js +4 -0
- package/node_modules/@scaleway/sdk-client/dist/helpers/is-response.cjs +4 -0
- package/node_modules/@scaleway/sdk-client/dist/helpers/is-response.d.ts +8 -0
- package/node_modules/@scaleway/sdk-client/dist/helpers/is-response.js +4 -0
- package/node_modules/@scaleway/sdk-client/dist/helpers/json.cjs +47 -0
- package/node_modules/@scaleway/sdk-client/dist/helpers/json.d.ts +32 -0
- package/node_modules/@scaleway/sdk-client/dist/helpers/json.js +47 -0
- package/node_modules/@scaleway/sdk-client/dist/helpers/marshalling.cjs +76 -0
- package/node_modules/@scaleway/sdk-client/dist/helpers/marshalling.d.ts +60 -0
- package/node_modules/@scaleway/sdk-client/dist/helpers/marshalling.js +76 -0
- package/node_modules/@scaleway/sdk-client/dist/index.cjs +56 -0
- package/node_modules/@scaleway/sdk-client/dist/index.d.ts +16 -0
- package/node_modules/@scaleway/sdk-client/dist/index.js +56 -0
- package/node_modules/@scaleway/sdk-client/dist/internal/async/interval-retrier.cjs +53 -0
- package/node_modules/@scaleway/sdk-client/dist/internal/async/interval-retrier.d.ts +111 -0
- package/node_modules/@scaleway/sdk-client/dist/internal/async/interval-retrier.js +53 -0
- package/node_modules/@scaleway/sdk-client/dist/internal/async/sleep.cjs +6 -0
- package/node_modules/@scaleway/sdk-client/dist/internal/async/sleep.d.ts +9 -0
- package/node_modules/@scaleway/sdk-client/dist/internal/async/sleep.js +6 -0
- package/node_modules/@scaleway/sdk-client/dist/internal/interceptors/composer.cjs +25 -0
- package/node_modules/@scaleway/sdk-client/dist/internal/interceptors/composer.d.ts +25 -0
- package/node_modules/@scaleway/sdk-client/dist/internal/interceptors/composer.js +25 -0
- package/node_modules/@scaleway/sdk-client/dist/internal/interceptors/helpers.cjs +12 -0
- package/node_modules/@scaleway/sdk-client/dist/internal/interceptors/helpers.d.ts +21 -0
- package/node_modules/@scaleway/sdk-client/dist/internal/interceptors/helpers.js +12 -0
- package/node_modules/@scaleway/sdk-client/dist/internal/interceptors/types.d.ts +89 -0
- package/node_modules/@scaleway/sdk-client/dist/internal/logger/console-logger.cjs +24 -0
- package/node_modules/@scaleway/sdk-client/dist/internal/logger/console-logger.d.ts +23 -0
- package/node_modules/@scaleway/sdk-client/dist/internal/logger/console-logger.js +24 -0
- package/node_modules/@scaleway/sdk-client/dist/internal/logger/index.cjs +12 -0
- package/node_modules/@scaleway/sdk-client/dist/internal/logger/index.d.ts +25 -0
- package/node_modules/@scaleway/sdk-client/dist/internal/logger/index.js +12 -0
- package/node_modules/@scaleway/sdk-client/dist/internal/logger/level-resolver.cjs +13 -0
- package/node_modules/@scaleway/sdk-client/dist/internal/logger/level-resolver.d.ts +9 -0
- package/node_modules/@scaleway/sdk-client/dist/internal/logger/level-resolver.js +13 -0
- package/node_modules/@scaleway/sdk-client/dist/internal/logger/logger.d.ts +13 -0
- package/node_modules/@scaleway/sdk-client/dist/internal/validations/string-validation.cjs +30 -0
- package/node_modules/@scaleway/sdk-client/dist/internal/validations/string-validation.d.ts +18 -0
- package/node_modules/@scaleway/sdk-client/dist/internal/validations/string-validation.js +30 -0
- package/node_modules/@scaleway/sdk-client/dist/internals.d.ts +10 -0
- package/node_modules/@scaleway/sdk-client/dist/package.json.cjs +8 -0
- package/node_modules/@scaleway/sdk-client/dist/package.json.js +8 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/api.cjs +8 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/api.d.ts +10 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/api.js +8 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/auth.cjs +25 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/auth.d.ts +70 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/auth.js +25 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/client-ini-factory.cjs +66 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/client-ini-factory.d.ts +111 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/client-ini-factory.js +66 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/client-ini-profile.cjs +23 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/client-ini-profile.d.ts +82 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/client-ini-profile.js +23 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/client-settings.cjs +51 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/client-settings.d.ts +59 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/client-settings.js +51 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/client.cjs +31 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/client.d.ts +71 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/client.js +31 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/constants.cjs +11 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/constants.d.ts +4 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/constants.js +11 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/custom-marshalling.cjs +152 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/custom-marshalling.d.ts +104 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/custom-marshalling.js +152 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/custom-types.cjs +11 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/custom-types.d.ts +74 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/custom-types.js +11 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/error-parser.cjs +76 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/error-parser.d.ts +12 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/error-parser.js +76 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/non-standard/invalid-request-mapper.cjs +36 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/non-standard/invalid-request-mapper.d.ts +12 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/non-standard/invalid-request-mapper.js +36 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/non-standard/unknown-resource-mapper.cjs +23 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/non-standard/unknown-resource-mapper.d.ts +11 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/non-standard/unknown-resource-mapper.js +23 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/scw-error-from-json.d.ts +10 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/scw-error.cjs +43 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/scw-error.d.ts +25 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/scw-error.js +43 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/already-exists-error.cjs +31 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/already-exists-error.d.ts +16 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/already-exists-error.js +31 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/denied-authentication-error.cjs +37 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/denied-authentication-error.d.ts +15 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/denied-authentication-error.js +37 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/index.cjs +28 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/index.d.ts +17 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/index.js +28 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/invalid-arguments-error.cjs +54 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/invalid-arguments-error.d.ts +24 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/invalid-arguments-error.js +54 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/out-of-stock-error.cjs +17 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/out-of-stock-error.d.ts +14 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/out-of-stock-error.js +17 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/permissions-denied-error.cjs +29 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/permissions-denied-error.d.ts +23 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/permissions-denied-error.js +29 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/precondition-failed-error.cjs +32 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/precondition-failed-error.d.ts +15 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/precondition-failed-error.js +32 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/quotas-exceeded-error.cjs +43 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/quotas-exceeded-error.d.ts +34 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/quotas-exceeded-error.js +43 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/resource-expired-error.cjs +31 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/resource-expired-error.d.ts +16 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/resource-expired-error.js +31 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/resource-locked-error.cjs +20 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/resource-locked-error.d.ts +15 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/resource-locked-error.js +20 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/resource-not-found-error.cjs +24 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/resource-not-found-error.d.ts +15 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/resource-not-found-error.js +24 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/too-many-requests-error.cjs +58 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/too-many-requests-error.d.ts +32 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/too-many-requests-error.js +58 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/transient-state-error.cjs +31 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/transient-state-error.d.ts +16 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/transient-state-error.js +31 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/types.cjs +15 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/types.d.ts +9 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/errors/types.js +15 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/fetch/build-fetcher.cjs +60 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/fetch/build-fetcher.d.ts +23 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/fetch/build-fetcher.js +60 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/fetch/http-dumper.cjs +20 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/fetch/http-dumper.d.ts +18 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/fetch/http-dumper.js +20 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/fetch/http-interceptors.cjs +43 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/fetch/http-interceptors.d.ts +38 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/fetch/http-interceptors.js +43 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/fetch/resource-paginator.cjs +36 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/fetch/resource-paginator.d.ts +47 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/fetch/resource-paginator.js +36 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/fetch/response-parser.cjs +55 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/fetch/response-parser.d.ts +25 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/fetch/response-parser.js +55 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/fetch/types.d.ts +16 -0
- package/node_modules/@scaleway/sdk-client/dist/scw/locality.d.ts +2 -0
- package/node_modules/@scaleway/sdk-client/dist/vendor/base64/index.cjs +46 -0
- package/node_modules/@scaleway/sdk-client/dist/vendor/base64/index.js +46 -0
- package/node_modules/@scaleway/sdk-client/package.json +36 -0
- package/package.json +41 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { isJSONObject } from "../../helpers/json.js";
|
|
2
|
+
import { isRecordOfStringArray } from "./types.js";
|
|
3
|
+
const buildDefaultMessage = (status, body) => {
|
|
4
|
+
const message = [`http error ${status}`];
|
|
5
|
+
if (typeof body === "string") {
|
|
6
|
+
message.push(body);
|
|
7
|
+
} else if (isJSONObject(body)) {
|
|
8
|
+
if (typeof body.resource === "string") {
|
|
9
|
+
message.push(`resource ${body.resource}`);
|
|
10
|
+
}
|
|
11
|
+
if (typeof body.message === "string") {
|
|
12
|
+
message.push(body.message);
|
|
13
|
+
}
|
|
14
|
+
if (body.fields && isRecordOfStringArray(body.fields)) {
|
|
15
|
+
message.push(
|
|
16
|
+
Object.entries(body.fields).map(([name, list]) => `${name} (${list.join(", ")})`).join(", ")
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return message.join(": ");
|
|
21
|
+
};
|
|
22
|
+
class ScalewayError extends Error {
|
|
23
|
+
constructor(status, body, message = buildDefaultMessage(status, body)) {
|
|
24
|
+
super(message);
|
|
25
|
+
this.status = status;
|
|
26
|
+
this.body = body;
|
|
27
|
+
this.message = message;
|
|
28
|
+
this.name = "ScalewayError";
|
|
29
|
+
this.rawMessage = typeof body === "object" && typeof body.message === "string" ? body.message : void 0;
|
|
30
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
31
|
+
}
|
|
32
|
+
/** The message originating from the payload. */
|
|
33
|
+
rawMessage;
|
|
34
|
+
static fromJSON(status, obj) {
|
|
35
|
+
return new ScalewayError(status, obj);
|
|
36
|
+
}
|
|
37
|
+
toString() {
|
|
38
|
+
return `${this.name}: ${this.message}`;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
export {
|
|
42
|
+
ScalewayError
|
|
43
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const scwError = require("../scw-error.cjs");
|
|
4
|
+
class AlreadyExistsError extends scwError.ScalewayError {
|
|
5
|
+
constructor(status, body, resource, resourceId, helpMessage) {
|
|
6
|
+
super(
|
|
7
|
+
status,
|
|
8
|
+
body,
|
|
9
|
+
`resource ${resource} with ID ${resourceId} already exists: ${helpMessage}`
|
|
10
|
+
);
|
|
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(
|
|
23
|
+
status,
|
|
24
|
+
obj,
|
|
25
|
+
obj.resource,
|
|
26
|
+
obj.resource_id,
|
|
27
|
+
obj.help_message
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.AlreadyExistsError = AlreadyExistsError;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { JSONObject } from '../../../helpers/json.js';
|
|
2
|
+
import { ScalewayError } from '../scw-error.js';
|
|
3
|
+
/**
|
|
4
|
+
* AlreadyExists error is used when a resource already exists.
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export declare class AlreadyExistsError extends ScalewayError {
|
|
9
|
+
readonly status: number;
|
|
10
|
+
readonly body: JSONObject;
|
|
11
|
+
readonly resource: string;
|
|
12
|
+
readonly resourceId: string;
|
|
13
|
+
readonly helpMessage: string;
|
|
14
|
+
constructor(status: number, body: JSONObject, resource: string, resourceId: string, helpMessage: string);
|
|
15
|
+
static fromJSON(status: number, obj: Readonly<JSONObject>): AlreadyExistsError | null;
|
|
16
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ScalewayError } from "../scw-error.js";
|
|
2
|
+
class AlreadyExistsError extends ScalewayError {
|
|
3
|
+
constructor(status, body, resource, resourceId, helpMessage) {
|
|
4
|
+
super(
|
|
5
|
+
status,
|
|
6
|
+
body,
|
|
7
|
+
`resource ${resource} with ID ${resourceId} already exists: ${helpMessage}`
|
|
8
|
+
);
|
|
9
|
+
this.status = status;
|
|
10
|
+
this.body = body;
|
|
11
|
+
this.resource = resource;
|
|
12
|
+
this.resourceId = resourceId;
|
|
13
|
+
this.helpMessage = helpMessage;
|
|
14
|
+
this.name = "AlreadyExistsError";
|
|
15
|
+
}
|
|
16
|
+
static fromJSON(status, obj) {
|
|
17
|
+
if (typeof obj.resource !== "string" || typeof obj.resource_id !== "string" || typeof obj.help_message !== "string") {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
return new AlreadyExistsError(
|
|
21
|
+
status,
|
|
22
|
+
obj,
|
|
23
|
+
obj.resource,
|
|
24
|
+
obj.resource_id,
|
|
25
|
+
obj.help_message
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
AlreadyExistsError
|
|
31
|
+
};
|
package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/denied-authentication-error.cjs
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const scwError = require("../scw-error.cjs");
|
|
4
|
+
const buildMessage = (method, reason) => {
|
|
5
|
+
let reasonDesc;
|
|
6
|
+
switch (reason) {
|
|
7
|
+
case "invalid_argument":
|
|
8
|
+
reasonDesc = `invalid ${method} format or empty value`;
|
|
9
|
+
break;
|
|
10
|
+
case "not_found":
|
|
11
|
+
reasonDesc = `${method} does not exist`;
|
|
12
|
+
break;
|
|
13
|
+
case "expired":
|
|
14
|
+
reasonDesc = `${method} is expired`;
|
|
15
|
+
break;
|
|
16
|
+
default:
|
|
17
|
+
reasonDesc = `unknown reason for ${method}`;
|
|
18
|
+
}
|
|
19
|
+
return `denied authentication: ${reasonDesc}`;
|
|
20
|
+
};
|
|
21
|
+
class DeniedAuthenticationError extends scwError.ScalewayError {
|
|
22
|
+
constructor(status, body, method, reason) {
|
|
23
|
+
super(status, body, buildMessage(method, reason));
|
|
24
|
+
this.status = status;
|
|
25
|
+
this.body = body;
|
|
26
|
+
this.method = method;
|
|
27
|
+
this.reason = reason;
|
|
28
|
+
this.name = "DeniedAuthenticationError";
|
|
29
|
+
}
|
|
30
|
+
static fromJSON(status, obj) {
|
|
31
|
+
if (typeof obj.method !== "string" || typeof obj.reason !== "string") {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
return new DeniedAuthenticationError(status, obj, obj.method, obj.reason);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.DeniedAuthenticationError = DeniedAuthenticationError;
|
package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/denied-authentication-error.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { JSONObject } from '../../../helpers/json.js';
|
|
2
|
+
import { ScalewayError } from '../scw-error.js';
|
|
3
|
+
/**
|
|
4
|
+
* DeniedAuthentication error is used by the API Gateway auth service to deny a request.
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export declare class DeniedAuthenticationError extends ScalewayError {
|
|
9
|
+
readonly status: number;
|
|
10
|
+
readonly body: JSONObject;
|
|
11
|
+
readonly method: string;
|
|
12
|
+
readonly reason: string;
|
|
13
|
+
constructor(status: number, body: JSONObject, method: string, reason: string);
|
|
14
|
+
static fromJSON(status: number, obj: Readonly<JSONObject>): DeniedAuthenticationError | null;
|
|
15
|
+
}
|
package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/denied-authentication-error.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ScalewayError } from "../scw-error.js";
|
|
2
|
+
const buildMessage = (method, reason) => {
|
|
3
|
+
let reasonDesc;
|
|
4
|
+
switch (reason) {
|
|
5
|
+
case "invalid_argument":
|
|
6
|
+
reasonDesc = `invalid ${method} format or empty value`;
|
|
7
|
+
break;
|
|
8
|
+
case "not_found":
|
|
9
|
+
reasonDesc = `${method} does not exist`;
|
|
10
|
+
break;
|
|
11
|
+
case "expired":
|
|
12
|
+
reasonDesc = `${method} is expired`;
|
|
13
|
+
break;
|
|
14
|
+
default:
|
|
15
|
+
reasonDesc = `unknown reason for ${method}`;
|
|
16
|
+
}
|
|
17
|
+
return `denied authentication: ${reasonDesc}`;
|
|
18
|
+
};
|
|
19
|
+
class DeniedAuthenticationError extends ScalewayError {
|
|
20
|
+
constructor(status, body, method, reason) {
|
|
21
|
+
super(status, body, buildMessage(method, reason));
|
|
22
|
+
this.status = status;
|
|
23
|
+
this.body = body;
|
|
24
|
+
this.method = method;
|
|
25
|
+
this.reason = reason;
|
|
26
|
+
this.name = "DeniedAuthenticationError";
|
|
27
|
+
}
|
|
28
|
+
static fromJSON(status, obj) {
|
|
29
|
+
if (typeof obj.method !== "string" || typeof obj.reason !== "string") {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
return new DeniedAuthenticationError(status, obj, obj.method, obj.reason);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export {
|
|
36
|
+
DeniedAuthenticationError
|
|
37
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const scwError = require("../scw-error.cjs");
|
|
4
|
+
const alreadyExistsError = require("./already-exists-error.cjs");
|
|
5
|
+
const deniedAuthenticationError = require("./denied-authentication-error.cjs");
|
|
6
|
+
const invalidArgumentsError = require("./invalid-arguments-error.cjs");
|
|
7
|
+
const outOfStockError = require("./out-of-stock-error.cjs");
|
|
8
|
+
const permissionsDeniedError = require("./permissions-denied-error.cjs");
|
|
9
|
+
const preconditionFailedError = require("./precondition-failed-error.cjs");
|
|
10
|
+
const quotasExceededError = require("./quotas-exceeded-error.cjs");
|
|
11
|
+
const resourceExpiredError = require("./resource-expired-error.cjs");
|
|
12
|
+
const resourceLockedError = require("./resource-locked-error.cjs");
|
|
13
|
+
const resourceNotFoundError = require("./resource-not-found-error.cjs");
|
|
14
|
+
const tooManyRequestsError = require("./too-many-requests-error.cjs");
|
|
15
|
+
const transientStateError = require("./transient-state-error.cjs");
|
|
16
|
+
exports.ScalewayError = scwError.ScalewayError;
|
|
17
|
+
exports.AlreadyExistsError = alreadyExistsError.AlreadyExistsError;
|
|
18
|
+
exports.DeniedAuthenticationError = deniedAuthenticationError.DeniedAuthenticationError;
|
|
19
|
+
exports.InvalidArgumentsError = invalidArgumentsError.InvalidArgumentsError;
|
|
20
|
+
exports.OutOfStockError = outOfStockError.OutOfStockError;
|
|
21
|
+
exports.PermissionsDeniedError = permissionsDeniedError.PermissionsDeniedError;
|
|
22
|
+
exports.PreconditionFailedError = preconditionFailedError.PreconditionFailedError;
|
|
23
|
+
exports.QuotasExceededError = quotasExceededError.QuotasExceededError;
|
|
24
|
+
exports.ResourceExpiredError = resourceExpiredError.ResourceExpiredError;
|
|
25
|
+
exports.ResourceLockedError = resourceLockedError.ResourceLockedError;
|
|
26
|
+
exports.ResourceNotFoundError = resourceNotFoundError.ResourceNotFoundError;
|
|
27
|
+
exports.TooManyRequestsError = tooManyRequestsError.TooManyRequestsError;
|
|
28
|
+
exports.TransientStateError = transientStateError.TransientStateError;
|
|
@@ -0,0 +1,17 @@
|
|
|
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 type { InvalidArgumentsErrorDetails } from './invalid-arguments-error.js';
|
|
6
|
+
export { OutOfStockError } from './out-of-stock-error.js';
|
|
7
|
+
export { PermissionsDeniedError } from './permissions-denied-error.js';
|
|
8
|
+
export type { PermissionsDeniedErrorDetails } from './permissions-denied-error.js';
|
|
9
|
+
export { PreconditionFailedError } from './precondition-failed-error.js';
|
|
10
|
+
export { QuotasExceededError } from './quotas-exceeded-error.js';
|
|
11
|
+
export type { QuotasExceededErrorDetails, QuotasExceededErrorScope, } from './quotas-exceeded-error.js';
|
|
12
|
+
export { ResourceExpiredError } from './resource-expired-error.js';
|
|
13
|
+
export { ResourceLockedError } from './resource-locked-error.js';
|
|
14
|
+
export { ResourceNotFoundError } from './resource-not-found-error.js';
|
|
15
|
+
export { TooManyRequestsError } from './too-many-requests-error.js';
|
|
16
|
+
export type { TooManyRequestsQuotaPolicy } from './too-many-requests-error.js';
|
|
17
|
+
export { TransientStateError } from './transient-state-error.js';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ScalewayError } from "../scw-error.js";
|
|
2
|
+
import { AlreadyExistsError } from "./already-exists-error.js";
|
|
3
|
+
import { DeniedAuthenticationError } from "./denied-authentication-error.js";
|
|
4
|
+
import { InvalidArgumentsError } from "./invalid-arguments-error.js";
|
|
5
|
+
import { OutOfStockError } from "./out-of-stock-error.js";
|
|
6
|
+
import { PermissionsDeniedError } from "./permissions-denied-error.js";
|
|
7
|
+
import { PreconditionFailedError } from "./precondition-failed-error.js";
|
|
8
|
+
import { QuotasExceededError } from "./quotas-exceeded-error.js";
|
|
9
|
+
import { ResourceExpiredError } from "./resource-expired-error.js";
|
|
10
|
+
import { ResourceLockedError } from "./resource-locked-error.js";
|
|
11
|
+
import { ResourceNotFoundError } from "./resource-not-found-error.js";
|
|
12
|
+
import { TooManyRequestsError } from "./too-many-requests-error.js";
|
|
13
|
+
import { TransientStateError } from "./transient-state-error.js";
|
|
14
|
+
export {
|
|
15
|
+
AlreadyExistsError,
|
|
16
|
+
DeniedAuthenticationError,
|
|
17
|
+
InvalidArgumentsError,
|
|
18
|
+
OutOfStockError,
|
|
19
|
+
PermissionsDeniedError,
|
|
20
|
+
PreconditionFailedError,
|
|
21
|
+
QuotasExceededError,
|
|
22
|
+
ResourceExpiredError,
|
|
23
|
+
ResourceLockedError,
|
|
24
|
+
ResourceNotFoundError,
|
|
25
|
+
ScalewayError,
|
|
26
|
+
TooManyRequestsError,
|
|
27
|
+
TransientStateError
|
|
28
|
+
};
|
package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/invalid-arguments-error.cjs
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const json = require("../../../helpers/json.cjs");
|
|
4
|
+
const scwError = require("../scw-error.cjs");
|
|
5
|
+
const buildMessage = (list) => {
|
|
6
|
+
const invalidArgs = list.reduce((acc, details) => {
|
|
7
|
+
let readableReason = "";
|
|
8
|
+
switch (details.reason) {
|
|
9
|
+
case "required":
|
|
10
|
+
readableReason = `is required`;
|
|
11
|
+
break;
|
|
12
|
+
case "format":
|
|
13
|
+
readableReason = `is wrongly formatted`;
|
|
14
|
+
break;
|
|
15
|
+
case "constraint":
|
|
16
|
+
readableReason = `does not respect constraint`;
|
|
17
|
+
break;
|
|
18
|
+
default:
|
|
19
|
+
readableReason = `is invalid for unexpected reason`;
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
if (details.helpMessage && details.helpMessage.length > 0) {
|
|
23
|
+
readableReason = readableReason.concat(`, `, details.helpMessage);
|
|
24
|
+
}
|
|
25
|
+
acc.push(`${details.argumentName} ${readableReason}`);
|
|
26
|
+
return acc;
|
|
27
|
+
}, []);
|
|
28
|
+
return `invalid argument(s): ${invalidArgs.join("; ")}`;
|
|
29
|
+
};
|
|
30
|
+
class InvalidArgumentsError extends scwError.ScalewayError {
|
|
31
|
+
constructor(status, body, details) {
|
|
32
|
+
super(status, body, buildMessage(details));
|
|
33
|
+
this.status = status;
|
|
34
|
+
this.body = body;
|
|
35
|
+
this.details = details;
|
|
36
|
+
this.name = "InvalidArgumentsError";
|
|
37
|
+
}
|
|
38
|
+
static fromJSON(status, obj) {
|
|
39
|
+
if (!Array.isArray(obj.details)) return null;
|
|
40
|
+
return new InvalidArgumentsError(
|
|
41
|
+
status,
|
|
42
|
+
obj,
|
|
43
|
+
obj.details.reduce(
|
|
44
|
+
(list, detail) => json.isJSONObject(detail) && typeof detail.argument_name === "string" && typeof detail.reason === "string" ? list.concat({
|
|
45
|
+
argumentName: detail.argument_name,
|
|
46
|
+
helpMessage: typeof detail.help_message === "string" ? detail.help_message : void 0,
|
|
47
|
+
reason: detail.reason
|
|
48
|
+
}) : list,
|
|
49
|
+
[]
|
|
50
|
+
)
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.InvalidArgumentsError = InvalidArgumentsError;
|
package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/invalid-arguments-error.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { JSONObject } from '../../../helpers/json.js';
|
|
2
|
+
import { ScalewayError } from '../scw-error.js';
|
|
3
|
+
/**
|
|
4
|
+
* Details of an {@link InvalidArgumentsError} error.
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export interface InvalidArgumentsErrorDetails {
|
|
9
|
+
readonly argumentName: string;
|
|
10
|
+
readonly reason: string;
|
|
11
|
+
readonly helpMessage?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* InvalidArguments error happens when one or many fields are invalid in the request message.
|
|
15
|
+
*
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
export declare class InvalidArgumentsError extends ScalewayError {
|
|
19
|
+
readonly status: number;
|
|
20
|
+
readonly body: JSONObject;
|
|
21
|
+
readonly details: InvalidArgumentsErrorDetails[];
|
|
22
|
+
constructor(status: number, body: JSONObject, details: InvalidArgumentsErrorDetails[]);
|
|
23
|
+
static fromJSON(status: number, obj: Readonly<JSONObject>): InvalidArgumentsError | null;
|
|
24
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { isJSONObject } from "../../../helpers/json.js";
|
|
2
|
+
import { ScalewayError } from "../scw-error.js";
|
|
3
|
+
const buildMessage = (list) => {
|
|
4
|
+
const invalidArgs = list.reduce((acc, details) => {
|
|
5
|
+
let readableReason = "";
|
|
6
|
+
switch (details.reason) {
|
|
7
|
+
case "required":
|
|
8
|
+
readableReason = `is required`;
|
|
9
|
+
break;
|
|
10
|
+
case "format":
|
|
11
|
+
readableReason = `is wrongly formatted`;
|
|
12
|
+
break;
|
|
13
|
+
case "constraint":
|
|
14
|
+
readableReason = `does not respect constraint`;
|
|
15
|
+
break;
|
|
16
|
+
default:
|
|
17
|
+
readableReason = `is invalid for unexpected reason`;
|
|
18
|
+
break;
|
|
19
|
+
}
|
|
20
|
+
if (details.helpMessage && details.helpMessage.length > 0) {
|
|
21
|
+
readableReason = readableReason.concat(`, `, details.helpMessage);
|
|
22
|
+
}
|
|
23
|
+
acc.push(`${details.argumentName} ${readableReason}`);
|
|
24
|
+
return acc;
|
|
25
|
+
}, []);
|
|
26
|
+
return `invalid argument(s): ${invalidArgs.join("; ")}`;
|
|
27
|
+
};
|
|
28
|
+
class InvalidArgumentsError extends ScalewayError {
|
|
29
|
+
constructor(status, body, details) {
|
|
30
|
+
super(status, body, buildMessage(details));
|
|
31
|
+
this.status = status;
|
|
32
|
+
this.body = body;
|
|
33
|
+
this.details = details;
|
|
34
|
+
this.name = "InvalidArgumentsError";
|
|
35
|
+
}
|
|
36
|
+
static fromJSON(status, obj) {
|
|
37
|
+
if (!Array.isArray(obj.details)) return null;
|
|
38
|
+
return new InvalidArgumentsError(
|
|
39
|
+
status,
|
|
40
|
+
obj,
|
|
41
|
+
obj.details.reduce(
|
|
42
|
+
(list, detail) => isJSONObject(detail) && typeof detail.argument_name === "string" && typeof detail.reason === "string" ? list.concat({
|
|
43
|
+
argumentName: detail.argument_name,
|
|
44
|
+
helpMessage: typeof detail.help_message === "string" ? detail.help_message : void 0,
|
|
45
|
+
reason: detail.reason
|
|
46
|
+
}) : list,
|
|
47
|
+
[]
|
|
48
|
+
)
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
export {
|
|
53
|
+
InvalidArgumentsError
|
|
54
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const scwError = require("../scw-error.cjs");
|
|
4
|
+
class OutOfStockError extends scwError.ScalewayError {
|
|
5
|
+
constructor(status, body, resource) {
|
|
6
|
+
super(status, body, `resource ${resource} is out of stock`);
|
|
7
|
+
this.status = status;
|
|
8
|
+
this.body = body;
|
|
9
|
+
this.resource = resource;
|
|
10
|
+
this.name = "OutOfStockError";
|
|
11
|
+
}
|
|
12
|
+
static fromJSON(status, obj) {
|
|
13
|
+
if (typeof obj.resource !== "string") return null;
|
|
14
|
+
return new OutOfStockError(status, obj, obj.resource);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.OutOfStockError = OutOfStockError;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { JSONObject } from '../../../helpers/json.js';
|
|
2
|
+
import { ScalewayError } from '../scw-error.js';
|
|
3
|
+
/**
|
|
4
|
+
* OutOfStock error happens when stocks are empty for the resource.
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export declare class OutOfStockError extends ScalewayError {
|
|
9
|
+
readonly status: number;
|
|
10
|
+
readonly body: JSONObject;
|
|
11
|
+
readonly resource: string;
|
|
12
|
+
constructor(status: number, body: JSONObject, resource: string);
|
|
13
|
+
static fromJSON(status: number, obj: Readonly<JSONObject>): OutOfStockError | null;
|
|
14
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ScalewayError } from "../scw-error.js";
|
|
2
|
+
class OutOfStockError extends ScalewayError {
|
|
3
|
+
constructor(status, body, resource) {
|
|
4
|
+
super(status, body, `resource ${resource} is out of stock`);
|
|
5
|
+
this.status = status;
|
|
6
|
+
this.body = body;
|
|
7
|
+
this.resource = resource;
|
|
8
|
+
this.name = "OutOfStockError";
|
|
9
|
+
}
|
|
10
|
+
static fromJSON(status, obj) {
|
|
11
|
+
if (typeof obj.resource !== "string") return null;
|
|
12
|
+
return new OutOfStockError(status, obj, obj.resource);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
OutOfStockError
|
|
17
|
+
};
|
package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/permissions-denied-error.cjs
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const json = require("../../../helpers/json.cjs");
|
|
4
|
+
const scwError = require("../scw-error.cjs");
|
|
5
|
+
const buildMessage = (list) => `insufficient permissions: ${list.map(({ action, resource }) => `${action} ${resource}`).join("; ")}`;
|
|
6
|
+
class PermissionsDeniedError extends scwError.ScalewayError {
|
|
7
|
+
constructor(status, body, list) {
|
|
8
|
+
super(status, body, buildMessage(list));
|
|
9
|
+
this.status = status;
|
|
10
|
+
this.body = body;
|
|
11
|
+
this.list = list;
|
|
12
|
+
this.name = "PermissionsDeniedError";
|
|
13
|
+
}
|
|
14
|
+
static fromJSON(status, obj) {
|
|
15
|
+
if (!Array.isArray(obj.details)) return null;
|
|
16
|
+
return new PermissionsDeniedError(
|
|
17
|
+
status,
|
|
18
|
+
obj,
|
|
19
|
+
obj.details.reduce(
|
|
20
|
+
(list, detail) => json.isJSONObject(detail) && typeof detail.resource === "string" && typeof detail.action === "string" ? list.concat({
|
|
21
|
+
action: detail.action,
|
|
22
|
+
resource: detail.resource
|
|
23
|
+
}) : list,
|
|
24
|
+
[]
|
|
25
|
+
)
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.PermissionsDeniedError = PermissionsDeniedError;
|
package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/permissions-denied-error.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { JSONObject } from '../../../helpers/json.js';
|
|
2
|
+
import { ScalewayError } from '../scw-error.js';
|
|
3
|
+
/**
|
|
4
|
+
* Details of an {@link PermissionsDeniedError} error.
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export interface PermissionsDeniedErrorDetails {
|
|
9
|
+
readonly resource: string;
|
|
10
|
+
readonly action: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* PermissionsDenied error happens when one or many permissions are not accorded to the user making the request.
|
|
14
|
+
*
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
export declare class PermissionsDeniedError extends ScalewayError {
|
|
18
|
+
readonly status: number;
|
|
19
|
+
readonly body: JSONObject;
|
|
20
|
+
readonly list: PermissionsDeniedErrorDetails[];
|
|
21
|
+
constructor(status: number, body: JSONObject, list: PermissionsDeniedErrorDetails[]);
|
|
22
|
+
static fromJSON(status: number, obj: Readonly<JSONObject>): ScalewayError | null;
|
|
23
|
+
}
|
package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/permissions-denied-error.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { isJSONObject } from "../../../helpers/json.js";
|
|
2
|
+
import { ScalewayError } from "../scw-error.js";
|
|
3
|
+
const buildMessage = (list) => `insufficient permissions: ${list.map(({ action, resource }) => `${action} ${resource}`).join("; ")}`;
|
|
4
|
+
class PermissionsDeniedError extends ScalewayError {
|
|
5
|
+
constructor(status, body, list) {
|
|
6
|
+
super(status, body, buildMessage(list));
|
|
7
|
+
this.status = status;
|
|
8
|
+
this.body = body;
|
|
9
|
+
this.list = list;
|
|
10
|
+
this.name = "PermissionsDeniedError";
|
|
11
|
+
}
|
|
12
|
+
static fromJSON(status, obj) {
|
|
13
|
+
if (!Array.isArray(obj.details)) return null;
|
|
14
|
+
return new PermissionsDeniedError(
|
|
15
|
+
status,
|
|
16
|
+
obj,
|
|
17
|
+
obj.details.reduce(
|
|
18
|
+
(list, detail) => isJSONObject(detail) && typeof detail.resource === "string" && typeof detail.action === "string" ? list.concat({
|
|
19
|
+
action: detail.action,
|
|
20
|
+
resource: detail.resource
|
|
21
|
+
}) : list,
|
|
22
|
+
[]
|
|
23
|
+
)
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
PermissionsDeniedError
|
|
29
|
+
};
|
package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/precondition-failed-error.cjs
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const scwError = require("../scw-error.cjs");
|
|
4
|
+
const buildMessage = (precondition, helpMessage) => {
|
|
5
|
+
let message = `precondition failed: ${precondition}`;
|
|
6
|
+
if (typeof helpMessage === "string" && helpMessage.length > 0) {
|
|
7
|
+
message = message.concat(", ", helpMessage);
|
|
8
|
+
}
|
|
9
|
+
return message;
|
|
10
|
+
};
|
|
11
|
+
class PreconditionFailedError extends scwError.ScalewayError {
|
|
12
|
+
constructor(status, body, precondition, helpMessage) {
|
|
13
|
+
super(status, body, buildMessage(precondition, helpMessage));
|
|
14
|
+
this.status = status;
|
|
15
|
+
this.body = body;
|
|
16
|
+
this.precondition = precondition;
|
|
17
|
+
this.helpMessage = helpMessage;
|
|
18
|
+
this.name = "PreconditionFailedError";
|
|
19
|
+
}
|
|
20
|
+
static fromJSON(status, obj) {
|
|
21
|
+
if (typeof obj.precondition !== "string" || typeof obj.help_message !== "string") {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
return new PreconditionFailedError(
|
|
25
|
+
status,
|
|
26
|
+
obj,
|
|
27
|
+
obj.precondition,
|
|
28
|
+
obj.help_message
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.PreconditionFailedError = PreconditionFailedError;
|
package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/precondition-failed-error.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { JSONObject } from '../../../helpers/json.js';
|
|
2
|
+
import { ScalewayError } from '../scw-error.js';
|
|
3
|
+
/**
|
|
4
|
+
* PreconditionFailed error is used when a precondition is not respected.
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export declare class PreconditionFailedError extends ScalewayError {
|
|
9
|
+
readonly status: number;
|
|
10
|
+
readonly body: JSONObject;
|
|
11
|
+
readonly precondition: string;
|
|
12
|
+
readonly helpMessage: string;
|
|
13
|
+
constructor(status: number, body: JSONObject, precondition: string, helpMessage: string);
|
|
14
|
+
static fromJSON(status: number, obj: Readonly<JSONObject>): PreconditionFailedError | null;
|
|
15
|
+
}
|
package/node_modules/@scaleway/sdk-client/dist/scw/errors/standard/precondition-failed-error.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ScalewayError } from "../scw-error.js";
|
|
2
|
+
const buildMessage = (precondition, helpMessage) => {
|
|
3
|
+
let message = `precondition failed: ${precondition}`;
|
|
4
|
+
if (typeof helpMessage === "string" && helpMessage.length > 0) {
|
|
5
|
+
message = message.concat(", ", helpMessage);
|
|
6
|
+
}
|
|
7
|
+
return message;
|
|
8
|
+
};
|
|
9
|
+
class PreconditionFailedError extends ScalewayError {
|
|
10
|
+
constructor(status, body, precondition, helpMessage) {
|
|
11
|
+
super(status, body, buildMessage(precondition, helpMessage));
|
|
12
|
+
this.status = status;
|
|
13
|
+
this.body = body;
|
|
14
|
+
this.precondition = precondition;
|
|
15
|
+
this.helpMessage = helpMessage;
|
|
16
|
+
this.name = "PreconditionFailedError";
|
|
17
|
+
}
|
|
18
|
+
static fromJSON(status, obj) {
|
|
19
|
+
if (typeof obj.precondition !== "string" || typeof obj.help_message !== "string") {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
return new PreconditionFailedError(
|
|
23
|
+
status,
|
|
24
|
+
obj,
|
|
25
|
+
obj.precondition,
|
|
26
|
+
obj.help_message
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export {
|
|
31
|
+
PreconditionFailedError
|
|
32
|
+
};
|