qcs_api/apis/
quantum_processors_api.rs1use reqwest;
12
13use super::{configuration, Error};
14use crate::apis::ResponseContent;
15
16#[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#[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#[derive(Debug, Clone, Serialize, Deserialize)]
36#[serde(untagged)]
37pub enum ListQuantumProcessorsError {
38 Status422(crate::models::ValidationError),
39 UnknownValue(serde_json::Value),
40}
41
42pub 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
87pub 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
132pub 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}