@planqk/planqk-service-sdk
v2.12.0
Published
SDK to interact with PLANQK Managed Services.
Readme
PLANQK Service SDK
Installation
The package can be installed using npm:
npm install @planqk/planqk-service-sdkUsage
const serviceEndpoint = "..."
const accessKeyId = "..."
const secretAccessKey = "..."
// Create a new PlanqkServiceClient instance
const client = new PlanqkServiceClient(serviceEndpoint, accessKeyId, secretAccessKey)
// List all service executions
const serviceExecutions = await client.api().getServiceExecutions()
// Start a new service execution
const data = {n_coin_tosses: 2}
const params = {shots: 100}
let serviceExecution = await client.api().startExecution({data, params}, {timeoutInSeconds: 60})
// Check the status of the service execution
serviceExecution = await client.api().getStatus(serviceExecution.id!)
// Wait for the service execution to finish
const finalStates = ["SUCCEEDED", "CANCELLED", "FAILED"]
while (!finalStates.includes(serviceExecution.status!)) {
serviceExecution = await client.api().getStatus(serviceExecution.id!)
}
// Get the result of the service execution
const result = await client.api().getResult(serviceExecution.id!)
// Get the logs of the service execution
const logs = await client.api().getLogs(serviceExecution.id!)
// Cancel the service execution if it is still pending or running
await client.api().cancelExecution(serviceExecution.id!)