ApiUtility#
- class qiskit_calculquebec.API.api_utility.ApiUtility#
Bases:
objectStatic helper methods for building Thunderhead API payloads.
Methods
basic_auth(username, password)Build a Basic Authentication header value.
convert_circuit(circuit)Convert a
QuantumCircuitto the Thunderhead circuit dictionary format.convert_instruction(instruction)Convert a Qiskit gate to a Thunderhead operation dictionary.
headers(username, password, realm)Build the HTTP request headers required by the Thunderhead API.
job_body(circuit, circuit_name, project_id, ...)Build the request body for the
POST /jobsendpoint.- static basic_auth(username: str, password: str) str#
Build a Basic Authentication header value.
- Parameters:
username (str) – Thunderhead username.
password (str) – Thunderhead access token.
- Returns:
"Basic <base64-encoded credentials>"header value.- Return type:
str
- static convert_circuit(circuit: QuantumCircuit) dict#
Convert a
QuantumCircuitto the Thunderhead circuit dictionary format.- Parameters:
circuit (QuantumCircuit) – Circuit to convert. All instructions must be in the supported gate set.
- Returns:
- Thunderhead circuit dict with
type,bitCount, qubitCount, andoperationsfields.
- Thunderhead circuit dict with
- Return type:
dict
- static convert_instruction(instruction: Gate) dict#
Convert a Qiskit gate to a Thunderhead operation dictionary.
- Parameters:
instruction (Gate) – A Qiskit gate instance with
qubits,clbits, andparamsattributes populated (as found inQuantumCircuit.data).- Returns:
- Thunderhead operation dict with
type,qubits, and optionally
bitsorparametersfields.
- Thunderhead operation dict with
- Return type:
dict
- Raises:
ValueError – If the instruction name is not in the supported gate set.
- static headers(username: str, password: str, realm: str) dict[str, str]#
Build the HTTP request headers required by the Thunderhead API.
- Parameters:
username (str) – Thunderhead username.
password (str) – Thunderhead access token.
realm (str) – Organizational realm identifier.
- Returns:
- Headers dict containing
Authorization, Content-Type, andX-Realm.
- Headers dict containing
- Return type:
dict[str, str]
- static job_body(circuit: dict, circuit_name: str, project_id: str, machine_name: str, shots: int) dict#
Build the request body for the
POST /jobsendpoint.- Parameters:
circuit (dict) – Circuit in Thunderhead dictionary format.
circuit_name (str) – Human-readable label for the circuit.
project_id (str) – ID of the project under which the job will be billed.
machine_name (str) – Target machine name (e.g.
"yukon").shots (int) – Number of shots to execute.
- Returns:
JSON-serializable body for the job creation request.
- Return type:
dict