1use 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 CreateAgentError {
22 Status401(models::ApiError),
23 UnknownValue(serde_json::Value),
24}
25
26#[derive(Debug, Clone, Serialize, Deserialize)]
28#[serde(untagged)]
29pub enum CreateAgentConversationError {
30 Status401(models::ApiError),
31 UnknownValue(serde_json::Value),
32}
33
34#[derive(Debug, Clone, Serialize, Deserialize)]
36#[serde(untagged)]
37pub enum CreateAgentMessageError {
38 Status401(models::ApiError),
39 UnknownValue(serde_json::Value),
40}
41
42#[derive(Debug, Clone, Serialize, Deserialize)]
44#[serde(untagged)]
45pub enum DeleteAgentError {
46 Status401(models::ApiError),
47 UnknownValue(serde_json::Value),
48}
49
50#[derive(Debug, Clone, Serialize, Deserialize)]
52#[serde(untagged)]
53pub enum ExecuteAgentActionError {
54 Status401(models::ApiError),
55 UnknownValue(serde_json::Value),
56}
57
58#[derive(Debug, Clone, Serialize, Deserialize)]
60#[serde(untagged)]
61pub enum GetAgentError {
62 Status401(models::ApiError),
63 Status404(models::ApiError),
64 UnknownValue(serde_json::Value),
65}
66
67#[derive(Debug, Clone, Serialize, Deserialize)]
69#[serde(untagged)]
70pub enum GetAgentConversationError {
71 Status401(models::ApiError),
72 Status404(models::ApiError),
73 UnknownValue(serde_json::Value),
74}
75
76#[derive(Debug, Clone, Serialize, Deserialize)]
78#[serde(untagged)]
79pub enum GetAgentSessionContextError {
80 Status401(models::ApiError),
81 UnknownValue(serde_json::Value),
82}
83
84#[derive(Debug, Clone, Serialize, Deserialize)]
86#[serde(untagged)]
87pub enum ListAgentConversationMessagesError {
88 Status401(models::ApiError),
89 UnknownValue(serde_json::Value),
90}
91
92#[derive(Debug, Clone, Serialize, Deserialize)]
94#[serde(untagged)]
95pub enum ListAgentConversationsError {
96 Status401(models::ApiError),
97 UnknownValue(serde_json::Value),
98}
99
100#[derive(Debug, Clone, Serialize, Deserialize)]
102#[serde(untagged)]
103pub enum ListAgentsError {
104 Status401(models::ApiError),
105 UnknownValue(serde_json::Value),
106}
107
108#[derive(Debug, Clone, Serialize, Deserialize)]
110#[serde(untagged)]
111pub enum ListPreconfiguredAgentsError {
112 Status401(models::ApiError),
113 UnknownValue(serde_json::Value),
114}
115
116#[derive(Debug, Clone, Serialize, Deserialize)]
118#[serde(untagged)]
119pub enum UpdateAgentError {
120 Status401(models::ApiError),
121 UnknownValue(serde_json::Value),
122}
123
124
125pub async fn create_agent(configuration: &configuration::Configuration, create_agent_request: models::CreateAgentRequest) -> Result<models::Agent, Error<CreateAgentError>> {
126 let p_body_create_agent_request = create_agent_request;
128
129 let uri_str = format!("{}/v1/agents", configuration.base_path);
130 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
131
132 if let Some(ref user_agent) = configuration.user_agent {
133 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
134 }
135 if let Some(ref token) = configuration.bearer_access_token {
136 req_builder = req_builder.bearer_auth(token.to_owned());
137 };
138 req_builder = req_builder.json(&p_body_create_agent_request);
139
140 let req = req_builder.build()?;
141 let resp = configuration.client.execute(req).await?;
142
143 let status = resp.status();
144 let content_type = resp
145 .headers()
146 .get("content-type")
147 .and_then(|v| v.to_str().ok())
148 .unwrap_or("application/octet-stream");
149 let content_type = super::ContentType::from(content_type);
150
151 if !status.is_client_error() && !status.is_server_error() {
152 let content = resp.text().await?;
153 match content_type {
154 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
155 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Agent`"))),
156 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::Agent`")))),
157 }
158 } else {
159 let content = resp.text().await?;
160 let entity: Option<CreateAgentError> = serde_json::from_str(&content).ok();
161 Err(Error::ResponseError(ResponseContent { status, content, entity }))
162 }
163}
164
165pub async fn create_agent_conversation(configuration: &configuration::Configuration, create_agent_conversation_request: Option<models::CreateAgentConversationRequest>) -> Result<models::AgentConversation, Error<CreateAgentConversationError>> {
166 let p_body_create_agent_conversation_request = create_agent_conversation_request;
168
169 let uri_str = format!("{}/v1/agent/conversations", configuration.base_path);
170 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
171
172 if let Some(ref user_agent) = configuration.user_agent {
173 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
174 }
175 if let Some(ref token) = configuration.bearer_access_token {
176 req_builder = req_builder.bearer_auth(token.to_owned());
177 };
178 req_builder = req_builder.json(&p_body_create_agent_conversation_request);
179
180 let req = req_builder.build()?;
181 let resp = configuration.client.execute(req).await?;
182
183 let status = resp.status();
184 let content_type = resp
185 .headers()
186 .get("content-type")
187 .and_then(|v| v.to_str().ok())
188 .unwrap_or("application/octet-stream");
189 let content_type = super::ContentType::from(content_type);
190
191 if !status.is_client_error() && !status.is_server_error() {
192 let content = resp.text().await?;
193 match content_type {
194 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
195 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AgentConversation`"))),
196 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::AgentConversation`")))),
197 }
198 } else {
199 let content = resp.text().await?;
200 let entity: Option<CreateAgentConversationError> = serde_json::from_str(&content).ok();
201 Err(Error::ResponseError(ResponseContent { status, content, entity }))
202 }
203}
204
205pub async fn create_agent_message(configuration: &configuration::Configuration, id: &str, create_agent_message_request: models::CreateAgentMessageRequest) -> Result<models::AgentMessage, Error<CreateAgentMessageError>> {
206 let p_path_id = id;
208 let p_body_create_agent_message_request = create_agent_message_request;
209
210 let uri_str = format!("{}/v1/agent/conversations/{id}/messages", configuration.base_path, id=crate::apis::urlencode(p_path_id));
211 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
212
213 if let Some(ref user_agent) = configuration.user_agent {
214 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
215 }
216 if let Some(ref token) = configuration.bearer_access_token {
217 req_builder = req_builder.bearer_auth(token.to_owned());
218 };
219 req_builder = req_builder.json(&p_body_create_agent_message_request);
220
221 let req = req_builder.build()?;
222 let resp = configuration.client.execute(req).await?;
223
224 let status = resp.status();
225 let content_type = resp
226 .headers()
227 .get("content-type")
228 .and_then(|v| v.to_str().ok())
229 .unwrap_or("application/octet-stream");
230 let content_type = super::ContentType::from(content_type);
231
232 if !status.is_client_error() && !status.is_server_error() {
233 let content = resp.text().await?;
234 match content_type {
235 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
236 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AgentMessage`"))),
237 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::AgentMessage`")))),
238 }
239 } else {
240 let content = resp.text().await?;
241 let entity: Option<CreateAgentMessageError> = serde_json::from_str(&content).ok();
242 Err(Error::ResponseError(ResponseContent { status, content, entity }))
243 }
244}
245
246pub async fn delete_agent(configuration: &configuration::Configuration, id: &str) -> Result<(), Error<DeleteAgentError>> {
247 let p_path_id = id;
249
250 let uri_str = format!("{}/v1/agents/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
251 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &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 if let Some(ref token) = configuration.bearer_access_token {
257 req_builder = req_builder.bearer_auth(token.to_owned());
258 };
259
260 let req = req_builder.build()?;
261 let resp = configuration.client.execute(req).await?;
262
263 let status = resp.status();
264
265 if !status.is_client_error() && !status.is_server_error() {
266 Ok(())
267 } else {
268 let content = resp.text().await?;
269 let entity: Option<DeleteAgentError> = serde_json::from_str(&content).ok();
270 Err(Error::ResponseError(ResponseContent { status, content, entity }))
271 }
272}
273
274pub async fn execute_agent_action(configuration: &configuration::Configuration, execute_action_request: models::ExecuteActionRequest) -> Result<models::ExecuteActionResponse, Error<ExecuteAgentActionError>> {
275 let p_body_execute_action_request = execute_action_request;
277
278 let uri_str = format!("{}/v1/agent/actions/execute", configuration.base_path);
279 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
280
281 if let Some(ref user_agent) = configuration.user_agent {
282 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
283 }
284 if let Some(ref token) = configuration.bearer_access_token {
285 req_builder = req_builder.bearer_auth(token.to_owned());
286 };
287 req_builder = req_builder.json(&p_body_execute_action_request);
288
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 => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ExecuteActionResponse`"))),
305 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::ExecuteActionResponse`")))),
306 }
307 } else {
308 let content = resp.text().await?;
309 let entity: Option<ExecuteAgentActionError> = serde_json::from_str(&content).ok();
310 Err(Error::ResponseError(ResponseContent { status, content, entity }))
311 }
312}
313
314pub async fn get_agent(configuration: &configuration::Configuration, id: &str) -> Result<models::Agent, Error<GetAgentError>> {
315 let p_path_id = id;
317
318 let uri_str = format!("{}/v1/agents/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
319 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
320
321 if let Some(ref user_agent) = configuration.user_agent {
322 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
323 }
324 if let Some(ref token) = configuration.bearer_access_token {
325 req_builder = req_builder.bearer_auth(token.to_owned());
326 };
327
328 let req = req_builder.build()?;
329 let resp = configuration.client.execute(req).await?;
330
331 let status = resp.status();
332 let content_type = resp
333 .headers()
334 .get("content-type")
335 .and_then(|v| v.to_str().ok())
336 .unwrap_or("application/octet-stream");
337 let content_type = super::ContentType::from(content_type);
338
339 if !status.is_client_error() && !status.is_server_error() {
340 let content = resp.text().await?;
341 match content_type {
342 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
343 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Agent`"))),
344 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::Agent`")))),
345 }
346 } else {
347 let content = resp.text().await?;
348 let entity: Option<GetAgentError> = serde_json::from_str(&content).ok();
349 Err(Error::ResponseError(ResponseContent { status, content, entity }))
350 }
351}
352
353pub async fn get_agent_conversation(configuration: &configuration::Configuration, id: &str) -> Result<models::AgentConversation, Error<GetAgentConversationError>> {
354 let p_path_id = id;
356
357 let uri_str = format!("{}/v1/agent/conversations/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
358 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
359
360 if let Some(ref user_agent) = configuration.user_agent {
361 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
362 }
363 if let Some(ref token) = configuration.bearer_access_token {
364 req_builder = req_builder.bearer_auth(token.to_owned());
365 };
366
367 let req = req_builder.build()?;
368 let resp = configuration.client.execute(req).await?;
369
370 let status = resp.status();
371 let content_type = resp
372 .headers()
373 .get("content-type")
374 .and_then(|v| v.to_str().ok())
375 .unwrap_or("application/octet-stream");
376 let content_type = super::ContentType::from(content_type);
377
378 if !status.is_client_error() && !status.is_server_error() {
379 let content = resp.text().await?;
380 match content_type {
381 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
382 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AgentConversation`"))),
383 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::AgentConversation`")))),
384 }
385 } else {
386 let content = resp.text().await?;
387 let entity: Option<GetAgentConversationError> = serde_json::from_str(&content).ok();
388 Err(Error::ResponseError(ResponseContent { status, content, entity }))
389 }
390}
391
392pub async fn get_agent_session_context(configuration: &configuration::Configuration, ) -> Result<models::AgentSessionContext, Error<GetAgentSessionContextError>> {
393
394 let uri_str = format!("{}/v1/agent/session-context", configuration.base_path);
395 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
396
397 if let Some(ref user_agent) = configuration.user_agent {
398 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
399 }
400 if let Some(ref token) = configuration.bearer_access_token {
401 req_builder = req_builder.bearer_auth(token.to_owned());
402 };
403
404 let req = req_builder.build()?;
405 let resp = configuration.client.execute(req).await?;
406
407 let status = resp.status();
408 let content_type = resp
409 .headers()
410 .get("content-type")
411 .and_then(|v| v.to_str().ok())
412 .unwrap_or("application/octet-stream");
413 let content_type = super::ContentType::from(content_type);
414
415 if !status.is_client_error() && !status.is_server_error() {
416 let content = resp.text().await?;
417 match content_type {
418 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
419 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AgentSessionContext`"))),
420 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::AgentSessionContext`")))),
421 }
422 } else {
423 let content = resp.text().await?;
424 let entity: Option<GetAgentSessionContextError> = serde_json::from_str(&content).ok();
425 Err(Error::ResponseError(ResponseContent { status, content, entity }))
426 }
427}
428
429pub async fn list_agent_conversation_messages(configuration: &configuration::Configuration, id: &str) -> Result<models::AgentMessageListResponse, Error<ListAgentConversationMessagesError>> {
430 let p_path_id = id;
432
433 let uri_str = format!("{}/v1/agent/conversations/{id}/messages", configuration.base_path, id=crate::apis::urlencode(p_path_id));
434 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
435
436 if let Some(ref user_agent) = configuration.user_agent {
437 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
438 }
439 if let Some(ref token) = configuration.bearer_access_token {
440 req_builder = req_builder.bearer_auth(token.to_owned());
441 };
442
443 let req = req_builder.build()?;
444 let resp = configuration.client.execute(req).await?;
445
446 let status = resp.status();
447 let content_type = resp
448 .headers()
449 .get("content-type")
450 .and_then(|v| v.to_str().ok())
451 .unwrap_or("application/octet-stream");
452 let content_type = super::ContentType::from(content_type);
453
454 if !status.is_client_error() && !status.is_server_error() {
455 let content = resp.text().await?;
456 match content_type {
457 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
458 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AgentMessageListResponse`"))),
459 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::AgentMessageListResponse`")))),
460 }
461 } else {
462 let content = resp.text().await?;
463 let entity: Option<ListAgentConversationMessagesError> = serde_json::from_str(&content).ok();
464 Err(Error::ResponseError(ResponseContent { status, content, entity }))
465 }
466}
467
468pub async fn list_agent_conversations(configuration: &configuration::Configuration, ) -> Result<models::AgentConversationListResponse, Error<ListAgentConversationsError>> {
469
470 let uri_str = format!("{}/v1/agent/conversations", configuration.base_path);
471 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
472
473 if let Some(ref user_agent) = configuration.user_agent {
474 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
475 }
476 if let Some(ref token) = configuration.bearer_access_token {
477 req_builder = req_builder.bearer_auth(token.to_owned());
478 };
479
480 let req = req_builder.build()?;
481 let resp = configuration.client.execute(req).await?;
482
483 let status = resp.status();
484 let content_type = resp
485 .headers()
486 .get("content-type")
487 .and_then(|v| v.to_str().ok())
488 .unwrap_or("application/octet-stream");
489 let content_type = super::ContentType::from(content_type);
490
491 if !status.is_client_error() && !status.is_server_error() {
492 let content = resp.text().await?;
493 match content_type {
494 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
495 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AgentConversationListResponse`"))),
496 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::AgentConversationListResponse`")))),
497 }
498 } else {
499 let content = resp.text().await?;
500 let entity: Option<ListAgentConversationsError> = serde_json::from_str(&content).ok();
501 Err(Error::ResponseError(ResponseContent { status, content, entity }))
502 }
503}
504
505pub async fn list_agents(configuration: &configuration::Configuration, ) -> Result<models::AgentListResponse, Error<ListAgentsError>> {
506
507 let uri_str = format!("{}/v1/agents", configuration.base_path);
508 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
509
510 if let Some(ref user_agent) = configuration.user_agent {
511 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
512 }
513 if let Some(ref token) = configuration.bearer_access_token {
514 req_builder = req_builder.bearer_auth(token.to_owned());
515 };
516
517 let req = req_builder.build()?;
518 let resp = configuration.client.execute(req).await?;
519
520 let status = resp.status();
521 let content_type = resp
522 .headers()
523 .get("content-type")
524 .and_then(|v| v.to_str().ok())
525 .unwrap_or("application/octet-stream");
526 let content_type = super::ContentType::from(content_type);
527
528 if !status.is_client_error() && !status.is_server_error() {
529 let content = resp.text().await?;
530 match content_type {
531 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
532 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AgentListResponse`"))),
533 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::AgentListResponse`")))),
534 }
535 } else {
536 let content = resp.text().await?;
537 let entity: Option<ListAgentsError> = serde_json::from_str(&content).ok();
538 Err(Error::ResponseError(ResponseContent { status, content, entity }))
539 }
540}
541
542pub async fn list_preconfigured_agents(configuration: &configuration::Configuration, ) -> Result<Vec<models::PreconfiguredAgent>, Error<ListPreconfiguredAgentsError>> {
543
544 let uri_str = format!("{}/v1/agents/preconfigured", configuration.base_path);
545 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
546
547 if let Some(ref user_agent) = configuration.user_agent {
548 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
549 }
550 if let Some(ref token) = configuration.bearer_access_token {
551 req_builder = req_builder.bearer_auth(token.to_owned());
552 };
553
554 let req = req_builder.build()?;
555 let resp = configuration.client.execute(req).await?;
556
557 let status = resp.status();
558 let content_type = resp
559 .headers()
560 .get("content-type")
561 .and_then(|v| v.to_str().ok())
562 .unwrap_or("application/octet-stream");
563 let content_type = super::ContentType::from(content_type);
564
565 if !status.is_client_error() && !status.is_server_error() {
566 let content = resp.text().await?;
567 match content_type {
568 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
569 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::PreconfiguredAgent>`"))),
570 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::PreconfiguredAgent>`")))),
571 }
572 } else {
573 let content = resp.text().await?;
574 let entity: Option<ListPreconfiguredAgentsError> = serde_json::from_str(&content).ok();
575 Err(Error::ResponseError(ResponseContent { status, content, entity }))
576 }
577}
578
579pub async fn update_agent(configuration: &configuration::Configuration, id: &str, update_agent_request: models::UpdateAgentRequest) -> Result<models::Agent, Error<UpdateAgentError>> {
580 let p_path_id = id;
582 let p_body_update_agent_request = update_agent_request;
583
584 let uri_str = format!("{}/v1/agents/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
585 let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
586
587 if let Some(ref user_agent) = configuration.user_agent {
588 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
589 }
590 if let Some(ref token) = configuration.bearer_access_token {
591 req_builder = req_builder.bearer_auth(token.to_owned());
592 };
593 req_builder = req_builder.json(&p_body_update_agent_request);
594
595 let req = req_builder.build()?;
596 let resp = configuration.client.execute(req).await?;
597
598 let status = resp.status();
599 let content_type = resp
600 .headers()
601 .get("content-type")
602 .and_then(|v| v.to_str().ok())
603 .unwrap_or("application/octet-stream");
604 let content_type = super::ContentType::from(content_type);
605
606 if !status.is_client_error() && !status.is_server_error() {
607 let content = resp.text().await?;
608 match content_type {
609 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
610 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Agent`"))),
611 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::Agent`")))),
612 }
613 } else {
614 let content = resp.text().await?;
615 let entity: Option<UpdateAgentError> = serde_json::from_str(&content).ok();
616 Err(Error::ResponseError(ResponseContent { status, content, entity }))
617 }
618}
619