@planqk/planqk-service-sdk 1.9.0 → 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
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
import * as environments from "../../../../environments";
|
|
6
6
|
import * as core from "../../../../core";
|
|
7
7
|
import * as PlanqkServiceApi from "../../../index";
|
|
8
|
-
import * as errors from "../../../../errors";
|
|
8
|
+
import * as errors from "../../../../errors/index";
|
|
9
9
|
import urlJoin from "url-join";
|
|
10
|
+
import * as stream from "stream";
|
|
10
11
|
|
|
11
12
|
export declare namespace ServiceApi {
|
|
12
13
|
interface Options {
|
|
@@ -15,8 +16,12 @@ export declare namespace ServiceApi {
|
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
interface RequestOptions {
|
|
19
|
+
/** The maximum time to wait for a response in seconds. */
|
|
18
20
|
timeoutInSeconds?: number;
|
|
21
|
+
/** The number of times to retry the request. Defaults to 2. */
|
|
19
22
|
maxRetries?: number;
|
|
23
|
+
/** A hook to abort the request. */
|
|
24
|
+
abortSignal?: AbortSignal;
|
|
20
25
|
}
|
|
21
26
|
}
|
|
22
27
|
|
|
@@ -24,7 +29,67 @@ export class ServiceApi {
|
|
|
24
29
|
constructor(protected readonly _options: ServiceApi.Options) {}
|
|
25
30
|
|
|
26
31
|
/**
|
|
27
|
-
* This method
|
|
32
|
+
* This method checks the health of the service.
|
|
33
|
+
*
|
|
34
|
+
* @param {ServiceApi.RequestOptions} requestOptions - Request-specific configuration.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* await client.serviceApi.healthCheck()
|
|
38
|
+
*/
|
|
39
|
+
public async healthCheck(
|
|
40
|
+
requestOptions?: ServiceApi.RequestOptions
|
|
41
|
+
): Promise<PlanqkServiceApi.HealthCheckResponse> {
|
|
42
|
+
const _response = await core.fetcher({
|
|
43
|
+
url:
|
|
44
|
+
(await core.Supplier.get(this._options.environment)) ??
|
|
45
|
+
environments.PlanqkServiceApiEnvironment.Default,
|
|
46
|
+
method: "GET",
|
|
47
|
+
headers: {
|
|
48
|
+
Authorization: await this._getAuthorizationHeader(),
|
|
49
|
+
"X-Fern-Language": "JavaScript",
|
|
50
|
+
"X-Fern-Runtime": core.RUNTIME.type,
|
|
51
|
+
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
52
|
+
},
|
|
53
|
+
contentType: "application/json",
|
|
54
|
+
requestType: "json",
|
|
55
|
+
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
56
|
+
maxRetries: requestOptions?.maxRetries,
|
|
57
|
+
withCredentials: true,
|
|
58
|
+
abortSignal: requestOptions?.abortSignal,
|
|
59
|
+
});
|
|
60
|
+
if (_response.ok) {
|
|
61
|
+
return _response.body as PlanqkServiceApi.HealthCheckResponse;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (_response.error.reason === "status-code") {
|
|
65
|
+
throw new errors.PlanqkServiceApiError({
|
|
66
|
+
statusCode: _response.error.statusCode,
|
|
67
|
+
body: _response.error.body,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
switch (_response.error.reason) {
|
|
72
|
+
case "non-json":
|
|
73
|
+
throw new errors.PlanqkServiceApiError({
|
|
74
|
+
statusCode: _response.error.statusCode,
|
|
75
|
+
body: _response.error.rawBody,
|
|
76
|
+
});
|
|
77
|
+
case "timeout":
|
|
78
|
+
throw new errors.PlanqkServiceApiTimeoutError();
|
|
79
|
+
case "unknown":
|
|
80
|
+
throw new errors.PlanqkServiceApiError({
|
|
81
|
+
message: _response.error.errorMessage,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* This method starts a service execution, which in turn is processed asynchronously by PLANQK.
|
|
88
|
+
* The location header of the response contains the URL which can be used to query the status and the result of the service execution.
|
|
89
|
+
*
|
|
90
|
+
* @param {Record<string, Record<string, any>>} request
|
|
91
|
+
* @param {ServiceApi.RequestOptions} requestOptions - Request-specific configuration.
|
|
92
|
+
*
|
|
28
93
|
* @throws {@link PlanqkServiceApi.BadRequestError}
|
|
29
94
|
* @throws {@link PlanqkServiceApi.UnauthorizedError}
|
|
30
95
|
* @throws {@link PlanqkServiceApi.ForbiddenError}
|
|
@@ -32,12 +97,16 @@ export class ServiceApi {
|
|
|
32
97
|
* @throws {@link PlanqkServiceApi.InternalServerError}
|
|
33
98
|
*
|
|
34
99
|
* @example
|
|
35
|
-
* await
|
|
100
|
+
* await client.serviceApi.execute({
|
|
101
|
+
* "key": {
|
|
102
|
+
* "key": "value"
|
|
103
|
+
* }
|
|
104
|
+
* })
|
|
36
105
|
*/
|
|
37
|
-
public async
|
|
38
|
-
request:
|
|
106
|
+
public async execute(
|
|
107
|
+
request: Record<string, Record<string, any>>,
|
|
39
108
|
requestOptions?: ServiceApi.RequestOptions
|
|
40
|
-
): Promise<PlanqkServiceApi.
|
|
109
|
+
): Promise<PlanqkServiceApi.ServiceExecution> {
|
|
41
110
|
const _response = await core.fetcher({
|
|
42
111
|
url:
|
|
43
112
|
(await core.Supplier.get(this._options.environment)) ??
|
|
@@ -46,15 +115,19 @@ export class ServiceApi {
|
|
|
46
115
|
headers: {
|
|
47
116
|
Authorization: await this._getAuthorizationHeader(),
|
|
48
117
|
"X-Fern-Language": "JavaScript",
|
|
118
|
+
"X-Fern-Runtime": core.RUNTIME.type,
|
|
119
|
+
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
49
120
|
},
|
|
50
121
|
contentType: "application/json",
|
|
122
|
+
requestType: "json",
|
|
51
123
|
body: request,
|
|
52
124
|
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
53
125
|
maxRetries: requestOptions?.maxRetries,
|
|
54
126
|
withCredentials: true,
|
|
127
|
+
abortSignal: requestOptions?.abortSignal,
|
|
55
128
|
});
|
|
56
129
|
if (_response.ok) {
|
|
57
|
-
return _response.body as PlanqkServiceApi.
|
|
130
|
+
return _response.body as PlanqkServiceApi.ServiceExecution;
|
|
58
131
|
}
|
|
59
132
|
|
|
60
133
|
if (_response.error.reason === "status-code") {
|
|
@@ -93,34 +166,45 @@ export class ServiceApi {
|
|
|
93
166
|
}
|
|
94
167
|
|
|
95
168
|
/**
|
|
96
|
-
*
|
|
169
|
+
* This method checks the status of a service execution.
|
|
170
|
+
*
|
|
171
|
+
* @param {string} id - The id of a service execution
|
|
172
|
+
* @param {ServiceApi.RequestOptions} requestOptions - Request-specific configuration.
|
|
173
|
+
*
|
|
97
174
|
* @throws {@link PlanqkServiceApi.UnauthorizedError}
|
|
98
175
|
* @throws {@link PlanqkServiceApi.ForbiddenError}
|
|
99
176
|
* @throws {@link PlanqkServiceApi.NotFoundError}
|
|
100
177
|
* @throws {@link PlanqkServiceApi.InternalServerError}
|
|
101
178
|
*
|
|
102
179
|
* @example
|
|
103
|
-
* await
|
|
180
|
+
* await client.serviceApi.getStatus("id")
|
|
104
181
|
*/
|
|
105
|
-
public async getStatus(
|
|
182
|
+
public async getStatus(
|
|
183
|
+
id: string,
|
|
184
|
+
requestOptions?: ServiceApi.RequestOptions
|
|
185
|
+
): Promise<PlanqkServiceApi.ServiceExecution> {
|
|
106
186
|
const _response = await core.fetcher({
|
|
107
187
|
url: urlJoin(
|
|
108
188
|
(await core.Supplier.get(this._options.environment)) ??
|
|
109
189
|
environments.PlanqkServiceApiEnvironment.Default,
|
|
110
|
-
`${id}`
|
|
190
|
+
`${encodeURIComponent(id)}`
|
|
111
191
|
),
|
|
112
192
|
method: "GET",
|
|
113
193
|
headers: {
|
|
114
194
|
Authorization: await this._getAuthorizationHeader(),
|
|
115
195
|
"X-Fern-Language": "JavaScript",
|
|
196
|
+
"X-Fern-Runtime": core.RUNTIME.type,
|
|
197
|
+
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
116
198
|
},
|
|
117
199
|
contentType: "application/json",
|
|
200
|
+
requestType: "json",
|
|
118
201
|
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
119
202
|
maxRetries: requestOptions?.maxRetries,
|
|
120
203
|
withCredentials: true,
|
|
204
|
+
abortSignal: requestOptions?.abortSignal,
|
|
121
205
|
});
|
|
122
206
|
if (_response.ok) {
|
|
123
|
-
return _response.body as PlanqkServiceApi.
|
|
207
|
+
return _response.body as PlanqkServiceApi.ServiceExecution;
|
|
124
208
|
}
|
|
125
209
|
|
|
126
210
|
if (_response.error.reason === "status-code") {
|
|
@@ -157,11 +241,18 @@ export class ServiceApi {
|
|
|
157
241
|
}
|
|
158
242
|
|
|
159
243
|
/**
|
|
160
|
-
*
|
|
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
|
+
*
|
|
161
249
|
* @throws {@link PlanqkServiceApi.UnauthorizedError}
|
|
162
250
|
* @throws {@link PlanqkServiceApi.ForbiddenError}
|
|
163
251
|
* @throws {@link PlanqkServiceApi.NotFoundError}
|
|
164
252
|
* @throws {@link PlanqkServiceApi.InternalServerError}
|
|
253
|
+
*
|
|
254
|
+
* @example
|
|
255
|
+
* await client.serviceApi.getResult("id")
|
|
165
256
|
*/
|
|
166
257
|
public async getResult(
|
|
167
258
|
id: string,
|
|
@@ -171,17 +262,21 @@ export class ServiceApi {
|
|
|
171
262
|
url: urlJoin(
|
|
172
263
|
(await core.Supplier.get(this._options.environment)) ??
|
|
173
264
|
environments.PlanqkServiceApiEnvironment.Default,
|
|
174
|
-
`${id}/result`
|
|
265
|
+
`${encodeURIComponent(id)}/result`
|
|
175
266
|
),
|
|
176
267
|
method: "GET",
|
|
177
268
|
headers: {
|
|
178
269
|
Authorization: await this._getAuthorizationHeader(),
|
|
179
270
|
"X-Fern-Language": "JavaScript",
|
|
271
|
+
"X-Fern-Runtime": core.RUNTIME.type,
|
|
272
|
+
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
180
273
|
},
|
|
181
274
|
contentType: "application/json",
|
|
275
|
+
requestType: "json",
|
|
182
276
|
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
183
277
|
maxRetries: requestOptions?.maxRetries,
|
|
184
278
|
withCredentials: true,
|
|
279
|
+
abortSignal: requestOptions?.abortSignal,
|
|
185
280
|
});
|
|
186
281
|
if (_response.ok) {
|
|
187
282
|
return _response.body as PlanqkServiceApi.GetResultResponse;
|
|
@@ -221,42 +316,112 @@ export class ServiceApi {
|
|
|
221
316
|
}
|
|
222
317
|
|
|
223
318
|
/**
|
|
224
|
-
*
|
|
319
|
+
* This method downloads a result file of a service execution.
|
|
225
320
|
* @throws {@link PlanqkServiceApi.UnauthorizedError}
|
|
226
321
|
* @throws {@link PlanqkServiceApi.ForbiddenError}
|
|
227
322
|
* @throws {@link PlanqkServiceApi.NotFoundError}
|
|
228
323
|
* @throws {@link PlanqkServiceApi.InternalServerError}
|
|
229
324
|
*/
|
|
230
|
-
public async
|
|
325
|
+
public async getResultFile(
|
|
231
326
|
id: string,
|
|
232
|
-
|
|
327
|
+
file: string,
|
|
233
328
|
requestOptions?: ServiceApi.RequestOptions
|
|
234
|
-
): Promise<
|
|
235
|
-
const
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
329
|
+
): Promise<stream.Readable> {
|
|
330
|
+
const _response = await core.fetcher<stream.Readable>({
|
|
331
|
+
url: urlJoin(
|
|
332
|
+
(await core.Supplier.get(this._options.environment)) ??
|
|
333
|
+
environments.PlanqkServiceApiEnvironment.Default,
|
|
334
|
+
`${encodeURIComponent(id)}/result/${encodeURIComponent(file)}`
|
|
335
|
+
),
|
|
336
|
+
method: "GET",
|
|
337
|
+
headers: {
|
|
338
|
+
Authorization: await this._getAuthorizationHeader(),
|
|
339
|
+
"X-Fern-Language": "JavaScript",
|
|
340
|
+
"X-Fern-Runtime": core.RUNTIME.type,
|
|
341
|
+
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
342
|
+
},
|
|
343
|
+
contentType: "application/json",
|
|
344
|
+
requestType: "json",
|
|
345
|
+
responseType: "streaming",
|
|
346
|
+
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
347
|
+
maxRetries: requestOptions?.maxRetries,
|
|
348
|
+
withCredentials: true,
|
|
349
|
+
abortSignal: requestOptions?.abortSignal,
|
|
350
|
+
});
|
|
351
|
+
if (_response.ok) {
|
|
352
|
+
return _response.body;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
if (_response.error.reason === "status-code") {
|
|
356
|
+
switch (_response.error.statusCode) {
|
|
357
|
+
case 401:
|
|
358
|
+
throw new PlanqkServiceApi.UnauthorizedError(_response.error.body as any);
|
|
359
|
+
case 403:
|
|
360
|
+
throw new PlanqkServiceApi.ForbiddenError(_response.error.body as any);
|
|
361
|
+
case 404:
|
|
362
|
+
throw new PlanqkServiceApi.NotFoundError(_response.error.body as any);
|
|
363
|
+
case 500:
|
|
364
|
+
throw new PlanqkServiceApi.InternalServerError(_response.error.body as any);
|
|
365
|
+
default:
|
|
366
|
+
throw new errors.PlanqkServiceApiError({
|
|
367
|
+
statusCode: _response.error.statusCode,
|
|
368
|
+
body: _response.error.body,
|
|
369
|
+
});
|
|
370
|
+
}
|
|
239
371
|
}
|
|
240
372
|
|
|
373
|
+
switch (_response.error.reason) {
|
|
374
|
+
case "non-json":
|
|
375
|
+
throw new errors.PlanqkServiceApiError({
|
|
376
|
+
statusCode: _response.error.statusCode,
|
|
377
|
+
body: _response.error.rawBody,
|
|
378
|
+
});
|
|
379
|
+
case "timeout":
|
|
380
|
+
throw new errors.PlanqkServiceApiTimeoutError();
|
|
381
|
+
case "unknown":
|
|
382
|
+
throw new errors.PlanqkServiceApiError({
|
|
383
|
+
message: _response.error.errorMessage,
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* This method retrieves the log output of a service execution.
|
|
390
|
+
*
|
|
391
|
+
* @param {string} id - The id of a service execution
|
|
392
|
+
* @param {ServiceApi.RequestOptions} requestOptions - Request-specific configuration.
|
|
393
|
+
*
|
|
394
|
+
* @throws {@link PlanqkServiceApi.UnauthorizedError}
|
|
395
|
+
* @throws {@link PlanqkServiceApi.ForbiddenError}
|
|
396
|
+
* @throws {@link PlanqkServiceApi.NotFoundError}
|
|
397
|
+
* @throws {@link PlanqkServiceApi.InternalServerError}
|
|
398
|
+
*
|
|
399
|
+
* @example
|
|
400
|
+
* await client.serviceApi.getLogs("id")
|
|
401
|
+
*/
|
|
402
|
+
public async getLogs(id: string, requestOptions?: ServiceApi.RequestOptions): Promise<string[]> {
|
|
241
403
|
const _response = await core.fetcher({
|
|
242
404
|
url: urlJoin(
|
|
243
405
|
(await core.Supplier.get(this._options.environment)) ??
|
|
244
406
|
environments.PlanqkServiceApiEnvironment.Default,
|
|
245
|
-
`${id}/
|
|
407
|
+
`${encodeURIComponent(id)}/log`
|
|
246
408
|
),
|
|
247
409
|
method: "GET",
|
|
248
410
|
headers: {
|
|
249
411
|
Authorization: await this._getAuthorizationHeader(),
|
|
250
412
|
"X-Fern-Language": "JavaScript",
|
|
413
|
+
"X-Fern-Runtime": core.RUNTIME.type,
|
|
414
|
+
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
251
415
|
},
|
|
252
416
|
contentType: "application/json",
|
|
253
|
-
|
|
417
|
+
requestType: "json",
|
|
254
418
|
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
255
419
|
maxRetries: requestOptions?.maxRetries,
|
|
256
420
|
withCredentials: true,
|
|
421
|
+
abortSignal: requestOptions?.abortSignal,
|
|
257
422
|
});
|
|
258
423
|
if (_response.ok) {
|
|
259
|
-
return _response.body as
|
|
424
|
+
return _response.body as string[];
|
|
260
425
|
}
|
|
261
426
|
|
|
262
427
|
if (_response.error.reason === "status-code") {
|
|
@@ -293,37 +458,45 @@ export class ServiceApi {
|
|
|
293
458
|
}
|
|
294
459
|
|
|
295
460
|
/**
|
|
296
|
-
*
|
|
461
|
+
* This method cancels a service execution.
|
|
462
|
+
*
|
|
463
|
+
* @param {string} id - The id of a service execution
|
|
464
|
+
* @param {ServiceApi.RequestOptions} requestOptions - Request-specific configuration.
|
|
465
|
+
*
|
|
297
466
|
* @throws {@link PlanqkServiceApi.UnauthorizedError}
|
|
298
467
|
* @throws {@link PlanqkServiceApi.ForbiddenError}
|
|
299
468
|
* @throws {@link PlanqkServiceApi.NotFoundError}
|
|
300
469
|
* @throws {@link PlanqkServiceApi.InternalServerError}
|
|
301
470
|
*
|
|
302
471
|
* @example
|
|
303
|
-
* await
|
|
472
|
+
* await client.serviceApi.cancel("id")
|
|
304
473
|
*/
|
|
305
|
-
public async
|
|
474
|
+
public async cancel(
|
|
306
475
|
id: string,
|
|
307
476
|
requestOptions?: ServiceApi.RequestOptions
|
|
308
|
-
): Promise<PlanqkServiceApi.
|
|
477
|
+
): Promise<PlanqkServiceApi.ServiceExecution> {
|
|
309
478
|
const _response = await core.fetcher({
|
|
310
479
|
url: urlJoin(
|
|
311
480
|
(await core.Supplier.get(this._options.environment)) ??
|
|
312
481
|
environments.PlanqkServiceApiEnvironment.Default,
|
|
313
|
-
`${id}/cancel`
|
|
482
|
+
`${encodeURIComponent(id)}/cancel`
|
|
314
483
|
),
|
|
315
484
|
method: "PUT",
|
|
316
485
|
headers: {
|
|
317
486
|
Authorization: await this._getAuthorizationHeader(),
|
|
318
487
|
"X-Fern-Language": "JavaScript",
|
|
488
|
+
"X-Fern-Runtime": core.RUNTIME.type,
|
|
489
|
+
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
319
490
|
},
|
|
320
491
|
contentType: "application/json",
|
|
492
|
+
requestType: "json",
|
|
321
493
|
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
322
494
|
maxRetries: requestOptions?.maxRetries,
|
|
323
495
|
withCredentials: true,
|
|
496
|
+
abortSignal: requestOptions?.abortSignal,
|
|
324
497
|
});
|
|
325
498
|
if (_response.ok) {
|
|
326
|
-
return _response.body as PlanqkServiceApi.
|
|
499
|
+
return _response.body as PlanqkServiceApi.ServiceExecution;
|
|
327
500
|
}
|
|
328
501
|
|
|
329
502
|
if (_response.error.reason === "status-code") {
|
|
@@ -359,7 +532,7 @@ export class ServiceApi {
|
|
|
359
532
|
}
|
|
360
533
|
}
|
|
361
534
|
|
|
362
|
-
protected async _getAuthorizationHeader() {
|
|
535
|
+
protected async _getAuthorizationHeader(): Promise<string> {
|
|
363
536
|
return `Bearer ${await core.Supplier.get(this._options.token)}`;
|
|
364
537
|
}
|
|
365
538
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export {};
|
|
@@ -4,8 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import * as PlanqkServiceApi from "../../../index";
|
|
6
6
|
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
| PlanqkServiceApi.ArrayResponse;
|
|
7
|
+
export interface GetResultResponse {
|
|
8
|
+
_links?: PlanqkServiceApi.GetResultResponseLinks;
|
|
9
|
+
_embedded?: PlanqkServiceApi.GetResultResponseEmbedded;
|
|
10
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export interface HalLink {
|
|
6
|
+
/** The URL of the link */
|
|
7
|
+
href?: string;
|
|
8
|
+
/** Whether the link is templated (optional) */
|
|
9
|
+
templated?: boolean;
|
|
10
|
+
/** The media type of the link (optional) */
|
|
11
|
+
type?: string;
|
|
12
|
+
/** A URL that provides further information about the deprecation of the link (optional) */
|
|
13
|
+
deprecation?: string;
|
|
14
|
+
/** The name of the link (optional) */
|
|
15
|
+
name?: string;
|
|
16
|
+
/** A URL that provides further information about the profile of the link (optional) */
|
|
17
|
+
profile?: string;
|
|
18
|
+
/** The title of the link (optional) */
|
|
19
|
+
title?: string;
|
|
20
|
+
/** The language of the link's target resource (optional) */
|
|
21
|
+
hreflang?: string;
|
|
22
|
+
}
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
import * as PlanqkServiceApi from "../index";
|
|
6
6
|
|
|
7
|
-
export interface
|
|
7
|
+
export interface ServiceExecution {
|
|
8
8
|
id?: string;
|
|
9
|
-
status?: PlanqkServiceApi.
|
|
9
|
+
status?: PlanqkServiceApi.ServiceExecutionStatus;
|
|
10
10
|
createdAt?: string;
|
|
11
11
|
startedAt?: string;
|
|
12
12
|
endedAt?: string;
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* This file was auto-generated by Fern from our API Definition.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
export type
|
|
5
|
+
export type ServiceExecutionStatus = "UNKNOWN" | "PENDING" | "RUNNING" | "SUCCEEDED" | "CANCELLED" | "FAILED";
|
|
6
6
|
|
|
7
|
-
export const
|
|
7
|
+
export const ServiceExecutionStatus = {
|
|
8
8
|
Unknown: "UNKNOWN",
|
|
9
9
|
Pending: "PENDING",
|
|
10
10
|
Running: "RUNNING",
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
export * from "./InputData";
|
|
2
2
|
export * from "./InputParams";
|
|
3
|
-
export * from "./
|
|
4
|
-
export * from "./
|
|
5
|
-
export * from "./
|
|
6
|
-
export * from "./
|
|
7
|
-
export * from "./NumberResponse";
|
|
8
|
-
export * from "./ArrayResponse";
|
|
9
|
-
export * from "./JobStatus";
|
|
10
|
-
export * from "./Job";
|
|
3
|
+
export * from "./InputDataRef";
|
|
4
|
+
export * from "./ServiceExecutionStatus";
|
|
5
|
+
export * from "./ServiceExecution";
|
|
6
|
+
export * from "./HalLink";
|