@planqk/planqk-api-sdk 1.2.0 → 1.3.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/.env.template +2 -1
- package/.gitlab-ci.yml +1 -0
- package/README-node.md +13 -0
- package/README-python.md +13 -0
- package/README.md +6 -49
- package/apps/python-test-app/main.py +159 -0
- package/apps/python-test-app/my_file.txt +1 -0
- package/apps/ts-test-app/index.ts +140 -0
- package/apps/ts-test-app/package-lock.json +693 -0
- package/apps/ts-test-app/package.json +19 -0
- package/apps/ts-test-app/test-file.txt +1 -0
- package/apps/ts-test-app/tsconfig.json +11 -0
- package/dist/index.d.ts +1 -4
- package/dist/index.js +4 -31
- package/dist/{Client.d.ts → sdk/Client.d.ts} +2 -5
- package/dist/{Client.js → sdk/Client.js} +1 -6
- package/dist/{api → sdk/api}/resources/dataPools/client/Client.d.ts +3 -3
- package/dist/{api → sdk/api}/resources/dataPools/client/Client.js +1 -1
- package/dist/sdk/api/resources/index.d.ts +2 -0
- package/dist/{api → sdk/api}/resources/index.js +1 -3
- package/dist/sdk/api/types/index.d.ts +3 -0
- package/dist/{api/resources/authentication → sdk/api}/types/index.js +3 -1
- package/dist/sdk/index.d.ts +4 -0
- package/dist/sdk/index.js +44 -0
- package/fern/fern.config.json +1 -1
- package/fern/openapi/openapi.json +2 -202
- package/package.json +3 -4
- package/planqk/api/_version.py +1 -1
- package/pyproject.toml +2 -6
- package/src/index.test.ts +6 -5
- package/src/index.ts +1 -4
- package/src/{Client.ts → sdk/Client.ts} +2 -8
- package/src/{api → sdk/api}/resources/dataPools/client/Client.ts +2 -2
- package/src/sdk/api/resources/index.ts +2 -0
- package/src/sdk/api/types/index.ts +3 -0
- package/src/sdk/index.ts +4 -0
- package/uv.lock +320 -297
- package/dist/api/resources/authentication/client/Client.d.ts +0 -55
- package/dist/api/resources/authentication/client/Client.js +0 -126
- package/dist/api/resources/authentication/client/index.d.ts +0 -1
- package/dist/api/resources/authentication/index.d.ts +0 -2
- package/dist/api/resources/authentication/index.js +0 -18
- package/dist/api/resources/authentication/types/AuthorizeResponse.d.ts +0 -5
- package/dist/api/resources/authentication/types/AuthorizeResponse.js +0 -5
- package/dist/api/resources/authentication/types/index.d.ts +0 -1
- package/dist/api/resources/dataPools/client/requests/index.js +0 -2
- package/dist/api/resources/index.d.ts +0 -4
- package/dist/api/types/AccessToken.d.ts +0 -10
- package/dist/api/types/AccessToken.js +0 -5
- package/dist/api/types/OrganizationMembership.d.ts +0 -22
- package/dist/api/types/OrganizationMembership.js +0 -19
- package/dist/api/types/PersonalAccessTokenPrincipal.d.ts +0 -18
- package/dist/api/types/PersonalAccessTokenPrincipal.js +0 -14
- package/dist/api/types/ServiceExecution.d.ts +0 -20
- package/dist/api/types/ServiceExecution.js +0 -16
- package/dist/api/types/ServiceExecutionTokenPrincipal.d.ts +0 -8
- package/dist/api/types/ServiceExecutionTokenPrincipal.js +0 -5
- package/dist/api/types/UserContext.d.ts +0 -24
- package/dist/api/types/UserContext.js +0 -19
- package/dist/api/types/index.d.ts +0 -9
- package/dist/api/types/index.js +0 -25
- package/src/api/resources/authentication/client/Client.ts +0 -134
- package/src/api/resources/authentication/client/index.ts +0 -1
- package/src/api/resources/authentication/index.ts +0 -2
- package/src/api/resources/authentication/types/AuthorizeResponse.ts +0 -7
- package/src/api/resources/authentication/types/index.ts +0 -1
- package/src/api/resources/index.ts +0 -4
- package/src/api/types/AccessToken.ts +0 -11
- package/src/api/types/OrganizationMembership.ts +0 -24
- package/src/api/types/PersonalAccessTokenPrincipal.ts +0 -21
- package/src/api/types/ServiceExecution.ts +0 -22
- package/src/api/types/ServiceExecutionTokenPrincipal.ts +0 -10
- package/src/api/types/UserContext.ts +0 -27
- package/src/api/types/index.ts +0 -9
- package/dist/{api → sdk/api}/errors/BadRequestError.d.ts +0 -0
- package/dist/{api → sdk/api}/errors/BadRequestError.js +0 -0
- package/dist/{api → sdk/api}/errors/ForbiddenError.d.ts +0 -0
- package/dist/{api → sdk/api}/errors/ForbiddenError.js +0 -0
- package/dist/{api → sdk/api}/errors/InternalServerError.d.ts +0 -0
- package/dist/{api → sdk/api}/errors/InternalServerError.js +0 -0
- package/dist/{api → sdk/api}/errors/NotFoundError.d.ts +0 -0
- package/dist/{api → sdk/api}/errors/NotFoundError.js +0 -0
- package/dist/{api → sdk/api}/errors/UnauthorizedError.d.ts +0 -0
- package/dist/{api → sdk/api}/errors/UnauthorizedError.js +0 -0
- package/dist/{api → sdk/api}/errors/index.d.ts +0 -0
- package/dist/{api → sdk/api}/errors/index.js +0 -0
- package/dist/{api → sdk/api}/index.d.ts +1 -1
- package/dist/{api → sdk/api}/index.js +1 -1
- package/dist/{api → sdk/api}/resources/dataPools/client/index.d.ts +0 -0
- package/dist/{api → sdk/api}/resources/dataPools/client/index.js +0 -0
- package/dist/{api → sdk/api}/resources/dataPools/client/requests/AddDataPoolFileRequest.d.ts +0 -0
- package/dist/{api → sdk/api}/resources/dataPools/client/requests/AddDataPoolFileRequest.js +0 -0
- package/dist/{api → sdk/api}/resources/dataPools/client/requests/CreateDataPoolRequest.d.ts +0 -0
- package/dist/{api → sdk/api}/resources/dataPools/client/requests/CreateDataPoolRequest.js +0 -0
- package/dist/{api → sdk/api}/resources/dataPools/client/requests/UpdateDataPoolRequest.d.ts +0 -0
- package/dist/{api → sdk/api}/resources/dataPools/client/requests/UpdateDataPoolRequest.js +0 -0
- package/dist/{api → sdk/api}/resources/dataPools/client/requests/index.d.ts +0 -0
- package/dist/{api/resources/authentication/client → sdk/api/resources/dataPools/client/requests}/index.js +0 -0
- package/dist/{api → sdk/api}/resources/dataPools/index.d.ts +0 -0
- package/dist/{api → sdk/api}/resources/dataPools/index.js +0 -0
- package/dist/{api → sdk/api}/types/DataPoolDto.d.ts +0 -0
- package/dist/{api → sdk/api}/types/DataPoolDto.js +0 -0
- package/dist/{api → sdk/api}/types/DataPoolFileDto.d.ts +0 -0
- package/dist/{api → sdk/api}/types/DataPoolFileDto.js +0 -0
- package/dist/{api → sdk/api}/types/OauthScope.d.ts +0 -0
- package/dist/{api → sdk/api}/types/OauthScope.js +0 -0
- package/dist/{core → sdk/core}/fetcher/APIResponse.d.ts +0 -0
- package/dist/{core → sdk/core}/fetcher/APIResponse.js +0 -0
- package/dist/{core → sdk/core}/fetcher/BinaryResponse.d.ts +0 -0
- package/dist/{core → sdk/core}/fetcher/BinaryResponse.js +0 -0
- package/dist/{core → sdk/core}/fetcher/Fetcher.d.ts +0 -0
- package/dist/{core → sdk/core}/fetcher/Fetcher.js +0 -0
- package/dist/{core → sdk/core}/fetcher/Headers.d.ts +0 -0
- package/dist/{core → sdk/core}/fetcher/Headers.js +0 -0
- package/dist/{core → sdk/core}/fetcher/HttpResponsePromise.d.ts +0 -0
- package/dist/{core → sdk/core}/fetcher/HttpResponsePromise.js +0 -0
- package/dist/{core → sdk/core}/fetcher/RawResponse.d.ts +0 -0
- package/dist/{core → sdk/core}/fetcher/RawResponse.js +0 -0
- package/dist/{core → sdk/core}/fetcher/ResponseWithBody.d.ts +0 -0
- package/dist/{core → sdk/core}/fetcher/ResponseWithBody.js +0 -0
- package/dist/{core → sdk/core}/fetcher/Supplier.d.ts +0 -0
- package/dist/{core → sdk/core}/fetcher/Supplier.js +0 -0
- package/dist/{core → sdk/core}/fetcher/createRequestUrl.d.ts +0 -0
- package/dist/{core → sdk/core}/fetcher/createRequestUrl.js +0 -0
- package/dist/{core → sdk/core}/fetcher/getErrorResponseBody.d.ts +0 -0
- package/dist/{core → sdk/core}/fetcher/getErrorResponseBody.js +0 -0
- package/dist/{core → sdk/core}/fetcher/getFetchFn.d.ts +0 -0
- package/dist/{core → sdk/core}/fetcher/getFetchFn.js +0 -0
- package/dist/{core → sdk/core}/fetcher/getHeader.d.ts +0 -0
- package/dist/{core → sdk/core}/fetcher/getHeader.js +0 -0
- package/dist/{core → sdk/core}/fetcher/getRequestBody.d.ts +0 -0
- package/dist/{core → sdk/core}/fetcher/getRequestBody.js +0 -0
- package/dist/{core → sdk/core}/fetcher/getResponseBody.d.ts +0 -0
- package/dist/{core → sdk/core}/fetcher/getResponseBody.js +0 -0
- package/dist/{core → sdk/core}/fetcher/index.d.ts +0 -0
- package/dist/{core → sdk/core}/fetcher/index.js +0 -0
- package/dist/{core → sdk/core}/fetcher/makeRequest.d.ts +0 -0
- package/dist/{core → sdk/core}/fetcher/makeRequest.js +0 -0
- package/dist/{core → sdk/core}/fetcher/requestWithRetries.d.ts +0 -0
- package/dist/{core → sdk/core}/fetcher/requestWithRetries.js +0 -0
- package/dist/{core → sdk/core}/fetcher/signals.d.ts +0 -0
- package/dist/{core → sdk/core}/fetcher/signals.js +0 -0
- package/dist/{core → sdk/core}/file.d.ts +0 -0
- package/dist/{core → sdk/core}/file.js +0 -0
- package/dist/{core → sdk/core}/form-data-utils/FormDataWrapper.d.ts +0 -0
- package/dist/{core → sdk/core}/form-data-utils/FormDataWrapper.js +0 -0
- package/dist/{core → sdk/core}/form-data-utils/encodeAsFormParameter.d.ts +0 -0
- package/dist/{core → sdk/core}/form-data-utils/encodeAsFormParameter.js +0 -0
- package/dist/{core → sdk/core}/form-data-utils/index.d.ts +0 -0
- package/dist/{core → sdk/core}/form-data-utils/index.js +0 -0
- package/dist/{core → sdk/core}/headers.d.ts +0 -0
- package/dist/{core → sdk/core}/headers.js +0 -0
- package/dist/{core → sdk/core}/index.d.ts +0 -0
- package/dist/{core → sdk/core}/index.js +0 -0
- package/dist/{core → sdk/core}/json.d.ts +0 -0
- package/dist/{core → sdk/core}/json.js +0 -0
- package/dist/{core → sdk/core}/runtime/index.d.ts +0 -0
- package/dist/{core → sdk/core}/runtime/index.js +0 -0
- package/dist/{core → sdk/core}/runtime/runtime.d.ts +0 -0
- package/dist/{core → sdk/core}/runtime/runtime.js +0 -0
- package/dist/{core → sdk/core}/url/index.d.ts +0 -0
- package/dist/{core → sdk/core}/url/index.js +0 -0
- package/dist/{core → sdk/core}/url/join.d.ts +0 -0
- package/dist/{core → sdk/core}/url/join.js +0 -0
- package/dist/{core → sdk/core}/url/qs.d.ts +0 -0
- package/dist/{core → sdk/core}/url/qs.js +0 -0
- package/dist/{environments.d.ts → sdk/environments.d.ts} +0 -0
- package/dist/{environments.js → sdk/environments.js} +0 -0
- package/dist/{errors → sdk/errors}/PlanqkApiError.d.ts +0 -0
- package/dist/{errors → sdk/errors}/PlanqkApiError.js +0 -0
- package/dist/{errors → sdk/errors}/PlanqkApiTimeoutError.d.ts +0 -0
- package/dist/{errors → sdk/errors}/PlanqkApiTimeoutError.js +0 -0
- package/dist/{errors → sdk/errors}/index.d.ts +0 -0
- package/dist/{errors → sdk/errors}/index.js +0 -0
- package/src/{api → sdk/api}/errors/BadRequestError.ts +0 -0
- package/src/{api → sdk/api}/errors/ForbiddenError.ts +0 -0
- package/src/{api → sdk/api}/errors/InternalServerError.ts +0 -0
- package/src/{api → sdk/api}/errors/NotFoundError.ts +0 -0
- package/src/{api → sdk/api}/errors/UnauthorizedError.ts +0 -0
- package/src/{api → sdk/api}/errors/index.ts +0 -0
- package/src/{api → sdk/api}/index.ts +1 -1
- /package/src/{api → sdk/api}/resources/dataPools/client/index.ts +0 -0
- /package/src/{api → sdk/api}/resources/dataPools/client/requests/AddDataPoolFileRequest.ts +0 -0
- /package/src/{api → sdk/api}/resources/dataPools/client/requests/CreateDataPoolRequest.ts +0 -0
- /package/src/{api → sdk/api}/resources/dataPools/client/requests/UpdateDataPoolRequest.ts +0 -0
- /package/src/{api → sdk/api}/resources/dataPools/client/requests/index.ts +0 -0
- /package/src/{api → sdk/api}/resources/dataPools/index.ts +0 -0
- /package/src/{api → sdk/api}/types/DataPoolDto.ts +0 -0
- /package/src/{api → sdk/api}/types/DataPoolFileDto.ts +0 -0
- /package/src/{api → sdk/api}/types/OauthScope.ts +0 -0
- /package/src/{core → sdk/core}/fetcher/APIResponse.ts +0 -0
- /package/src/{core → sdk/core}/fetcher/BinaryResponse.ts +0 -0
- /package/src/{core → sdk/core}/fetcher/Fetcher.ts +0 -0
- /package/src/{core → sdk/core}/fetcher/Headers.ts +0 -0
- /package/src/{core → sdk/core}/fetcher/HttpResponsePromise.ts +0 -0
- /package/src/{core → sdk/core}/fetcher/RawResponse.ts +0 -0
- /package/src/{core → sdk/core}/fetcher/ResponseWithBody.ts +0 -0
- /package/src/{core → sdk/core}/fetcher/Supplier.ts +0 -0
- /package/src/{core → sdk/core}/fetcher/createRequestUrl.ts +0 -0
- /package/src/{core → sdk/core}/fetcher/getErrorResponseBody.ts +0 -0
- /package/src/{core → sdk/core}/fetcher/getFetchFn.ts +0 -0
- /package/src/{core → sdk/core}/fetcher/getHeader.ts +0 -0
- /package/src/{core → sdk/core}/fetcher/getRequestBody.ts +0 -0
- /package/src/{core → sdk/core}/fetcher/getResponseBody.ts +0 -0
- /package/src/{core → sdk/core}/fetcher/index.ts +0 -0
- /package/src/{core → sdk/core}/fetcher/makeRequest.ts +0 -0
- /package/src/{core → sdk/core}/fetcher/requestWithRetries.ts +0 -0
- /package/src/{core → sdk/core}/fetcher/signals.ts +0 -0
- /package/src/{core → sdk/core}/file.ts +0 -0
- /package/src/{core → sdk/core}/form-data-utils/FormDataWrapper.ts +0 -0
- /package/src/{core → sdk/core}/form-data-utils/encodeAsFormParameter.ts +0 -0
- /package/src/{core → sdk/core}/form-data-utils/index.ts +0 -0
- /package/src/{core → sdk/core}/headers.ts +0 -0
- /package/src/{core → sdk/core}/index.ts +0 -0
- /package/src/{core → sdk/core}/json.ts +0 -0
- /package/src/{core → sdk/core}/runtime/index.ts +0 -0
- /package/src/{core → sdk/core}/runtime/runtime.ts +0 -0
- /package/src/{core → sdk/core}/url/index.ts +0 -0
- /package/src/{core → sdk/core}/url/join.ts +0 -0
- /package/src/{core → sdk/core}/url/qs.ts +0 -0
- /package/src/{environments.ts → sdk/environments.ts} +0 -0
- /package/src/{errors → sdk/errors}/PlanqkApiError.ts +0 -0
- /package/src/{errors → sdk/errors}/PlanqkApiTimeoutError.ts +0 -0
- /package/src/{errors → sdk/errors}/index.ts +0 -0
package/.env.template
CHANGED
package/.gitlab-ci.yml
CHANGED
package/README-node.md
ADDED
package/README-python.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# PLANQK API SDK
|
|
2
|
+
|
|
3
|
+
## Installation
|
|
4
|
+
|
|
5
|
+
The package is published on PyPI and can be installed via `pip`:
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install --upgrade planqk-api-sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
The usage docs are available at <https://docs.planqk.de/sdk-api-reference.html>.
|
package/README.md
CHANGED
|
@@ -1,56 +1,13 @@
|
|
|
1
|
-
#
|
|
1
|
+
# PLANQK API SDK
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
The clients are generated from a very general [OpenAPI](https://swagger.io/specification) description using [Fern](https://buildwithfern.com).
|
|
5
|
-
The generated clients are a baseline, and the idea is to adapt and extend them to our specific needs.
|
|
3
|
+
## Installation
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
> <https://buildwithfern.com/docs/getting-started>
|
|
10
|
-
|
|
11
|
-
```bash
|
|
12
|
-
npm install -g fern-api
|
|
13
|
-
fern upgrade
|
|
14
|
-
fern generate
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
## Python Setup
|
|
18
|
-
|
|
19
|
-
To create a new virtual environment and install the dependencies, run:
|
|
5
|
+
The package can be installed using `npm`:
|
|
20
6
|
|
|
21
7
|
```bash
|
|
22
|
-
|
|
23
|
-
source .venv/bin/activate
|
|
24
|
-
|
|
25
|
-
uv sync
|
|
8
|
+
npm install @planqk/planqk-api-sdk
|
|
26
9
|
```
|
|
27
10
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
```bash
|
|
31
|
-
uv sync -U
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
## How to update the Python client?
|
|
35
|
-
|
|
36
|
-
After generating the SDK clients with Fern, the Python client needs to be copied manually.
|
|
37
|
-
|
|
38
|
-
Copy the content of `./generated/python` to `./planqk/api/sdk`.
|
|
39
|
-
Make sure you overwrite any existing files.
|
|
40
|
-
It is recommended to remove the old files first.
|
|
41
|
-
|
|
42
|
-
Next, check if the changes are compatible with our wrapper, e.g., by running the notebooks.
|
|
43
|
-
|
|
44
|
-
## How to update the TypeScript client?
|
|
45
|
-
|
|
46
|
-
After generating the SDK clients with Fern, the TypeScript client needs to be copied manually.
|
|
47
|
-
|
|
48
|
-
Copy the content of `./generated/typescript` to `./typescript/src`.
|
|
49
|
-
Make sure you overwrite any existing files.
|
|
50
|
-
It is recommended to remove the old files first.
|
|
51
|
-
|
|
52
|
-
Next, check if the changes are compatible with our wrapper, e.g., by running the `index.test.ts` file.
|
|
53
|
-
|
|
54
|
-
## License
|
|
11
|
+
## Usage
|
|
55
12
|
|
|
56
|
-
|
|
13
|
+
The usage docs are available at <https://docs.planqk.de/sdk-api-reference.html>.
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import time
|
|
3
|
+
|
|
4
|
+
from dotenv import load_dotenv
|
|
5
|
+
|
|
6
|
+
from planqk.api.client import PlanqkApiClient
|
|
7
|
+
from planqk.api.sdk.core import RequestOptions
|
|
8
|
+
|
|
9
|
+
# Load environment variables from .env file
|
|
10
|
+
load_dotenv()
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def main():
|
|
14
|
+
print("--- Testing Data Pool Operations ---")
|
|
15
|
+
|
|
16
|
+
# Initialize client with environment variables
|
|
17
|
+
client = PlanqkApiClient(
|
|
18
|
+
access_token=os.getenv("PLANQK_ACCESS_TOKEN"),
|
|
19
|
+
organization_id=os.getenv("PLANQK_ORGANIZATION_ID")
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
# List Data Pools
|
|
23
|
+
start_time = time.time()
|
|
24
|
+
print("\nListing Data Pools...")
|
|
25
|
+
initial_data_pools = client.data_pools.get_data_pools()
|
|
26
|
+
print(f"Initial Number of Data Pools: {len(initial_data_pools)}")
|
|
27
|
+
print(f"List Data Pools: {time.time() - start_time:.3f}s")
|
|
28
|
+
|
|
29
|
+
# Create a Data Pool
|
|
30
|
+
start_time = time.time()
|
|
31
|
+
print("\nCreating a Data Pool...")
|
|
32
|
+
new_data_pool = client.data_pools.create_data_pool(name="Test Data Pool")
|
|
33
|
+
data_pool_id = new_data_pool.id
|
|
34
|
+
print(f"Created Data Pool with ID: {data_pool_id}, Name: {new_data_pool.name}")
|
|
35
|
+
print(f"Create Data Pool: {time.time() - start_time:.3f}s")
|
|
36
|
+
|
|
37
|
+
# Get a Specific Data Pool
|
|
38
|
+
start_time = time.time()
|
|
39
|
+
print("\nGetting the created Data Pool...")
|
|
40
|
+
fetched_data_pool = client.data_pools.get_data_pool(data_pool_id)
|
|
41
|
+
print(f"Fetched Data Pool Name: {fetched_data_pool.name}")
|
|
42
|
+
print(f"Get Specific Data Pool: {time.time() - start_time:.3f}s")
|
|
43
|
+
|
|
44
|
+
# Update a Data Pool
|
|
45
|
+
start_time = time.time()
|
|
46
|
+
print("\nUpdating the Data Pool...")
|
|
47
|
+
updated_data_pool = client.data_pools.update_data_pool(
|
|
48
|
+
id=data_pool_id,
|
|
49
|
+
name="Updated Test Data Pool 234",
|
|
50
|
+
description="This is an updated description."
|
|
51
|
+
)
|
|
52
|
+
print(f"Updated Data Pool Name: {updated_data_pool.name}, Description: {updated_data_pool.description}")
|
|
53
|
+
print(f"Update Data Pool: {time.time() - start_time:.3f}s")
|
|
54
|
+
|
|
55
|
+
print("\n--- Testing Data Pool File Operations ---")
|
|
56
|
+
|
|
57
|
+
# List Files in a Data Pool (initially empty)
|
|
58
|
+
start_time = time.time()
|
|
59
|
+
print("\nListing files in the Data Pool (should be empty)...")
|
|
60
|
+
initial_files = client.data_pools.get_data_pool_files(data_pool_id)
|
|
61
|
+
print(f"Initial Number of Files: {len(initial_files)}")
|
|
62
|
+
print(f"List Files (initial): {time.time() - start_time:.3f}s")
|
|
63
|
+
|
|
64
|
+
# Add a File to a Data Pool
|
|
65
|
+
start_time = time.time()
|
|
66
|
+
print("\nAdding a file to the Data Pool...")
|
|
67
|
+
file_to_upload = "my_file.txt"
|
|
68
|
+
with open(file_to_upload, "rb") as f:
|
|
69
|
+
added_file = client.data_pools.add_data_pool_file(
|
|
70
|
+
id=data_pool_id,
|
|
71
|
+
file=(file_to_upload, f)
|
|
72
|
+
)
|
|
73
|
+
file_id = added_file.id
|
|
74
|
+
print(f"Added File with ID: {added_file.id}, Name: {added_file.name}")
|
|
75
|
+
print(f"Add File: {time.time() - start_time:.3f}s")
|
|
76
|
+
|
|
77
|
+
# Add a large File to a Data Pool (if environment variable is set)
|
|
78
|
+
large_file_path = os.getenv("LARGE_TEST_FILE_PATH")
|
|
79
|
+
large_file_id = None
|
|
80
|
+
if large_file_path and os.path.exists(large_file_path):
|
|
81
|
+
start_time = time.time()
|
|
82
|
+
print("\nAdding a large file to the Data Pool...")
|
|
83
|
+
with open(large_file_path, "rb") as f:
|
|
84
|
+
large_file = client.data_pools.add_data_pool_file(
|
|
85
|
+
id=data_pool_id,
|
|
86
|
+
file=("300MB-test-file.zip", f),
|
|
87
|
+
request_options=RequestOptions(
|
|
88
|
+
timeout_in_seconds=600 # 10 minutes timeout for large file uploads
|
|
89
|
+
)
|
|
90
|
+
)
|
|
91
|
+
large_file_id = large_file.id
|
|
92
|
+
print(f"Added large file with ID: {large_file.id}, Name: {large_file.name}")
|
|
93
|
+
print(f"Add large file: {time.time() - start_time:.3f}s")
|
|
94
|
+
else:
|
|
95
|
+
if large_file_path:
|
|
96
|
+
print(f"\nLarge file {large_file_path} not found, skipping large file upload...")
|
|
97
|
+
else:
|
|
98
|
+
print("\nLARGE_TEST_FILE_PATH environment variable not set, skipping large file upload...")
|
|
99
|
+
|
|
100
|
+
# List Files in a Data Pool (after adding)
|
|
101
|
+
start_time = time.time()
|
|
102
|
+
print("\nListing files in the Data Pool (after adding)...")
|
|
103
|
+
files_after_add = client.data_pools.get_data_pool_files(data_pool_id)
|
|
104
|
+
print(f"Number of Files after adding: {len(files_after_add)}")
|
|
105
|
+
for file in files_after_add:
|
|
106
|
+
print(f" File ID: {file.id}, Name: {file.name}")
|
|
107
|
+
print(f"List Files (after add): {time.time() - start_time:.3f}s")
|
|
108
|
+
|
|
109
|
+
# Download a File from a Data Pool
|
|
110
|
+
download_file_id = large_file_id if large_file_id else file_id
|
|
111
|
+
start_time = time.time()
|
|
112
|
+
print("\nDownloading the file from the Data Pool...")
|
|
113
|
+
response = client.data_pools.get_data_pool_file(data_pool_id, download_file_id)
|
|
114
|
+
|
|
115
|
+
# Save the downloaded file
|
|
116
|
+
downloaded_filename = "downloaded-test-file.txt"
|
|
117
|
+
with open(downloaded_filename, "wb") as f:
|
|
118
|
+
for chunk in response:
|
|
119
|
+
f.write(chunk)
|
|
120
|
+
print(f"File downloaded to {downloaded_filename}.")
|
|
121
|
+
print(f"Download File: {time.time() - start_time:.3f}s")
|
|
122
|
+
|
|
123
|
+
for file in files_after_add:
|
|
124
|
+
# Delete a File from a Data Pool
|
|
125
|
+
start_time = time.time()
|
|
126
|
+
print("\nDeleting the file from the Data Pool...")
|
|
127
|
+
client.data_pools.delete_data_pool_file(data_pool_id, file.id)
|
|
128
|
+
print("File deleted.")
|
|
129
|
+
print(f"Delete File {file.name}: {time.time() - start_time:.3f}s")
|
|
130
|
+
|
|
131
|
+
# List Files in a Data Pool (after deleting)
|
|
132
|
+
start_time = time.time()
|
|
133
|
+
print("\nListing files in the Data Pool (after deleting)...")
|
|
134
|
+
files_after_delete = client.data_pools.get_data_pool_files(data_pool_id)
|
|
135
|
+
print(f"Number of Files after deleting: {len(files_after_delete)}")
|
|
136
|
+
print(f"List Files (after delete): {time.time() - start_time:.3f}s")
|
|
137
|
+
|
|
138
|
+
# Delete a Data Pool
|
|
139
|
+
start_time = time.time()
|
|
140
|
+
print("\nDeleting the Data Pool...")
|
|
141
|
+
client.data_pools.delete_data_pool(data_pool_id)
|
|
142
|
+
print("Data Pool deleted.")
|
|
143
|
+
print(f"Delete Data Pool: {time.time() - start_time:.3f}s")
|
|
144
|
+
|
|
145
|
+
# Verify Data Pool deletion
|
|
146
|
+
start_time = time.time()
|
|
147
|
+
print("\nVerifying Data Pool deletion...")
|
|
148
|
+
final_data_pools = client.data_pools.get_data_pools()
|
|
149
|
+
print(f"Final Number of Data Pools: {len(final_data_pools)}")
|
|
150
|
+
print(f"Verify Data Pool Deletion: {time.time() - start_time:.3f}s")
|
|
151
|
+
|
|
152
|
+
print("\n--- All documented calls tested ---")
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
if __name__ == "__main__":
|
|
156
|
+
try:
|
|
157
|
+
main()
|
|
158
|
+
except Exception as e:
|
|
159
|
+
print(f"Error: {e}")
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Hello World
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import {PlanqkApiClient} from "@planqk/planqk-api-sdk"
|
|
2
|
+
import * as fs from "fs";
|
|
3
|
+
import {Readable} from "stream";
|
|
4
|
+
import * as dotenv from "dotenv";
|
|
5
|
+
|
|
6
|
+
dotenv.config();
|
|
7
|
+
|
|
8
|
+
const client = new PlanqkApiClient({
|
|
9
|
+
apiKey: process.env.PLANQK_ACCESS_TOKEN!,
|
|
10
|
+
baseUrl: process.env.PLANQK_API_BASE_URL || "https://platform.planqk.de/qc-catalog",
|
|
11
|
+
organizationId: process.env.PLANQK_ORGANIZATION_ID
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
async function main() {
|
|
15
|
+
console.log("--- Testing Data Pool Operations ---");
|
|
16
|
+
|
|
17
|
+
// List Data Pools
|
|
18
|
+
console.time("List Data Pools");
|
|
19
|
+
console.log("\nListing Data Pools...");
|
|
20
|
+
const initialDataPools = await client.dataPools.getDataPools();
|
|
21
|
+
console.log(`Initial Number of Data Pools: ${initialDataPools.length}`);
|
|
22
|
+
console.timeEnd("List Data Pools");
|
|
23
|
+
|
|
24
|
+
// Create a Data Pool
|
|
25
|
+
console.time("Create Data Pool");
|
|
26
|
+
console.log("\nCreating a Data Pool...");
|
|
27
|
+
const newDataPool = await client.dataPools.createDataPool({name: "Test Data Pool"});
|
|
28
|
+
const dataPoolId: string = newDataPool.id!;
|
|
29
|
+
console.log(`Created Data Pool with ID: ${dataPoolId}, Name: ${newDataPool.name}`);
|
|
30
|
+
console.timeEnd("Create Data Pool");
|
|
31
|
+
|
|
32
|
+
// Get a Specific Data Pool
|
|
33
|
+
console.time("Get Specific Data Pool");
|
|
34
|
+
console.log("\nGetting the created Data Pool...");
|
|
35
|
+
const fetchedDataPool = await client.dataPools.getDataPool(dataPoolId);
|
|
36
|
+
console.log(`Fetched Data Pool Name: ${fetchedDataPool.name}`);
|
|
37
|
+
console.timeEnd("Get Specific Data Pool");
|
|
38
|
+
|
|
39
|
+
// Update a Data Pool
|
|
40
|
+
console.time("Update Data Pool");
|
|
41
|
+
console.log("\nUpdating the Data Pool...");
|
|
42
|
+
const updatedDataPool = await client.dataPools.updateDataPool(dataPoolId, {
|
|
43
|
+
name: "Updated Test Data Pool",
|
|
44
|
+
description: "This is an updated description.",
|
|
45
|
+
});
|
|
46
|
+
console.log(`Updated Data Pool Name: ${updatedDataPool.name}, Description: ${updatedDataPool.description}`);
|
|
47
|
+
console.timeEnd("Update Data Pool");
|
|
48
|
+
|
|
49
|
+
console.log("\n--- Testing Data Pool File Operations ---");
|
|
50
|
+
|
|
51
|
+
// List Files in a Data Pool (initially empty)
|
|
52
|
+
console.time("List Files (initial)");
|
|
53
|
+
console.log("\nListing files in the Data Pool (should be empty)...");
|
|
54
|
+
const initialFiles = await client.dataPools.getDataPoolFiles(dataPoolId);
|
|
55
|
+
console.log(`Initial Number of Files: ${initialFiles.length}`);
|
|
56
|
+
console.timeEnd("List Files (initial)");
|
|
57
|
+
|
|
58
|
+
// Add a File to a Data Pool
|
|
59
|
+
console.time("Add File");
|
|
60
|
+
console.log("\nAdding a file to the Data Pool...");
|
|
61
|
+
const addedFile = await client.dataPools.addDataPoolFile(dataPoolId, {
|
|
62
|
+
file: fs.createReadStream("test-file.txt"),
|
|
63
|
+
filename: "my-test-file.txt",
|
|
64
|
+
});
|
|
65
|
+
const fileId = addedFile.id!;
|
|
66
|
+
console.log(`Added File with ID: ${addedFile.id}, Name: ${addedFile.name}`);
|
|
67
|
+
console.timeEnd("Add File");
|
|
68
|
+
|
|
69
|
+
const largeTestFile = process.env.LARGE_TEST_FILE_PATH;
|
|
70
|
+
if (largeTestFile) {
|
|
71
|
+
// Add a File to a Data Pool
|
|
72
|
+
console.time("Add large file");
|
|
73
|
+
console.log("\nAdding a large file to the Data Pool...");
|
|
74
|
+
const largeFile = await client.dataPools.addDataPoolFile(
|
|
75
|
+
dataPoolId,
|
|
76
|
+
{
|
|
77
|
+
file: fs.createReadStream(largeTestFile),
|
|
78
|
+
filename: largeTestFile,
|
|
79
|
+
}, {
|
|
80
|
+
timeoutInSeconds: 600 // 10 minutes timeout for large file uploads
|
|
81
|
+
}
|
|
82
|
+
);
|
|
83
|
+
console.log(`Added large file with ID: ${largeFile.id}, Name: ${largeFile.name}`);
|
|
84
|
+
console.timeEnd("Add large file");
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// List Files in a Data Pool (after adding)
|
|
88
|
+
console.time("List Files (after add)");
|
|
89
|
+
console.log("\nListing files in the Data Pool (after adding)...");
|
|
90
|
+
const filesAfterAdd = await client.dataPools.getDataPoolFiles(dataPoolId);
|
|
91
|
+
console.log(`Number of Files after adding: ${filesAfterAdd.length}`);
|
|
92
|
+
for (const file of filesAfterAdd) {
|
|
93
|
+
console.log(` File ID: ${file.id}, Name: ${file.name}`);
|
|
94
|
+
}
|
|
95
|
+
console.timeEnd("List Files (after add)");
|
|
96
|
+
|
|
97
|
+
// Download a File from a Data Pool
|
|
98
|
+
console.time("Download File");
|
|
99
|
+
console.log("\nDownloading the file from the Data Pool...");
|
|
100
|
+
const response = await client.dataPools.getDataPoolFile(dataPoolId, fileId);
|
|
101
|
+
const dest = fs.createWriteStream("test-file.txt");
|
|
102
|
+
Readable.fromWeb(response.stream() as any).pipe(dest);
|
|
103
|
+
await new Promise<void>((resolve) => dest.on("finish", () => resolve())); // Wait for download to complete
|
|
104
|
+
console.log("File downloaded to downloaded-test-file.txt.");
|
|
105
|
+
console.timeEnd("Download File");
|
|
106
|
+
|
|
107
|
+
for (const file of filesAfterAdd) {
|
|
108
|
+
// Delete a File from a Data Pool
|
|
109
|
+
console.time("Delete File");
|
|
110
|
+
console.log("\nDeleting the file from the Data Pool...");
|
|
111
|
+
await client.dataPools.deleteDataPoolFile(dataPoolId, file.id!);
|
|
112
|
+
console.log("File deleted.");
|
|
113
|
+
console.timeEnd(`Delete File ${file.name}`);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// List Files in a Data Pool (after deleting)
|
|
117
|
+
console.time("List Files (after delete)");
|
|
118
|
+
console.log("\nListing files in the Data Pool (after deleting)...");
|
|
119
|
+
const filesAfterDelete = await client.dataPools.getDataPoolFiles(dataPoolId);
|
|
120
|
+
console.log(`Number of Files after deleting: ${filesAfterDelete.length}`);
|
|
121
|
+
console.timeEnd("List Files (after delete)");
|
|
122
|
+
|
|
123
|
+
// Delete a Data Pool
|
|
124
|
+
console.time("Delete Data Pool");
|
|
125
|
+
console.log("\nDeleting the Data Pool...");
|
|
126
|
+
await client.dataPools.deleteDataPool(dataPoolId);
|
|
127
|
+
console.log("Data Pool deleted.");
|
|
128
|
+
console.timeEnd("Delete Data Pool");
|
|
129
|
+
|
|
130
|
+
// Verify Data Pool deletion
|
|
131
|
+
console.time("Verify Data Pool Deletion");
|
|
132
|
+
console.log("\nVerifying Data Pool deletion...");
|
|
133
|
+
const finalDataPools = await client.dataPools.getDataPools();
|
|
134
|
+
console.log(`Final Number of Data Pools: ${finalDataPools.length}`);
|
|
135
|
+
console.timeEnd("Verify Data Pool Deletion");
|
|
136
|
+
|
|
137
|
+
console.log("\n--- All documented calls tested ---");
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
main().catch(console.error);
|