@planqk/planqk-service-sdk 2.1.1 → 2.2.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.
Files changed (173) hide show
  1. package/.gitlab-ci.yml +8 -39
  2. package/README-node.md +16 -12
  3. package/README.md +30 -41
  4. package/dist/sdk/Client.d.ts +10 -4
  5. package/dist/sdk/Client.js +46 -4
  6. package/dist/sdk/api/index.d.ts +2 -3
  7. package/dist/sdk/api/index.js +2 -3
  8. package/dist/sdk/api/resources/index.d.ts +2 -2
  9. package/dist/sdk/api/resources/index.js +2 -2
  10. package/dist/sdk/api/resources/serviceApi/client/Client.d.ts +41 -55
  11. package/dist/sdk/api/resources/serviceApi/client/Client.js +131 -227
  12. package/dist/sdk/api/resources/serviceApi/index.d.ts +2 -2
  13. package/dist/sdk/api/resources/serviceApi/index.js +2 -2
  14. package/dist/sdk/api/resources/serviceApi/types/GetResultResponse.d.ts +13 -3
  15. package/dist/sdk/api/resources/serviceApi/types/index.d.ts +1 -4
  16. package/dist/sdk/api/resources/serviceApi/types/index.js +1 -4
  17. package/dist/sdk/api/types/ServiceExecution.d.ts +12 -2
  18. package/dist/sdk/api/types/ServiceExecution.js +12 -0
  19. package/dist/sdk/api/types/index.d.ts +2 -6
  20. package/dist/sdk/api/types/index.js +2 -6
  21. package/dist/sdk/core/auth/BasicAuth.js +3 -3
  22. package/dist/sdk/core/auth/index.d.ts +2 -2
  23. package/dist/sdk/core/auth/index.js +4 -4
  24. package/dist/sdk/core/base64.d.ts +2 -0
  25. package/dist/sdk/core/base64.js +26 -0
  26. package/dist/sdk/core/fetcher/APIResponse.d.ts +10 -0
  27. package/dist/sdk/core/fetcher/BinaryResponse.d.ts +20 -0
  28. package/dist/sdk/core/fetcher/BinaryResponse.js +17 -0
  29. package/dist/sdk/core/fetcher/Fetcher.d.ts +5 -4
  30. package/dist/sdk/core/fetcher/Fetcher.js +41 -22
  31. package/dist/sdk/core/fetcher/Headers.d.ts +2 -0
  32. package/dist/sdk/core/fetcher/Headers.js +85 -0
  33. package/dist/sdk/core/fetcher/HttpResponsePromise.d.ts +58 -0
  34. package/dist/sdk/core/fetcher/HttpResponsePromise.js +94 -0
  35. package/dist/sdk/core/fetcher/RawResponse.d.ts +29 -0
  36. package/dist/sdk/core/fetcher/RawResponse.js +44 -0
  37. package/dist/sdk/core/fetcher/ResponseWithBody.d.ts +4 -0
  38. package/dist/sdk/core/fetcher/ResponseWithBody.js +6 -0
  39. package/dist/sdk/core/fetcher/createRequestUrl.d.ts +1 -1
  40. package/dist/sdk/core/fetcher/createRequestUrl.js +3 -7
  41. package/dist/sdk/core/fetcher/getErrorResponseBody.d.ts +1 -0
  42. package/dist/sdk/core/fetcher/getErrorResponseBody.js +32 -0
  43. package/dist/sdk/core/fetcher/getFetchFn.d.ts +1 -4
  44. package/dist/sdk/core/fetcher/getFetchFn.js +1 -52
  45. package/dist/sdk/core/fetcher/getRequestBody.js +2 -1
  46. package/dist/sdk/core/fetcher/getResponseBody.js +34 -30
  47. package/dist/sdk/core/fetcher/index.d.ts +9 -5
  48. package/dist/sdk/core/fetcher/index.js +13 -7
  49. package/dist/sdk/core/fetcher/makeRequest.js +3 -3
  50. package/dist/sdk/core/fetcher/requestWithRetries.js +14 -5
  51. package/dist/sdk/core/headers.d.ts +3 -0
  52. package/dist/sdk/core/headers.js +29 -0
  53. package/dist/sdk/core/index.d.ts +5 -3
  54. package/dist/sdk/core/index.js +28 -3
  55. package/dist/sdk/core/json.d.ts +15 -0
  56. package/dist/sdk/core/json.js +24 -0
  57. package/dist/sdk/core/runtime/index.d.ts +1 -1
  58. package/dist/sdk/core/runtime/index.js +2 -2
  59. package/dist/sdk/core/runtime/runtime.d.ts +1 -1
  60. package/dist/sdk/core/runtime/runtime.js +49 -40
  61. package/dist/sdk/core/url/index.d.ts +2 -0
  62. package/dist/sdk/core/url/index.js +7 -0
  63. package/dist/sdk/core/url/join.d.ts +1 -0
  64. package/dist/sdk/core/url/join.js +49 -0
  65. package/dist/sdk/core/url/qs.d.ts +6 -0
  66. package/dist/sdk/core/url/qs.js +67 -0
  67. package/dist/sdk/errors/PlanqkServiceApiError.d.ts +4 -1
  68. package/dist/sdk/errors/PlanqkServiceApiError.js +7 -8
  69. package/dist/sdk/errors/PlanqkServiceApiTimeoutError.d.ts +1 -1
  70. package/dist/sdk/errors/PlanqkServiceApiTimeoutError.js +2 -2
  71. package/dist/sdk/errors/index.d.ts +2 -2
  72. package/dist/sdk/errors/index.js +4 -4
  73. package/dist/sdk/index.d.ts +4 -4
  74. package/dist/sdk/index.js +9 -9
  75. package/fern/fern.config.json +1 -1
  76. package/fern/generators.yml +2 -2
  77. package/fern/openapi/openapi.yml +41 -131
  78. package/notebooks/python-sdk.ipynb +1 -1
  79. package/package.json +2 -3
  80. package/planqk/service/_version.py +1 -1
  81. package/pyproject.toml +1 -1
  82. package/src/index.test.ts +29 -16
  83. package/src/sdk/Client.ts +27 -7
  84. package/src/sdk/api/index.ts +2 -3
  85. package/src/sdk/api/resources/index.ts +2 -2
  86. package/src/sdk/api/resources/serviceApi/client/Client.ts +223 -250
  87. package/src/sdk/api/resources/serviceApi/index.ts +2 -2
  88. package/src/sdk/api/resources/serviceApi/types/GetResultResponse.ts +15 -3
  89. package/src/sdk/api/resources/serviceApi/types/index.ts +1 -4
  90. package/src/sdk/api/types/ServiceExecution.ts +13 -3
  91. package/src/sdk/api/types/index.ts +2 -6
  92. package/src/sdk/core/auth/BasicAuth.ts +3 -3
  93. package/src/sdk/core/auth/index.ts +2 -2
  94. package/src/sdk/core/base64.ts +27 -0
  95. package/src/sdk/core/fetcher/APIResponse.ts +11 -0
  96. package/src/sdk/core/fetcher/BinaryResponse.ts +36 -0
  97. package/src/sdk/core/fetcher/Fetcher.ts +46 -26
  98. package/src/sdk/core/fetcher/Headers.ts +93 -0
  99. package/src/sdk/core/fetcher/HttpResponsePromise.ts +116 -0
  100. package/src/sdk/core/fetcher/RawResponse.ts +61 -0
  101. package/src/sdk/core/fetcher/ResponseWithBody.ts +7 -0
  102. package/src/sdk/core/fetcher/createRequestUrl.ts +4 -8
  103. package/src/sdk/core/fetcher/getErrorResponseBody.ts +32 -0
  104. package/src/sdk/core/fetcher/getFetchFn.ts +2 -24
  105. package/src/sdk/core/fetcher/getRequestBody.ts +3 -1
  106. package/src/sdk/core/fetcher/getResponseBody.ts +38 -27
  107. package/src/sdk/core/fetcher/index.ts +9 -5
  108. package/src/sdk/core/fetcher/makeRequest.ts +2 -2
  109. package/src/sdk/core/fetcher/requestWithRetries.ts +18 -6
  110. package/src/sdk/core/fetcher/signals.ts +1 -1
  111. package/src/sdk/core/headers.ts +35 -0
  112. package/src/sdk/core/index.ts +5 -3
  113. package/src/sdk/core/json.ts +27 -0
  114. package/src/sdk/core/runtime/index.ts +1 -1
  115. package/src/sdk/core/runtime/runtime.ts +60 -53
  116. package/src/sdk/core/url/index.ts +2 -0
  117. package/src/sdk/core/url/join.ts +55 -0
  118. package/src/sdk/core/url/qs.ts +74 -0
  119. package/src/sdk/errors/PlanqkServiceApiError.ts +21 -11
  120. package/src/sdk/errors/PlanqkServiceApiTimeoutError.ts +2 -2
  121. package/src/sdk/errors/index.ts +2 -2
  122. package/src/sdk/index.ts +4 -4
  123. package/dist/sdk/api/errors/BadRequestError.d.ts +0 -7
  124. package/dist/sdk/api/errors/BadRequestError.js +0 -51
  125. package/dist/sdk/api/errors/ForbiddenError.d.ts +0 -7
  126. package/dist/sdk/api/errors/ForbiddenError.js +0 -51
  127. package/dist/sdk/api/errors/InternalServerError.d.ts +0 -7
  128. package/dist/sdk/api/errors/InternalServerError.js +0 -51
  129. package/dist/sdk/api/errors/NotFoundError.d.ts +0 -7
  130. package/dist/sdk/api/errors/NotFoundError.js +0 -51
  131. package/dist/sdk/api/errors/UnauthorizedError.d.ts +0 -7
  132. package/dist/sdk/api/errors/UnauthorizedError.js +0 -51
  133. package/dist/sdk/api/errors/index.d.ts +0 -5
  134. package/dist/sdk/api/errors/index.js +0 -21
  135. package/dist/sdk/api/resources/serviceApi/types/GetResultResponseEmbedded.d.ts +0 -7
  136. package/dist/sdk/api/resources/serviceApi/types/GetResultResponseEmbedded.js +0 -5
  137. package/dist/sdk/api/resources/serviceApi/types/GetResultResponseLinks.d.ts +0 -7
  138. package/dist/sdk/api/resources/serviceApi/types/GetResultResponseLinks.js +0 -5
  139. package/dist/sdk/api/resources/serviceApi/types/HealthCheckResponse.d.ts +0 -7
  140. package/dist/sdk/api/resources/serviceApi/types/HealthCheckResponse.js +0 -5
  141. package/dist/sdk/api/types/InputData.d.ts +0 -4
  142. package/dist/sdk/api/types/InputData.js +0 -5
  143. package/dist/sdk/api/types/InputDataRef.d.ts +0 -8
  144. package/dist/sdk/api/types/InputDataRef.js +0 -5
  145. package/dist/sdk/api/types/InputParams.d.ts +0 -4
  146. package/dist/sdk/api/types/InputParams.js +0 -5
  147. package/dist/sdk/api/types/ServiceExecutionStatus.d.ts +0 -12
  148. package/dist/sdk/api/types/ServiceExecutionStatus.js +0 -14
  149. package/dist/sdk/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.d.ts +0 -30
  150. package/dist/sdk/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.js +0 -232
  151. package/dist/sdk/core/fetcher/stream-wrappers/NodePre18StreamWrapper.d.ts +0 -21
  152. package/dist/sdk/core/fetcher/stream-wrappers/NodePre18StreamWrapper.js +0 -91
  153. package/dist/sdk/core/fetcher/stream-wrappers/UndiciStreamWrapper.d.ts +0 -31
  154. package/dist/sdk/core/fetcher/stream-wrappers/UndiciStreamWrapper.js +0 -214
  155. package/dist/sdk/core/fetcher/stream-wrappers/chooseStreamWrapper.d.ts +0 -18
  156. package/dist/sdk/core/fetcher/stream-wrappers/chooseStreamWrapper.js +0 -48
  157. package/src/sdk/api/errors/BadRequestError.ts +0 -16
  158. package/src/sdk/api/errors/ForbiddenError.ts +0 -16
  159. package/src/sdk/api/errors/InternalServerError.ts +0 -16
  160. package/src/sdk/api/errors/NotFoundError.ts +0 -16
  161. package/src/sdk/api/errors/UnauthorizedError.ts +0 -16
  162. package/src/sdk/api/errors/index.ts +0 -5
  163. package/src/sdk/api/resources/serviceApi/types/GetResultResponseEmbedded.ts +0 -9
  164. package/src/sdk/api/resources/serviceApi/types/GetResultResponseLinks.ts +0 -9
  165. package/src/sdk/api/resources/serviceApi/types/HealthCheckResponse.ts +0 -8
  166. package/src/sdk/api/types/InputData.ts +0 -5
  167. package/src/sdk/api/types/InputDataRef.ts +0 -9
  168. package/src/sdk/api/types/InputParams.ts +0 -5
  169. package/src/sdk/api/types/ServiceExecutionStatus.ts +0 -14
  170. package/src/sdk/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.ts +0 -252
  171. package/src/sdk/core/fetcher/stream-wrappers/NodePre18StreamWrapper.ts +0 -106
  172. package/src/sdk/core/fetcher/stream-wrappers/UndiciStreamWrapper.ts +0 -239
  173. package/src/sdk/core/fetcher/stream-wrappers/chooseStreamWrapper.ts +0 -33
@@ -2,69 +2,84 @@
2
2
  * This file was auto-generated by Fern from our API Definition.
3
3
  */
4
4
 
5
- import * as environments from "../../../../environments";
6
- import * as core from "../../../../core";
7
- import * as PlanqkServiceApi from "../../../index";
8
- import * as errors from "../../../../errors/index";
9
- import urlJoin from "url-join";
10
- import * as stream from "stream";
5
+ import * as environments from "../../../../environments.js";
6
+ import * as core from "../../../../core/index.js";
7
+ import * as PlanqkServiceApi from "../../../index.js";
8
+ import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js";
9
+ import * as errors from "../../../../errors/index.js";
11
10
 
12
11
  export declare namespace ServiceApi {
13
- interface Options {
12
+ export interface Options {
14
13
  environment?: core.Supplier<environments.PlanqkServiceApiEnvironment | string>;
14
+ /** Specify a custom URL to connect the client to. */
15
+ baseUrl?: core.Supplier<string>;
15
16
  token: core.Supplier<core.BearerToken>;
17
+ /** Additional headers to include in requests. */
18
+ headers?: Record<string, string | core.Supplier<string | undefined> | undefined>;
16
19
  }
17
20
 
18
- interface RequestOptions {
21
+ export interface RequestOptions {
19
22
  /** The maximum time to wait for a response in seconds. */
20
23
  timeoutInSeconds?: number;
21
24
  /** The number of times to retry the request. Defaults to 2. */
22
25
  maxRetries?: number;
23
26
  /** A hook to abort the request. */
24
27
  abortSignal?: AbortSignal;
28
+ /** Additional headers to include in the request. */
29
+ headers?: Record<string, string | core.Supplier<string | undefined> | undefined>;
25
30
  }
26
31
  }
27
32
 
28
33
  export class ServiceApi {
29
- constructor(protected readonly _options: ServiceApi.Options) {}
34
+ protected readonly _options: ServiceApi.Options;
35
+
36
+ constructor(_options: ServiceApi.Options) {
37
+ this._options = _options;
38
+ }
30
39
 
31
40
  /**
32
- * This method checks the health of the service.
41
+ * Retrieves a list of all service executions.
42
+ * The response includes links to each service execution, allowing for further queries on their status and results.
33
43
  *
34
44
  * @param {ServiceApi.RequestOptions} requestOptions - Request-specific configuration.
35
45
  *
36
46
  * @example
37
- * await client.serviceApi.healthCheck()
47
+ * await client.serviceApi.getServiceExecutions()
38
48
  */
39
- public async healthCheck(
40
- requestOptions?: ServiceApi.RequestOptions
41
- ): Promise<PlanqkServiceApi.HealthCheckResponse> {
49
+ public getServiceExecutions(
50
+ requestOptions?: ServiceApi.RequestOptions,
51
+ ): core.HttpResponsePromise<PlanqkServiceApi.ServiceExecution[]> {
52
+ return core.HttpResponsePromise.fromPromise(this.__getServiceExecutions(requestOptions));
53
+ }
54
+
55
+ private async __getServiceExecutions(
56
+ requestOptions?: ServiceApi.RequestOptions,
57
+ ): Promise<core.WithRawResponse<PlanqkServiceApi.ServiceExecution[]>> {
42
58
  const _response = await core.fetcher({
43
59
  url:
60
+ (await core.Supplier.get(this._options.baseUrl)) ??
44
61
  (await core.Supplier.get(this._options.environment)) ??
45
62
  environments.PlanqkServiceApiEnvironment.Default,
46
63
  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",
64
+ headers: mergeHeaders(
65
+ this._options?.headers,
66
+ mergeOnlyDefinedHeaders({ Authorization: await this._getAuthorizationHeader() }),
67
+ requestOptions?.headers,
68
+ ),
55
69
  timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
56
70
  maxRetries: requestOptions?.maxRetries,
57
71
  withCredentials: true,
58
72
  abortSignal: requestOptions?.abortSignal,
59
73
  });
60
74
  if (_response.ok) {
61
- return _response.body as PlanqkServiceApi.HealthCheckResponse;
75
+ return { data: _response.body as PlanqkServiceApi.ServiceExecution[], rawResponse: _response.rawResponse };
62
76
  }
63
77
 
64
78
  if (_response.error.reason === "status-code") {
65
79
  throw new errors.PlanqkServiceApiError({
66
80
  statusCode: _response.error.statusCode,
67
81
  body: _response.error.body,
82
+ rawResponse: _response.rawResponse,
68
83
  });
69
84
  }
70
85
 
@@ -73,51 +88,52 @@ export class ServiceApi {
73
88
  throw new errors.PlanqkServiceApiError({
74
89
  statusCode: _response.error.statusCode,
75
90
  body: _response.error.rawBody,
91
+ rawResponse: _response.rawResponse,
76
92
  });
77
93
  case "timeout":
78
- throw new errors.PlanqkServiceApiTimeoutError();
94
+ throw new errors.PlanqkServiceApiTimeoutError("Timeout exceeded when calling GET /.");
79
95
  case "unknown":
80
96
  throw new errors.PlanqkServiceApiError({
81
97
  message: _response.error.errorMessage,
98
+ rawResponse: _response.rawResponse,
82
99
  });
83
100
  }
84
101
  }
85
102
 
86
103
  /**
87
- * This method starts a service execution, which in turn is processed asynchronously by PLANQK.
104
+ * Starts a service execution, which in turn is processed asynchronously.
88
105
  * 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
106
  *
90
- * @param {Record<string, Record<string, any>>} request
107
+ * @param {Record<string, any>} request
91
108
  * @param {ServiceApi.RequestOptions} requestOptions - Request-specific configuration.
92
109
  *
93
- * @throws {@link PlanqkServiceApi.BadRequestError}
94
- * @throws {@link PlanqkServiceApi.UnauthorizedError}
95
- * @throws {@link PlanqkServiceApi.ForbiddenError}
96
- * @throws {@link PlanqkServiceApi.NotFoundError}
97
- * @throws {@link PlanqkServiceApi.InternalServerError}
98
- *
99
110
  * @example
100
- * await client.serviceApi.execute({
101
- * "key": {
102
- * "key": "value"
103
- * }
111
+ * await client.serviceApi.startExecution({
112
+ * "key": "value"
104
113
  * })
105
114
  */
106
- public async execute(
107
- request: Record<string, Record<string, any>>,
108
- requestOptions?: ServiceApi.RequestOptions
109
- ): Promise<PlanqkServiceApi.ServiceExecution> {
115
+ public startExecution(
116
+ request: Record<string, any>,
117
+ requestOptions?: ServiceApi.RequestOptions,
118
+ ): core.HttpResponsePromise<PlanqkServiceApi.ServiceExecution> {
119
+ return core.HttpResponsePromise.fromPromise(this.__startExecution(request, requestOptions));
120
+ }
121
+
122
+ private async __startExecution(
123
+ request: Record<string, any>,
124
+ requestOptions?: ServiceApi.RequestOptions,
125
+ ): Promise<core.WithRawResponse<PlanqkServiceApi.ServiceExecution>> {
110
126
  const _response = await core.fetcher({
111
127
  url:
128
+ (await core.Supplier.get(this._options.baseUrl)) ??
112
129
  (await core.Supplier.get(this._options.environment)) ??
113
130
  environments.PlanqkServiceApiEnvironment.Default,
114
131
  method: "POST",
115
- headers: {
116
- Authorization: await this._getAuthorizationHeader(),
117
- "X-Fern-Language": "JavaScript",
118
- "X-Fern-Runtime": core.RUNTIME.type,
119
- "X-Fern-Runtime-Version": core.RUNTIME.version,
120
- },
132
+ headers: mergeHeaders(
133
+ this._options?.headers,
134
+ mergeOnlyDefinedHeaders({ Authorization: await this._getAuthorizationHeader() }),
135
+ requestOptions?.headers,
136
+ ),
121
137
  contentType: "application/json",
122
138
  requestType: "json",
123
139
  body: request,
@@ -127,27 +143,15 @@ export class ServiceApi {
127
143
  abortSignal: requestOptions?.abortSignal,
128
144
  });
129
145
  if (_response.ok) {
130
- return _response.body as PlanqkServiceApi.ServiceExecution;
146
+ return { data: _response.body as PlanqkServiceApi.ServiceExecution, rawResponse: _response.rawResponse };
131
147
  }
132
148
 
133
149
  if (_response.error.reason === "status-code") {
134
- switch (_response.error.statusCode) {
135
- case 400:
136
- throw new PlanqkServiceApi.BadRequestError(_response.error.body as any);
137
- case 401:
138
- throw new PlanqkServiceApi.UnauthorizedError(_response.error.body as any);
139
- case 403:
140
- throw new PlanqkServiceApi.ForbiddenError(_response.error.body as any);
141
- case 404:
142
- throw new PlanqkServiceApi.NotFoundError(_response.error.body as any);
143
- case 500:
144
- throw new PlanqkServiceApi.InternalServerError(_response.error.body as any);
145
- default:
146
- throw new errors.PlanqkServiceApiError({
147
- statusCode: _response.error.statusCode,
148
- body: _response.error.body,
149
- });
150
- }
150
+ throw new errors.PlanqkServiceApiError({
151
+ statusCode: _response.error.statusCode,
152
+ body: _response.error.body,
153
+ rawResponse: _response.rawResponse,
154
+ });
151
155
  }
152
156
 
153
157
  switch (_response.error.reason) {
@@ -155,74 +159,67 @@ export class ServiceApi {
155
159
  throw new errors.PlanqkServiceApiError({
156
160
  statusCode: _response.error.statusCode,
157
161
  body: _response.error.rawBody,
162
+ rawResponse: _response.rawResponse,
158
163
  });
159
164
  case "timeout":
160
- throw new errors.PlanqkServiceApiTimeoutError();
165
+ throw new errors.PlanqkServiceApiTimeoutError("Timeout exceeded when calling POST /.");
161
166
  case "unknown":
162
167
  throw new errors.PlanqkServiceApiError({
163
168
  message: _response.error.errorMessage,
169
+ rawResponse: _response.rawResponse,
164
170
  });
165
171
  }
166
172
  }
167
173
 
168
174
  /**
169
- * This method checks the status of a service execution.
175
+ * Retrieves the status of a service execution.
176
+ * The status can be one of the following: UNKNOWN, PENDING, RUNNING, SUCCEEDED, CANCELLED, FAILED.
170
177
  *
171
178
  * @param {string} id - The id of a service execution
172
179
  * @param {ServiceApi.RequestOptions} requestOptions - Request-specific configuration.
173
180
  *
174
- * @throws {@link PlanqkServiceApi.UnauthorizedError}
175
- * @throws {@link PlanqkServiceApi.ForbiddenError}
176
- * @throws {@link PlanqkServiceApi.NotFoundError}
177
- * @throws {@link PlanqkServiceApi.InternalServerError}
178
- *
179
181
  * @example
180
182
  * await client.serviceApi.getStatus("id")
181
183
  */
182
- public async getStatus(
184
+ public getStatus(
185
+ id: string,
186
+ requestOptions?: ServiceApi.RequestOptions,
187
+ ): core.HttpResponsePromise<PlanqkServiceApi.ServiceExecution> {
188
+ return core.HttpResponsePromise.fromPromise(this.__getStatus(id, requestOptions));
189
+ }
190
+
191
+ private async __getStatus(
183
192
  id: string,
184
- requestOptions?: ServiceApi.RequestOptions
185
- ): Promise<PlanqkServiceApi.ServiceExecution> {
193
+ requestOptions?: ServiceApi.RequestOptions,
194
+ ): Promise<core.WithRawResponse<PlanqkServiceApi.ServiceExecution>> {
186
195
  const _response = await core.fetcher({
187
- url: urlJoin(
188
- (await core.Supplier.get(this._options.environment)) ??
196
+ url: core.url.join(
197
+ (await core.Supplier.get(this._options.baseUrl)) ??
198
+ (await core.Supplier.get(this._options.environment)) ??
189
199
  environments.PlanqkServiceApiEnvironment.Default,
190
- `${encodeURIComponent(id)}`
200
+ `${encodeURIComponent(id)}`,
191
201
  ),
192
202
  method: "GET",
193
- headers: {
194
- Authorization: await this._getAuthorizationHeader(),
195
- "X-Fern-Language": "JavaScript",
196
- "X-Fern-Runtime": core.RUNTIME.type,
197
- "X-Fern-Runtime-Version": core.RUNTIME.version,
198
- },
199
- contentType: "application/json",
200
- requestType: "json",
203
+ headers: mergeHeaders(
204
+ this._options?.headers,
205
+ mergeOnlyDefinedHeaders({ Authorization: await this._getAuthorizationHeader() }),
206
+ requestOptions?.headers,
207
+ ),
201
208
  timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
202
209
  maxRetries: requestOptions?.maxRetries,
203
210
  withCredentials: true,
204
211
  abortSignal: requestOptions?.abortSignal,
205
212
  });
206
213
  if (_response.ok) {
207
- return _response.body as PlanqkServiceApi.ServiceExecution;
214
+ return { data: _response.body as PlanqkServiceApi.ServiceExecution, rawResponse: _response.rawResponse };
208
215
  }
209
216
 
210
217
  if (_response.error.reason === "status-code") {
211
- switch (_response.error.statusCode) {
212
- case 401:
213
- throw new PlanqkServiceApi.UnauthorizedError(_response.error.body as any);
214
- case 403:
215
- throw new PlanqkServiceApi.ForbiddenError(_response.error.body as any);
216
- case 404:
217
- throw new PlanqkServiceApi.NotFoundError(_response.error.body as any);
218
- case 500:
219
- throw new PlanqkServiceApi.InternalServerError(_response.error.body as any);
220
- default:
221
- throw new errors.PlanqkServiceApiError({
222
- statusCode: _response.error.statusCode,
223
- body: _response.error.body,
224
- });
225
- }
218
+ throw new errors.PlanqkServiceApiError({
219
+ statusCode: _response.error.statusCode,
220
+ body: _response.error.body,
221
+ rawResponse: _response.rawResponse,
222
+ });
226
223
  }
227
224
 
228
225
  switch (_response.error.reason) {
@@ -230,74 +227,68 @@ export class ServiceApi {
230
227
  throw new errors.PlanqkServiceApiError({
231
228
  statusCode: _response.error.statusCode,
232
229
  body: _response.error.rawBody,
230
+ rawResponse: _response.rawResponse,
233
231
  });
234
232
  case "timeout":
235
- throw new errors.PlanqkServiceApiTimeoutError();
233
+ throw new errors.PlanqkServiceApiTimeoutError("Timeout exceeded when calling GET /{id}.");
236
234
  case "unknown":
237
235
  throw new errors.PlanqkServiceApiError({
238
236
  message: _response.error.errorMessage,
237
+ rawResponse: _response.rawResponse,
239
238
  });
240
239
  }
241
240
  }
242
241
 
243
242
  /**
244
- * This method retrieves the result of a service execution.
243
+ * Retrieves the result of a service execution.
244
+ * The result is returned as a JSON object containing the status and any additional data.
245
+ * The result may include links to download specific result files.
245
246
  *
246
247
  * @param {string} id - The id of a service execution
247
248
  * @param {ServiceApi.RequestOptions} requestOptions - Request-specific configuration.
248
249
  *
249
- * @throws {@link PlanqkServiceApi.UnauthorizedError}
250
- * @throws {@link PlanqkServiceApi.ForbiddenError}
251
- * @throws {@link PlanqkServiceApi.NotFoundError}
252
- * @throws {@link PlanqkServiceApi.InternalServerError}
253
- *
254
250
  * @example
255
251
  * await client.serviceApi.getResult("id")
256
252
  */
257
- public async getResult(
253
+ public getResult(
258
254
  id: string,
259
- requestOptions?: ServiceApi.RequestOptions
260
- ): Promise<PlanqkServiceApi.GetResultResponse> {
255
+ requestOptions?: ServiceApi.RequestOptions,
256
+ ): core.HttpResponsePromise<PlanqkServiceApi.GetResultResponse> {
257
+ return core.HttpResponsePromise.fromPromise(this.__getResult(id, requestOptions));
258
+ }
259
+
260
+ private async __getResult(
261
+ id: string,
262
+ requestOptions?: ServiceApi.RequestOptions,
263
+ ): Promise<core.WithRawResponse<PlanqkServiceApi.GetResultResponse>> {
261
264
  const _response = await core.fetcher({
262
- url: urlJoin(
263
- (await core.Supplier.get(this._options.environment)) ??
265
+ url: core.url.join(
266
+ (await core.Supplier.get(this._options.baseUrl)) ??
267
+ (await core.Supplier.get(this._options.environment)) ??
264
268
  environments.PlanqkServiceApiEnvironment.Default,
265
- `${encodeURIComponent(id)}/result`
269
+ `${encodeURIComponent(id)}/result`,
266
270
  ),
267
271
  method: "GET",
268
- headers: {
269
- Authorization: await this._getAuthorizationHeader(),
270
- "X-Fern-Language": "JavaScript",
271
- "X-Fern-Runtime": core.RUNTIME.type,
272
- "X-Fern-Runtime-Version": core.RUNTIME.version,
273
- },
274
- contentType: "application/json",
275
- requestType: "json",
272
+ headers: mergeHeaders(
273
+ this._options?.headers,
274
+ mergeOnlyDefinedHeaders({ Authorization: await this._getAuthorizationHeader() }),
275
+ requestOptions?.headers,
276
+ ),
276
277
  timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
277
278
  maxRetries: requestOptions?.maxRetries,
278
279
  withCredentials: true,
279
280
  abortSignal: requestOptions?.abortSignal,
280
281
  });
281
282
  if (_response.ok) {
282
- return _response.body as PlanqkServiceApi.GetResultResponse;
283
+ return { data: _response.body as PlanqkServiceApi.GetResultResponse, rawResponse: _response.rawResponse };
283
284
  }
284
285
 
285
286
  if (_response.error.reason === "status-code") {
286
- switch (_response.error.statusCode) {
287
- case 401:
288
- throw new PlanqkServiceApi.UnauthorizedError(_response.error.body as any);
289
- case 403:
290
- throw new PlanqkServiceApi.ForbiddenError(_response.error.body as any);
291
- case 404:
292
- throw new PlanqkServiceApi.NotFoundError(_response.error.body as any);
293
- case 500:
294
- throw new PlanqkServiceApi.InternalServerError(_response.error.body as any);
295
- default:
296
- throw new errors.PlanqkServiceApiError({
297
- statusCode: _response.error.statusCode,
298
- body: _response.error.body,
299
- });
300
- }
287
+ throw new errors.PlanqkServiceApiError({
288
+ statusCode: _response.error.statusCode,
289
+ body: _response.error.body,
290
+ rawResponse: _response.rawResponse,
291
+ });
301
292
  }
302
293
 
303
294
  switch (_response.error.reason) {
@@ -305,69 +296,65 @@ export class ServiceApi {
305
296
  throw new errors.PlanqkServiceApiError({
306
297
  statusCode: _response.error.statusCode,
307
298
  body: _response.error.rawBody,
299
+ rawResponse: _response.rawResponse,
308
300
  });
309
301
  case "timeout":
310
- throw new errors.PlanqkServiceApiTimeoutError();
302
+ throw new errors.PlanqkServiceApiTimeoutError("Timeout exceeded when calling GET /{id}/result.");
311
303
  case "unknown":
312
304
  throw new errors.PlanqkServiceApiError({
313
305
  message: _response.error.errorMessage,
306
+ rawResponse: _response.rawResponse,
314
307
  });
315
308
  }
316
309
  }
317
310
 
318
311
  /**
319
- * This method downloads a result file of a service execution.
320
- * @throws {@link PlanqkServiceApi.UnauthorizedError}
321
- * @throws {@link PlanqkServiceApi.ForbiddenError}
322
- * @throws {@link PlanqkServiceApi.NotFoundError}
323
- * @throws {@link PlanqkServiceApi.InternalServerError}
312
+ * Retrieves a specific result file of a service execution.
313
+ * The file name is provided in the path parameter.
314
+ * The result file is returned as a binary stream.
324
315
  */
325
- public async getResultFile(
316
+ public getResultFile(
326
317
  id: string,
327
318
  file: string,
328
- requestOptions?: ServiceApi.RequestOptions
329
- ): Promise<stream.Readable> {
330
- const _response = await core.fetcher<stream.Readable>({
331
- url: urlJoin(
332
- (await core.Supplier.get(this._options.environment)) ??
319
+ requestOptions?: ServiceApi.RequestOptions,
320
+ ): core.HttpResponsePromise<core.BinaryResponse> {
321
+ return core.HttpResponsePromise.fromPromise(this.__getResultFile(id, file, requestOptions));
322
+ }
323
+
324
+ private async __getResultFile(
325
+ id: string,
326
+ file: string,
327
+ requestOptions?: ServiceApi.RequestOptions,
328
+ ): Promise<core.WithRawResponse<core.BinaryResponse>> {
329
+ const _response = await core.fetcher<core.BinaryResponse>({
330
+ url: core.url.join(
331
+ (await core.Supplier.get(this._options.baseUrl)) ??
332
+ (await core.Supplier.get(this._options.environment)) ??
333
333
  environments.PlanqkServiceApiEnvironment.Default,
334
- `${encodeURIComponent(id)}/result/${encodeURIComponent(file)}`
334
+ `${encodeURIComponent(id)}/result/${encodeURIComponent(file)}`,
335
335
  ),
336
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",
337
+ headers: mergeHeaders(
338
+ this._options?.headers,
339
+ mergeOnlyDefinedHeaders({ Authorization: await this._getAuthorizationHeader() }),
340
+ requestOptions?.headers,
341
+ ),
342
+ responseType: "binary-response",
346
343
  timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
347
344
  maxRetries: requestOptions?.maxRetries,
348
345
  withCredentials: true,
349
346
  abortSignal: requestOptions?.abortSignal,
350
347
  });
351
348
  if (_response.ok) {
352
- return _response.body;
349
+ return { data: _response.body, rawResponse: _response.rawResponse };
353
350
  }
354
351
 
355
352
  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
- }
353
+ throw new errors.PlanqkServiceApiError({
354
+ statusCode: _response.error.statusCode,
355
+ body: _response.error.body,
356
+ rawResponse: _response.rawResponse,
357
+ });
371
358
  }
372
359
 
373
360
  switch (_response.error.reason) {
@@ -375,71 +362,63 @@ export class ServiceApi {
375
362
  throw new errors.PlanqkServiceApiError({
376
363
  statusCode: _response.error.statusCode,
377
364
  body: _response.error.rawBody,
365
+ rawResponse: _response.rawResponse,
378
366
  });
379
367
  case "timeout":
380
- throw new errors.PlanqkServiceApiTimeoutError();
368
+ throw new errors.PlanqkServiceApiTimeoutError("Timeout exceeded when calling GET /{id}/result/{file}.");
381
369
  case "unknown":
382
370
  throw new errors.PlanqkServiceApiError({
383
371
  message: _response.error.errorMessage,
372
+ rawResponse: _response.rawResponse,
384
373
  });
385
374
  }
386
375
  }
387
376
 
388
377
  /**
389
- * This method retrieves the log output of a service execution.
378
+ * Returns a list of log entries for a service execution in chronological order, where the first entry is the oldest.
390
379
  *
391
380
  * @param {string} id - The id of a service execution
392
381
  * @param {ServiceApi.RequestOptions} requestOptions - Request-specific configuration.
393
382
  *
394
- * @throws {@link PlanqkServiceApi.UnauthorizedError}
395
- * @throws {@link PlanqkServiceApi.ForbiddenError}
396
- * @throws {@link PlanqkServiceApi.NotFoundError}
397
- * @throws {@link PlanqkServiceApi.InternalServerError}
398
- *
399
383
  * @example
400
384
  * await client.serviceApi.getLogs("id")
401
385
  */
402
- public async getLogs(id: string, requestOptions?: ServiceApi.RequestOptions): Promise<string[]> {
386
+ public getLogs(id: string, requestOptions?: ServiceApi.RequestOptions): core.HttpResponsePromise<string[]> {
387
+ return core.HttpResponsePromise.fromPromise(this.__getLogs(id, requestOptions));
388
+ }
389
+
390
+ private async __getLogs(
391
+ id: string,
392
+ requestOptions?: ServiceApi.RequestOptions,
393
+ ): Promise<core.WithRawResponse<string[]>> {
403
394
  const _response = await core.fetcher({
404
- url: urlJoin(
405
- (await core.Supplier.get(this._options.environment)) ??
395
+ url: core.url.join(
396
+ (await core.Supplier.get(this._options.baseUrl)) ??
397
+ (await core.Supplier.get(this._options.environment)) ??
406
398
  environments.PlanqkServiceApiEnvironment.Default,
407
- `${encodeURIComponent(id)}/log`
399
+ `${encodeURIComponent(id)}/log`,
408
400
  ),
409
401
  method: "GET",
410
- headers: {
411
- Authorization: await this._getAuthorizationHeader(),
412
- "X-Fern-Language": "JavaScript",
413
- "X-Fern-Runtime": core.RUNTIME.type,
414
- "X-Fern-Runtime-Version": core.RUNTIME.version,
415
- },
416
- contentType: "application/json",
417
- requestType: "json",
402
+ headers: mergeHeaders(
403
+ this._options?.headers,
404
+ mergeOnlyDefinedHeaders({ Authorization: await this._getAuthorizationHeader() }),
405
+ requestOptions?.headers,
406
+ ),
418
407
  timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
419
408
  maxRetries: requestOptions?.maxRetries,
420
409
  withCredentials: true,
421
410
  abortSignal: requestOptions?.abortSignal,
422
411
  });
423
412
  if (_response.ok) {
424
- return _response.body as string[];
413
+ return { data: _response.body as string[], rawResponse: _response.rawResponse };
425
414
  }
426
415
 
427
416
  if (_response.error.reason === "status-code") {
428
- switch (_response.error.statusCode) {
429
- case 401:
430
- throw new PlanqkServiceApi.UnauthorizedError(_response.error.body as any);
431
- case 403:
432
- throw new PlanqkServiceApi.ForbiddenError(_response.error.body as any);
433
- case 404:
434
- throw new PlanqkServiceApi.NotFoundError(_response.error.body as any);
435
- case 500:
436
- throw new PlanqkServiceApi.InternalServerError(_response.error.body as any);
437
- default:
438
- throw new errors.PlanqkServiceApiError({
439
- statusCode: _response.error.statusCode,
440
- body: _response.error.body,
441
- });
442
- }
417
+ throw new errors.PlanqkServiceApiError({
418
+ statusCode: _response.error.statusCode,
419
+ body: _response.error.body,
420
+ rawResponse: _response.rawResponse,
421
+ });
443
422
  }
444
423
 
445
424
  switch (_response.error.reason) {
@@ -447,74 +426,66 @@ export class ServiceApi {
447
426
  throw new errors.PlanqkServiceApiError({
448
427
  statusCode: _response.error.statusCode,
449
428
  body: _response.error.rawBody,
429
+ rawResponse: _response.rawResponse,
450
430
  });
451
431
  case "timeout":
452
- throw new errors.PlanqkServiceApiTimeoutError();
432
+ throw new errors.PlanqkServiceApiTimeoutError("Timeout exceeded when calling GET /{id}/log.");
453
433
  case "unknown":
454
434
  throw new errors.PlanqkServiceApiError({
455
435
  message: _response.error.errorMessage,
436
+ rawResponse: _response.rawResponse,
456
437
  });
457
438
  }
458
439
  }
459
440
 
460
441
  /**
461
- * This method cancels a service execution.
442
+ * Cancel a pending or running service execution.
462
443
  *
463
444
  * @param {string} id - The id of a service execution
464
445
  * @param {ServiceApi.RequestOptions} requestOptions - Request-specific configuration.
465
446
  *
466
- * @throws {@link PlanqkServiceApi.UnauthorizedError}
467
- * @throws {@link PlanqkServiceApi.ForbiddenError}
468
- * @throws {@link PlanqkServiceApi.NotFoundError}
469
- * @throws {@link PlanqkServiceApi.InternalServerError}
470
- *
471
447
  * @example
472
- * await client.serviceApi.cancel("id")
448
+ * await client.serviceApi.cancelExecution("id")
473
449
  */
474
- public async cancel(
450
+ public cancelExecution(
451
+ id: string,
452
+ requestOptions?: ServiceApi.RequestOptions,
453
+ ): core.HttpResponsePromise<PlanqkServiceApi.ServiceExecution> {
454
+ return core.HttpResponsePromise.fromPromise(this.__cancelExecution(id, requestOptions));
455
+ }
456
+
457
+ private async __cancelExecution(
475
458
  id: string,
476
- requestOptions?: ServiceApi.RequestOptions
477
- ): Promise<PlanqkServiceApi.ServiceExecution> {
459
+ requestOptions?: ServiceApi.RequestOptions,
460
+ ): Promise<core.WithRawResponse<PlanqkServiceApi.ServiceExecution>> {
478
461
  const _response = await core.fetcher({
479
- url: urlJoin(
480
- (await core.Supplier.get(this._options.environment)) ??
462
+ url: core.url.join(
463
+ (await core.Supplier.get(this._options.baseUrl)) ??
464
+ (await core.Supplier.get(this._options.environment)) ??
481
465
  environments.PlanqkServiceApiEnvironment.Default,
482
- `${encodeURIComponent(id)}/cancel`
466
+ `${encodeURIComponent(id)}/cancel`,
483
467
  ),
484
468
  method: "PUT",
485
- headers: {
486
- Authorization: await this._getAuthorizationHeader(),
487
- "X-Fern-Language": "JavaScript",
488
- "X-Fern-Runtime": core.RUNTIME.type,
489
- "X-Fern-Runtime-Version": core.RUNTIME.version,
490
- },
491
- contentType: "application/json",
492
- requestType: "json",
469
+ headers: mergeHeaders(
470
+ this._options?.headers,
471
+ mergeOnlyDefinedHeaders({ Authorization: await this._getAuthorizationHeader() }),
472
+ requestOptions?.headers,
473
+ ),
493
474
  timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
494
475
  maxRetries: requestOptions?.maxRetries,
495
476
  withCredentials: true,
496
477
  abortSignal: requestOptions?.abortSignal,
497
478
  });
498
479
  if (_response.ok) {
499
- return _response.body as PlanqkServiceApi.ServiceExecution;
480
+ return { data: _response.body as PlanqkServiceApi.ServiceExecution, rawResponse: _response.rawResponse };
500
481
  }
501
482
 
502
483
  if (_response.error.reason === "status-code") {
503
- switch (_response.error.statusCode) {
504
- case 401:
505
- throw new PlanqkServiceApi.UnauthorizedError(_response.error.body as any);
506
- case 403:
507
- throw new PlanqkServiceApi.ForbiddenError(_response.error.body as any);
508
- case 404:
509
- throw new PlanqkServiceApi.NotFoundError(_response.error.body as any);
510
- case 500:
511
- throw new PlanqkServiceApi.InternalServerError(_response.error.body as any);
512
- default:
513
- throw new errors.PlanqkServiceApiError({
514
- statusCode: _response.error.statusCode,
515
- body: _response.error.body,
516
- });
517
- }
484
+ throw new errors.PlanqkServiceApiError({
485
+ statusCode: _response.error.statusCode,
486
+ body: _response.error.body,
487
+ rawResponse: _response.rawResponse,
488
+ });
518
489
  }
519
490
 
520
491
  switch (_response.error.reason) {
@@ -522,12 +493,14 @@ export class ServiceApi {
522
493
  throw new errors.PlanqkServiceApiError({
523
494
  statusCode: _response.error.statusCode,
524
495
  body: _response.error.rawBody,
496
+ rawResponse: _response.rawResponse,
525
497
  });
526
498
  case "timeout":
527
- throw new errors.PlanqkServiceApiTimeoutError();
499
+ throw new errors.PlanqkServiceApiTimeoutError("Timeout exceeded when calling PUT /{id}/cancel.");
528
500
  case "unknown":
529
501
  throw new errors.PlanqkServiceApiError({
530
502
  message: _response.error.errorMessage,
503
+ rawResponse: _response.rawResponse,
531
504
  });
532
505
  }
533
506
  }