langgraph_api/generated/apis/
crons_plus_tier_api.rs

1/*
2 * LangSmith Deployment
3 *
4 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 *
6 * The version of the OpenAPI document: 0.1.0
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11use super::{ContentType, Error, UploadFile, configuration};
12use crate::{apis::ResponseContent, models};
13use reqwest;
14use serde::{Deserialize, Serialize, de::Error as _};
15
16/// struct for typed errors of method [`count_crons_runs_crons_count_post`]
17#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum CountCronsRunsCronsCountPostError {
20    Status404(String),
21    Status422(String),
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method [`create_cron_runs_crons_post`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum CreateCronRunsCronsPostError {
29    Status404(String),
30    Status422(String),
31    UnknownValue(serde_json::Value),
32}
33
34/// struct for typed errors of method [`create_thread_cron_threads_thread_id_runs_crons_post`]
35#[derive(Debug, Clone, Serialize, Deserialize)]
36#[serde(untagged)]
37pub enum CreateThreadCronThreadsThreadIdRunsCronsPostError {
38    Status404(String),
39    Status422(String),
40    UnknownValue(serde_json::Value),
41}
42
43/// struct for typed errors of method [`delete_cron_runs_crons_cron_id_delete`]
44#[derive(Debug, Clone, Serialize, Deserialize)]
45#[serde(untagged)]
46pub enum DeleteCronRunsCronsCronIdDeleteError {
47    Status404(String),
48    Status422(String),
49    UnknownValue(serde_json::Value),
50}
51
52/// struct for typed errors of method [`search_crons_runs_crons_post`]
53#[derive(Debug, Clone, Serialize, Deserialize)]
54#[serde(untagged)]
55pub enum SearchCronsRunsCronsPostError {
56    Status422(String),
57    UnknownValue(serde_json::Value),
58}
59
60/// Get the count of crons matching the specified criteria.
61pub fn count_crons_runs_crons_count_post_request_builder(
62    configuration: &configuration::Configuration,
63    cron_count_request: models::CronCountRequest,
64) -> Result<reqwest::RequestBuilder, Error<serde_json::Error>> {
65    // add a prefix to parameters to efficiently prevent name collisions
66    let p_body_cron_count_request = cron_count_request;
67
68    let uri_str = format!("{}/runs/crons/count", configuration.base_path);
69    let mut req_builder = configuration
70        .client
71        .request(reqwest::Method::POST, &uri_str);
72
73    if let Some(ref user_agent) = configuration.user_agent {
74        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
75    }
76    req_builder = req_builder.json(&p_body_cron_count_request);
77
78    Ok(req_builder)
79}
80
81pub async fn count_crons_runs_crons_count_post(
82    configuration: &configuration::Configuration,
83    cron_count_request: models::CronCountRequest,
84) -> Result<i32, Error<CountCronsRunsCronsCountPostError>> {
85    let req_builder =
86        count_crons_runs_crons_count_post_request_builder(configuration, cron_count_request)
87            .map_err(super::map_request_builder_error)?;
88    let req = req_builder.build()?;
89    let resp = configuration.client.execute(req).await?;
90
91    let status = resp.status();
92    let content_type = resp
93        .headers()
94        .get("content-type")
95        .and_then(|v| v.to_str().ok())
96        .unwrap_or("application/octet-stream");
97    let content_type = super::ContentType::from(content_type);
98
99    if !status.is_client_error() && !status.is_server_error() {
100        let content = resp.text().await?;
101        match content_type {
102            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
103            ContentType::Text => Err(Error::from(serde_json::Error::custom(
104                "Received `text/plain` content type response that cannot be converted to `i32`",
105            ))),
106            ContentType::Unsupported(unknown_type) => {
107                Err(Error::from(serde_json::Error::custom(format!(
108                    "Received `{unknown_type}` content type response that cannot be converted to `i32`"
109                ))))
110            }
111        }
112    } else {
113        let content = resp.text().await?;
114        let entity: Option<CountCronsRunsCronsCountPostError> = serde_json::from_str(&content).ok();
115        Err(Error::ResponseError(ResponseContent {
116            status,
117            content,
118            entity,
119        }))
120    }
121}
122
123/// Create a cron to schedule runs on new threads.
124pub fn create_cron_runs_crons_post_request_builder(
125    configuration: &configuration::Configuration,
126    cron_create: models::CronCreate,
127) -> Result<reqwest::RequestBuilder, Error<serde_json::Error>> {
128    // add a prefix to parameters to efficiently prevent name collisions
129    let p_body_cron_create = cron_create;
130
131    let uri_str = format!("{}/runs/crons", configuration.base_path);
132    let mut req_builder = configuration
133        .client
134        .request(reqwest::Method::POST, &uri_str);
135
136    if let Some(ref user_agent) = configuration.user_agent {
137        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
138    }
139    req_builder = req_builder.json(&p_body_cron_create);
140
141    Ok(req_builder)
142}
143
144pub async fn create_cron_runs_crons_post(
145    configuration: &configuration::Configuration,
146    cron_create: models::CronCreate,
147) -> Result<models::Cron, Error<CreateCronRunsCronsPostError>> {
148    let req_builder = create_cron_runs_crons_post_request_builder(configuration, cron_create)
149        .map_err(super::map_request_builder_error)?;
150    let req = req_builder.build()?;
151    let resp = configuration.client.execute(req).await?;
152
153    let status = resp.status();
154    let content_type = resp
155        .headers()
156        .get("content-type")
157        .and_then(|v| v.to_str().ok())
158        .unwrap_or("application/octet-stream");
159    let content_type = super::ContentType::from(content_type);
160
161    if !status.is_client_error() && !status.is_server_error() {
162        let content = resp.text().await?;
163        match content_type {
164            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
165            ContentType::Text => Err(Error::from(serde_json::Error::custom(
166                "Received `text/plain` content type response that cannot be converted to `models::Cron`",
167            ))),
168            ContentType::Unsupported(unknown_type) => {
169                Err(Error::from(serde_json::Error::custom(format!(
170                    "Received `{unknown_type}` content type response that cannot be converted to `models::Cron`"
171                ))))
172            }
173        }
174    } else {
175        let content = resp.text().await?;
176        let entity: Option<CreateCronRunsCronsPostError> = serde_json::from_str(&content).ok();
177        Err(Error::ResponseError(ResponseContent {
178            status,
179            content,
180            entity,
181        }))
182    }
183}
184
185/// Create a cron to schedule runs on a thread.
186pub fn create_thread_cron_threads_thread_id_runs_crons_post_request_builder(
187    configuration: &configuration::Configuration,
188    thread_id: &str,
189    thread_cron_create: models::ThreadCronCreate,
190) -> Result<reqwest::RequestBuilder, Error<serde_json::Error>> {
191    // add a prefix to parameters to efficiently prevent name collisions
192    let p_path_thread_id = thread_id;
193    let p_body_thread_cron_create = thread_cron_create;
194
195    let uri_str = format!(
196        "{}/threads/{thread_id}/runs/crons",
197        configuration.base_path,
198        thread_id = crate::apis::urlencode(p_path_thread_id)
199    );
200    let mut req_builder = configuration
201        .client
202        .request(reqwest::Method::POST, &uri_str);
203
204    if let Some(ref user_agent) = configuration.user_agent {
205        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
206    }
207    req_builder = req_builder.json(&p_body_thread_cron_create);
208
209    Ok(req_builder)
210}
211
212pub async fn create_thread_cron_threads_thread_id_runs_crons_post(
213    configuration: &configuration::Configuration,
214    thread_id: &str,
215    thread_cron_create: models::ThreadCronCreate,
216) -> Result<models::Cron, Error<CreateThreadCronThreadsThreadIdRunsCronsPostError>> {
217    let req_builder = create_thread_cron_threads_thread_id_runs_crons_post_request_builder(
218        configuration,
219        thread_id,
220        thread_cron_create,
221    )
222    .map_err(super::map_request_builder_error)?;
223    let req = req_builder.build()?;
224    let resp = configuration.client.execute(req).await?;
225
226    let status = resp.status();
227    let content_type = resp
228        .headers()
229        .get("content-type")
230        .and_then(|v| v.to_str().ok())
231        .unwrap_or("application/octet-stream");
232    let content_type = super::ContentType::from(content_type);
233
234    if !status.is_client_error() && !status.is_server_error() {
235        let content = resp.text().await?;
236        match content_type {
237            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
238            ContentType::Text => Err(Error::from(serde_json::Error::custom(
239                "Received `text/plain` content type response that cannot be converted to `models::Cron`",
240            ))),
241            ContentType::Unsupported(unknown_type) => {
242                Err(Error::from(serde_json::Error::custom(format!(
243                    "Received `{unknown_type}` content type response that cannot be converted to `models::Cron`"
244                ))))
245            }
246        }
247    } else {
248        let content = resp.text().await?;
249        let entity: Option<CreateThreadCronThreadsThreadIdRunsCronsPostError> =
250            serde_json::from_str(&content).ok();
251        Err(Error::ResponseError(ResponseContent {
252            status,
253            content,
254            entity,
255        }))
256    }
257}
258
259/// Delete a cron by ID.
260pub fn delete_cron_runs_crons_cron_id_delete_request_builder(
261    configuration: &configuration::Configuration,
262    cron_id: &str,
263) -> Result<reqwest::RequestBuilder, Error<serde_json::Error>> {
264    // add a prefix to parameters to efficiently prevent name collisions
265    let p_path_cron_id = cron_id;
266
267    let uri_str = format!(
268        "{}/runs/crons/{cron_id}",
269        configuration.base_path,
270        cron_id = crate::apis::urlencode(p_path_cron_id)
271    );
272    let mut req_builder = configuration
273        .client
274        .request(reqwest::Method::DELETE, &uri_str);
275
276    if let Some(ref user_agent) = configuration.user_agent {
277        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
278    }
279
280    Ok(req_builder)
281}
282
283pub async fn delete_cron_runs_crons_cron_id_delete(
284    configuration: &configuration::Configuration,
285    cron_id: &str,
286) -> Result<serde_json::Value, Error<DeleteCronRunsCronsCronIdDeleteError>> {
287    let req_builder = delete_cron_runs_crons_cron_id_delete_request_builder(configuration, cron_id)
288        .map_err(super::map_request_builder_error)?;
289    let req = req_builder.build()?;
290    let resp = configuration.client.execute(req).await?;
291
292    let status = resp.status();
293    let content_type = resp
294        .headers()
295        .get("content-type")
296        .and_then(|v| v.to_str().ok())
297        .unwrap_or("application/octet-stream");
298    let content_type = super::ContentType::from(content_type);
299
300    if !status.is_client_error() && !status.is_server_error() {
301        let content = resp.text().await?;
302        match content_type {
303            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
304            ContentType::Text => Err(Error::from(serde_json::Error::custom(
305                "Received `text/plain` content type response that cannot be converted to `serde_json::Value`",
306            ))),
307            ContentType::Unsupported(unknown_type) => {
308                Err(Error::from(serde_json::Error::custom(format!(
309                    "Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`"
310                ))))
311            }
312        }
313    } else {
314        let content = resp.text().await?;
315        let entity: Option<DeleteCronRunsCronsCronIdDeleteError> =
316            serde_json::from_str(&content).ok();
317        Err(Error::ResponseError(ResponseContent {
318            status,
319            content,
320            entity,
321        }))
322    }
323}
324
325/// Search all active crons
326pub fn search_crons_runs_crons_post_request_builder(
327    configuration: &configuration::Configuration,
328    cron_search: models::CronSearch,
329) -> Result<reqwest::RequestBuilder, Error<serde_json::Error>> {
330    // add a prefix to parameters to efficiently prevent name collisions
331    let p_body_cron_search = cron_search;
332
333    let uri_str = format!("{}/runs/crons/search", configuration.base_path);
334    let mut req_builder = configuration
335        .client
336        .request(reqwest::Method::POST, &uri_str);
337
338    if let Some(ref user_agent) = configuration.user_agent {
339        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
340    }
341    req_builder = req_builder.json(&p_body_cron_search);
342
343    Ok(req_builder)
344}
345
346pub async fn search_crons_runs_crons_post(
347    configuration: &configuration::Configuration,
348    cron_search: models::CronSearch,
349) -> Result<Vec<models::Cron>, Error<SearchCronsRunsCronsPostError>> {
350    let req_builder = search_crons_runs_crons_post_request_builder(configuration, cron_search)
351        .map_err(super::map_request_builder_error)?;
352    let req = req_builder.build()?;
353    let resp = configuration.client.execute(req).await?;
354
355    let status = resp.status();
356    let content_type = resp
357        .headers()
358        .get("content-type")
359        .and_then(|v| v.to_str().ok())
360        .unwrap_or("application/octet-stream");
361    let content_type = super::ContentType::from(content_type);
362
363    if !status.is_client_error() && !status.is_server_error() {
364        let content = resp.text().await?;
365        match content_type {
366            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
367            ContentType::Text => Err(Error::from(serde_json::Error::custom(
368                "Received `text/plain` content type response that cannot be converted to `Vec&lt;models::Cron&gt;`",
369            ))),
370            ContentType::Unsupported(unknown_type) => {
371                Err(Error::from(serde_json::Error::custom(format!(
372                    "Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;models::Cron&gt;`"
373                ))))
374            }
375        }
376    } else {
377        let content = resp.text().await?;
378        let entity: Option<SearchCronsRunsCronsPostError> = serde_json::from_str(&content).ok();
379        Err(Error::ResponseError(ResponseContent {
380            status,
381            content,
382            entity,
383        }))
384    }
385}