ApiAdapter#

class qiskit_calculquebec.API.adapter.ApiAdapter#

Bases: object

Singleton wrapper around the Thunderhead REST API.

Initialize with ApiAdapter.initialize(client), then access the instance with ApiAdapter.instance(). Machine, benchmark, and qubit/coupler data are cached for up to 24 hours.

Provides: - Job submission and retrieval - Machine listing and lookup - Benchmark / calibration data retrieval - Project ID resolution by name

client: ApiClient#
headers: dict[str, str]#

clean_cache()

Clear all cached API responses (machine, benchmark, qubits/couplers).

get_benchmark(*args, **kwargs)

get_connectivity_for_machine()

Return the coupler-to-qubit connectivity map for a machine.

get_machine_by_name(*args, **kwargs)

get_project_id_by_name(*args, **kwargs)

get_qubits_and_couplers(*args, **kwargs)

initialize(client)

Create and configure the singleton ApiAdapter instance.

instance()

Return the singleton ApiAdapter instance.

is_last_update_expired()

Return whether the cached data is older than 24 hours.

job_by_id(*args, **kwargs)

list_jobs(*args, **kwargs)

list_machines(*args, **kwargs)

post_job(*args, **kwargs)

raise_exception(res)

Parse an HTTP response and raise an ApiException.

static clean_cache()#

Clear all cached API responses (machine, benchmark, qubits/couplers).

static get_benchmark(*args, **kwargs)#
get_connectivity_for_machine() dict#

Return the coupler-to-qubit connectivity map for a machine.

Parameters:

machine_name (str) – Name of the machine.

Returns:

Coupler-to-qubit mapping describing hardware connectivity.

Return type:

dict

Raises:

ApiException – If no machine with the given name is found.

static get_machine_by_name(*args, **kwargs)#
static get_project_id_by_name(*args, **kwargs)#
static get_qubits_and_couplers(*args, **kwargs)#
classmethod initialize(client: ApiClient)#

Create and configure the singleton ApiAdapter instance.

If client.project_name is set, the corresponding project ID is resolved automatically via the API.

Parameters:

client (ApiClient) – Authenticated client containing host, credentials, and project info.

classmethod instance() ApiAdapter#

Return the singleton ApiAdapter instance.

Returns:

The initialized singleton, or None if not yet initialized.

Return type:

ApiAdapter

static is_last_update_expired() bool#

Return whether the cached data is older than 24 hours.

Returns:

True if the cache is stale and should be refreshed.

Return type:

bool

static job_by_id(*args, **kwargs)#
static list_jobs(*args, **kwargs)#
static list_machines(*args, **kwargs)#
static post_job(*args, **kwargs)#
static raise_exception(res)#

Parse an HTTP response and raise an ApiException.

Attempts to extract a human-readable error message from the JSON body.

Parameters:

res (requests.Response) – The failed HTTP response.

Raises:

ApiException – Always raised with the status code and parsed message.