mirakurun_client/apis/
log_api.rs1use reqwest;
13
14use crate::apis::ResponseContent;
15use super::{Error, configuration};
16
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum GetLogError {
22 DefaultResponse(),
23 UnknownValue(serde_json::Value),
24}
25
26#[derive(Debug, Clone, Serialize, Deserialize)]
28#[serde(untagged)]
29pub enum GetLogStreamError {
30 DefaultResponse(),
31 UnknownValue(serde_json::Value),
32}
33
34
35pub fn get_log(configuration: &configuration::Configuration, ) -> Result<(), Error<GetLogError>> {
36 let local_var_configuration = configuration;
37
38 let local_var_client = &local_var_configuration.client;
39
40 let local_var_uri_str = format!("{}/log", local_var_configuration.base_path);
41 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
42
43 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
44 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
45 }
46
47 let local_var_req = local_var_req_builder.build()?;
48 let mut local_var_resp = local_var_client.execute(local_var_req)?;
49
50 let local_var_status = local_var_resp.status();
51 let local_var_content = local_var_resp.text()?;
52
53 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
54 Ok(())
55 } else {
56 let local_var_entity: Option<GetLogError> = serde_json::from_str(&local_var_content).ok();
57 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
58 Err(Error::ResponseError(local_var_error))
59 }
60}
61
62pub fn get_log_stream(configuration: &configuration::Configuration, ) -> Result<(), Error<GetLogStreamError>> {
63 let local_var_configuration = configuration;
64
65 let local_var_client = &local_var_configuration.client;
66
67 let local_var_uri_str = format!("{}/log/stream", local_var_configuration.base_path);
68 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
69
70 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
71 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
72 }
73
74 let local_var_req = local_var_req_builder.build()?;
75 let mut local_var_resp = local_var_client.execute(local_var_req)?;
76
77 let local_var_status = local_var_resp.status();
78 let local_var_content = local_var_resp.text()?;
79
80 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
81 Ok(())
82 } else {
83 let local_var_entity: Option<GetLogStreamError> = serde_json::from_str(&local_var_content).ok();
84 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
85 Err(Error::ResponseError(local_var_error))
86 }
87}
88