hanzo_client/apis/
lsp_api.rs1use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum PostLspCompleteError {
22 UnknownValue(serde_json::Value),
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum PostLspDiagnosticsError {
29 UnknownValue(serde_json::Value),
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum PostLspHoverError {
36 UnknownValue(serde_json::Value),
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum PostLspLocateError {
43 UnknownValue(serde_json::Value),
44}
45
46#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum PostLspSymbolsError {
50 UnknownValue(serde_json::Value),
51}
52
53
54pub async fn post_lsp_complete(configuration: &configuration::Configuration, query: models::Query) -> Result<models::Answer, Error<PostLspCompleteError>> {
56 let p_query = query;
58
59 let uri_str = format!("{}/v1/lsp/complete", configuration.base_path);
60 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
61
62 if let Some(ref user_agent) = configuration.user_agent {
63 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
64 }
65 if let Some(ref token) = configuration.bearer_access_token {
66 req_builder = req_builder.bearer_auth(token.to_owned());
67 };
68 req_builder = req_builder.json(&p_query);
69
70 let req = req_builder.build()?;
71 let resp = configuration.client.execute(req).await?;
72
73 let status = resp.status();
74 let content_type = resp
75 .headers()
76 .get("content-type")
77 .and_then(|v| v.to_str().ok())
78 .unwrap_or("application/octet-stream");
79 let content_type = super::ContentType::from(content_type);
80
81 if !status.is_client_error() && !status.is_server_error() {
82 let content = resp.text().await?;
83 match content_type {
84 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
85 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Answer`"))),
86 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Answer`")))),
87 }
88 } else {
89 let content = resp.text().await?;
90 let entity: Option<PostLspCompleteError> = serde_json::from_str(&content).ok();
91 Err(Error::ResponseError(ResponseContent { status, content, entity }))
92 }
93}
94
95pub async fn post_lsp_diagnostics(configuration: &configuration::Configuration, query: models::Query) -> Result<models::Answer, Error<PostLspDiagnosticsError>> {
97 let p_query = query;
99
100 let uri_str = format!("{}/v1/lsp/diagnostics", configuration.base_path);
101 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
102
103 if let Some(ref user_agent) = configuration.user_agent {
104 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
105 }
106 if let Some(ref token) = configuration.bearer_access_token {
107 req_builder = req_builder.bearer_auth(token.to_owned());
108 };
109 req_builder = req_builder.json(&p_query);
110
111 let req = req_builder.build()?;
112 let resp = configuration.client.execute(req).await?;
113
114 let status = resp.status();
115 let content_type = resp
116 .headers()
117 .get("content-type")
118 .and_then(|v| v.to_str().ok())
119 .unwrap_or("application/octet-stream");
120 let content_type = super::ContentType::from(content_type);
121
122 if !status.is_client_error() && !status.is_server_error() {
123 let content = resp.text().await?;
124 match content_type {
125 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
126 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Answer`"))),
127 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Answer`")))),
128 }
129 } else {
130 let content = resp.text().await?;
131 let entity: Option<PostLspDiagnosticsError> = serde_json::from_str(&content).ok();
132 Err(Error::ResponseError(ResponseContent { status, content, entity }))
133 }
134}
135
136pub async fn post_lsp_hover(configuration: &configuration::Configuration, query: models::Query) -> Result<models::Answer, Error<PostLspHoverError>> {
138 let p_query = query;
140
141 let uri_str = format!("{}/v1/lsp/hover", configuration.base_path);
142 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
143
144 if let Some(ref user_agent) = configuration.user_agent {
145 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
146 }
147 if let Some(ref token) = configuration.bearer_access_token {
148 req_builder = req_builder.bearer_auth(token.to_owned());
149 };
150 req_builder = req_builder.json(&p_query);
151
152 let req = req_builder.build()?;
153 let resp = configuration.client.execute(req).await?;
154
155 let status = resp.status();
156 let content_type = resp
157 .headers()
158 .get("content-type")
159 .and_then(|v| v.to_str().ok())
160 .unwrap_or("application/octet-stream");
161 let content_type = super::ContentType::from(content_type);
162
163 if !status.is_client_error() && !status.is_server_error() {
164 let content = resp.text().await?;
165 match content_type {
166 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
167 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Answer`"))),
168 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Answer`")))),
169 }
170 } else {
171 let content = resp.text().await?;
172 let entity: Option<PostLspHoverError> = serde_json::from_str(&content).ok();
173 Err(Error::ResponseError(ResponseContent { status, content, entity }))
174 }
175}
176
177pub async fn post_lsp_locate(configuration: &configuration::Configuration, query: models::Query) -> Result<models::Answer, Error<PostLspLocateError>> {
179 let p_query = query;
181
182 let uri_str = format!("{}/v1/lsp/locate", configuration.base_path);
183 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
184
185 if let Some(ref user_agent) = configuration.user_agent {
186 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
187 }
188 if let Some(ref token) = configuration.bearer_access_token {
189 req_builder = req_builder.bearer_auth(token.to_owned());
190 };
191 req_builder = req_builder.json(&p_query);
192
193 let req = req_builder.build()?;
194 let resp = configuration.client.execute(req).await?;
195
196 let status = resp.status();
197 let content_type = resp
198 .headers()
199 .get("content-type")
200 .and_then(|v| v.to_str().ok())
201 .unwrap_or("application/octet-stream");
202 let content_type = super::ContentType::from(content_type);
203
204 if !status.is_client_error() && !status.is_server_error() {
205 let content = resp.text().await?;
206 match content_type {
207 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
208 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Answer`"))),
209 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Answer`")))),
210 }
211 } else {
212 let content = resp.text().await?;
213 let entity: Option<PostLspLocateError> = serde_json::from_str(&content).ok();
214 Err(Error::ResponseError(ResponseContent { status, content, entity }))
215 }
216}
217
218pub async fn post_lsp_symbols(configuration: &configuration::Configuration, query: models::Query) -> Result<models::Answer, Error<PostLspSymbolsError>> {
220 let p_query = query;
222
223 let uri_str = format!("{}/v1/lsp/symbols", configuration.base_path);
224 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
225
226 if let Some(ref user_agent) = configuration.user_agent {
227 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
228 }
229 if let Some(ref token) = configuration.bearer_access_token {
230 req_builder = req_builder.bearer_auth(token.to_owned());
231 };
232 req_builder = req_builder.json(&p_query);
233
234 let req = req_builder.build()?;
235 let resp = configuration.client.execute(req).await?;
236
237 let status = resp.status();
238 let content_type = resp
239 .headers()
240 .get("content-type")
241 .and_then(|v| v.to_str().ok())
242 .unwrap_or("application/octet-stream");
243 let content_type = super::ContentType::from(content_type);
244
245 if !status.is_client_error() && !status.is_server_error() {
246 let content = resp.text().await?;
247 match content_type {
248 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
249 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Answer`"))),
250 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Answer`")))),
251 }
252 } else {
253 let content = resp.text().await?;
254 let entity: Option<PostLspSymbolsError> = serde_json::from_str(&content).ok();
255 Err(Error::ResponseError(ResponseContent { status, content, entity }))
256 }
257}
258