qcs_api/apis/
translation_api.rs1use reqwest;
12
13use super::{configuration, Error};
14use crate::apis::ResponseContent;
15
16#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum GetQuiltCalibrationsError {
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 TranslateNativeQuilToEncryptedBinaryError {
29 Status400(crate::models::Error),
30 Status404(crate::models::Error),
31 Status422(crate::models::ValidationError),
32 UnknownValue(serde_json::Value),
33}
34
35pub async fn get_quilt_calibrations(
37 configuration: &configuration::Configuration,
38 quantum_processor_id: &str,
39) -> Result<crate::models::GetQuiltCalibrationsResponse, Error<GetQuiltCalibrationsError>> {
40 let local_var_configuration = configuration;
41
42 let local_var_client = &local_var_configuration.client;
43
44 let local_var_uri_str = format!(
45 "{}/v1/quantumProcessors/{quantumProcessorId}/quiltCalibrations",
46 local_var_configuration.base_path,
47 quantumProcessorId = crate::apis::urlencode(quantum_processor_id)
48 );
49 let mut local_var_req_builder =
50 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
51
52 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
53 local_var_req_builder =
54 local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
55 }
56 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
57 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
58 };
59
60 let local_var_req = local_var_req_builder.build()?;
61 let local_var_resp = local_var_client.execute(local_var_req).await?;
62
63 let local_var_status = local_var_resp.status();
64 let local_var_content = local_var_resp.text().await?;
65
66 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
67 serde_json::from_str(&local_var_content).map_err(Error::from)
68 } else {
69 let local_var_entity: Option<GetQuiltCalibrationsError> =
70 serde_json::from_str(&local_var_content).ok();
71 let local_var_error = ResponseContent {
72 status: local_var_status,
73 content: local_var_content,
74 entity: local_var_entity,
75 };
76 Err(Error::ResponseError(local_var_error))
77 }
78}
79
80pub async fn translate_native_quil_to_encrypted_binary(
82 configuration: &configuration::Configuration,
83 quantum_processor_id: &str,
84 translate_native_quil_to_encrypted_binary_request: crate::models::TranslateNativeQuilToEncryptedBinaryRequest,
85) -> Result<
86 crate::models::TranslateNativeQuilToEncryptedBinaryResponse,
87 Error<TranslateNativeQuilToEncryptedBinaryError>,
88> {
89 let local_var_configuration = configuration;
90
91 let local_var_client = &local_var_configuration.client;
92
93 let local_var_uri_str = format!(
94 "{}/v1/quantumProcessors/{quantumProcessorId}:translateNativeQuilToEncryptedBinary",
95 local_var_configuration.base_path,
96 quantumProcessorId = crate::apis::urlencode(quantum_processor_id)
97 );
98 let mut local_var_req_builder =
99 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
100
101 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
102 local_var_req_builder =
103 local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
104 }
105 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
106 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
107 };
108 local_var_req_builder =
109 local_var_req_builder.json(&translate_native_quil_to_encrypted_binary_request);
110
111 let local_var_req = local_var_req_builder.build()?;
112 let local_var_resp = local_var_client.execute(local_var_req).await?;
113
114 let local_var_status = local_var_resp.status();
115 let local_var_content = local_var_resp.text().await?;
116
117 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
118 serde_json::from_str(&local_var_content).map_err(Error::from)
119 } else {
120 let local_var_entity: Option<TranslateNativeQuilToEncryptedBinaryError> =
121 serde_json::from_str(&local_var_content).ok();
122 let local_var_error = ResponseContent {
123 status: local_var_status,
124 content: local_var_content,
125 entity: local_var_entity,
126 };
127 Err(Error::ResponseError(local_var_error))
128 }
129}