qcs_api/apis/
client_applications_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 [`check_client_application`]
17#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum CheckClientApplicationError {
20    Status404(crate::models::Error),
21    Status422(crate::models::Error),
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method [`get_client_application`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum GetClientApplicationError {
29    Status404(crate::models::Error),
30    UnknownValue(serde_json::Value),
31}
32
33/// struct for typed errors of method [`list_client_applications`]
34#[derive(Debug, Clone, Serialize, Deserialize)]
35#[serde(untagged)]
36pub enum ListClientApplicationsError {
37    UnknownValue(serde_json::Value),
38}
39
40/// Check the requested client application version against the latest and minimum version.
41pub async fn check_client_application(
42    configuration: &configuration::Configuration,
43    check_client_application_request: crate::models::CheckClientApplicationRequest,
44) -> Result<crate::models::CheckClientApplicationResponse, Error<CheckClientApplicationError>> {
45    let local_var_configuration = configuration;
46
47    let local_var_client = &local_var_configuration.client;
48
49    let local_var_uri_str = format!(
50        "{}/v1/clientApplications:check",
51        local_var_configuration.base_path
52    );
53    let mut local_var_req_builder =
54        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
55
56    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
57        local_var_req_builder =
58            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
59    }
60    local_var_req_builder = local_var_req_builder.json(&check_client_application_request);
61
62    let local_var_req = local_var_req_builder.build()?;
63    let local_var_resp = local_var_client.execute(local_var_req).await?;
64
65    let local_var_status = local_var_resp.status();
66    let local_var_content = local_var_resp.text().await?;
67
68    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
69        serde_json::from_str(&local_var_content).map_err(Error::from)
70    } else {
71        let local_var_entity: Option<CheckClientApplicationError> =
72            serde_json::from_str(&local_var_content).ok();
73        let local_var_error = ResponseContent {
74            status: local_var_status,
75            content: local_var_content,
76            entity: local_var_entity,
77        };
78        Err(Error::ResponseError(local_var_error))
79    }
80}
81
82/// Get details of a specific Rigetti system component along with its latest and minimum supported versions.
83pub async fn get_client_application(
84    configuration: &configuration::Configuration,
85    client_application_name: &str,
86) -> Result<crate::models::ClientApplication, Error<GetClientApplicationError>> {
87    let local_var_configuration = configuration;
88
89    let local_var_client = &local_var_configuration.client;
90
91    let local_var_uri_str = format!(
92        "{}/v1/clientApplications/{clientApplicationName}",
93        local_var_configuration.base_path,
94        clientApplicationName = crate::apis::urlencode(client_application_name)
95    );
96    let mut local_var_req_builder =
97        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
98
99    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
100        local_var_req_builder =
101            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
102    }
103
104    let local_var_req = local_var_req_builder.build()?;
105    let local_var_resp = local_var_client.execute(local_var_req).await?;
106
107    let local_var_status = local_var_resp.status();
108    let local_var_content = local_var_resp.text().await?;
109
110    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
111        serde_json::from_str(&local_var_content).map_err(Error::from)
112    } else {
113        let local_var_entity: Option<GetClientApplicationError> =
114            serde_json::from_str(&local_var_content).ok();
115        let local_var_error = ResponseContent {
116            status: local_var_status,
117            content: local_var_content,
118            entity: local_var_entity,
119        };
120        Err(Error::ResponseError(local_var_error))
121    }
122}
123
124/// List supported clients of Rigetti system components along with their latest and minimum supported versions.
125pub async fn list_client_applications(
126    configuration: &configuration::Configuration,
127) -> Result<crate::models::ListClientApplicationsResponse, Error<ListClientApplicationsError>> {
128    let local_var_configuration = configuration;
129
130    let local_var_client = &local_var_configuration.client;
131
132    let local_var_uri_str = format!(
133        "{}/v1/clientApplications",
134        local_var_configuration.base_path
135    );
136    let mut local_var_req_builder =
137        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
138
139    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
140        local_var_req_builder =
141            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
142    }
143
144    let local_var_req = local_var_req_builder.build()?;
145    let local_var_resp = local_var_client.execute(local_var_req).await?;
146
147    let local_var_status = local_var_resp.status();
148    let local_var_content = local_var_resp.text().await?;
149
150    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
151        serde_json::from_str(&local_var_content).map_err(Error::from)
152    } else {
153        let local_var_entity: Option<ListClientApplicationsError> =
154            serde_json::from_str(&local_var_content).ok();
155        let local_var_error = ResponseContent {
156            status: local_var_status,
157            content: local_var_content,
158            entity: local_var_entity,
159        };
160        Err(Error::ResponseError(local_var_error))
161    }
162}