@planqk/planqk-api-sdk 1.0.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 +2 -0
- package/.gitlab-ci.yml +71 -0
- package/.python-version +1 -0
- package/.releaserc.json +45 -0
- package/LICENSE +201 -0
- package/README-node.md +18 -0
- package/README-python.md +21 -0
- package/README.md +56 -0
- package/dist/Client.d.ts +32 -0
- package/dist/Client.js +60 -0
- package/dist/api/errors/BadRequestError.d.ts +8 -0
- package/dist/api/errors/BadRequestError.js +52 -0
- package/dist/api/errors/ForbiddenError.d.ts +8 -0
- package/dist/api/errors/ForbiddenError.js +52 -0
- package/dist/api/errors/InternalServerError.d.ts +8 -0
- package/dist/api/errors/InternalServerError.js +52 -0
- package/dist/api/errors/NotFoundError.d.ts +8 -0
- package/dist/api/errors/NotFoundError.js +52 -0
- package/dist/api/errors/UnauthorizedError.d.ts +8 -0
- package/dist/api/errors/UnauthorizedError.js +52 -0
- package/dist/api/errors/index.d.ts +5 -0
- package/dist/api/errors/index.js +21 -0
- package/dist/api/index.d.ts +3 -0
- package/dist/api/index.js +19 -0
- package/dist/api/resources/dataPools/client/Client.d.ts +177 -0
- package/dist/api/resources/dataPools/client/Client.js +676 -0
- package/dist/api/resources/dataPools/client/index.d.ts +2 -0
- package/dist/api/resources/dataPools/client/index.js +17 -0
- package/dist/api/resources/dataPools/client/requests/AddDataPoolFileRequest.d.ts +14 -0
- package/dist/api/resources/dataPools/client/requests/AddDataPoolFileRequest.js +5 -0
- package/dist/api/resources/dataPools/client/requests/CreateDataPoolRequest.d.ts +10 -0
- package/dist/api/resources/dataPools/client/requests/CreateDataPoolRequest.js +5 -0
- package/dist/api/resources/dataPools/client/requests/UpdateDataPoolRequest.d.ts +12 -0
- package/dist/api/resources/dataPools/client/requests/UpdateDataPoolRequest.js +5 -0
- package/dist/api/resources/dataPools/client/requests/index.d.ts +3 -0
- package/dist/api/resources/dataPools/client/requests/index.js +2 -0
- package/dist/api/resources/dataPools/index.d.ts +1 -0
- package/dist/api/resources/dataPools/index.js +17 -0
- package/dist/api/resources/index.d.ts +2 -0
- package/dist/api/resources/index.js +41 -0
- package/dist/api/types/DataPoolDto.d.ts +23 -0
- package/dist/api/types/DataPoolDto.js +14 -0
- package/dist/api/types/DataPoolFileDto.d.ts +12 -0
- package/dist/api/types/DataPoolFileDto.js +5 -0
- package/dist/api/types/OauthScope.d.ts +9 -0
- package/dist/api/types/OauthScope.js +9 -0
- package/dist/api/types/index.d.ts +3 -0
- package/dist/api/types/index.js +19 -0
- package/dist/core/fetcher/APIResponse.d.ts +20 -0
- package/dist/core/fetcher/APIResponse.js +2 -0
- package/dist/core/fetcher/BinaryResponse.d.ts +20 -0
- package/dist/core/fetcher/BinaryResponse.js +17 -0
- package/dist/core/fetcher/Fetcher.d.ts +40 -0
- package/dist/core/fetcher/Fetcher.js +105 -0
- package/dist/core/fetcher/Headers.d.ts +2 -0
- package/dist/core/fetcher/Headers.js +85 -0
- package/dist/core/fetcher/HttpResponsePromise.d.ts +58 -0
- package/dist/core/fetcher/HttpResponsePromise.js +94 -0
- package/dist/core/fetcher/RawResponse.d.ts +29 -0
- package/dist/core/fetcher/RawResponse.js +44 -0
- package/dist/core/fetcher/ResponseWithBody.d.ts +4 -0
- package/dist/core/fetcher/ResponseWithBody.js +6 -0
- package/dist/core/fetcher/Supplier.d.ts +4 -0
- package/dist/core/fetcher/Supplier.js +13 -0
- package/dist/core/fetcher/createRequestUrl.d.ts +1 -0
- package/dist/core/fetcher/createRequestUrl.js +8 -0
- package/dist/core/fetcher/getErrorResponseBody.d.ts +1 -0
- package/dist/core/fetcher/getErrorResponseBody.js +32 -0
- package/dist/core/fetcher/getFetchFn.d.ts +1 -0
- package/dist/core/fetcher/getFetchFn.js +6 -0
- package/dist/core/fetcher/getHeader.d.ts +1 -0
- package/dist/core/fetcher/getHeader.js +11 -0
- package/dist/core/fetcher/getRequestBody.d.ts +7 -0
- package/dist/core/fetcher/getRequestBody.js +12 -0
- package/dist/core/fetcher/getResponseBody.d.ts +1 -0
- package/dist/core/fetcher/getResponseBody.js +44 -0
- package/dist/core/fetcher/index.d.ts +9 -0
- package/dist/core/fetcher/index.js +15 -0
- package/dist/core/fetcher/makeRequest.d.ts +1 -0
- package/dist/core/fetcher/makeRequest.js +33 -0
- package/dist/core/fetcher/requestWithRetries.d.ts +1 -0
- package/dist/core/fetcher/requestWithRetries.js +29 -0
- package/dist/core/fetcher/signals.d.ts +11 -0
- package/dist/core/fetcher/signals.js +36 -0
- package/dist/core/file.d.ts +1 -0
- package/dist/core/file.js +2 -0
- package/dist/core/form-data-utils/FormDataWrapper.d.ts +16 -0
- package/dist/core/form-data-utils/FormDataWrapper.js +166 -0
- package/dist/core/form-data-utils/encodeAsFormParameter.d.ts +1 -0
- package/dist/core/form-data-utils/encodeAsFormParameter.js +12 -0
- package/dist/core/form-data-utils/index.d.ts +2 -0
- package/dist/core/form-data-utils/index.js +20 -0
- package/dist/core/headers.d.ts +3 -0
- package/dist/core/headers.js +29 -0
- package/dist/core/index.d.ts +5 -0
- package/dist/core/index.js +44 -0
- package/dist/core/json.d.ts +15 -0
- package/dist/core/json.js +24 -0
- package/dist/core/runtime/index.d.ts +1 -0
- package/dist/core/runtime/index.js +5 -0
- package/dist/core/runtime/runtime.d.ts +9 -0
- package/dist/core/runtime/runtime.js +101 -0
- package/dist/core/url/index.d.ts +2 -0
- package/dist/core/url/index.js +7 -0
- package/dist/core/url/join.d.ts +1 -0
- package/dist/core/url/join.js +49 -0
- package/dist/core/url/qs.d.ts +6 -0
- package/dist/core/url/qs.js +67 -0
- package/dist/environments.d.ts +7 -0
- package/dist/environments.js +9 -0
- package/dist/errors/PlanqkApiError.d.ts +15 -0
- package/dist/errors/PlanqkApiError.js +33 -0
- package/dist/errors/PlanqkApiTimeoutError.d.ts +6 -0
- package/dist/errors/PlanqkApiTimeoutError.js +13 -0
- package/dist/errors/index.d.ts +2 -0
- package/dist/errors/index.js +7 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +44 -0
- package/eslint.config.mjs +11 -0
- package/fern/fern.config.json +4 -0
- package/fern/generators.yml +25 -0
- package/fern/openapi/openapi.json +610 -0
- package/notebooks/python-sdk.ipynb +218 -0
- package/package.json +48 -0
- package/planqk/__init__.py +0 -0
- package/planqk/api/__init__.py +1 -0
- package/planqk/api/_version.py +1 -0
- package/planqk/api/client.py +19 -0
- package/planqk/api/credentials.py +103 -0
- package/planqk/api/sdk/__init__.py +25 -0
- package/planqk/api/sdk/client.py +153 -0
- package/planqk/api/sdk/core/__init__.py +52 -0
- package/planqk/api/sdk/core/api_error.py +23 -0
- package/planqk/api/sdk/core/client_wrapper.py +76 -0
- package/planqk/api/sdk/core/datetime_utils.py +28 -0
- package/planqk/api/sdk/core/file.py +67 -0
- package/planqk/api/sdk/core/force_multipart.py +16 -0
- package/planqk/api/sdk/core/http_client.py +543 -0
- package/planqk/api/sdk/core/http_response.py +55 -0
- package/planqk/api/sdk/core/jsonable_encoder.py +100 -0
- package/planqk/api/sdk/core/pydantic_utilities.py +255 -0
- package/planqk/api/sdk/core/query_encoder.py +58 -0
- package/planqk/api/sdk/core/remove_none_from_dict.py +11 -0
- package/planqk/api/sdk/core/request_options.py +35 -0
- package/planqk/api/sdk/core/serialization.py +276 -0
- package/planqk/api/sdk/data_pools/__init__.py +4 -0
- package/planqk/api/sdk/data_pools/client.py +700 -0
- package/planqk/api/sdk/data_pools/raw_client.py +1650 -0
- package/planqk/api/sdk/environment.py +7 -0
- package/planqk/api/sdk/errors/__init__.py +11 -0
- package/planqk/api/sdk/errors/bad_request_error.py +10 -0
- package/planqk/api/sdk/errors/forbidden_error.py +10 -0
- package/planqk/api/sdk/errors/internal_server_error.py +10 -0
- package/planqk/api/sdk/errors/not_found_error.py +10 -0
- package/planqk/api/sdk/errors/unauthorized_error.py +10 -0
- package/planqk/api/sdk/types/__init__.py +10 -0
- package/planqk/api/sdk/types/data_pool_dto.py +33 -0
- package/planqk/api/sdk/types/data_pool_dto_current_user_permission.py +5 -0
- package/planqk/api/sdk/types/data_pool_file_dto.py +27 -0
- package/planqk/api/sdk/types/oauth_scope.py +5 -0
- package/pyproject.toml +51 -0
- package/scripts/update-version.sh +6 -0
- package/src/Client.ts +53 -0
- package/src/api/errors/BadRequestError.ts +18 -0
- package/src/api/errors/ForbiddenError.ts +18 -0
- package/src/api/errors/InternalServerError.ts +18 -0
- package/src/api/errors/NotFoundError.ts +18 -0
- package/src/api/errors/UnauthorizedError.ts +18 -0
- package/src/api/errors/index.ts +5 -0
- package/src/api/index.ts +3 -0
- package/src/api/resources/dataPools/client/Client.ts +825 -0
- package/src/api/resources/dataPools/client/index.ts +2 -0
- package/src/api/resources/dataPools/client/requests/AddDataPoolFileRequest.ts +17 -0
- package/src/api/resources/dataPools/client/requests/CreateDataPoolRequest.ts +11 -0
- package/src/api/resources/dataPools/client/requests/UpdateDataPoolRequest.ts +13 -0
- package/src/api/resources/dataPools/client/requests/index.ts +3 -0
- package/src/api/resources/dataPools/index.ts +1 -0
- package/src/api/resources/index.ts +2 -0
- package/src/api/types/DataPoolDto.ts +25 -0
- package/src/api/types/DataPoolFileDto.ts +13 -0
- package/src/api/types/OauthScope.ts +10 -0
- package/src/api/types/index.ts +3 -0
- package/src/core/fetcher/APIResponse.ts +23 -0
- package/src/core/fetcher/BinaryResponse.ts +36 -0
- package/src/core/fetcher/Fetcher.ts +163 -0
- package/src/core/fetcher/Headers.ts +93 -0
- package/src/core/fetcher/HttpResponsePromise.ts +116 -0
- package/src/core/fetcher/RawResponse.ts +61 -0
- package/src/core/fetcher/ResponseWithBody.ts +7 -0
- package/src/core/fetcher/Supplier.ts +11 -0
- package/src/core/fetcher/createRequestUrl.ts +6 -0
- package/src/core/fetcher/getErrorResponseBody.ts +32 -0
- package/src/core/fetcher/getFetchFn.ts +3 -0
- package/src/core/fetcher/getHeader.ts +8 -0
- package/src/core/fetcher/getRequestBody.ts +16 -0
- package/src/core/fetcher/getResponseBody.ts +43 -0
- package/src/core/fetcher/index.ts +9 -0
- package/src/core/fetcher/makeRequest.ts +44 -0
- package/src/core/fetcher/requestWithRetries.ts +33 -0
- package/src/core/fetcher/signals.ts +38 -0
- package/src/core/file.ts +11 -0
- package/src/core/form-data-utils/FormDataWrapper.ts +176 -0
- package/src/core/form-data-utils/encodeAsFormParameter.ts +12 -0
- package/src/core/form-data-utils/index.ts +2 -0
- package/src/core/headers.ts +35 -0
- package/src/core/index.ts +5 -0
- package/src/core/json.ts +27 -0
- package/src/core/runtime/index.ts +1 -0
- package/src/core/runtime/runtime.ts +133 -0
- package/src/core/url/index.ts +2 -0
- package/src/core/url/join.ts +55 -0
- package/src/core/url/qs.ts +74 -0
- package/src/environments.ts +9 -0
- package/src/errors/PlanqkApiError.ts +55 -0
- package/src/errors/PlanqkApiTimeoutError.ts +10 -0
- package/src/errors/index.ts +2 -0
- package/src/index.test.ts +17 -0
- package/src/index.ts +4 -0
- package/tsconfig.json +18 -0
- package/uv.lock +1102 -0
|
@@ -0,0 +1,825 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as environments from "../../../../environments.js";
|
|
6
|
+
import * as core from "../../../../core/index.js";
|
|
7
|
+
import * as PlanqkApi from "../../../index.js";
|
|
8
|
+
import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js";
|
|
9
|
+
import * as errors from "../../../../errors/index.js";
|
|
10
|
+
import * as fs from "fs";
|
|
11
|
+
|
|
12
|
+
export declare namespace DataPools {
|
|
13
|
+
export interface Options {
|
|
14
|
+
environment?: core.Supplier<environments.PlanqkApiEnvironment | string>;
|
|
15
|
+
/** Specify a custom URL to connect the client to. */
|
|
16
|
+
baseUrl?: core.Supplier<string>;
|
|
17
|
+
apiKey: core.Supplier<string>;
|
|
18
|
+
/** Additional headers to include in requests. */
|
|
19
|
+
headers?: Record<string, string | core.Supplier<string | undefined> | undefined>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface RequestOptions {
|
|
23
|
+
/** The maximum time to wait for a response in seconds. */
|
|
24
|
+
timeoutInSeconds?: number;
|
|
25
|
+
/** The number of times to retry the request. Defaults to 2. */
|
|
26
|
+
maxRetries?: number;
|
|
27
|
+
/** A hook to abort the request. */
|
|
28
|
+
abortSignal?: AbortSignal;
|
|
29
|
+
/** Additional headers to include in the request. */
|
|
30
|
+
headers?: Record<string, string | core.Supplier<string | undefined> | undefined>;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export class DataPools {
|
|
35
|
+
protected readonly _options: DataPools.Options;
|
|
36
|
+
|
|
37
|
+
constructor(_options: DataPools.Options) {
|
|
38
|
+
this._options = _options;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Get a specific data pool (identified by its ID).
|
|
43
|
+
*
|
|
44
|
+
* @param {string} id
|
|
45
|
+
* @param {DataPools.RequestOptions} requestOptions - Request-specific configuration.
|
|
46
|
+
*
|
|
47
|
+
* @throws {@link PlanqkApi.UnauthorizedError}
|
|
48
|
+
* @throws {@link PlanqkApi.ForbiddenError}
|
|
49
|
+
* @throws {@link PlanqkApi.NotFoundError}
|
|
50
|
+
* @throws {@link PlanqkApi.InternalServerError}
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* await client.dataPools.getDataPool("id")
|
|
54
|
+
*/
|
|
55
|
+
public getDataPool(
|
|
56
|
+
id: string,
|
|
57
|
+
requestOptions?: DataPools.RequestOptions,
|
|
58
|
+
): core.HttpResponsePromise<PlanqkApi.DataPoolDto> {
|
|
59
|
+
return core.HttpResponsePromise.fromPromise(this.__getDataPool(id, requestOptions));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
private async __getDataPool(
|
|
63
|
+
id: string,
|
|
64
|
+
requestOptions?: DataPools.RequestOptions,
|
|
65
|
+
): Promise<core.WithRawResponse<PlanqkApi.DataPoolDto>> {
|
|
66
|
+
const _response = await core.fetcher({
|
|
67
|
+
url: core.url.join(
|
|
68
|
+
(await core.Supplier.get(this._options.baseUrl)) ??
|
|
69
|
+
(await core.Supplier.get(this._options.environment)) ??
|
|
70
|
+
environments.PlanqkApiEnvironment.Default,
|
|
71
|
+
`datapools/${encodeURIComponent(id)}`,
|
|
72
|
+
),
|
|
73
|
+
method: "GET",
|
|
74
|
+
headers: mergeHeaders(
|
|
75
|
+
this._options?.headers,
|
|
76
|
+
mergeOnlyDefinedHeaders({ ...(await this._getCustomAuthorizationHeaders()) }),
|
|
77
|
+
requestOptions?.headers,
|
|
78
|
+
),
|
|
79
|
+
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
80
|
+
maxRetries: requestOptions?.maxRetries,
|
|
81
|
+
withCredentials: true,
|
|
82
|
+
abortSignal: requestOptions?.abortSignal,
|
|
83
|
+
});
|
|
84
|
+
if (_response.ok) {
|
|
85
|
+
return { data: _response.body as PlanqkApi.DataPoolDto, rawResponse: _response.rawResponse };
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (_response.error.reason === "status-code") {
|
|
89
|
+
switch (_response.error.statusCode) {
|
|
90
|
+
case 401:
|
|
91
|
+
throw new PlanqkApi.UnauthorizedError(_response.error.body as any, _response.rawResponse);
|
|
92
|
+
case 403:
|
|
93
|
+
throw new PlanqkApi.ForbiddenError(_response.error.body as any, _response.rawResponse);
|
|
94
|
+
case 404:
|
|
95
|
+
throw new PlanqkApi.NotFoundError(_response.error.body as any, _response.rawResponse);
|
|
96
|
+
case 500:
|
|
97
|
+
throw new PlanqkApi.InternalServerError(_response.error.body as any, _response.rawResponse);
|
|
98
|
+
default:
|
|
99
|
+
throw new errors.PlanqkApiError({
|
|
100
|
+
statusCode: _response.error.statusCode,
|
|
101
|
+
body: _response.error.body,
|
|
102
|
+
rawResponse: _response.rawResponse,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
switch (_response.error.reason) {
|
|
108
|
+
case "non-json":
|
|
109
|
+
throw new errors.PlanqkApiError({
|
|
110
|
+
statusCode: _response.error.statusCode,
|
|
111
|
+
body: _response.error.rawBody,
|
|
112
|
+
rawResponse: _response.rawResponse,
|
|
113
|
+
});
|
|
114
|
+
case "timeout":
|
|
115
|
+
throw new errors.PlanqkApiTimeoutError("Timeout exceeded when calling GET /datapools/{id}.");
|
|
116
|
+
case "unknown":
|
|
117
|
+
throw new errors.PlanqkApiError({
|
|
118
|
+
message: _response.error.errorMessage,
|
|
119
|
+
rawResponse: _response.rawResponse,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Update an existing data pool (identified by its ID).
|
|
126
|
+
*
|
|
127
|
+
* @param {string} id
|
|
128
|
+
* @param {PlanqkApi.UpdateDataPoolRequest} request
|
|
129
|
+
* @param {DataPools.RequestOptions} requestOptions - Request-specific configuration.
|
|
130
|
+
*
|
|
131
|
+
* @throws {@link PlanqkApi.BadRequestError}
|
|
132
|
+
* @throws {@link PlanqkApi.UnauthorizedError}
|
|
133
|
+
* @throws {@link PlanqkApi.ForbiddenError}
|
|
134
|
+
* @throws {@link PlanqkApi.NotFoundError}
|
|
135
|
+
* @throws {@link PlanqkApi.InternalServerError}
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* await client.dataPools.updateDataPool("id")
|
|
139
|
+
*/
|
|
140
|
+
public updateDataPool(
|
|
141
|
+
id: string,
|
|
142
|
+
request: PlanqkApi.UpdateDataPoolRequest = {},
|
|
143
|
+
requestOptions?: DataPools.RequestOptions,
|
|
144
|
+
): core.HttpResponsePromise<PlanqkApi.DataPoolDto> {
|
|
145
|
+
return core.HttpResponsePromise.fromPromise(this.__updateDataPool(id, request, requestOptions));
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
private async __updateDataPool(
|
|
149
|
+
id: string,
|
|
150
|
+
request: PlanqkApi.UpdateDataPoolRequest = {},
|
|
151
|
+
requestOptions?: DataPools.RequestOptions,
|
|
152
|
+
): Promise<core.WithRawResponse<PlanqkApi.DataPoolDto>> {
|
|
153
|
+
const _response = await core.fetcher({
|
|
154
|
+
url: core.url.join(
|
|
155
|
+
(await core.Supplier.get(this._options.baseUrl)) ??
|
|
156
|
+
(await core.Supplier.get(this._options.environment)) ??
|
|
157
|
+
environments.PlanqkApiEnvironment.Default,
|
|
158
|
+
`datapools/${encodeURIComponent(id)}`,
|
|
159
|
+
),
|
|
160
|
+
method: "PUT",
|
|
161
|
+
headers: mergeHeaders(
|
|
162
|
+
this._options?.headers,
|
|
163
|
+
mergeOnlyDefinedHeaders({ ...(await this._getCustomAuthorizationHeaders()) }),
|
|
164
|
+
requestOptions?.headers,
|
|
165
|
+
),
|
|
166
|
+
contentType: "application/json",
|
|
167
|
+
requestType: "json",
|
|
168
|
+
body: request,
|
|
169
|
+
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
170
|
+
maxRetries: requestOptions?.maxRetries,
|
|
171
|
+
withCredentials: true,
|
|
172
|
+
abortSignal: requestOptions?.abortSignal,
|
|
173
|
+
});
|
|
174
|
+
if (_response.ok) {
|
|
175
|
+
return { data: _response.body as PlanqkApi.DataPoolDto, rawResponse: _response.rawResponse };
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if (_response.error.reason === "status-code") {
|
|
179
|
+
switch (_response.error.statusCode) {
|
|
180
|
+
case 400:
|
|
181
|
+
throw new PlanqkApi.BadRequestError(_response.error.body as any, _response.rawResponse);
|
|
182
|
+
case 401:
|
|
183
|
+
throw new PlanqkApi.UnauthorizedError(_response.error.body as any, _response.rawResponse);
|
|
184
|
+
case 403:
|
|
185
|
+
throw new PlanqkApi.ForbiddenError(_response.error.body as any, _response.rawResponse);
|
|
186
|
+
case 404:
|
|
187
|
+
throw new PlanqkApi.NotFoundError(_response.error.body as any, _response.rawResponse);
|
|
188
|
+
case 500:
|
|
189
|
+
throw new PlanqkApi.InternalServerError(_response.error.body as any, _response.rawResponse);
|
|
190
|
+
default:
|
|
191
|
+
throw new errors.PlanqkApiError({
|
|
192
|
+
statusCode: _response.error.statusCode,
|
|
193
|
+
body: _response.error.body,
|
|
194
|
+
rawResponse: _response.rawResponse,
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
switch (_response.error.reason) {
|
|
200
|
+
case "non-json":
|
|
201
|
+
throw new errors.PlanqkApiError({
|
|
202
|
+
statusCode: _response.error.statusCode,
|
|
203
|
+
body: _response.error.rawBody,
|
|
204
|
+
rawResponse: _response.rawResponse,
|
|
205
|
+
});
|
|
206
|
+
case "timeout":
|
|
207
|
+
throw new errors.PlanqkApiTimeoutError("Timeout exceeded when calling PUT /datapools/{id}.");
|
|
208
|
+
case "unknown":
|
|
209
|
+
throw new errors.PlanqkApiError({
|
|
210
|
+
message: _response.error.errorMessage,
|
|
211
|
+
rawResponse: _response.rawResponse,
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Delete a specific data pool (identified by its ID).
|
|
218
|
+
*
|
|
219
|
+
* @param {string} id
|
|
220
|
+
* @param {DataPools.RequestOptions} requestOptions - Request-specific configuration.
|
|
221
|
+
*
|
|
222
|
+
* @throws {@link PlanqkApi.UnauthorizedError}
|
|
223
|
+
* @throws {@link PlanqkApi.ForbiddenError}
|
|
224
|
+
* @throws {@link PlanqkApi.NotFoundError}
|
|
225
|
+
* @throws {@link PlanqkApi.InternalServerError}
|
|
226
|
+
*
|
|
227
|
+
* @example
|
|
228
|
+
* await client.dataPools.deleteDataPool("id")
|
|
229
|
+
*/
|
|
230
|
+
public deleteDataPool(id: string, requestOptions?: DataPools.RequestOptions): core.HttpResponsePromise<void> {
|
|
231
|
+
return core.HttpResponsePromise.fromPromise(this.__deleteDataPool(id, requestOptions));
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
private async __deleteDataPool(
|
|
235
|
+
id: string,
|
|
236
|
+
requestOptions?: DataPools.RequestOptions,
|
|
237
|
+
): Promise<core.WithRawResponse<void>> {
|
|
238
|
+
const _response = await core.fetcher({
|
|
239
|
+
url: core.url.join(
|
|
240
|
+
(await core.Supplier.get(this._options.baseUrl)) ??
|
|
241
|
+
(await core.Supplier.get(this._options.environment)) ??
|
|
242
|
+
environments.PlanqkApiEnvironment.Default,
|
|
243
|
+
`datapools/${encodeURIComponent(id)}`,
|
|
244
|
+
),
|
|
245
|
+
method: "DELETE",
|
|
246
|
+
headers: mergeHeaders(
|
|
247
|
+
this._options?.headers,
|
|
248
|
+
mergeOnlyDefinedHeaders({ ...(await this._getCustomAuthorizationHeaders()) }),
|
|
249
|
+
requestOptions?.headers,
|
|
250
|
+
),
|
|
251
|
+
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
252
|
+
maxRetries: requestOptions?.maxRetries,
|
|
253
|
+
withCredentials: true,
|
|
254
|
+
abortSignal: requestOptions?.abortSignal,
|
|
255
|
+
});
|
|
256
|
+
if (_response.ok) {
|
|
257
|
+
return { data: undefined, rawResponse: _response.rawResponse };
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
if (_response.error.reason === "status-code") {
|
|
261
|
+
switch (_response.error.statusCode) {
|
|
262
|
+
case 401:
|
|
263
|
+
throw new PlanqkApi.UnauthorizedError(_response.error.body as any, _response.rawResponse);
|
|
264
|
+
case 403:
|
|
265
|
+
throw new PlanqkApi.ForbiddenError(_response.error.body as any, _response.rawResponse);
|
|
266
|
+
case 404:
|
|
267
|
+
throw new PlanqkApi.NotFoundError(_response.error.body as any, _response.rawResponse);
|
|
268
|
+
case 500:
|
|
269
|
+
throw new PlanqkApi.InternalServerError(_response.error.body as any, _response.rawResponse);
|
|
270
|
+
default:
|
|
271
|
+
throw new errors.PlanqkApiError({
|
|
272
|
+
statusCode: _response.error.statusCode,
|
|
273
|
+
body: _response.error.body,
|
|
274
|
+
rawResponse: _response.rawResponse,
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
switch (_response.error.reason) {
|
|
280
|
+
case "non-json":
|
|
281
|
+
throw new errors.PlanqkApiError({
|
|
282
|
+
statusCode: _response.error.statusCode,
|
|
283
|
+
body: _response.error.rawBody,
|
|
284
|
+
rawResponse: _response.rawResponse,
|
|
285
|
+
});
|
|
286
|
+
case "timeout":
|
|
287
|
+
throw new errors.PlanqkApiTimeoutError("Timeout exceeded when calling DELETE /datapools/{id}.");
|
|
288
|
+
case "unknown":
|
|
289
|
+
throw new errors.PlanqkApiError({
|
|
290
|
+
message: _response.error.errorMessage,
|
|
291
|
+
rawResponse: _response.rawResponse,
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Get a list of all data pools for the current user.
|
|
298
|
+
*
|
|
299
|
+
* @param {DataPools.RequestOptions} requestOptions - Request-specific configuration.
|
|
300
|
+
*
|
|
301
|
+
* @throws {@link PlanqkApi.UnauthorizedError}
|
|
302
|
+
* @throws {@link PlanqkApi.ForbiddenError}
|
|
303
|
+
* @throws {@link PlanqkApi.NotFoundError}
|
|
304
|
+
* @throws {@link PlanqkApi.InternalServerError}
|
|
305
|
+
*
|
|
306
|
+
* @example
|
|
307
|
+
* await client.dataPools.getDataPools()
|
|
308
|
+
*/
|
|
309
|
+
public getDataPools(requestOptions?: DataPools.RequestOptions): core.HttpResponsePromise<PlanqkApi.DataPoolDto[]> {
|
|
310
|
+
return core.HttpResponsePromise.fromPromise(this.__getDataPools(requestOptions));
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
private async __getDataPools(
|
|
314
|
+
requestOptions?: DataPools.RequestOptions,
|
|
315
|
+
): Promise<core.WithRawResponse<PlanqkApi.DataPoolDto[]>> {
|
|
316
|
+
const _response = await core.fetcher({
|
|
317
|
+
url: core.url.join(
|
|
318
|
+
(await core.Supplier.get(this._options.baseUrl)) ??
|
|
319
|
+
(await core.Supplier.get(this._options.environment)) ??
|
|
320
|
+
environments.PlanqkApiEnvironment.Default,
|
|
321
|
+
"datapools",
|
|
322
|
+
),
|
|
323
|
+
method: "GET",
|
|
324
|
+
headers: mergeHeaders(
|
|
325
|
+
this._options?.headers,
|
|
326
|
+
mergeOnlyDefinedHeaders({ ...(await this._getCustomAuthorizationHeaders()) }),
|
|
327
|
+
requestOptions?.headers,
|
|
328
|
+
),
|
|
329
|
+
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
330
|
+
maxRetries: requestOptions?.maxRetries,
|
|
331
|
+
withCredentials: true,
|
|
332
|
+
abortSignal: requestOptions?.abortSignal,
|
|
333
|
+
});
|
|
334
|
+
if (_response.ok) {
|
|
335
|
+
return { data: _response.body as PlanqkApi.DataPoolDto[], rawResponse: _response.rawResponse };
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
if (_response.error.reason === "status-code") {
|
|
339
|
+
switch (_response.error.statusCode) {
|
|
340
|
+
case 401:
|
|
341
|
+
throw new PlanqkApi.UnauthorizedError(_response.error.body as any, _response.rawResponse);
|
|
342
|
+
case 403:
|
|
343
|
+
throw new PlanqkApi.ForbiddenError(_response.error.body as any, _response.rawResponse);
|
|
344
|
+
case 404:
|
|
345
|
+
throw new PlanqkApi.NotFoundError(_response.error.body as any, _response.rawResponse);
|
|
346
|
+
case 500:
|
|
347
|
+
throw new PlanqkApi.InternalServerError(_response.error.body as any, _response.rawResponse);
|
|
348
|
+
default:
|
|
349
|
+
throw new errors.PlanqkApiError({
|
|
350
|
+
statusCode: _response.error.statusCode,
|
|
351
|
+
body: _response.error.body,
|
|
352
|
+
rawResponse: _response.rawResponse,
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
switch (_response.error.reason) {
|
|
358
|
+
case "non-json":
|
|
359
|
+
throw new errors.PlanqkApiError({
|
|
360
|
+
statusCode: _response.error.statusCode,
|
|
361
|
+
body: _response.error.rawBody,
|
|
362
|
+
rawResponse: _response.rawResponse,
|
|
363
|
+
});
|
|
364
|
+
case "timeout":
|
|
365
|
+
throw new errors.PlanqkApiTimeoutError("Timeout exceeded when calling GET /datapools.");
|
|
366
|
+
case "unknown":
|
|
367
|
+
throw new errors.PlanqkApiError({
|
|
368
|
+
message: _response.error.errorMessage,
|
|
369
|
+
rawResponse: _response.rawResponse,
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* Create a new data pool.
|
|
376
|
+
*
|
|
377
|
+
* @param {PlanqkApi.CreateDataPoolRequest} request
|
|
378
|
+
* @param {DataPools.RequestOptions} requestOptions - Request-specific configuration.
|
|
379
|
+
*
|
|
380
|
+
* @throws {@link PlanqkApi.BadRequestError}
|
|
381
|
+
* @throws {@link PlanqkApi.UnauthorizedError}
|
|
382
|
+
* @throws {@link PlanqkApi.ForbiddenError}
|
|
383
|
+
* @throws {@link PlanqkApi.NotFoundError}
|
|
384
|
+
* @throws {@link PlanqkApi.InternalServerError}
|
|
385
|
+
*
|
|
386
|
+
* @example
|
|
387
|
+
* await client.dataPools.createDataPool()
|
|
388
|
+
*/
|
|
389
|
+
public createDataPool(
|
|
390
|
+
request: PlanqkApi.CreateDataPoolRequest = {},
|
|
391
|
+
requestOptions?: DataPools.RequestOptions,
|
|
392
|
+
): core.HttpResponsePromise<PlanqkApi.DataPoolDto> {
|
|
393
|
+
return core.HttpResponsePromise.fromPromise(this.__createDataPool(request, requestOptions));
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
private async __createDataPool(
|
|
397
|
+
request: PlanqkApi.CreateDataPoolRequest = {},
|
|
398
|
+
requestOptions?: DataPools.RequestOptions,
|
|
399
|
+
): Promise<core.WithRawResponse<PlanqkApi.DataPoolDto>> {
|
|
400
|
+
const _response = await core.fetcher({
|
|
401
|
+
url: core.url.join(
|
|
402
|
+
(await core.Supplier.get(this._options.baseUrl)) ??
|
|
403
|
+
(await core.Supplier.get(this._options.environment)) ??
|
|
404
|
+
environments.PlanqkApiEnvironment.Default,
|
|
405
|
+
"datapools",
|
|
406
|
+
),
|
|
407
|
+
method: "POST",
|
|
408
|
+
headers: mergeHeaders(
|
|
409
|
+
this._options?.headers,
|
|
410
|
+
mergeOnlyDefinedHeaders({ ...(await this._getCustomAuthorizationHeaders()) }),
|
|
411
|
+
requestOptions?.headers,
|
|
412
|
+
),
|
|
413
|
+
contentType: "application/json",
|
|
414
|
+
requestType: "json",
|
|
415
|
+
body: request,
|
|
416
|
+
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
417
|
+
maxRetries: requestOptions?.maxRetries,
|
|
418
|
+
withCredentials: true,
|
|
419
|
+
abortSignal: requestOptions?.abortSignal,
|
|
420
|
+
});
|
|
421
|
+
if (_response.ok) {
|
|
422
|
+
return { data: _response.body as PlanqkApi.DataPoolDto, rawResponse: _response.rawResponse };
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
if (_response.error.reason === "status-code") {
|
|
426
|
+
switch (_response.error.statusCode) {
|
|
427
|
+
case 400:
|
|
428
|
+
throw new PlanqkApi.BadRequestError(_response.error.body as any, _response.rawResponse);
|
|
429
|
+
case 401:
|
|
430
|
+
throw new PlanqkApi.UnauthorizedError(_response.error.body as any, _response.rawResponse);
|
|
431
|
+
case 403:
|
|
432
|
+
throw new PlanqkApi.ForbiddenError(_response.error.body as any, _response.rawResponse);
|
|
433
|
+
case 404:
|
|
434
|
+
throw new PlanqkApi.NotFoundError(_response.error.body as any, _response.rawResponse);
|
|
435
|
+
case 500:
|
|
436
|
+
throw new PlanqkApi.InternalServerError(_response.error.body as any, _response.rawResponse);
|
|
437
|
+
default:
|
|
438
|
+
throw new errors.PlanqkApiError({
|
|
439
|
+
statusCode: _response.error.statusCode,
|
|
440
|
+
body: _response.error.body,
|
|
441
|
+
rawResponse: _response.rawResponse,
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
switch (_response.error.reason) {
|
|
447
|
+
case "non-json":
|
|
448
|
+
throw new errors.PlanqkApiError({
|
|
449
|
+
statusCode: _response.error.statusCode,
|
|
450
|
+
body: _response.error.rawBody,
|
|
451
|
+
rawResponse: _response.rawResponse,
|
|
452
|
+
});
|
|
453
|
+
case "timeout":
|
|
454
|
+
throw new errors.PlanqkApiTimeoutError("Timeout exceeded when calling POST /datapools.");
|
|
455
|
+
case "unknown":
|
|
456
|
+
throw new errors.PlanqkApiError({
|
|
457
|
+
message: _response.error.errorMessage,
|
|
458
|
+
rawResponse: _response.rawResponse,
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
/**
|
|
464
|
+
* Get all files associated with a specific data pool (identified by its ID).
|
|
465
|
+
*
|
|
466
|
+
* @param {string} id
|
|
467
|
+
* @param {DataPools.RequestOptions} requestOptions - Request-specific configuration.
|
|
468
|
+
*
|
|
469
|
+
* @throws {@link PlanqkApi.UnauthorizedError}
|
|
470
|
+
* @throws {@link PlanqkApi.ForbiddenError}
|
|
471
|
+
* @throws {@link PlanqkApi.NotFoundError}
|
|
472
|
+
* @throws {@link PlanqkApi.InternalServerError}
|
|
473
|
+
*
|
|
474
|
+
* @example
|
|
475
|
+
* await client.dataPools.getDataPoolFiles("id")
|
|
476
|
+
*/
|
|
477
|
+
public getDataPoolFiles(
|
|
478
|
+
id: string,
|
|
479
|
+
requestOptions?: DataPools.RequestOptions,
|
|
480
|
+
): core.HttpResponsePromise<PlanqkApi.DataPoolFileDto[]> {
|
|
481
|
+
return core.HttpResponsePromise.fromPromise(this.__getDataPoolFiles(id, requestOptions));
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
private async __getDataPoolFiles(
|
|
485
|
+
id: string,
|
|
486
|
+
requestOptions?: DataPools.RequestOptions,
|
|
487
|
+
): Promise<core.WithRawResponse<PlanqkApi.DataPoolFileDto[]>> {
|
|
488
|
+
const _response = await core.fetcher({
|
|
489
|
+
url: core.url.join(
|
|
490
|
+
(await core.Supplier.get(this._options.baseUrl)) ??
|
|
491
|
+
(await core.Supplier.get(this._options.environment)) ??
|
|
492
|
+
environments.PlanqkApiEnvironment.Default,
|
|
493
|
+
`datapools/${encodeURIComponent(id)}/files`,
|
|
494
|
+
),
|
|
495
|
+
method: "GET",
|
|
496
|
+
headers: mergeHeaders(
|
|
497
|
+
this._options?.headers,
|
|
498
|
+
mergeOnlyDefinedHeaders({ ...(await this._getCustomAuthorizationHeaders()) }),
|
|
499
|
+
requestOptions?.headers,
|
|
500
|
+
),
|
|
501
|
+
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
502
|
+
maxRetries: requestOptions?.maxRetries,
|
|
503
|
+
withCredentials: true,
|
|
504
|
+
abortSignal: requestOptions?.abortSignal,
|
|
505
|
+
});
|
|
506
|
+
if (_response.ok) {
|
|
507
|
+
return { data: _response.body as PlanqkApi.DataPoolFileDto[], rawResponse: _response.rawResponse };
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
if (_response.error.reason === "status-code") {
|
|
511
|
+
switch (_response.error.statusCode) {
|
|
512
|
+
case 401:
|
|
513
|
+
throw new PlanqkApi.UnauthorizedError(_response.error.body as any, _response.rawResponse);
|
|
514
|
+
case 403:
|
|
515
|
+
throw new PlanqkApi.ForbiddenError(_response.error.body as any, _response.rawResponse);
|
|
516
|
+
case 404:
|
|
517
|
+
throw new PlanqkApi.NotFoundError(_response.error.body as any, _response.rawResponse);
|
|
518
|
+
case 500:
|
|
519
|
+
throw new PlanqkApi.InternalServerError(_response.error.body as any, _response.rawResponse);
|
|
520
|
+
default:
|
|
521
|
+
throw new errors.PlanqkApiError({
|
|
522
|
+
statusCode: _response.error.statusCode,
|
|
523
|
+
body: _response.error.body,
|
|
524
|
+
rawResponse: _response.rawResponse,
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
switch (_response.error.reason) {
|
|
530
|
+
case "non-json":
|
|
531
|
+
throw new errors.PlanqkApiError({
|
|
532
|
+
statusCode: _response.error.statusCode,
|
|
533
|
+
body: _response.error.rawBody,
|
|
534
|
+
rawResponse: _response.rawResponse,
|
|
535
|
+
});
|
|
536
|
+
case "timeout":
|
|
537
|
+
throw new errors.PlanqkApiTimeoutError("Timeout exceeded when calling GET /datapools/{id}/files.");
|
|
538
|
+
case "unknown":
|
|
539
|
+
throw new errors.PlanqkApiError({
|
|
540
|
+
message: _response.error.errorMessage,
|
|
541
|
+
rawResponse: _response.rawResponse,
|
|
542
|
+
});
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
/**
|
|
547
|
+
* Add a new file to a specific data pool (identified by its ID).
|
|
548
|
+
*
|
|
549
|
+
* @param {string} id
|
|
550
|
+
* @param {PlanqkApi.AddDataPoolFileRequest} request
|
|
551
|
+
* @param {DataPools.RequestOptions} requestOptions - Request-specific configuration.
|
|
552
|
+
*
|
|
553
|
+
* @throws {@link PlanqkApi.BadRequestError}
|
|
554
|
+
* @throws {@link PlanqkApi.UnauthorizedError}
|
|
555
|
+
* @throws {@link PlanqkApi.ForbiddenError}
|
|
556
|
+
* @throws {@link PlanqkApi.NotFoundError}
|
|
557
|
+
* @throws {@link PlanqkApi.InternalServerError}
|
|
558
|
+
*
|
|
559
|
+
* @example
|
|
560
|
+
* await client.dataPools.addDataPoolFile("id", {
|
|
561
|
+
* file: fs.createReadStream("/path/to/your/file")
|
|
562
|
+
* })
|
|
563
|
+
*/
|
|
564
|
+
public addDataPoolFile(
|
|
565
|
+
id: string,
|
|
566
|
+
request: PlanqkApi.AddDataPoolFileRequest,
|
|
567
|
+
requestOptions?: DataPools.RequestOptions,
|
|
568
|
+
): core.HttpResponsePromise<PlanqkApi.DataPoolFileDto> {
|
|
569
|
+
return core.HttpResponsePromise.fromPromise(this.__addDataPoolFile(id, request, requestOptions));
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
private async __addDataPoolFile(
|
|
573
|
+
id: string,
|
|
574
|
+
request: PlanqkApi.AddDataPoolFileRequest,
|
|
575
|
+
requestOptions?: DataPools.RequestOptions,
|
|
576
|
+
): Promise<core.WithRawResponse<PlanqkApi.DataPoolFileDto>> {
|
|
577
|
+
const _queryParams: Record<string, string | string[] | object | object[] | null> = {};
|
|
578
|
+
if (request.filename != null) {
|
|
579
|
+
_queryParams["filename"] = request.filename;
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
const _request = await core.newFormData();
|
|
583
|
+
await _request.appendFile("file", request.file);
|
|
584
|
+
const _maybeEncodedRequest = await _request.getRequest();
|
|
585
|
+
const _response = await core.fetcher({
|
|
586
|
+
url: core.url.join(
|
|
587
|
+
(await core.Supplier.get(this._options.baseUrl)) ??
|
|
588
|
+
(await core.Supplier.get(this._options.environment)) ??
|
|
589
|
+
environments.PlanqkApiEnvironment.Default,
|
|
590
|
+
`datapools/${encodeURIComponent(id)}/files`,
|
|
591
|
+
),
|
|
592
|
+
method: "POST",
|
|
593
|
+
headers: mergeHeaders(
|
|
594
|
+
this._options?.headers,
|
|
595
|
+
mergeOnlyDefinedHeaders({
|
|
596
|
+
...(await this._getCustomAuthorizationHeaders()),
|
|
597
|
+
..._maybeEncodedRequest.headers,
|
|
598
|
+
}),
|
|
599
|
+
requestOptions?.headers,
|
|
600
|
+
),
|
|
601
|
+
queryParameters: _queryParams,
|
|
602
|
+
requestType: "file",
|
|
603
|
+
duplex: _maybeEncodedRequest.duplex,
|
|
604
|
+
body: _maybeEncodedRequest.body,
|
|
605
|
+
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
606
|
+
maxRetries: requestOptions?.maxRetries,
|
|
607
|
+
withCredentials: true,
|
|
608
|
+
abortSignal: requestOptions?.abortSignal,
|
|
609
|
+
});
|
|
610
|
+
if (_response.ok) {
|
|
611
|
+
return { data: _response.body as PlanqkApi.DataPoolFileDto, rawResponse: _response.rawResponse };
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
if (_response.error.reason === "status-code") {
|
|
615
|
+
switch (_response.error.statusCode) {
|
|
616
|
+
case 400:
|
|
617
|
+
throw new PlanqkApi.BadRequestError(_response.error.body as any, _response.rawResponse);
|
|
618
|
+
case 401:
|
|
619
|
+
throw new PlanqkApi.UnauthorizedError(_response.error.body as any, _response.rawResponse);
|
|
620
|
+
case 403:
|
|
621
|
+
throw new PlanqkApi.ForbiddenError(_response.error.body as any, _response.rawResponse);
|
|
622
|
+
case 404:
|
|
623
|
+
throw new PlanqkApi.NotFoundError(_response.error.body as any, _response.rawResponse);
|
|
624
|
+
case 500:
|
|
625
|
+
throw new PlanqkApi.InternalServerError(_response.error.body as any, _response.rawResponse);
|
|
626
|
+
default:
|
|
627
|
+
throw new errors.PlanqkApiError({
|
|
628
|
+
statusCode: _response.error.statusCode,
|
|
629
|
+
body: _response.error.body,
|
|
630
|
+
rawResponse: _response.rawResponse,
|
|
631
|
+
});
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
switch (_response.error.reason) {
|
|
636
|
+
case "non-json":
|
|
637
|
+
throw new errors.PlanqkApiError({
|
|
638
|
+
statusCode: _response.error.statusCode,
|
|
639
|
+
body: _response.error.rawBody,
|
|
640
|
+
rawResponse: _response.rawResponse,
|
|
641
|
+
});
|
|
642
|
+
case "timeout":
|
|
643
|
+
throw new errors.PlanqkApiTimeoutError("Timeout exceeded when calling POST /datapools/{id}/files.");
|
|
644
|
+
case "unknown":
|
|
645
|
+
throw new errors.PlanqkApiError({
|
|
646
|
+
message: _response.error.errorMessage,
|
|
647
|
+
rawResponse: _response.rawResponse,
|
|
648
|
+
});
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
/**
|
|
653
|
+
* Get the content of a specific file from a data pool (both file and data pool identified by their ID).
|
|
654
|
+
* @throws {@link PlanqkApi.UnauthorizedError}
|
|
655
|
+
* @throws {@link PlanqkApi.ForbiddenError}
|
|
656
|
+
* @throws {@link PlanqkApi.NotFoundError}
|
|
657
|
+
* @throws {@link PlanqkApi.InternalServerError}
|
|
658
|
+
*/
|
|
659
|
+
public getDataPoolFile(
|
|
660
|
+
id: string,
|
|
661
|
+
fileId: string,
|
|
662
|
+
requestOptions?: DataPools.RequestOptions,
|
|
663
|
+
): core.HttpResponsePromise<core.BinaryResponse> {
|
|
664
|
+
return core.HttpResponsePromise.fromPromise(this.__getDataPoolFile(id, fileId, requestOptions));
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
private async __getDataPoolFile(
|
|
668
|
+
id: string,
|
|
669
|
+
fileId: string,
|
|
670
|
+
requestOptions?: DataPools.RequestOptions,
|
|
671
|
+
): Promise<core.WithRawResponse<core.BinaryResponse>> {
|
|
672
|
+
const _response = await core.fetcher<core.BinaryResponse>({
|
|
673
|
+
url: core.url.join(
|
|
674
|
+
(await core.Supplier.get(this._options.baseUrl)) ??
|
|
675
|
+
(await core.Supplier.get(this._options.environment)) ??
|
|
676
|
+
environments.PlanqkApiEnvironment.Default,
|
|
677
|
+
`datapools/${encodeURIComponent(id)}/files/${encodeURIComponent(fileId)}`,
|
|
678
|
+
),
|
|
679
|
+
method: "GET",
|
|
680
|
+
headers: mergeHeaders(
|
|
681
|
+
this._options?.headers,
|
|
682
|
+
mergeOnlyDefinedHeaders({ ...(await this._getCustomAuthorizationHeaders()) }),
|
|
683
|
+
requestOptions?.headers,
|
|
684
|
+
),
|
|
685
|
+
responseType: "binary-response",
|
|
686
|
+
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
687
|
+
maxRetries: requestOptions?.maxRetries,
|
|
688
|
+
withCredentials: true,
|
|
689
|
+
abortSignal: requestOptions?.abortSignal,
|
|
690
|
+
});
|
|
691
|
+
if (_response.ok) {
|
|
692
|
+
return { data: _response.body, rawResponse: _response.rawResponse };
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
if (_response.error.reason === "status-code") {
|
|
696
|
+
switch (_response.error.statusCode) {
|
|
697
|
+
case 401:
|
|
698
|
+
throw new PlanqkApi.UnauthorizedError(_response.error.body as any, _response.rawResponse);
|
|
699
|
+
case 403:
|
|
700
|
+
throw new PlanqkApi.ForbiddenError(_response.error.body as any, _response.rawResponse);
|
|
701
|
+
case 404:
|
|
702
|
+
throw new PlanqkApi.NotFoundError(_response.error.body as any, _response.rawResponse);
|
|
703
|
+
case 500:
|
|
704
|
+
throw new PlanqkApi.InternalServerError(_response.error.body as any, _response.rawResponse);
|
|
705
|
+
default:
|
|
706
|
+
throw new errors.PlanqkApiError({
|
|
707
|
+
statusCode: _response.error.statusCode,
|
|
708
|
+
body: _response.error.body,
|
|
709
|
+
rawResponse: _response.rawResponse,
|
|
710
|
+
});
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
switch (_response.error.reason) {
|
|
715
|
+
case "non-json":
|
|
716
|
+
throw new errors.PlanqkApiError({
|
|
717
|
+
statusCode: _response.error.statusCode,
|
|
718
|
+
body: _response.error.rawBody,
|
|
719
|
+
rawResponse: _response.rawResponse,
|
|
720
|
+
});
|
|
721
|
+
case "timeout":
|
|
722
|
+
throw new errors.PlanqkApiTimeoutError(
|
|
723
|
+
"Timeout exceeded when calling GET /datapools/{id}/files/{fileId}.",
|
|
724
|
+
);
|
|
725
|
+
case "unknown":
|
|
726
|
+
throw new errors.PlanqkApiError({
|
|
727
|
+
message: _response.error.errorMessage,
|
|
728
|
+
rawResponse: _response.rawResponse,
|
|
729
|
+
});
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
/**
|
|
734
|
+
* Delete a specific file from a data pool (both file and data pool identified by their IDs).
|
|
735
|
+
*
|
|
736
|
+
* @param {string} id
|
|
737
|
+
* @param {string} fileId
|
|
738
|
+
* @param {DataPools.RequestOptions} requestOptions - Request-specific configuration.
|
|
739
|
+
*
|
|
740
|
+
* @throws {@link PlanqkApi.UnauthorizedError}
|
|
741
|
+
* @throws {@link PlanqkApi.ForbiddenError}
|
|
742
|
+
* @throws {@link PlanqkApi.NotFoundError}
|
|
743
|
+
* @throws {@link PlanqkApi.InternalServerError}
|
|
744
|
+
*
|
|
745
|
+
* @example
|
|
746
|
+
* await client.dataPools.deleteDataPoolFile("id", "fileId")
|
|
747
|
+
*/
|
|
748
|
+
public deleteDataPoolFile(
|
|
749
|
+
id: string,
|
|
750
|
+
fileId: string,
|
|
751
|
+
requestOptions?: DataPools.RequestOptions,
|
|
752
|
+
): core.HttpResponsePromise<void> {
|
|
753
|
+
return core.HttpResponsePromise.fromPromise(this.__deleteDataPoolFile(id, fileId, requestOptions));
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
private async __deleteDataPoolFile(
|
|
757
|
+
id: string,
|
|
758
|
+
fileId: string,
|
|
759
|
+
requestOptions?: DataPools.RequestOptions,
|
|
760
|
+
): Promise<core.WithRawResponse<void>> {
|
|
761
|
+
const _response = await core.fetcher({
|
|
762
|
+
url: core.url.join(
|
|
763
|
+
(await core.Supplier.get(this._options.baseUrl)) ??
|
|
764
|
+
(await core.Supplier.get(this._options.environment)) ??
|
|
765
|
+
environments.PlanqkApiEnvironment.Default,
|
|
766
|
+
`datapools/${encodeURIComponent(id)}/files/${encodeURIComponent(fileId)}`,
|
|
767
|
+
),
|
|
768
|
+
method: "DELETE",
|
|
769
|
+
headers: mergeHeaders(
|
|
770
|
+
this._options?.headers,
|
|
771
|
+
mergeOnlyDefinedHeaders({ ...(await this._getCustomAuthorizationHeaders()) }),
|
|
772
|
+
requestOptions?.headers,
|
|
773
|
+
),
|
|
774
|
+
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
775
|
+
maxRetries: requestOptions?.maxRetries,
|
|
776
|
+
withCredentials: true,
|
|
777
|
+
abortSignal: requestOptions?.abortSignal,
|
|
778
|
+
});
|
|
779
|
+
if (_response.ok) {
|
|
780
|
+
return { data: undefined, rawResponse: _response.rawResponse };
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
if (_response.error.reason === "status-code") {
|
|
784
|
+
switch (_response.error.statusCode) {
|
|
785
|
+
case 401:
|
|
786
|
+
throw new PlanqkApi.UnauthorizedError(_response.error.body as any, _response.rawResponse);
|
|
787
|
+
case 403:
|
|
788
|
+
throw new PlanqkApi.ForbiddenError(_response.error.body as any, _response.rawResponse);
|
|
789
|
+
case 404:
|
|
790
|
+
throw new PlanqkApi.NotFoundError(_response.error.body as any, _response.rawResponse);
|
|
791
|
+
case 500:
|
|
792
|
+
throw new PlanqkApi.InternalServerError(_response.error.body as any, _response.rawResponse);
|
|
793
|
+
default:
|
|
794
|
+
throw new errors.PlanqkApiError({
|
|
795
|
+
statusCode: _response.error.statusCode,
|
|
796
|
+
body: _response.error.body,
|
|
797
|
+
rawResponse: _response.rawResponse,
|
|
798
|
+
});
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
switch (_response.error.reason) {
|
|
803
|
+
case "non-json":
|
|
804
|
+
throw new errors.PlanqkApiError({
|
|
805
|
+
statusCode: _response.error.statusCode,
|
|
806
|
+
body: _response.error.rawBody,
|
|
807
|
+
rawResponse: _response.rawResponse,
|
|
808
|
+
});
|
|
809
|
+
case "timeout":
|
|
810
|
+
throw new errors.PlanqkApiTimeoutError(
|
|
811
|
+
"Timeout exceeded when calling DELETE /datapools/{id}/files/{fileId}.",
|
|
812
|
+
);
|
|
813
|
+
case "unknown":
|
|
814
|
+
throw new errors.PlanqkApiError({
|
|
815
|
+
message: _response.error.errorMessage,
|
|
816
|
+
rawResponse: _response.rawResponse,
|
|
817
|
+
});
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
protected async _getCustomAuthorizationHeaders() {
|
|
822
|
+
const apiKeyValue = await core.Supplier.get(this._options.apiKey);
|
|
823
|
+
return { "X-Auth-Token": apiKeyValue };
|
|
824
|
+
}
|
|
825
|
+
}
|