langgraph_api/generated/apis/
mcp_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 DeleteMcpError {
20 Status404(),
21 UnknownValue(serde_json::Value),
22}
23
24#[derive(Debug, Clone, Serialize, Deserialize)]
26#[serde(untagged)]
27pub enum GetMcpError {
28 Status405(),
29 UnknownValue(serde_json::Value),
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum PostMcpError {
36 Status400(),
37 Status405(),
38 Status500(),
39 UnknownValue(serde_json::Value),
40}
41
42pub fn delete_mcp_request_builder(
44 configuration: &configuration::Configuration,
45) -> Result<reqwest::RequestBuilder, Error<serde_json::Error>> {
46 let uri_str = format!("{}/mcp/", configuration.base_path);
47 let mut req_builder = configuration
48 .client
49 .request(reqwest::Method::DELETE, &uri_str);
50
51 if let Some(ref user_agent) = configuration.user_agent {
52 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
53 }
54
55 Ok(req_builder)
56}
57
58pub async fn delete_mcp(
59 configuration: &configuration::Configuration,
60) -> Result<(), Error<DeleteMcpError>> {
61 let req_builder =
62 delete_mcp_request_builder(configuration).map_err(super::map_request_builder_error)?;
63 let req = req_builder.build()?;
64 let resp = configuration.client.execute(req).await?;
65
66 let status = resp.status();
67
68 if !status.is_client_error() && !status.is_server_error() {
69 Ok(())
70 } else {
71 let content = resp.text().await?;
72 let entity: Option<DeleteMcpError> = serde_json::from_str(&content).ok();
73 Err(Error::ResponseError(ResponseContent {
74 status,
75 content,
76 entity,
77 }))
78 }
79}
80
81pub fn get_mcp_request_builder(
83 configuration: &configuration::Configuration,
84) -> Result<reqwest::RequestBuilder, Error<serde_json::Error>> {
85 let uri_str = format!("{}/mcp/", configuration.base_path);
86 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
87
88 if let Some(ref user_agent) = configuration.user_agent {
89 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
90 }
91
92 Ok(req_builder)
93}
94
95pub async fn get_mcp(
96 configuration: &configuration::Configuration,
97) -> Result<(), Error<GetMcpError>> {
98 let req_builder =
99 get_mcp_request_builder(configuration).map_err(super::map_request_builder_error)?;
100 let req = req_builder.build()?;
101 let resp = configuration.client.execute(req).await?;
102
103 let status = resp.status();
104
105 if !status.is_client_error() && !status.is_server_error() {
106 Ok(())
107 } else {
108 let content = resp.text().await?;
109 let entity: Option<GetMcpError> = serde_json::from_str(&content).ok();
110 Err(Error::ResponseError(ResponseContent {
111 status,
112 content,
113 entity,
114 }))
115 }
116}
117
118pub fn post_mcp_request_builder(
120 configuration: &configuration::Configuration,
121 accept: &str,
122 body: serde_json::Value,
123) -> Result<reqwest::RequestBuilder, Error<serde_json::Error>> {
124 let p_header_accept = accept;
126 let p_body_body = body;
127
128 let uri_str = format!("{}/mcp/", configuration.base_path);
129 let mut req_builder = configuration
130 .client
131 .request(reqwest::Method::POST, &uri_str);
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 req_builder = req_builder.header("Accept", p_header_accept.to_string());
137 req_builder = req_builder.json(&p_body_body);
138
139 Ok(req_builder)
140}
141
142pub async fn post_mcp(
143 configuration: &configuration::Configuration,
144 accept: &str,
145 body: serde_json::Value,
146) -> Result<serde_json::Value, Error<PostMcpError>> {
147 let req_builder = post_mcp_request_builder(configuration, accept, body)
148 .map_err(super::map_request_builder_error)?;
149 let req = req_builder.build()?;
150 let resp = configuration.client.execute(req).await?;
151
152 let status = resp.status();
153 let content_type = resp
154 .headers()
155 .get("content-type")
156 .and_then(|v| v.to_str().ok())
157 .unwrap_or("application/octet-stream");
158 let content_type = super::ContentType::from(content_type);
159
160 if !status.is_client_error() && !status.is_server_error() {
161 let content = resp.text().await?;
162 match content_type {
163 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
164 ContentType::Text => Err(Error::from(serde_json::Error::custom(
165 "Received `text/plain` content type response that cannot be converted to `serde_json::Value`",
166 ))),
167 ContentType::Unsupported(unknown_type) => {
168 Err(Error::from(serde_json::Error::custom(format!(
169 "Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`"
170 ))))
171 }
172 }
173 } else {
174 let content = resp.text().await?;
175 let entity: Option<PostMcpError> = serde_json::from_str(&content).ok();
176 Err(Error::ResponseError(ResponseContent {
177 status,
178 content,
179 entity,
180 }))
181 }
182}