@planqk/planqk-service-sdk 1.9.1 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.devcontainer/devcontainer.json +32 -0
- package/.devcontainer/post-create.sh +7 -0
- package/.env.template +4 -0
- package/.gitlab-ci.yml +103 -0
- package/.python-version +1 -0
- package/.releaserc.json +45 -0
- package/LICENSE +201 -0
- package/README-node.md +41 -0
- package/README-python.md +52 -0
- package/README.md +42 -21
- package/dist/auth.js +12 -19
- package/dist/client.d.ts +2 -12
- package/dist/client.js +5 -76
- package/dist/sdk/Client.d.ts +4 -3
- package/dist/sdk/Client.js +4 -8
- package/dist/sdk/api/errors/BadRequestError.d.ts +1 -1
- package/dist/sdk/api/errors/BadRequestError.js +18 -8
- package/dist/sdk/api/errors/ForbiddenError.d.ts +1 -1
- package/dist/sdk/api/errors/ForbiddenError.js +18 -8
- package/dist/sdk/api/errors/InternalServerError.d.ts +1 -1
- package/dist/sdk/api/errors/InternalServerError.js +18 -8
- package/dist/sdk/api/errors/NotFoundError.d.ts +1 -1
- package/dist/sdk/api/errors/NotFoundError.js +18 -8
- package/dist/sdk/api/errors/UnauthorizedError.d.ts +1 -1
- package/dist/sdk/api/errors/UnauthorizedError.js +18 -8
- package/dist/sdk/api/resources/index.d.ts +0 -3
- package/dist/sdk/api/resources/index.js +18 -11
- package/dist/sdk/api/resources/serviceApi/client/Client.d.ts +65 -12
- package/dist/sdk/api/resources/serviceApi/client/Client.js +405 -261
- package/dist/sdk/api/resources/serviceApi/client/index.d.ts +1 -1
- package/dist/sdk/api/resources/serviceApi/client/index.js +0 -15
- package/dist/sdk/api/resources/serviceApi/types/GetResultResponse.d.ts +4 -1
- package/dist/sdk/api/resources/serviceApi/types/{GetInterimResultsResponse.d.ts → GetResultResponseEmbedded.d.ts} +3 -1
- package/dist/sdk/api/resources/serviceApi/types/GetResultResponseLinks.d.ts +7 -0
- package/dist/sdk/api/resources/{statusApi → serviceApi}/types/HealthCheckResponse.d.ts +1 -0
- package/dist/sdk/api/resources/serviceApi/types/index.d.ts +3 -1
- package/dist/sdk/api/resources/serviceApi/types/index.js +3 -1
- package/dist/sdk/api/types/HalLink.d.ts +21 -0
- package/dist/sdk/api/types/InputData.d.ts +1 -1
- package/dist/sdk/api/types/{InputRef.d.ts → InputDataRef.d.ts} +1 -1
- package/dist/sdk/api/types/InputParams.d.ts +1 -1
- package/dist/sdk/api/types/{Job.d.ts → ServiceExecution.d.ts} +2 -2
- package/dist/sdk/api/types/{JobStatus.d.ts → ServiceExecutionStatus.d.ts} +2 -2
- package/dist/sdk/api/types/{JobStatus.js → ServiceExecutionStatus.js} +2 -2
- package/dist/sdk/api/types/index.d.ts +4 -8
- package/dist/sdk/api/types/index.js +4 -8
- package/dist/sdk/core/fetcher/APIResponse.d.ts +1 -0
- package/dist/sdk/core/fetcher/Fetcher.d.ts +6 -5
- package/dist/sdk/core/fetcher/Fetcher.js +68 -112
- package/dist/sdk/core/fetcher/Supplier.js +2 -11
- package/dist/sdk/core/fetcher/createRequestUrl.d.ts +1 -0
- package/dist/sdk/core/fetcher/createRequestUrl.js +12 -0
- package/dist/sdk/core/fetcher/getFetchFn.d.ts +4 -0
- package/dist/sdk/core/fetcher/getFetchFn.js +57 -0
- package/dist/sdk/core/fetcher/getHeader.d.ts +1 -0
- package/dist/sdk/core/fetcher/getHeader.js +11 -0
- package/dist/sdk/core/fetcher/getRequestBody.d.ts +7 -0
- package/dist/sdk/core/fetcher/getRequestBody.js +11 -0
- package/dist/sdk/core/fetcher/getResponseBody.d.ts +1 -0
- package/dist/sdk/core/fetcher/getResponseBody.js +40 -0
- package/dist/sdk/core/fetcher/index.d.ts +1 -0
- package/dist/sdk/core/fetcher/index.js +3 -1
- package/dist/sdk/core/fetcher/makeRequest.d.ts +1 -0
- package/dist/sdk/core/fetcher/makeRequest.js +33 -0
- package/dist/sdk/core/fetcher/requestWithRetries.d.ts +1 -0
- package/dist/sdk/core/fetcher/requestWithRetries.js +20 -0
- package/dist/sdk/core/fetcher/signals.d.ts +11 -0
- package/dist/sdk/core/fetcher/signals.js +36 -0
- package/dist/sdk/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.d.ts +30 -0
- package/dist/sdk/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.js +232 -0
- package/dist/sdk/core/fetcher/stream-wrappers/NodePre18StreamWrapper.d.ts +21 -0
- package/dist/sdk/core/fetcher/stream-wrappers/NodePre18StreamWrapper.js +91 -0
- package/dist/sdk/core/fetcher/stream-wrappers/UndiciStreamWrapper.d.ts +31 -0
- package/dist/sdk/core/fetcher/stream-wrappers/UndiciStreamWrapper.js +214 -0
- package/dist/sdk/core/fetcher/stream-wrappers/chooseStreamWrapper.d.ts +18 -0
- package/dist/sdk/core/fetcher/stream-wrappers/chooseStreamWrapper.js +48 -0
- package/dist/sdk/core/index.d.ts +1 -0
- package/dist/sdk/core/index.js +1 -0
- package/dist/sdk/core/runtime/index.d.ts +1 -0
- package/dist/sdk/core/runtime/index.js +5 -0
- package/dist/sdk/core/runtime/runtime.d.ts +9 -0
- package/dist/sdk/core/runtime/runtime.js +92 -0
- package/dist/sdk/errors/PlanqkServiceApiError.js +2 -0
- package/dist/sdk/index.js +17 -7
- package/eslint.config.mjs +11 -0
- package/fern/fern.config.json +4 -0
- package/fern/generators.yml +25 -0
- package/fern/openapi/openapi.yml +342 -0
- package/notebooks/python-sdk.ipynb +280 -0
- package/package.json +27 -28
- package/planqk/__init__.py +0 -0
- package/planqk/service/__init__.py +1 -0
- package/planqk/service/_version.py +1 -0
- package/planqk/service/auth.py +30 -0
- package/planqk/service/client.py +151 -0
- package/planqk/service/sdk/__init__.py +48 -0
- package/planqk/service/sdk/client.py +152 -0
- package/planqk/service/sdk/core/__init__.py +47 -0
- package/planqk/service/sdk/core/api_error.py +17 -0
- package/planqk/service/sdk/core/client_wrapper.py +74 -0
- package/planqk/service/sdk/core/datetime_utils.py +30 -0
- package/planqk/service/sdk/core/file.py +70 -0
- package/planqk/service/sdk/core/http_client.py +575 -0
- package/planqk/service/sdk/core/jsonable_encoder.py +103 -0
- package/planqk/service/sdk/core/pydantic_utilities.py +323 -0
- package/planqk/service/sdk/core/query_encoder.py +60 -0
- package/planqk/service/sdk/core/remove_none_from_dict.py +11 -0
- package/planqk/service/sdk/core/request_options.py +35 -0
- package/planqk/service/sdk/core/serialization.py +276 -0
- package/planqk/service/sdk/environment.py +7 -0
- package/planqk/service/sdk/errors/__init__.py +15 -0
- package/planqk/service/sdk/errors/bad_request_error.py +9 -0
- package/planqk/service/sdk/errors/forbidden_error.py +9 -0
- package/planqk/service/sdk/errors/internal_server_error.py +9 -0
- package/planqk/service/sdk/errors/not_found_error.py +9 -0
- package/planqk/service/sdk/errors/unauthorized_error.py +9 -0
- package/planqk/service/sdk/service_api/__init__.py +15 -0
- package/planqk/service/sdk/service_api/client.py +1257 -0
- package/planqk/service/sdk/service_api/types/__init__.py +13 -0
- package/planqk/service/sdk/service_api/types/get_result_response.py +30 -0
- package/planqk/service/sdk/service_api/types/get_result_response_embedded.py +22 -0
- package/planqk/service/sdk/service_api/types/get_result_response_links.py +22 -0
- package/planqk/service/sdk/service_api/types/health_check_response.py +24 -0
- package/planqk/service/sdk/types/__init__.py +17 -0
- package/planqk/service/sdk/types/hal_link.py +59 -0
- package/planqk/service/sdk/types/input_data.py +5 -0
- package/planqk/service/sdk/types/input_data_ref.py +27 -0
- package/planqk/service/sdk/types/input_params.py +5 -0
- package/planqk/service/sdk/types/service_execution.py +34 -0
- package/planqk/service/sdk/types/service_execution_status.py +8 -0
- package/pyproject.toml +51 -0
- package/scripts/update-version.sh +6 -0
- package/src/client.ts +4 -78
- package/src/index.test.ts +43 -0
- package/src/sdk/Client.ts +4 -7
- package/src/sdk/api/errors/BadRequestError.ts +1 -1
- package/src/sdk/api/errors/ForbiddenError.ts +1 -1
- package/src/sdk/api/errors/InternalServerError.ts +1 -1
- package/src/sdk/api/errors/NotFoundError.ts +1 -1
- package/src/sdk/api/errors/UnauthorizedError.ts +1 -1
- package/src/sdk/api/resources/index.ts +0 -3
- package/src/sdk/api/resources/serviceApi/client/Client.ts +205 -32
- package/src/sdk/api/resources/serviceApi/client/index.ts +1 -1
- package/src/sdk/api/resources/serviceApi/types/GetResultResponse.ts +4 -5
- package/src/sdk/api/resources/serviceApi/types/GetResultResponseEmbedded.ts +9 -0
- package/src/sdk/api/resources/serviceApi/types/GetResultResponseLinks.ts +9 -0
- package/src/sdk/api/resources/{statusApi → serviceApi}/types/HealthCheckResponse.ts +1 -0
- package/src/sdk/api/resources/serviceApi/types/index.ts +3 -1
- package/src/sdk/api/types/HalLink.ts +22 -0
- package/src/sdk/api/types/InputData.ts +1 -1
- package/src/sdk/api/types/{InputRef.ts → InputDataRef.ts} +1 -1
- package/src/sdk/api/types/InputParams.ts +1 -1
- package/src/sdk/api/types/{Job.ts → ServiceExecution.ts} +2 -2
- package/src/sdk/api/types/{JobStatus.ts → ServiceExecutionStatus.ts} +2 -2
- package/src/sdk/api/types/index.ts +4 -8
- package/src/sdk/core/fetcher/APIResponse.ts +1 -0
- package/src/sdk/core/fetcher/Fetcher.ts +55 -72
- package/src/sdk/core/fetcher/createRequestUrl.ts +10 -0
- package/src/sdk/core/fetcher/getFetchFn.ts +25 -0
- package/src/sdk/core/fetcher/getHeader.ts +8 -0
- package/src/sdk/core/fetcher/getRequestBody.ts +14 -0
- package/src/sdk/core/fetcher/getResponseBody.ts +32 -0
- package/src/sdk/core/fetcher/index.ts +1 -0
- package/src/sdk/core/fetcher/makeRequest.ts +44 -0
- package/src/sdk/core/fetcher/requestWithRetries.ts +21 -0
- package/src/sdk/core/fetcher/signals.ts +38 -0
- package/src/sdk/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.ts +252 -0
- package/src/sdk/core/fetcher/stream-wrappers/NodePre18StreamWrapper.ts +106 -0
- package/src/sdk/core/fetcher/stream-wrappers/UndiciStreamWrapper.ts +239 -0
- package/src/sdk/core/fetcher/stream-wrappers/chooseStreamWrapper.ts +33 -0
- package/src/sdk/core/index.ts +1 -0
- package/src/sdk/core/runtime/index.ts +1 -0
- package/src/sdk/core/runtime/runtime.ts +126 -0
- package/tsconfig.json +15 -107
- package/uv.lock +1109 -0
- package/.eslintignore +0 -3
- package/.eslintrc +0 -7
- package/dist/sdk/api/resources/serviceApi/client/requests/GetInterimResultsRequest.d.ts +0 -9
- package/dist/sdk/api/resources/serviceApi/client/requests/StartExecutionRequest.d.ts +0 -13
- package/dist/sdk/api/resources/serviceApi/client/requests/index.d.ts +0 -2
- package/dist/sdk/api/resources/serviceApi/client/requests/index.js +0 -2
- package/dist/sdk/api/resources/statusApi/client/Client.d.ts +0 -28
- package/dist/sdk/api/resources/statusApi/client/Client.js +0 -97
- package/dist/sdk/api/resources/statusApi/client/index.d.ts +0 -1
- package/dist/sdk/api/resources/statusApi/client/index.js +0 -2
- package/dist/sdk/api/resources/statusApi/index.d.ts +0 -2
- package/dist/sdk/api/resources/statusApi/index.js +0 -18
- package/dist/sdk/api/resources/statusApi/types/index.d.ts +0 -1
- package/dist/sdk/api/resources/statusApi/types/index.js +0 -17
- package/dist/sdk/api/types/ArrayResponse.d.ts +0 -4
- package/dist/sdk/api/types/InterimResultResponse.d.ts +0 -4
- package/dist/sdk/api/types/InterimResultResponse.js +0 -5
- package/dist/sdk/api/types/Job.js +0 -5
- package/dist/sdk/api/types/NumberResponse.d.ts +0 -4
- package/dist/sdk/api/types/NumberResponse.js +0 -5
- package/dist/sdk/api/types/ObjectResponse.d.ts +0 -4
- package/dist/sdk/api/types/ObjectResponse.js +0 -5
- package/dist/sdk/api/types/StringResponse.d.ts +0 -4
- package/dist/sdk/api/types/StringResponse.js +0 -5
- package/jest.config.js +0 -12
- package/src/sdk/api/resources/serviceApi/client/requests/GetInterimResultsRequest.ts +0 -10
- package/src/sdk/api/resources/serviceApi/client/requests/StartExecutionRequest.ts +0 -15
- package/src/sdk/api/resources/serviceApi/client/requests/index.ts +0 -2
- package/src/sdk/api/resources/serviceApi/types/GetInterimResultsResponse.ts +0 -9
- package/src/sdk/api/resources/statusApi/client/Client.ts +0 -75
- package/src/sdk/api/resources/statusApi/client/index.ts +0 -1
- package/src/sdk/api/resources/statusApi/index.ts +0 -2
- package/src/sdk/api/resources/statusApi/types/index.ts +0 -1
- package/src/sdk/api/types/ArrayResponse.ts +0 -5
- package/src/sdk/api/types/InterimResultResponse.ts +0 -5
- package/src/sdk/api/types/NumberResponse.ts +0 -5
- package/src/sdk/api/types/ObjectResponse.ts +0 -5
- package/src/sdk/api/types/StringResponse.ts +0 -5
- package/tests/fixtures/complex-input.ts +0 -477
- package/tests/integration.test.ts +0 -92
- /package/dist/sdk/api/resources/serviceApi/{client/requests/GetInterimResultsRequest.js → types/GetResultResponseEmbedded.js} +0 -0
- /package/dist/sdk/api/resources/serviceApi/{client/requests/StartExecutionRequest.js → types/GetResultResponseLinks.js} +0 -0
- /package/dist/sdk/api/resources/{statusApi → serviceApi}/types/HealthCheckResponse.js +0 -0
- /package/dist/sdk/api/{resources/serviceApi/types/GetInterimResultsResponse.js → types/HalLink.js} +0 -0
- /package/dist/sdk/api/types/{ArrayResponse.js → InputDataRef.js} +0 -0
- /package/dist/sdk/api/types/{InputRef.js → ServiceExecution.js} +0 -0
|
@@ -18,22 +18,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
18
18
|
}) : function(o, v) {
|
|
19
19
|
o["default"] = v;
|
|
20
20
|
});
|
|
21
|
-
var __importStar = (this && this.__importStar) || function (
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
return
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
};
|
|
21
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
+
var ownKeys = function(o) {
|
|
23
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
+
var ar = [];
|
|
25
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
return ownKeys(o);
|
|
29
|
+
};
|
|
30
|
+
return function (mod) {
|
|
31
|
+
if (mod && mod.__esModule) return mod;
|
|
32
|
+
var result = {};
|
|
33
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
+
__setModuleDefault(result, mod);
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
})();
|
|
37
38
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
38
39
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
39
40
|
};
|
|
@@ -42,14 +43,69 @@ exports.ServiceApi = void 0;
|
|
|
42
43
|
const environments = __importStar(require("../../../../environments"));
|
|
43
44
|
const core = __importStar(require("../../../../core"));
|
|
44
45
|
const PlanqkServiceApi = __importStar(require("../../../index"));
|
|
45
|
-
const errors = __importStar(require("../../../../errors"));
|
|
46
|
+
const errors = __importStar(require("../../../../errors/index"));
|
|
46
47
|
const url_join_1 = __importDefault(require("url-join"));
|
|
47
48
|
class ServiceApi {
|
|
49
|
+
_options;
|
|
48
50
|
constructor(_options) {
|
|
49
51
|
this._options = _options;
|
|
50
52
|
}
|
|
51
53
|
/**
|
|
52
|
-
* This method
|
|
54
|
+
* This method checks the health of the service.
|
|
55
|
+
*
|
|
56
|
+
* @param {ServiceApi.RequestOptions} requestOptions - Request-specific configuration.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* await client.serviceApi.healthCheck()
|
|
60
|
+
*/
|
|
61
|
+
async healthCheck(requestOptions) {
|
|
62
|
+
const _response = await core.fetcher({
|
|
63
|
+
url: (await core.Supplier.get(this._options.environment)) ??
|
|
64
|
+
environments.PlanqkServiceApiEnvironment.Default,
|
|
65
|
+
method: "GET",
|
|
66
|
+
headers: {
|
|
67
|
+
Authorization: await this._getAuthorizationHeader(),
|
|
68
|
+
"X-Fern-Language": "JavaScript",
|
|
69
|
+
"X-Fern-Runtime": core.RUNTIME.type,
|
|
70
|
+
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
71
|
+
},
|
|
72
|
+
contentType: "application/json",
|
|
73
|
+
requestType: "json",
|
|
74
|
+
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
75
|
+
maxRetries: requestOptions?.maxRetries,
|
|
76
|
+
withCredentials: true,
|
|
77
|
+
abortSignal: requestOptions?.abortSignal,
|
|
78
|
+
});
|
|
79
|
+
if (_response.ok) {
|
|
80
|
+
return _response.body;
|
|
81
|
+
}
|
|
82
|
+
if (_response.error.reason === "status-code") {
|
|
83
|
+
throw new errors.PlanqkServiceApiError({
|
|
84
|
+
statusCode: _response.error.statusCode,
|
|
85
|
+
body: _response.error.body,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
switch (_response.error.reason) {
|
|
89
|
+
case "non-json":
|
|
90
|
+
throw new errors.PlanqkServiceApiError({
|
|
91
|
+
statusCode: _response.error.statusCode,
|
|
92
|
+
body: _response.error.rawBody,
|
|
93
|
+
});
|
|
94
|
+
case "timeout":
|
|
95
|
+
throw new errors.PlanqkServiceApiTimeoutError();
|
|
96
|
+
case "unknown":
|
|
97
|
+
throw new errors.PlanqkServiceApiError({
|
|
98
|
+
message: _response.error.errorMessage,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* This method starts a service execution, which in turn is processed asynchronously by PLANQK.
|
|
104
|
+
* The location header of the response contains the URL which can be used to query the status and the result of the service execution.
|
|
105
|
+
*
|
|
106
|
+
* @param {Record<string, Record<string, any>>} request
|
|
107
|
+
* @param {ServiceApi.RequestOptions} requestOptions - Request-specific configuration.
|
|
108
|
+
*
|
|
53
109
|
* @throws {@link PlanqkServiceApi.BadRequestError}
|
|
54
110
|
* @throws {@link PlanqkServiceApi.UnauthorizedError}
|
|
55
111
|
* @throws {@link PlanqkServiceApi.ForbiddenError}
|
|
@@ -57,305 +113,393 @@ class ServiceApi {
|
|
|
57
113
|
* @throws {@link PlanqkServiceApi.InternalServerError}
|
|
58
114
|
*
|
|
59
115
|
* @example
|
|
60
|
-
* await
|
|
116
|
+
* await client.serviceApi.execute({
|
|
117
|
+
* "key": {
|
|
118
|
+
* "key": "value"
|
|
119
|
+
* }
|
|
120
|
+
* })
|
|
61
121
|
*/
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
switch (_response.error.reason) {
|
|
101
|
-
case "non-json":
|
|
122
|
+
async execute(request, requestOptions) {
|
|
123
|
+
const _response = await core.fetcher({
|
|
124
|
+
url: (await core.Supplier.get(this._options.environment)) ??
|
|
125
|
+
environments.PlanqkServiceApiEnvironment.Default,
|
|
126
|
+
method: "POST",
|
|
127
|
+
headers: {
|
|
128
|
+
Authorization: await this._getAuthorizationHeader(),
|
|
129
|
+
"X-Fern-Language": "JavaScript",
|
|
130
|
+
"X-Fern-Runtime": core.RUNTIME.type,
|
|
131
|
+
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
132
|
+
},
|
|
133
|
+
contentType: "application/json",
|
|
134
|
+
requestType: "json",
|
|
135
|
+
body: request,
|
|
136
|
+
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
137
|
+
maxRetries: requestOptions?.maxRetries,
|
|
138
|
+
withCredentials: true,
|
|
139
|
+
abortSignal: requestOptions?.abortSignal,
|
|
140
|
+
});
|
|
141
|
+
if (_response.ok) {
|
|
142
|
+
return _response.body;
|
|
143
|
+
}
|
|
144
|
+
if (_response.error.reason === "status-code") {
|
|
145
|
+
switch (_response.error.statusCode) {
|
|
146
|
+
case 400:
|
|
147
|
+
throw new PlanqkServiceApi.BadRequestError(_response.error.body);
|
|
148
|
+
case 401:
|
|
149
|
+
throw new PlanqkServiceApi.UnauthorizedError(_response.error.body);
|
|
150
|
+
case 403:
|
|
151
|
+
throw new PlanqkServiceApi.ForbiddenError(_response.error.body);
|
|
152
|
+
case 404:
|
|
153
|
+
throw new PlanqkServiceApi.NotFoundError(_response.error.body);
|
|
154
|
+
case 500:
|
|
155
|
+
throw new PlanqkServiceApi.InternalServerError(_response.error.body);
|
|
156
|
+
default:
|
|
102
157
|
throw new errors.PlanqkServiceApiError({
|
|
103
158
|
statusCode: _response.error.statusCode,
|
|
104
|
-
body: _response.error.
|
|
105
|
-
});
|
|
106
|
-
case "timeout":
|
|
107
|
-
throw new errors.PlanqkServiceApiTimeoutError();
|
|
108
|
-
case "unknown":
|
|
109
|
-
throw new errors.PlanqkServiceApiError({
|
|
110
|
-
message: _response.error.errorMessage,
|
|
159
|
+
body: _response.error.body,
|
|
111
160
|
});
|
|
112
161
|
}
|
|
113
|
-
}
|
|
162
|
+
}
|
|
163
|
+
switch (_response.error.reason) {
|
|
164
|
+
case "non-json":
|
|
165
|
+
throw new errors.PlanqkServiceApiError({
|
|
166
|
+
statusCode: _response.error.statusCode,
|
|
167
|
+
body: _response.error.rawBody,
|
|
168
|
+
});
|
|
169
|
+
case "timeout":
|
|
170
|
+
throw new errors.PlanqkServiceApiTimeoutError();
|
|
171
|
+
case "unknown":
|
|
172
|
+
throw new errors.PlanqkServiceApiError({
|
|
173
|
+
message: _response.error.errorMessage,
|
|
174
|
+
});
|
|
175
|
+
}
|
|
114
176
|
}
|
|
115
177
|
/**
|
|
116
|
-
*
|
|
178
|
+
* This method checks the status of a service execution.
|
|
179
|
+
*
|
|
180
|
+
* @param {string} id - The id of a service execution
|
|
181
|
+
* @param {ServiceApi.RequestOptions} requestOptions - Request-specific configuration.
|
|
182
|
+
*
|
|
117
183
|
* @throws {@link PlanqkServiceApi.UnauthorizedError}
|
|
118
184
|
* @throws {@link PlanqkServiceApi.ForbiddenError}
|
|
119
185
|
* @throws {@link PlanqkServiceApi.NotFoundError}
|
|
120
186
|
* @throws {@link PlanqkServiceApi.InternalServerError}
|
|
121
187
|
*
|
|
122
188
|
* @example
|
|
123
|
-
* await
|
|
189
|
+
* await client.serviceApi.getStatus("id")
|
|
124
190
|
*/
|
|
125
|
-
getStatus(id, requestOptions) {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
switch (_response.error.reason) {
|
|
161
|
-
case "non-json":
|
|
191
|
+
async getStatus(id, requestOptions) {
|
|
192
|
+
const _response = await core.fetcher({
|
|
193
|
+
url: (0, url_join_1.default)((await core.Supplier.get(this._options.environment)) ??
|
|
194
|
+
environments.PlanqkServiceApiEnvironment.Default, `${encodeURIComponent(id)}`),
|
|
195
|
+
method: "GET",
|
|
196
|
+
headers: {
|
|
197
|
+
Authorization: await this._getAuthorizationHeader(),
|
|
198
|
+
"X-Fern-Language": "JavaScript",
|
|
199
|
+
"X-Fern-Runtime": core.RUNTIME.type,
|
|
200
|
+
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
201
|
+
},
|
|
202
|
+
contentType: "application/json",
|
|
203
|
+
requestType: "json",
|
|
204
|
+
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
205
|
+
maxRetries: requestOptions?.maxRetries,
|
|
206
|
+
withCredentials: true,
|
|
207
|
+
abortSignal: requestOptions?.abortSignal,
|
|
208
|
+
});
|
|
209
|
+
if (_response.ok) {
|
|
210
|
+
return _response.body;
|
|
211
|
+
}
|
|
212
|
+
if (_response.error.reason === "status-code") {
|
|
213
|
+
switch (_response.error.statusCode) {
|
|
214
|
+
case 401:
|
|
215
|
+
throw new PlanqkServiceApi.UnauthorizedError(_response.error.body);
|
|
216
|
+
case 403:
|
|
217
|
+
throw new PlanqkServiceApi.ForbiddenError(_response.error.body);
|
|
218
|
+
case 404:
|
|
219
|
+
throw new PlanqkServiceApi.NotFoundError(_response.error.body);
|
|
220
|
+
case 500:
|
|
221
|
+
throw new PlanqkServiceApi.InternalServerError(_response.error.body);
|
|
222
|
+
default:
|
|
162
223
|
throw new errors.PlanqkServiceApiError({
|
|
163
224
|
statusCode: _response.error.statusCode,
|
|
164
|
-
body: _response.error.
|
|
165
|
-
});
|
|
166
|
-
case "timeout":
|
|
167
|
-
throw new errors.PlanqkServiceApiTimeoutError();
|
|
168
|
-
case "unknown":
|
|
169
|
-
throw new errors.PlanqkServiceApiError({
|
|
170
|
-
message: _response.error.errorMessage,
|
|
225
|
+
body: _response.error.body,
|
|
171
226
|
});
|
|
172
227
|
}
|
|
173
|
-
}
|
|
228
|
+
}
|
|
229
|
+
switch (_response.error.reason) {
|
|
230
|
+
case "non-json":
|
|
231
|
+
throw new errors.PlanqkServiceApiError({
|
|
232
|
+
statusCode: _response.error.statusCode,
|
|
233
|
+
body: _response.error.rawBody,
|
|
234
|
+
});
|
|
235
|
+
case "timeout":
|
|
236
|
+
throw new errors.PlanqkServiceApiTimeoutError();
|
|
237
|
+
case "unknown":
|
|
238
|
+
throw new errors.PlanqkServiceApiError({
|
|
239
|
+
message: _response.error.errorMessage,
|
|
240
|
+
});
|
|
241
|
+
}
|
|
174
242
|
}
|
|
175
243
|
/**
|
|
176
|
-
*
|
|
244
|
+
* This method retrieves the result of a service execution.
|
|
245
|
+
*
|
|
246
|
+
* @param {string} id - The id of a service execution
|
|
247
|
+
* @param {ServiceApi.RequestOptions} requestOptions - Request-specific configuration.
|
|
248
|
+
*
|
|
177
249
|
* @throws {@link PlanqkServiceApi.UnauthorizedError}
|
|
178
250
|
* @throws {@link PlanqkServiceApi.ForbiddenError}
|
|
179
251
|
* @throws {@link PlanqkServiceApi.NotFoundError}
|
|
180
252
|
* @throws {@link PlanqkServiceApi.InternalServerError}
|
|
253
|
+
*
|
|
254
|
+
* @example
|
|
255
|
+
* await client.serviceApi.getResult("id")
|
|
181
256
|
*/
|
|
182
|
-
getResult(id, requestOptions) {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
switch (_response.error.reason) {
|
|
218
|
-
case "non-json":
|
|
257
|
+
async getResult(id, requestOptions) {
|
|
258
|
+
const _response = await core.fetcher({
|
|
259
|
+
url: (0, url_join_1.default)((await core.Supplier.get(this._options.environment)) ??
|
|
260
|
+
environments.PlanqkServiceApiEnvironment.Default, `${encodeURIComponent(id)}/result`),
|
|
261
|
+
method: "GET",
|
|
262
|
+
headers: {
|
|
263
|
+
Authorization: await this._getAuthorizationHeader(),
|
|
264
|
+
"X-Fern-Language": "JavaScript",
|
|
265
|
+
"X-Fern-Runtime": core.RUNTIME.type,
|
|
266
|
+
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
267
|
+
},
|
|
268
|
+
contentType: "application/json",
|
|
269
|
+
requestType: "json",
|
|
270
|
+
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
271
|
+
maxRetries: requestOptions?.maxRetries,
|
|
272
|
+
withCredentials: true,
|
|
273
|
+
abortSignal: requestOptions?.abortSignal,
|
|
274
|
+
});
|
|
275
|
+
if (_response.ok) {
|
|
276
|
+
return _response.body;
|
|
277
|
+
}
|
|
278
|
+
if (_response.error.reason === "status-code") {
|
|
279
|
+
switch (_response.error.statusCode) {
|
|
280
|
+
case 401:
|
|
281
|
+
throw new PlanqkServiceApi.UnauthorizedError(_response.error.body);
|
|
282
|
+
case 403:
|
|
283
|
+
throw new PlanqkServiceApi.ForbiddenError(_response.error.body);
|
|
284
|
+
case 404:
|
|
285
|
+
throw new PlanqkServiceApi.NotFoundError(_response.error.body);
|
|
286
|
+
case 500:
|
|
287
|
+
throw new PlanqkServiceApi.InternalServerError(_response.error.body);
|
|
288
|
+
default:
|
|
219
289
|
throw new errors.PlanqkServiceApiError({
|
|
220
290
|
statusCode: _response.error.statusCode,
|
|
221
|
-
body: _response.error.
|
|
222
|
-
});
|
|
223
|
-
case "timeout":
|
|
224
|
-
throw new errors.PlanqkServiceApiTimeoutError();
|
|
225
|
-
case "unknown":
|
|
226
|
-
throw new errors.PlanqkServiceApiError({
|
|
227
|
-
message: _response.error.errorMessage,
|
|
291
|
+
body: _response.error.body,
|
|
228
292
|
});
|
|
229
293
|
}
|
|
230
|
-
}
|
|
294
|
+
}
|
|
295
|
+
switch (_response.error.reason) {
|
|
296
|
+
case "non-json":
|
|
297
|
+
throw new errors.PlanqkServiceApiError({
|
|
298
|
+
statusCode: _response.error.statusCode,
|
|
299
|
+
body: _response.error.rawBody,
|
|
300
|
+
});
|
|
301
|
+
case "timeout":
|
|
302
|
+
throw new errors.PlanqkServiceApiTimeoutError();
|
|
303
|
+
case "unknown":
|
|
304
|
+
throw new errors.PlanqkServiceApiError({
|
|
305
|
+
message: _response.error.errorMessage,
|
|
306
|
+
});
|
|
307
|
+
}
|
|
231
308
|
}
|
|
232
309
|
/**
|
|
233
|
-
*
|
|
310
|
+
* This method downloads a result file of a service execution.
|
|
234
311
|
* @throws {@link PlanqkServiceApi.UnauthorizedError}
|
|
235
312
|
* @throws {@link PlanqkServiceApi.ForbiddenError}
|
|
236
313
|
* @throws {@link PlanqkServiceApi.NotFoundError}
|
|
237
314
|
* @throws {@link PlanqkServiceApi.InternalServerError}
|
|
238
315
|
*/
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
throw new PlanqkServiceApi.InternalServerError(_response.error.body);
|
|
273
|
-
default:
|
|
274
|
-
throw new errors.PlanqkServiceApiError({
|
|
275
|
-
statusCode: _response.error.statusCode,
|
|
276
|
-
body: _response.error.body,
|
|
277
|
-
});
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
switch (_response.error.reason) {
|
|
281
|
-
case "non-json":
|
|
316
|
+
async getResultFile(id, file, requestOptions) {
|
|
317
|
+
const _response = await core.fetcher({
|
|
318
|
+
url: (0, url_join_1.default)((await core.Supplier.get(this._options.environment)) ??
|
|
319
|
+
environments.PlanqkServiceApiEnvironment.Default, `${encodeURIComponent(id)}/result/${encodeURIComponent(file)}`),
|
|
320
|
+
method: "GET",
|
|
321
|
+
headers: {
|
|
322
|
+
Authorization: await this._getAuthorizationHeader(),
|
|
323
|
+
"X-Fern-Language": "JavaScript",
|
|
324
|
+
"X-Fern-Runtime": core.RUNTIME.type,
|
|
325
|
+
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
326
|
+
},
|
|
327
|
+
contentType: "application/json",
|
|
328
|
+
requestType: "json",
|
|
329
|
+
responseType: "streaming",
|
|
330
|
+
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
331
|
+
maxRetries: requestOptions?.maxRetries,
|
|
332
|
+
withCredentials: true,
|
|
333
|
+
abortSignal: requestOptions?.abortSignal,
|
|
334
|
+
});
|
|
335
|
+
if (_response.ok) {
|
|
336
|
+
return _response.body;
|
|
337
|
+
}
|
|
338
|
+
if (_response.error.reason === "status-code") {
|
|
339
|
+
switch (_response.error.statusCode) {
|
|
340
|
+
case 401:
|
|
341
|
+
throw new PlanqkServiceApi.UnauthorizedError(_response.error.body);
|
|
342
|
+
case 403:
|
|
343
|
+
throw new PlanqkServiceApi.ForbiddenError(_response.error.body);
|
|
344
|
+
case 404:
|
|
345
|
+
throw new PlanqkServiceApi.NotFoundError(_response.error.body);
|
|
346
|
+
case 500:
|
|
347
|
+
throw new PlanqkServiceApi.InternalServerError(_response.error.body);
|
|
348
|
+
default:
|
|
282
349
|
throw new errors.PlanqkServiceApiError({
|
|
283
350
|
statusCode: _response.error.statusCode,
|
|
284
|
-
body: _response.error.
|
|
285
|
-
});
|
|
286
|
-
case "timeout":
|
|
287
|
-
throw new errors.PlanqkServiceApiTimeoutError();
|
|
288
|
-
case "unknown":
|
|
289
|
-
throw new errors.PlanqkServiceApiError({
|
|
290
|
-
message: _response.error.errorMessage,
|
|
351
|
+
body: _response.error.body,
|
|
291
352
|
});
|
|
292
353
|
}
|
|
293
|
-
}
|
|
354
|
+
}
|
|
355
|
+
switch (_response.error.reason) {
|
|
356
|
+
case "non-json":
|
|
357
|
+
throw new errors.PlanqkServiceApiError({
|
|
358
|
+
statusCode: _response.error.statusCode,
|
|
359
|
+
body: _response.error.rawBody,
|
|
360
|
+
});
|
|
361
|
+
case "timeout":
|
|
362
|
+
throw new errors.PlanqkServiceApiTimeoutError();
|
|
363
|
+
case "unknown":
|
|
364
|
+
throw new errors.PlanqkServiceApiError({
|
|
365
|
+
message: _response.error.errorMessage,
|
|
366
|
+
});
|
|
367
|
+
}
|
|
294
368
|
}
|
|
295
369
|
/**
|
|
296
|
-
*
|
|
370
|
+
* This method retrieves the log output of a service execution.
|
|
371
|
+
*
|
|
372
|
+
* @param {string} id - The id of a service execution
|
|
373
|
+
* @param {ServiceApi.RequestOptions} requestOptions - Request-specific configuration.
|
|
374
|
+
*
|
|
297
375
|
* @throws {@link PlanqkServiceApi.UnauthorizedError}
|
|
298
376
|
* @throws {@link PlanqkServiceApi.ForbiddenError}
|
|
299
377
|
* @throws {@link PlanqkServiceApi.NotFoundError}
|
|
300
378
|
* @throws {@link PlanqkServiceApi.InternalServerError}
|
|
301
379
|
*
|
|
302
380
|
* @example
|
|
303
|
-
* await
|
|
381
|
+
* await client.serviceApi.getLogs("id")
|
|
304
382
|
*/
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
});
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
switch (_response.error.reason) {
|
|
341
|
-
case "non-json":
|
|
383
|
+
async getLogs(id, requestOptions) {
|
|
384
|
+
const _response = await core.fetcher({
|
|
385
|
+
url: (0, url_join_1.default)((await core.Supplier.get(this._options.environment)) ??
|
|
386
|
+
environments.PlanqkServiceApiEnvironment.Default, `${encodeURIComponent(id)}/log`),
|
|
387
|
+
method: "GET",
|
|
388
|
+
headers: {
|
|
389
|
+
Authorization: await this._getAuthorizationHeader(),
|
|
390
|
+
"X-Fern-Language": "JavaScript",
|
|
391
|
+
"X-Fern-Runtime": core.RUNTIME.type,
|
|
392
|
+
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
393
|
+
},
|
|
394
|
+
contentType: "application/json",
|
|
395
|
+
requestType: "json",
|
|
396
|
+
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
397
|
+
maxRetries: requestOptions?.maxRetries,
|
|
398
|
+
withCredentials: true,
|
|
399
|
+
abortSignal: requestOptions?.abortSignal,
|
|
400
|
+
});
|
|
401
|
+
if (_response.ok) {
|
|
402
|
+
return _response.body;
|
|
403
|
+
}
|
|
404
|
+
if (_response.error.reason === "status-code") {
|
|
405
|
+
switch (_response.error.statusCode) {
|
|
406
|
+
case 401:
|
|
407
|
+
throw new PlanqkServiceApi.UnauthorizedError(_response.error.body);
|
|
408
|
+
case 403:
|
|
409
|
+
throw new PlanqkServiceApi.ForbiddenError(_response.error.body);
|
|
410
|
+
case 404:
|
|
411
|
+
throw new PlanqkServiceApi.NotFoundError(_response.error.body);
|
|
412
|
+
case 500:
|
|
413
|
+
throw new PlanqkServiceApi.InternalServerError(_response.error.body);
|
|
414
|
+
default:
|
|
342
415
|
throw new errors.PlanqkServiceApiError({
|
|
343
416
|
statusCode: _response.error.statusCode,
|
|
344
|
-
body: _response.error.
|
|
417
|
+
body: _response.error.body,
|
|
345
418
|
});
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
switch (_response.error.reason) {
|
|
422
|
+
case "non-json":
|
|
423
|
+
throw new errors.PlanqkServiceApiError({
|
|
424
|
+
statusCode: _response.error.statusCode,
|
|
425
|
+
body: _response.error.rawBody,
|
|
426
|
+
});
|
|
427
|
+
case "timeout":
|
|
428
|
+
throw new errors.PlanqkServiceApiTimeoutError();
|
|
429
|
+
case "unknown":
|
|
430
|
+
throw new errors.PlanqkServiceApiError({
|
|
431
|
+
message: _response.error.errorMessage,
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* This method cancels a service execution.
|
|
437
|
+
*
|
|
438
|
+
* @param {string} id - The id of a service execution
|
|
439
|
+
* @param {ServiceApi.RequestOptions} requestOptions - Request-specific configuration.
|
|
440
|
+
*
|
|
441
|
+
* @throws {@link PlanqkServiceApi.UnauthorizedError}
|
|
442
|
+
* @throws {@link PlanqkServiceApi.ForbiddenError}
|
|
443
|
+
* @throws {@link PlanqkServiceApi.NotFoundError}
|
|
444
|
+
* @throws {@link PlanqkServiceApi.InternalServerError}
|
|
445
|
+
*
|
|
446
|
+
* @example
|
|
447
|
+
* await client.serviceApi.cancel("id")
|
|
448
|
+
*/
|
|
449
|
+
async cancel(id, requestOptions) {
|
|
450
|
+
const _response = await core.fetcher({
|
|
451
|
+
url: (0, url_join_1.default)((await core.Supplier.get(this._options.environment)) ??
|
|
452
|
+
environments.PlanqkServiceApiEnvironment.Default, `${encodeURIComponent(id)}/cancel`),
|
|
453
|
+
method: "PUT",
|
|
454
|
+
headers: {
|
|
455
|
+
Authorization: await this._getAuthorizationHeader(),
|
|
456
|
+
"X-Fern-Language": "JavaScript",
|
|
457
|
+
"X-Fern-Runtime": core.RUNTIME.type,
|
|
458
|
+
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
459
|
+
},
|
|
460
|
+
contentType: "application/json",
|
|
461
|
+
requestType: "json",
|
|
462
|
+
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
463
|
+
maxRetries: requestOptions?.maxRetries,
|
|
464
|
+
withCredentials: true,
|
|
465
|
+
abortSignal: requestOptions?.abortSignal,
|
|
466
|
+
});
|
|
467
|
+
if (_response.ok) {
|
|
468
|
+
return _response.body;
|
|
469
|
+
}
|
|
470
|
+
if (_response.error.reason === "status-code") {
|
|
471
|
+
switch (_response.error.statusCode) {
|
|
472
|
+
case 401:
|
|
473
|
+
throw new PlanqkServiceApi.UnauthorizedError(_response.error.body);
|
|
474
|
+
case 403:
|
|
475
|
+
throw new PlanqkServiceApi.ForbiddenError(_response.error.body);
|
|
476
|
+
case 404:
|
|
477
|
+
throw new PlanqkServiceApi.NotFoundError(_response.error.body);
|
|
478
|
+
case 500:
|
|
479
|
+
throw new PlanqkServiceApi.InternalServerError(_response.error.body);
|
|
480
|
+
default:
|
|
349
481
|
throw new errors.PlanqkServiceApiError({
|
|
350
|
-
|
|
482
|
+
statusCode: _response.error.statusCode,
|
|
483
|
+
body: _response.error.body,
|
|
351
484
|
});
|
|
352
485
|
}
|
|
353
|
-
}
|
|
486
|
+
}
|
|
487
|
+
switch (_response.error.reason) {
|
|
488
|
+
case "non-json":
|
|
489
|
+
throw new errors.PlanqkServiceApiError({
|
|
490
|
+
statusCode: _response.error.statusCode,
|
|
491
|
+
body: _response.error.rawBody,
|
|
492
|
+
});
|
|
493
|
+
case "timeout":
|
|
494
|
+
throw new errors.PlanqkServiceApiTimeoutError();
|
|
495
|
+
case "unknown":
|
|
496
|
+
throw new errors.PlanqkServiceApiError({
|
|
497
|
+
message: _response.error.errorMessage,
|
|
498
|
+
});
|
|
499
|
+
}
|
|
354
500
|
}
|
|
355
|
-
_getAuthorizationHeader() {
|
|
356
|
-
return
|
|
357
|
-
return `Bearer ${yield core.Supplier.get(this._options.token)}`;
|
|
358
|
-
});
|
|
501
|
+
async _getAuthorizationHeader() {
|
|
502
|
+
return `Bearer ${await core.Supplier.get(this._options.token)}`;
|
|
359
503
|
}
|
|
360
504
|
}
|
|
361
505
|
exports.ServiceApi = ServiceApi;
|