langgraph_api/generated/apis/
store_api.rs1use super::{ContentType, Error, UploadFile, configuration};
12use crate::{apis::ResponseContent, models};
13use reqwest;
14use serde::{Deserialize, Serialize, de::Error as _};
15
16#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum DeleteItemError {
20 Status422(String),
21 UnknownValue(serde_json::Value),
22}
23
24#[derive(Debug, Clone, Serialize, Deserialize)]
26#[serde(untagged)]
27pub enum GetItemError {
28 Status400(String),
29 Status422(String),
30 UnknownValue(serde_json::Value),
31}
32
33#[derive(Debug, Clone, Serialize, Deserialize)]
35#[serde(untagged)]
36pub enum ListNamespacesError {
37 Status422(String),
38 UnknownValue(serde_json::Value),
39}
40
41#[derive(Debug, Clone, Serialize, Deserialize)]
43#[serde(untagged)]
44pub enum PutItemError {
45 Status422(String),
46 UnknownValue(serde_json::Value),
47}
48
49#[derive(Debug, Clone, Serialize, Deserialize)]
51#[serde(untagged)]
52pub enum SearchItemsError {
53 Status422(String),
54 UnknownValue(serde_json::Value),
55}
56
57pub fn delete_item_request_builder(
58 configuration: &configuration::Configuration,
59 store_delete_request: models::StoreDeleteRequest,
60) -> Result<reqwest::RequestBuilder, Error<serde_json::Error>> {
61 let p_body_store_delete_request = store_delete_request;
63
64 let uri_str = format!("{}/store/items", configuration.base_path);
65 let mut req_builder = configuration
66 .client
67 .request(reqwest::Method::DELETE, &uri_str);
68
69 if let Some(ref user_agent) = configuration.user_agent {
70 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
71 }
72 req_builder = req_builder.json(&p_body_store_delete_request);
73
74 Ok(req_builder)
75}
76
77pub async fn delete_item(
78 configuration: &configuration::Configuration,
79 store_delete_request: models::StoreDeleteRequest,
80) -> Result<(), Error<DeleteItemError>> {
81 let req_builder = delete_item_request_builder(configuration, store_delete_request)
82 .map_err(super::map_request_builder_error)?;
83 let req = req_builder.build()?;
84 let resp = configuration.client.execute(req).await?;
85
86 let status = resp.status();
87
88 if !status.is_client_error() && !status.is_server_error() {
89 Ok(())
90 } else {
91 let content = resp.text().await?;
92 let entity: Option<DeleteItemError> = serde_json::from_str(&content).ok();
93 Err(Error::ResponseError(ResponseContent {
94 status,
95 content,
96 entity,
97 }))
98 }
99}
100
101pub fn get_item_request_builder(
102 configuration: &configuration::Configuration,
103 key: &str,
104 namespace: Option<Vec<String>>,
105) -> Result<reqwest::RequestBuilder, Error<serde_json::Error>> {
106 let p_query_key = key;
108 let p_query_namespace = namespace;
109
110 let uri_str = format!("{}/store/items", configuration.base_path);
111 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
112
113 req_builder = req_builder.query(&[("key", &p_query_key.to_string())]);
114 if let Some(ref param_value) = p_query_namespace {
115 req_builder = match "multi" {
116 "multi" => req_builder.query(
117 ¶m_value
118 .iter()
119 .map(|p| ("namespace".to_owned(), p.to_string()))
120 .collect::<Vec<(std::string::String, std::string::String)>>(),
121 ),
122 _ => req_builder.query(&[(
123 "namespace",
124 ¶m_value
125 .iter()
126 .map(|p| p.to_string())
127 .collect::<Vec<String>>()
128 .join(",")
129 .to_string(),
130 )]),
131 };
132 }
133 if let Some(ref user_agent) = configuration.user_agent {
134 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
135 }
136
137 Ok(req_builder)
138}
139
140pub async fn get_item(
141 configuration: &configuration::Configuration,
142 key: &str,
143 namespace: Option<Vec<String>>,
144) -> Result<models::Item, Error<GetItemError>> {
145 let req_builder = get_item_request_builder(configuration, key, namespace)
146 .map_err(super::map_request_builder_error)?;
147 let req = req_builder.build()?;
148 let resp = configuration.client.execute(req).await?;
149
150 let status = resp.status();
151 let content_type = resp
152 .headers()
153 .get("content-type")
154 .and_then(|v| v.to_str().ok())
155 .unwrap_or("application/octet-stream");
156 let content_type = super::ContentType::from(content_type);
157
158 if !status.is_client_error() && !status.is_server_error() {
159 let content = resp.text().await?;
160 match content_type {
161 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
162 ContentType::Text => Err(Error::from(serde_json::Error::custom(
163 "Received `text/plain` content type response that cannot be converted to `models::Item`",
164 ))),
165 ContentType::Unsupported(unknown_type) => {
166 Err(Error::from(serde_json::Error::custom(format!(
167 "Received `{unknown_type}` content type response that cannot be converted to `models::Item`"
168 ))))
169 }
170 }
171 } else {
172 let content = resp.text().await?;
173 let entity: Option<GetItemError> = serde_json::from_str(&content).ok();
174 Err(Error::ResponseError(ResponseContent {
175 status,
176 content,
177 entity,
178 }))
179 }
180}
181
182pub fn list_namespaces_request_builder(
183 configuration: &configuration::Configuration,
184 store_list_namespaces_request: models::StoreListNamespacesRequest,
185) -> Result<reqwest::RequestBuilder, Error<serde_json::Error>> {
186 let p_body_store_list_namespaces_request = store_list_namespaces_request;
188
189 let uri_str = format!("{}/store/namespaces", configuration.base_path);
190 let mut req_builder = configuration
191 .client
192 .request(reqwest::Method::POST, &uri_str);
193
194 if let Some(ref user_agent) = configuration.user_agent {
195 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
196 }
197 req_builder = req_builder.json(&p_body_store_list_namespaces_request);
198
199 Ok(req_builder)
200}
201
202pub async fn list_namespaces(
203 configuration: &configuration::Configuration,
204 store_list_namespaces_request: models::StoreListNamespacesRequest,
205) -> Result<Vec<Vec<String>>, Error<ListNamespacesError>> {
206 let req_builder = list_namespaces_request_builder(configuration, store_list_namespaces_request)
207 .map_err(super::map_request_builder_error)?;
208 let req = req_builder.build()?;
209 let resp = configuration.client.execute(req).await?;
210
211 let status = resp.status();
212 let content_type = resp
213 .headers()
214 .get("content-type")
215 .and_then(|v| v.to_str().ok())
216 .unwrap_or("application/octet-stream");
217 let content_type = super::ContentType::from(content_type);
218
219 if !status.is_client_error() && !status.is_server_error() {
220 let content = resp.text().await?;
221 match content_type {
222 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
223 ContentType::Text => Err(Error::from(serde_json::Error::custom(
224 "Received `text/plain` content type response that cannot be converted to `Vec<Vec<String>>`",
225 ))),
226 ContentType::Unsupported(unknown_type) => {
227 Err(Error::from(serde_json::Error::custom(format!(
228 "Received `{unknown_type}` content type response that cannot be converted to `Vec<Vec<String>>`"
229 ))))
230 }
231 }
232 } else {
233 let content = resp.text().await?;
234 let entity: Option<ListNamespacesError> = serde_json::from_str(&content).ok();
235 Err(Error::ResponseError(ResponseContent {
236 status,
237 content,
238 entity,
239 }))
240 }
241}
242
243pub fn put_item_request_builder(
244 configuration: &configuration::Configuration,
245 store_put_request: models::StorePutRequest,
246) -> Result<reqwest::RequestBuilder, Error<serde_json::Error>> {
247 let p_body_store_put_request = store_put_request;
249
250 let uri_str = format!("{}/store/items", configuration.base_path);
251 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
252
253 if let Some(ref user_agent) = configuration.user_agent {
254 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
255 }
256 req_builder = req_builder.json(&p_body_store_put_request);
257
258 Ok(req_builder)
259}
260
261pub async fn put_item(
262 configuration: &configuration::Configuration,
263 store_put_request: models::StorePutRequest,
264) -> Result<(), Error<PutItemError>> {
265 let req_builder = put_item_request_builder(configuration, store_put_request)
266 .map_err(super::map_request_builder_error)?;
267 let req = req_builder.build()?;
268 let resp = configuration.client.execute(req).await?;
269
270 let status = resp.status();
271
272 if !status.is_client_error() && !status.is_server_error() {
273 Ok(())
274 } else {
275 let content = resp.text().await?;
276 let entity: Option<PutItemError> = serde_json::from_str(&content).ok();
277 Err(Error::ResponseError(ResponseContent {
278 status,
279 content,
280 entity,
281 }))
282 }
283}
284
285pub fn search_items_request_builder(
286 configuration: &configuration::Configuration,
287 store_search_request: models::StoreSearchRequest,
288) -> Result<reqwest::RequestBuilder, Error<serde_json::Error>> {
289 let p_body_store_search_request = store_search_request;
291
292 let uri_str = format!("{}/store/items/search", configuration.base_path);
293 let mut req_builder = configuration
294 .client
295 .request(reqwest::Method::POST, &uri_str);
296
297 if let Some(ref user_agent) = configuration.user_agent {
298 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
299 }
300 req_builder = req_builder.json(&p_body_store_search_request);
301
302 Ok(req_builder)
303}
304
305pub async fn search_items(
306 configuration: &configuration::Configuration,
307 store_search_request: models::StoreSearchRequest,
308) -> Result<models::SearchItemsResponse, Error<SearchItemsError>> {
309 let req_builder = search_items_request_builder(configuration, store_search_request)
310 .map_err(super::map_request_builder_error)?;
311 let req = req_builder.build()?;
312 let resp = configuration.client.execute(req).await?;
313
314 let status = resp.status();
315 let content_type = resp
316 .headers()
317 .get("content-type")
318 .and_then(|v| v.to_str().ok())
319 .unwrap_or("application/octet-stream");
320 let content_type = super::ContentType::from(content_type);
321
322 if !status.is_client_error() && !status.is_server_error() {
323 let content = resp.text().await?;
324 match content_type {
325 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
326 ContentType::Text => Err(Error::from(serde_json::Error::custom(
327 "Received `text/plain` content type response that cannot be converted to `models::SearchItemsResponse`",
328 ))),
329 ContentType::Unsupported(unknown_type) => {
330 Err(Error::from(serde_json::Error::custom(format!(
331 "Received `{unknown_type}` content type response that cannot be converted to `models::SearchItemsResponse`"
332 ))))
333 }
334 }
335 } else {
336 let content = resp.text().await?;
337 let entity: Option<SearchItemsError> = serde_json::from_str(&content).ok();
338 Err(Error::ResponseError(ResponseContent {
339 status,
340 content,
341 entity,
342 }))
343 }
344}