qcs_api/apis/
quantum_processors_api.rs

1/*
2 * Rigetti QCS API
3 *
4 * # Introduction  This is the documentation for the Rigetti QCS HTTP API.  You can find out more about Rigetti at [https://rigetti.com](https://rigetti.com), and also interact with QCS via the web at [https://qcs.rigetti.com](https://qcs.rigetti.com).  This API is documented in **OpenAPI format** and so is compatible with the dozens of language-specific client generators available [here](https://github.com/OpenAPITools/openapi-generator) and elsewhere on the web.  # Principles  This API follows REST design principles where appropriate, and otherwise an HTTP RPC paradigm. We adhere to the Google [API Improvement Proposals](https://google.aip.dev/general) where reasonable to provide a consistent, intuitive developer experience. HTTP response codes match their specifications, and error messages fit a common format.  # Authentication  All access to the QCS API requires OAuth2 authentication provided by Okta. You can request access [here](https://www.rigetti.com/get-quantum). Once you have a user account, you can download your access token from QCS [here](https://qcs.rigetti.com/auth/token).   That access token is valid for 24 hours after issuance. The value of `access_token` within the JSON file is the token used for authentication (don't use the entire JSON file).  Authenticate requests using the `Authorization` header and a `Bearer` prefix:  ``` curl --header \"Authorization: Bearer eyJraW...Iow\" ```  # Quantum Processor Access  Access to the quantum processors themselves is not yet provided directly by this HTTP API, but is instead performed over ZeroMQ/[rpcq](https://gitlab.com/rigetti/rpcq). Until that changes, we suggest using [pyquil](https://gitlab.com/rigetti/pyquil) to build and execute quantum programs via the Legacy API.  # Legacy API  Our legacy HTTP API remains accessible at https://forest-server.qcs.rigetti.com, and it shares a source of truth with this API's services. You can use either service with the same user account and means of authentication. We strongly recommend using the API documented here, as the legacy API is on the path to deprecation.
5 *
6 * The version of the OpenAPI document: 2020-07-31
7 * Contact: support@rigetti.com
8 * Generated by: https://openapi-generator.tech
9 */
10
11use reqwest;
12
13use super::{configuration, Error};
14use crate::apis::ResponseContent;
15
16/// struct for typed errors of method [`get_instruction_set_architecture`]
17#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum GetInstructionSetArchitectureError {
20    Status404(crate::models::Error),
21    Status422(crate::models::ValidationError),
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method [`get_quantum_processor`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum GetQuantumProcessorError {
29    Status404(crate::models::Error),
30    Status422(crate::models::ValidationError),
31    UnknownValue(serde_json::Value),
32}
33
34/// struct for typed errors of method [`list_quantum_processors`]
35#[derive(Debug, Clone, Serialize, Deserialize)]
36#[serde(untagged)]
37pub enum ListQuantumProcessorsError {
38    Status422(crate::models::ValidationError),
39    UnknownValue(serde_json::Value),
40}
41
42/// Retrieve the Instruction Set Architecture of a QuantumProcessor by ID.
43pub async fn get_instruction_set_architecture(
44    configuration: &configuration::Configuration,
45    quantum_processor_id: &str,
46) -> Result<crate::models::InstructionSetArchitecture, Error<GetInstructionSetArchitectureError>> {
47    let local_var_configuration = configuration;
48
49    let local_var_client = &local_var_configuration.client;
50
51    let local_var_uri_str = format!(
52        "{}/v1/quantumProcessors/{quantumProcessorId}/instructionSetArchitecture",
53        local_var_configuration.base_path,
54        quantumProcessorId = crate::apis::urlencode(quantum_processor_id)
55    );
56    let mut local_var_req_builder =
57        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
58
59    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
60        local_var_req_builder =
61            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
62    }
63    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
64        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
65    };
66
67    let local_var_req = local_var_req_builder.build()?;
68    let local_var_resp = local_var_client.execute(local_var_req).await?;
69
70    let local_var_status = local_var_resp.status();
71    let local_var_content = local_var_resp.text().await?;
72
73    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
74        serde_json::from_str(&local_var_content).map_err(Error::from)
75    } else {
76        let local_var_entity: Option<GetInstructionSetArchitectureError> =
77            serde_json::from_str(&local_var_content).ok();
78        let local_var_error = ResponseContent {
79            status: local_var_status,
80            content: local_var_content,
81            entity: local_var_entity,
82        };
83        Err(Error::ResponseError(local_var_error))
84    }
85}
86
87/// Retrieve a single QuantumProcessor by ID.
88pub async fn get_quantum_processor(
89    configuration: &configuration::Configuration,
90    quantum_processor_id: &str,
91) -> Result<crate::models::QuantumProcessor, Error<GetQuantumProcessorError>> {
92    let local_var_configuration = configuration;
93
94    let local_var_client = &local_var_configuration.client;
95
96    let local_var_uri_str = format!(
97        "{}/v1/quantumProcessors/{quantumProcessorId}",
98        local_var_configuration.base_path,
99        quantumProcessorId = crate::apis::urlencode(quantum_processor_id)
100    );
101    let mut local_var_req_builder =
102        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
103
104    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
105        local_var_req_builder =
106            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
107    }
108    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
109        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
110    };
111
112    let local_var_req = local_var_req_builder.build()?;
113    let local_var_resp = local_var_client.execute(local_var_req).await?;
114
115    let local_var_status = local_var_resp.status();
116    let local_var_content = local_var_resp.text().await?;
117
118    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
119        serde_json::from_str(&local_var_content).map_err(Error::from)
120    } else {
121        let local_var_entity: Option<GetQuantumProcessorError> =
122            serde_json::from_str(&local_var_content).ok();
123        let local_var_error = ResponseContent {
124            status: local_var_status,
125            content: local_var_content,
126            entity: local_var_entity,
127        };
128        Err(Error::ResponseError(local_var_error))
129    }
130}
131
132/// List all QuantumProcessors available to the user.
133pub async fn list_quantum_processors(
134    configuration: &configuration::Configuration,
135    page_size: Option<i32>,
136    page_token: Option<&str>,
137) -> Result<crate::models::ListQuantumProcessorsResponse, Error<ListQuantumProcessorsError>> {
138    let local_var_configuration = configuration;
139
140    let local_var_client = &local_var_configuration.client;
141
142    let local_var_uri_str = format!("{}/v1/quantumProcessors", local_var_configuration.base_path);
143    let mut local_var_req_builder =
144        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
145
146    if let Some(ref local_var_str) = page_size {
147        local_var_req_builder =
148            local_var_req_builder.query(&[("pageSize", &local_var_str.to_string())]);
149    }
150    if let Some(ref local_var_str) = page_token {
151        local_var_req_builder =
152            local_var_req_builder.query(&[("pageToken", &local_var_str.to_string())]);
153    }
154    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
155        local_var_req_builder =
156            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
157    }
158    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
159        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
160    };
161
162    let local_var_req = local_var_req_builder.build()?;
163    let local_var_resp = local_var_client.execute(local_var_req).await?;
164
165    let local_var_status = local_var_resp.status();
166    let local_var_content = local_var_resp.text().await?;
167
168    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
169        serde_json::from_str(&local_var_content).map_err(Error::from)
170    } else {
171        let local_var_entity: Option<ListQuantumProcessorsError> =
172            serde_json::from_str(&local_var_content).ok();
173        let local_var_error = ResponseContent {
174            status: local_var_status,
175            content: local_var_content,
176            entity: local_var_entity,
177        };
178        Err(Error::ResponseError(local_var_error))
179    }
180}