@planqk/planqk-service-sdk 2.11.0 → 2.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.template +2 -2
- package/README-node.md +20 -3
- package/README-python.md +20 -3
- package/README.md +58 -31
- package/notebooks/python-sdk.ipynb +4 -6
- package/package.json +1 -1
- package/planqk/service/_version.py +1 -1
- package/planqk/service/auth.py +4 -4
- package/planqk/service/client.py +7 -7
- package/pyproject.toml +1 -1
- package/src/auth.ts +7 -7
- package/src/client.ts +3 -3
- package/src/index.test.ts +5 -7
- package/uv.lock +1 -1
- package/dist/auth.d.ts +0 -10
- package/dist/auth.js +0 -43
- package/dist/client.d.ts +0 -6
- package/dist/client.js +0 -27
- package/dist/datapool.d.ts +0 -11
- package/dist/datapool.js +0 -17
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -7
- package/dist/sdk/BaseClient.d.ts +0 -26
- package/dist/sdk/BaseClient.js +0 -3
- package/dist/sdk/Client.d.ts +0 -14
- package/dist/sdk/Client.js +0 -58
- package/dist/sdk/api/index.d.ts +0 -2
- package/dist/sdk/api/index.js +0 -18
- package/dist/sdk/api/resources/index.d.ts +0 -1
- package/dist/sdk/api/resources/index.js +0 -37
- package/dist/sdk/api/resources/serviceApi/client/Client.d.ts +0 -93
- package/dist/sdk/api/resources/serviceApi/client/Client.js +0 -425
- package/dist/sdk/api/resources/serviceApi/client/index.d.ts +0 -1
- package/dist/sdk/api/resources/serviceApi/client/index.js +0 -2
- package/dist/sdk/api/resources/serviceApi/index.d.ts +0 -1
- package/dist/sdk/api/resources/serviceApi/index.js +0 -17
- package/dist/sdk/api/types/HalLink.d.ts +0 -18
- package/dist/sdk/api/types/HalLink.js +0 -3
- package/dist/sdk/api/types/LogEntry.d.ts +0 -19
- package/dist/sdk/api/types/LogEntry.js +0 -15
- package/dist/sdk/api/types/RequestBody.d.ts +0 -1
- package/dist/sdk/api/types/RequestBody.js +0 -3
- package/dist/sdk/api/types/ResultResponse.d.ts +0 -15
- package/dist/sdk/api/types/ResultResponse.js +0 -3
- package/dist/sdk/api/types/ServiceExecution.d.ts +0 -38
- package/dist/sdk/api/types/ServiceExecution.js +0 -21
- package/dist/sdk/api/types/index.d.ts +0 -5
- package/dist/sdk/api/types/index.js +0 -21
- package/dist/sdk/core/auth/AuthProvider.d.ts +0 -4
- package/dist/sdk/core/auth/AuthProvider.js +0 -2
- package/dist/sdk/core/auth/AuthRequest.d.ts +0 -9
- package/dist/sdk/core/auth/AuthRequest.js +0 -2
- package/dist/sdk/core/auth/BasicAuth.d.ts +0 -8
- package/dist/sdk/core/auth/BasicAuth.js +0 -27
- package/dist/sdk/core/auth/BearerToken.d.ts +0 -5
- package/dist/sdk/core/auth/BearerToken.js +0 -15
- package/dist/sdk/core/auth/index.d.ts +0 -4
- package/dist/sdk/core/auth/index.js +0 -7
- package/dist/sdk/core/base64.d.ts +0 -2
- package/dist/sdk/core/base64.js +0 -26
- package/dist/sdk/core/fetcher/APIResponse.d.ts +0 -20
- package/dist/sdk/core/fetcher/APIResponse.js +0 -2
- package/dist/sdk/core/fetcher/BinaryResponse.d.ts +0 -20
- package/dist/sdk/core/fetcher/BinaryResponse.js +0 -17
- package/dist/sdk/core/fetcher/EndpointMetadata.d.ts +0 -13
- package/dist/sdk/core/fetcher/EndpointMetadata.js +0 -2
- package/dist/sdk/core/fetcher/EndpointSupplier.d.ts +0 -12
- package/dist/sdk/core/fetcher/EndpointSupplier.js +0 -13
- package/dist/sdk/core/fetcher/Fetcher.d.ts +0 -42
- package/dist/sdk/core/fetcher/Fetcher.js +0 -105
- package/dist/sdk/core/fetcher/Headers.d.ts +0 -2
- package/dist/sdk/core/fetcher/Headers.js +0 -85
- package/dist/sdk/core/fetcher/HttpResponsePromise.d.ts +0 -58
- package/dist/sdk/core/fetcher/HttpResponsePromise.js +0 -94
- package/dist/sdk/core/fetcher/RawResponse.d.ts +0 -29
- package/dist/sdk/core/fetcher/RawResponse.js +0 -44
- package/dist/sdk/core/fetcher/ResponseWithBody.d.ts +0 -4
- package/dist/sdk/core/fetcher/ResponseWithBody.js +0 -6
- package/dist/sdk/core/fetcher/Supplier.d.ts +0 -4
- package/dist/sdk/core/fetcher/Supplier.js +0 -13
- package/dist/sdk/core/fetcher/createRequestUrl.d.ts +0 -1
- package/dist/sdk/core/fetcher/createRequestUrl.js +0 -8
- package/dist/sdk/core/fetcher/getErrorResponseBody.d.ts +0 -1
- package/dist/sdk/core/fetcher/getErrorResponseBody.js +0 -32
- package/dist/sdk/core/fetcher/getFetchFn.d.ts +0 -1
- package/dist/sdk/core/fetcher/getFetchFn.js +0 -6
- package/dist/sdk/core/fetcher/getHeader.d.ts +0 -1
- package/dist/sdk/core/fetcher/getHeader.js +0 -11
- package/dist/sdk/core/fetcher/getRequestBody.d.ts +0 -7
- package/dist/sdk/core/fetcher/getRequestBody.js +0 -12
- package/dist/sdk/core/fetcher/getResponseBody.d.ts +0 -1
- package/dist/sdk/core/fetcher/getResponseBody.js +0 -44
- package/dist/sdk/core/fetcher/index.d.ts +0 -11
- package/dist/sdk/core/fetcher/index.js +0 -17
- package/dist/sdk/core/fetcher/makeRequest.d.ts +0 -1
- package/dist/sdk/core/fetcher/makeRequest.js +0 -33
- package/dist/sdk/core/fetcher/requestWithRetries.d.ts +0 -1
- package/dist/sdk/core/fetcher/requestWithRetries.js +0 -65
- package/dist/sdk/core/fetcher/signals.d.ts +0 -11
- package/dist/sdk/core/fetcher/signals.js +0 -36
- package/dist/sdk/core/headers.d.ts +0 -2
- package/dist/sdk/core/headers.js +0 -29
- package/dist/sdk/core/index.d.ts +0 -5
- package/dist/sdk/core/index.js +0 -44
- package/dist/sdk/core/json.d.ts +0 -15
- package/dist/sdk/core/json.js +0 -24
- package/dist/sdk/core/runtime/index.d.ts +0 -1
- package/dist/sdk/core/runtime/index.js +0 -5
- package/dist/sdk/core/runtime/runtime.d.ts +0 -9
- package/dist/sdk/core/runtime/runtime.js +0 -101
- package/dist/sdk/core/url/index.d.ts +0 -2
- package/dist/sdk/core/url/index.js +0 -7
- package/dist/sdk/core/url/join.d.ts +0 -1
- package/dist/sdk/core/url/join.js +0 -69
- package/dist/sdk/core/url/qs.d.ts +0 -6
- package/dist/sdk/core/url/qs.js +0 -67
- package/dist/sdk/environments.d.ts +0 -4
- package/dist/sdk/environments.js +0 -7
- package/dist/sdk/errors/PlanqkServiceApiError.d.ts +0 -12
- package/dist/sdk/errors/PlanqkServiceApiError.js +0 -31
- package/dist/sdk/errors/PlanqkServiceApiTimeoutError.d.ts +0 -3
- package/dist/sdk/errors/PlanqkServiceApiTimeoutError.js +0 -11
- package/dist/sdk/errors/index.d.ts +0 -2
- package/dist/sdk/errors/index.js +0 -7
- package/dist/sdk/index.d.ts +0 -5
- package/dist/sdk/index.js +0 -44
- package/requirements-dev.txt +0 -727
- package/requirements.txt +0 -280
package/.env.template
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
TOKEN_ENDPOINT=https://gateway.hub.kipu-quantum.com/token
|
|
2
2
|
SERVICE_ENDPOINT=https://gateway.hub.kipu-quantum.com/your-organization/your-service/1.0.0
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
ACCESS_KEY_ID=your-access-key-id
|
|
4
|
+
SECRET_ACCESS_KEY=your-secret-access-key
|
package/README-node.md
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
> **⚠️ DEPRECATED ⚠️**
|
|
2
|
+
>
|
|
3
|
+
> **This package has been deprecated and is no longer maintained.**
|
|
4
|
+
>
|
|
5
|
+
> Please migrate to the new package:
|
|
6
|
+
> - PyPI: **[`qhub-service`](https://pypi.org/project/qhub-service)**
|
|
7
|
+
> - NPM: **[`@quantum-hub/qhub-service`](https://www.npmjs.com/package/@quantum-hub/qhub-service)**
|
|
8
|
+
>
|
|
9
|
+
> Install the new package:
|
|
10
|
+
> ```bash
|
|
11
|
+
> pip install qhub-service
|
|
12
|
+
> # or
|
|
13
|
+
> npm install @quantum-hub/qhub-service
|
|
14
|
+
> ```
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
1
18
|
# PLANQK Service SDK
|
|
2
19
|
|
|
3
20
|
## Installation
|
|
@@ -12,11 +29,11 @@ npm install @planqk/planqk-service-sdk
|
|
|
12
29
|
|
|
13
30
|
```typescript
|
|
14
31
|
const serviceEndpoint = "..."
|
|
15
|
-
const
|
|
16
|
-
const
|
|
32
|
+
const accessKeyId = "..."
|
|
33
|
+
const secretAccessKey = "..."
|
|
17
34
|
|
|
18
35
|
// Create a new PlanqkServiceClient instance
|
|
19
|
-
const client = new PlanqkServiceClient(serviceEndpoint,
|
|
36
|
+
const client = new PlanqkServiceClient(serviceEndpoint, accessKeyId, secretAccessKey)
|
|
20
37
|
|
|
21
38
|
// List all service executions
|
|
22
39
|
const serviceExecutions = await client.api().getServiceExecutions()
|
package/README-python.md
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
> **⚠️ DEPRECATED ⚠️**
|
|
2
|
+
>
|
|
3
|
+
> **This package has been deprecated and is no longer maintained.**
|
|
4
|
+
>
|
|
5
|
+
> Please migrate to the new package:
|
|
6
|
+
> - PyPI: **[`qhub-service`](https://pypi.org/project/qhub-service)**
|
|
7
|
+
> - NPM: **[`@quantum-hub/qhub-service`](https://www.npmjs.com/package/@quantum-hub/qhub-service)**
|
|
8
|
+
>
|
|
9
|
+
> Install the new package:
|
|
10
|
+
> ```bash
|
|
11
|
+
> pip install qhub-service
|
|
12
|
+
> # or
|
|
13
|
+
> npm install @quantum-hub/qhub-service
|
|
14
|
+
> ```
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
1
18
|
# PLANQK Service SDK
|
|
2
19
|
|
|
3
20
|
## Installation
|
|
@@ -14,12 +31,12 @@ pip install --upgrade planqk-service-sdk
|
|
|
14
31
|
import os
|
|
15
32
|
from planqk.service.client import PlanqkServiceClient
|
|
16
33
|
|
|
17
|
-
consumer_key = "..."
|
|
18
|
-
consumer_secret = "..."
|
|
19
34
|
service_endpoint = "..."
|
|
35
|
+
access_key_id = "..."
|
|
36
|
+
secret_access_key = "..."
|
|
20
37
|
|
|
21
38
|
# Create a new PlanqkServiceClient instance
|
|
22
|
-
client = PlanqkServiceClient(service_endpoint,
|
|
39
|
+
client = PlanqkServiceClient(service_endpoint, access_key_id, secret_access_key)
|
|
23
40
|
|
|
24
41
|
# Prepare your input data and parameters
|
|
25
42
|
data = {"values": [2]}
|
package/README.md
CHANGED
|
@@ -1,46 +1,73 @@
|
|
|
1
|
-
|
|
1
|
+
> **⚠️ DEPRECATED ⚠️**
|
|
2
|
+
>
|
|
3
|
+
> **This package has been deprecated and is no longer maintained.**
|
|
4
|
+
>
|
|
5
|
+
> Please migrate to the new package:
|
|
6
|
+
> - PyPI: **[`qhub-service`](https://pypi.org/project/qhub-service)**
|
|
7
|
+
> - NPM: **[`@quantum-hub/qhub-service`](https://www.npmjs.com/package/@quantum-hub/qhub-service)**
|
|
8
|
+
>
|
|
9
|
+
> Install the new package:
|
|
10
|
+
> ```bash
|
|
11
|
+
> pip install qhub-service
|
|
12
|
+
> # or
|
|
13
|
+
> npm install @quantum-hub/qhub-service
|
|
14
|
+
> ```
|
|
2
15
|
|
|
3
|
-
|
|
16
|
+
---
|
|
4
17
|
|
|
5
|
-
|
|
18
|
+
# planqk-service-sdk
|
|
19
|
+
|
|
20
|
+
This repository contains the SDK clients to execute PLANQK Managed Services.
|
|
21
|
+
The clients are generated from a very general [OpenAPI](https://swagger.io/specification) description using [Fern](https://buildwithfern.com).
|
|
22
|
+
The generated clients are a baseline, and the idea is to adapt and extend them to our specific needs.
|
|
23
|
+
|
|
24
|
+
## Generate the SDK clients with Fern
|
|
25
|
+
|
|
26
|
+
> <https://buildwithfern.com/docs/getting-started>
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npm install -g fern-api
|
|
30
|
+
fern upgrade
|
|
31
|
+
fern generate
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Python Setup
|
|
35
|
+
|
|
36
|
+
To create a new virtual environment and install the dependencies, run:
|
|
6
37
|
|
|
7
38
|
```bash
|
|
8
|
-
|
|
39
|
+
uv venv
|
|
40
|
+
source .venv/bin/activate
|
|
41
|
+
|
|
42
|
+
uv sync
|
|
9
43
|
```
|
|
10
44
|
|
|
11
|
-
|
|
45
|
+
Update dependencies and lock files:
|
|
12
46
|
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const consumerSecret = "..."
|
|
47
|
+
```bash
|
|
48
|
+
uv sync -U
|
|
49
|
+
```
|
|
17
50
|
|
|
18
|
-
|
|
19
|
-
const client = new PlanqkServiceClient(serviceEndpoint, consumerKey, consumerSecret)
|
|
51
|
+
## How to update the Python client?
|
|
20
52
|
|
|
21
|
-
|
|
22
|
-
const serviceExecutions = await client.api().getServiceExecutions()
|
|
53
|
+
After generating the SDK clients with Fern, the Python client needs to be copied manually.
|
|
23
54
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
let serviceExecution = await client.api().startExecution({data, params}, {timeoutInSeconds: 60})
|
|
55
|
+
Copy the content of `./generated/python` to `./planqk/service/sdk`.
|
|
56
|
+
Make sure you overwrite any existing files.
|
|
57
|
+
It is recommended to remove the old files first.
|
|
28
58
|
|
|
29
|
-
|
|
30
|
-
serviceExecution = await client.api().getStatus(serviceExecution.id!)
|
|
59
|
+
Next, check by executing `pytest` if the changes are compatible with our wrapper.
|
|
31
60
|
|
|
32
|
-
|
|
33
|
-
const finalStates = ["SUCCEEDED", "CANCELLED", "FAILED"]
|
|
34
|
-
while (!finalStates.includes(serviceExecution.status!)) {
|
|
35
|
-
serviceExecution = await client.api().getStatus(serviceExecution.id!)
|
|
36
|
-
}
|
|
61
|
+
## How to update the TypeScript client?
|
|
37
62
|
|
|
38
|
-
|
|
39
|
-
const result = await client.api().getResult(serviceExecution.id!)
|
|
63
|
+
After generating the SDK clients with Fern, the TypeScript client needs to be copied manually.
|
|
40
64
|
|
|
41
|
-
|
|
42
|
-
|
|
65
|
+
Copy the content of `./generated/typescript` to `./typescript/src/sdk`.
|
|
66
|
+
Make sure you overwrite any existing files.
|
|
67
|
+
It is recommended to remove the old files first.
|
|
43
68
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
69
|
+
Next, check by executing `npm test` if the changes are compatible with our wrapper.
|
|
70
|
+
|
|
71
|
+
## License
|
|
72
|
+
|
|
73
|
+
Apache-2.0 | Copyright 2023-2024 Kipu Quantum GmbH
|
|
@@ -28,13 +28,11 @@
|
|
|
28
28
|
"\n",
|
|
29
29
|
"token_endpoint = os.getenv(\"TOKEN_ENDPOINT\", \"https://gateway.hub.kipu-quantum.com/token\")\n",
|
|
30
30
|
"service_endpoint = os.getenv(\"SERVICE_ENDPOINT\", \"https://gateway.hub.kipu-quantum.com/your-organization/your-service/1.0.0\")\n",
|
|
31
|
-
"
|
|
32
|
-
"
|
|
31
|
+
"access_key_id = os.getenv(\"ACCESS_KEY_ID\", None)\n",
|
|
32
|
+
"secret_access_key = os.getenv(\"SECRET_ACCESS_KEY\", None)\n",
|
|
33
33
|
"\n",
|
|
34
34
|
"print(f\"Token endpoint: {token_endpoint}\")\n",
|
|
35
|
-
"print(f\"Service endpoint: {service_endpoint}\")
|
|
36
|
-
"print(f\"Consumer key: {consumer_key}\")\n",
|
|
37
|
-
"print(f\"Consumer secret: {consumer_secret}\")"
|
|
35
|
+
"print(f\"Service endpoint: {service_endpoint}\")"
|
|
38
36
|
]
|
|
39
37
|
},
|
|
40
38
|
{
|
|
@@ -54,7 +52,7 @@
|
|
|
54
52
|
"\n",
|
|
55
53
|
"# Create a new PlanqkServiceClient instance\n",
|
|
56
54
|
"client = PlanqkServiceClient(\n",
|
|
57
|
-
" service_endpoint,
|
|
55
|
+
" service_endpoint, access_key_id, secret_access_key, token_endpoint\n",
|
|
58
56
|
")"
|
|
59
57
|
]
|
|
60
58
|
},
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "2.
|
|
1
|
+
__version__ = "2.12.0"
|
package/planqk/service/auth.py
CHANGED
|
@@ -9,9 +9,9 @@ DEFAULT_TOKEN_ENDPOINT = "https://gateway.hub.kipu-quantum.com/token"
|
|
|
9
9
|
class PlanqkServiceAuth:
|
|
10
10
|
_logger = logging.getLogger(__name__)
|
|
11
11
|
|
|
12
|
-
def __init__(self,
|
|
13
|
-
self.
|
|
14
|
-
self.
|
|
12
|
+
def __init__(self, access_key_id: str, secret_access_key: str, token_endpoint: str = DEFAULT_TOKEN_ENDPOINT):
|
|
13
|
+
self._access_key_id = access_key_id
|
|
14
|
+
self._secret_access_key = secret_access_key
|
|
15
15
|
self._token_endpoint = token_endpoint
|
|
16
16
|
self._token = None
|
|
17
17
|
self._last_token_fetch = None
|
|
@@ -28,7 +28,7 @@ class PlanqkServiceAuth:
|
|
|
28
28
|
|
|
29
29
|
def _refresh_token(self):
|
|
30
30
|
self._logger.debug("Creating new token using client credentials flow")
|
|
31
|
-
with OAuth2Client(self.
|
|
31
|
+
with OAuth2Client(self._access_key_id, self._secret_access_key) as client:
|
|
32
32
|
token = client.fetch_token(self._token_endpoint, grant_type='client_credentials')
|
|
33
33
|
|
|
34
34
|
self._token = token
|
package/planqk/service/client.py
CHANGED
|
@@ -113,19 +113,19 @@ class PlanqkServiceClient:
|
|
|
113
113
|
def __init__(
|
|
114
114
|
self,
|
|
115
115
|
service_endpoint: str,
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
access_key_id: typing.Union[str, None],
|
|
117
|
+
secret_access_key: typing.Union[str, None],
|
|
118
118
|
token_endpoint: str = DEFAULT_TOKEN_ENDPOINT,
|
|
119
119
|
):
|
|
120
120
|
self._service_endpoint = service_endpoint
|
|
121
|
-
self.
|
|
122
|
-
self.
|
|
121
|
+
self._access_key_id = access_key_id
|
|
122
|
+
self._secret_access_key = secret_access_key
|
|
123
123
|
self._token_endpoint = token_endpoint
|
|
124
124
|
|
|
125
|
-
if (self.
|
|
125
|
+
if (self._access_key_id is not None) or (self._secret_access_key is not None):
|
|
126
126
|
self._auth = PlanqkServiceAuth(
|
|
127
|
-
|
|
128
|
-
|
|
127
|
+
access_key_id=self._access_key_id,
|
|
128
|
+
secret_access_key=self._secret_access_key,
|
|
129
129
|
token_endpoint=self._token_endpoint,
|
|
130
130
|
)
|
|
131
131
|
self._api = PlanqkServiceApi(base_url=self._service_endpoint, token=self._auth.get_token)
|
package/pyproject.toml
CHANGED
package/src/auth.ts
CHANGED
|
@@ -4,13 +4,13 @@ export const DEFAULT_TOKEN_ENDPOINT = 'https://gateway.hub.kipu-quantum.com/toke
|
|
|
4
4
|
|
|
5
5
|
export class PlanqkServiceAuth {
|
|
6
6
|
private accessToken: AccessToken | undefined
|
|
7
|
-
private readonly
|
|
8
|
-
private readonly
|
|
7
|
+
private readonly accessKeyId: string
|
|
8
|
+
private readonly secretAccessKey: string
|
|
9
9
|
private readonly tokenEndpoint: string
|
|
10
10
|
|
|
11
|
-
constructor(
|
|
12
|
-
this.
|
|
13
|
-
this.
|
|
11
|
+
constructor(accessKeyId: string, secretAccessKey: string, tokenEndpoint: string = DEFAULT_TOKEN_ENDPOINT) {
|
|
12
|
+
this.accessKeyId = accessKeyId
|
|
13
|
+
this.secretAccessKey = secretAccessKey
|
|
14
14
|
this.tokenEndpoint = tokenEndpoint
|
|
15
15
|
}
|
|
16
16
|
|
|
@@ -33,8 +33,8 @@ export class PlanqkServiceAuth {
|
|
|
33
33
|
tokenPath: '/token',
|
|
34
34
|
},
|
|
35
35
|
client: {
|
|
36
|
-
id: this.
|
|
37
|
-
secret: this.
|
|
36
|
+
id: this.accessKeyId,
|
|
37
|
+
secret: this.secretAccessKey,
|
|
38
38
|
},
|
|
39
39
|
options: {
|
|
40
40
|
authorizationMethod: 'body',
|
package/src/client.ts
CHANGED
|
@@ -5,9 +5,9 @@ import {ServiceApi} from "./sdk/api/resources/serviceApi/client/Client";
|
|
|
5
5
|
export class PlanqkServiceClient {
|
|
6
6
|
private _api: PlanqkServiceApiClient
|
|
7
7
|
|
|
8
|
-
constructor(serviceEndpoint: string,
|
|
9
|
-
if (
|
|
10
|
-
const auth = new PlanqkServiceAuth(
|
|
8
|
+
constructor(serviceEndpoint: string, accessKeyId?: string, secretAccessKey?: string, tokenEndpoint: string = DEFAULT_TOKEN_ENDPOINT) {
|
|
9
|
+
if (accessKeyId && secretAccessKey) {
|
|
10
|
+
const auth = new PlanqkServiceAuth(accessKeyId, secretAccessKey, tokenEndpoint)
|
|
11
11
|
this._api = new PlanqkServiceApiClient({
|
|
12
12
|
environment: () => serviceEndpoint,
|
|
13
13
|
token: async () => auth.getAccessToken(),
|
package/src/index.test.ts
CHANGED
|
@@ -6,16 +6,14 @@ import {withDataPoolReference} from "./datapool";
|
|
|
6
6
|
|
|
7
7
|
const tokenEndpoint = process.env.TOKEN_ENDPOINT
|
|
8
8
|
const serviceEndpoint = process.env.SERVICE_ENDPOINT
|
|
9
|
-
const
|
|
10
|
-
const
|
|
9
|
+
const accessKeyId = process.env.ACCESS_KEY_ID
|
|
10
|
+
const secretAccessKey = process.env.SECRET_ACCESS_KEY
|
|
11
11
|
|
|
12
12
|
console.log(`Token endpoint: ${tokenEndpoint}`)
|
|
13
13
|
console.log(`Service endpoint: ${serviceEndpoint}`)
|
|
14
|
-
console.log(`Consumer key: ${consumerKey}`)
|
|
15
|
-
console.log(`Consumer secret: ${consumerSecret}`)
|
|
16
14
|
|
|
17
15
|
test.skip('integration test: retrieve logs', {timeout: 5 * 60 * 1000}, async () => {
|
|
18
|
-
const client = new PlanqkServiceClient(serviceEndpoint!,
|
|
16
|
+
const client = new PlanqkServiceClient(serviceEndpoint!, accessKeyId, secretAccessKey, tokenEndpoint);
|
|
19
17
|
|
|
20
18
|
const serviceExecutions = await client.api().getServiceExecutions()
|
|
21
19
|
console.log(serviceExecutions)
|
|
@@ -25,7 +23,7 @@ test.skip('integration test: retrieve logs', {timeout: 5 * 60 * 1000}, async ()
|
|
|
25
23
|
})
|
|
26
24
|
|
|
27
25
|
test.skip('integration test: coin toss', {timeout: 5 * 60 * 1000}, async () => {
|
|
28
|
-
const client = new PlanqkServiceClient(serviceEndpoint!,
|
|
26
|
+
const client = new PlanqkServiceClient(serviceEndpoint!, accessKeyId, secretAccessKey, tokenEndpoint);
|
|
29
27
|
|
|
30
28
|
let serviceExecutions = await client.api().getServiceExecutions()
|
|
31
29
|
console.log(serviceExecutions)
|
|
@@ -62,7 +60,7 @@ test.skip('integration test: coin toss', {timeout: 5 * 60 * 1000}, async () => {
|
|
|
62
60
|
})
|
|
63
61
|
|
|
64
62
|
test.skip('integration test: using data pools', {timeout: 5 * 60 * 1000}, async () => {
|
|
65
|
-
const client = new PlanqkServiceClient(serviceEndpoint!,
|
|
63
|
+
const client = new PlanqkServiceClient(serviceEndpoint!, accessKeyId, secretAccessKey, tokenEndpoint);
|
|
66
64
|
|
|
67
65
|
const data = {file_to_read: "example.txt"}
|
|
68
66
|
const dataset = withDataPoolReference("89ae42e1-9697-4742-adfb-95bf018104c3")
|
package/uv.lock
CHANGED
package/dist/auth.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export declare const DEFAULT_TOKEN_ENDPOINT = "https://gateway.hub.kipu-quantum.com/token";
|
|
2
|
-
export declare class PlanqkServiceAuth {
|
|
3
|
-
private accessToken;
|
|
4
|
-
private readonly consumerKey;
|
|
5
|
-
private readonly consumerSecret;
|
|
6
|
-
private readonly tokenEndpoint;
|
|
7
|
-
constructor(consumerKey: string, consumerSecret: string, tokenEndpoint?: string);
|
|
8
|
-
getAccessToken(): Promise<string>;
|
|
9
|
-
private fetchAccessToken;
|
|
10
|
-
}
|
package/dist/auth.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PlanqkServiceAuth = exports.DEFAULT_TOKEN_ENDPOINT = void 0;
|
|
4
|
-
const simple_oauth2_1 = require("simple-oauth2");
|
|
5
|
-
exports.DEFAULT_TOKEN_ENDPOINT = 'https://gateway.hub.kipu-quantum.com/token';
|
|
6
|
-
class PlanqkServiceAuth {
|
|
7
|
-
accessToken;
|
|
8
|
-
consumerKey;
|
|
9
|
-
consumerSecret;
|
|
10
|
-
tokenEndpoint;
|
|
11
|
-
constructor(consumerKey, consumerSecret, tokenEndpoint = exports.DEFAULT_TOKEN_ENDPOINT) {
|
|
12
|
-
this.consumerKey = consumerKey;
|
|
13
|
-
this.consumerSecret = consumerSecret;
|
|
14
|
-
this.tokenEndpoint = tokenEndpoint;
|
|
15
|
-
}
|
|
16
|
-
async getAccessToken() {
|
|
17
|
-
if (!this.accessToken) {
|
|
18
|
-
this.accessToken = await this.fetchAccessToken();
|
|
19
|
-
}
|
|
20
|
-
if (this.accessToken.expired()) {
|
|
21
|
-
this.accessToken = await this.accessToken.refresh();
|
|
22
|
-
}
|
|
23
|
-
return this.accessToken.token.access_token;
|
|
24
|
-
}
|
|
25
|
-
fetchAccessToken() {
|
|
26
|
-
const client = new simple_oauth2_1.ClientCredentials({
|
|
27
|
-
auth: {
|
|
28
|
-
tokenHost: this.tokenEndpoint,
|
|
29
|
-
tokenPath: '/token',
|
|
30
|
-
},
|
|
31
|
-
client: {
|
|
32
|
-
id: this.consumerKey,
|
|
33
|
-
secret: this.consumerSecret,
|
|
34
|
-
},
|
|
35
|
-
options: {
|
|
36
|
-
authorizationMethod: 'body',
|
|
37
|
-
bodyFormat: 'form'
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
return client.getToken({});
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
exports.PlanqkServiceAuth = PlanqkServiceAuth;
|
package/dist/client.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { ServiceApi } from "./sdk/api/resources/serviceApi/client/Client";
|
|
2
|
-
export declare class PlanqkServiceClient {
|
|
3
|
-
private _api;
|
|
4
|
-
constructor(serviceEndpoint: string, consumerKey?: string, consumerSecret?: string, tokenEndpoint?: string);
|
|
5
|
-
api(): ServiceApi;
|
|
6
|
-
}
|
package/dist/client.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PlanqkServiceClient = void 0;
|
|
4
|
-
const auth_1 = require("./auth");
|
|
5
|
-
const sdk_1 = require("./sdk");
|
|
6
|
-
class PlanqkServiceClient {
|
|
7
|
-
_api;
|
|
8
|
-
constructor(serviceEndpoint, consumerKey, consumerSecret, tokenEndpoint = auth_1.DEFAULT_TOKEN_ENDPOINT) {
|
|
9
|
-
if (consumerKey && consumerSecret) {
|
|
10
|
-
const auth = new auth_1.PlanqkServiceAuth(consumerKey, consumerSecret, tokenEndpoint);
|
|
11
|
-
this._api = new sdk_1.PlanqkServiceApiClient({
|
|
12
|
-
environment: () => serviceEndpoint,
|
|
13
|
-
token: async () => auth.getAccessToken(),
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
17
|
-
this._api = new sdk_1.PlanqkServiceApiClient({
|
|
18
|
-
environment: () => serviceEndpoint,
|
|
19
|
-
token: async () => Math.random().toString(36).slice(2),
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
api() {
|
|
24
|
-
return this._api.serviceApi;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
exports.PlanqkServiceClient = PlanqkServiceClient;
|
package/dist/datapool.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export declare enum ReferenceType {
|
|
2
|
-
DATAPOOL = "DATAPOOL"
|
|
3
|
-
}
|
|
4
|
-
export interface DataPoolReference {
|
|
5
|
-
id: string;
|
|
6
|
-
ref: ReferenceType;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Factory function to create DataPoolReference objects with ref always set to DATAPOOL.
|
|
10
|
-
*/
|
|
11
|
-
export declare function withDataPoolReference(id: string): DataPoolReference;
|
package/dist/datapool.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ReferenceType = void 0;
|
|
4
|
-
exports.withDataPoolReference = withDataPoolReference;
|
|
5
|
-
var ReferenceType;
|
|
6
|
-
(function (ReferenceType) {
|
|
7
|
-
ReferenceType["DATAPOOL"] = "DATAPOOL";
|
|
8
|
-
})(ReferenceType || (exports.ReferenceType = ReferenceType = {}));
|
|
9
|
-
/**
|
|
10
|
-
* Factory function to create DataPoolReference objects with ref always set to DATAPOOL.
|
|
11
|
-
*/
|
|
12
|
-
function withDataPoolReference(id) {
|
|
13
|
-
return {
|
|
14
|
-
id,
|
|
15
|
-
ref: ReferenceType.DATAPOOL,
|
|
16
|
-
};
|
|
17
|
-
}
|
package/dist/index.d.ts
DELETED
package/dist/index.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PlanqkServiceClient = exports.PlanqkServiceAuth = void 0;
|
|
4
|
-
var auth_1 = require("./auth");
|
|
5
|
-
Object.defineProperty(exports, "PlanqkServiceAuth", { enumerable: true, get: function () { return auth_1.PlanqkServiceAuth; } });
|
|
6
|
-
var client_1 = require("./client");
|
|
7
|
-
Object.defineProperty(exports, "PlanqkServiceClient", { enumerable: true, get: function () { return client_1.PlanqkServiceClient; } });
|
package/dist/sdk/BaseClient.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import * as environments from "./environments.js";
|
|
2
|
-
import * as core from "./core/index.js";
|
|
3
|
-
export interface BaseClientOptions {
|
|
4
|
-
environment?: core.Supplier<environments.PlanqkServiceApiEnvironment | string>;
|
|
5
|
-
/** Specify a custom URL to connect the client to. */
|
|
6
|
-
baseUrl?: core.Supplier<string>;
|
|
7
|
-
token?: core.Supplier<core.BearerToken | undefined>;
|
|
8
|
-
/** Additional headers to include in requests. */
|
|
9
|
-
headers?: Record<string, string | core.Supplier<string | null | undefined> | null | undefined>;
|
|
10
|
-
/** The default maximum time to wait for a response in seconds. */
|
|
11
|
-
timeoutInSeconds?: number;
|
|
12
|
-
/** The default number of times to retry the request. Defaults to 2. */
|
|
13
|
-
maxRetries?: number;
|
|
14
|
-
}
|
|
15
|
-
export interface BaseRequestOptions {
|
|
16
|
-
/** The maximum time to wait for a response in seconds. */
|
|
17
|
-
timeoutInSeconds?: number;
|
|
18
|
-
/** The number of times to retry the request. Defaults to 2. */
|
|
19
|
-
maxRetries?: number;
|
|
20
|
-
/** A hook to abort the request. */
|
|
21
|
-
abortSignal?: AbortSignal;
|
|
22
|
-
/** Additional query string parameters to include in the request. */
|
|
23
|
-
queryParams?: Record<string, unknown>;
|
|
24
|
-
/** Additional headers to include in the request. */
|
|
25
|
-
headers?: Record<string, string | core.Supplier<string | null | undefined> | null | undefined>;
|
|
26
|
-
}
|
package/dist/sdk/BaseClient.js
DELETED
package/dist/sdk/Client.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { BaseClientOptions, BaseRequestOptions } from "./BaseClient.js";
|
|
2
|
-
import { ServiceApi } from "./api/resources/serviceApi/client/Client.js";
|
|
3
|
-
export declare namespace PlanqkServiceApiClient {
|
|
4
|
-
interface Options extends BaseClientOptions {
|
|
5
|
-
}
|
|
6
|
-
interface RequestOptions extends BaseRequestOptions {
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
export declare class PlanqkServiceApiClient {
|
|
10
|
-
protected readonly _options: PlanqkServiceApiClient.Options;
|
|
11
|
-
protected _serviceApi: ServiceApi | undefined;
|
|
12
|
-
constructor(_options?: PlanqkServiceApiClient.Options);
|
|
13
|
-
get serviceApi(): ServiceApi;
|
|
14
|
-
}
|
package/dist/sdk/Client.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// This file was auto-generated by Fern from our API Definition.
|
|
3
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
-
if (k2 === undefined) k2 = k;
|
|
5
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
-
}
|
|
9
|
-
Object.defineProperty(o, k2, desc);
|
|
10
|
-
}) : (function(o, m, k, k2) {
|
|
11
|
-
if (k2 === undefined) k2 = k;
|
|
12
|
-
o[k2] = m[k];
|
|
13
|
-
}));
|
|
14
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
-
}) : function(o, v) {
|
|
17
|
-
o["default"] = v;
|
|
18
|
-
});
|
|
19
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
-
var ownKeys = function(o) {
|
|
21
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
-
var ar = [];
|
|
23
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
-
return ar;
|
|
25
|
-
};
|
|
26
|
-
return ownKeys(o);
|
|
27
|
-
};
|
|
28
|
-
return function (mod) {
|
|
29
|
-
if (mod && mod.__esModule) return mod;
|
|
30
|
-
var result = {};
|
|
31
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
-
__setModuleDefault(result, mod);
|
|
33
|
-
return result;
|
|
34
|
-
};
|
|
35
|
-
})();
|
|
36
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
-
exports.PlanqkServiceApiClient = void 0;
|
|
38
|
-
const core = __importStar(require("./core/index.js"));
|
|
39
|
-
const headers_js_1 = require("./core/headers.js");
|
|
40
|
-
const Client_js_1 = require("./api/resources/serviceApi/client/Client.js");
|
|
41
|
-
class PlanqkServiceApiClient {
|
|
42
|
-
_options;
|
|
43
|
-
_serviceApi;
|
|
44
|
-
constructor(_options = {}) {
|
|
45
|
-
this._options = {
|
|
46
|
-
..._options,
|
|
47
|
-
headers: (0, headers_js_1.mergeHeaders)({
|
|
48
|
-
"X-Fern-Language": "JavaScript",
|
|
49
|
-
"X-Fern-Runtime": core.RUNTIME.type,
|
|
50
|
-
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
51
|
-
}, _options?.headers),
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
get serviceApi() {
|
|
55
|
-
return (this._serviceApi ??= new Client_js_1.ServiceApi(this._options));
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
exports.PlanqkServiceApiClient = PlanqkServiceApiClient;
|
package/dist/sdk/api/index.d.ts
DELETED
package/dist/sdk/api/index.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./types/index.js"), exports);
|
|
18
|
-
__exportStar(require("./resources/index.js"), exports);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * as serviceApi from "./serviceApi/index.js";
|