murdock_api/apis/
job_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 JobHandlerJobUidGetError {
22 Status422(crate::models::HttpValidationError),
23 UnknownValue(serde_json::Value),
24}
25
26#[derive(Debug, Clone, Serialize, Deserialize)]
28#[serde(untagged)]
29pub enum JobRemoveHandlerJobUidDeleteError {
30 Status422(crate::models::HttpValidationError),
31 UnknownValue(serde_json::Value),
32}
33
34#[derive(Debug, Clone, Serialize, Deserialize)]
36#[serde(untagged)]
37pub enum JobRestartHandlerJobUidPostError {
38 Status422(crate::models::HttpValidationError),
39 UnknownValue(serde_json::Value),
40}
41
42#[derive(Debug, Clone, Serialize, Deserialize)]
44#[serde(untagged)]
45pub enum RunningJobStatusHandlerJobUidStatusPutError {
46 Status422(crate::models::HttpValidationError),
47 UnknownValue(serde_json::Value),
48}
49
50
51pub async fn job_handler_job_uid_get(configuration: &configuration::Configuration, uid: &str) -> Result<crate::models::JobModel, Error<JobHandlerJobUidGetError>> {
52 let local_var_configuration = configuration;
53
54 let local_var_client = &local_var_configuration.client;
55
56 let local_var_uri_str = format!("{}/job/{uid}", local_var_configuration.base_path, uid=crate::apis::urlencode(uid));
57 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
58
59 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
60 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
61 }
62
63 let local_var_req = local_var_req_builder.build()?;
64 let local_var_resp = local_var_client.execute(local_var_req).await?;
65
66 let local_var_status = local_var_resp.status();
67 let local_var_content = local_var_resp.text().await?;
68
69 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
70 serde_json::from_str(&local_var_content).map_err(Error::from)
71 } else {
72 let local_var_entity: Option<JobHandlerJobUidGetError> = serde_json::from_str(&local_var_content).ok();
73 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
74 Err(Error::ResponseError(local_var_error))
75 }
76}
77
78pub async fn job_remove_handler_job_uid_delete(configuration: &configuration::Configuration, uid: &str) -> Result<crate::models::JobModel, Error<JobRemoveHandlerJobUidDeleteError>> {
79 let local_var_configuration = configuration;
80
81 let local_var_client = &local_var_configuration.client;
82
83 let local_var_uri_str = format!("{}/job/{uid}", local_var_configuration.base_path, uid=crate::apis::urlencode(uid));
84 let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
85
86 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
87 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
88 }
89 if let Some(ref local_var_apikey) = local_var_configuration.api_key {
90 let local_var_key = local_var_apikey.key.clone();
91 let local_var_value = match local_var_apikey.prefix {
92 Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
93 None => local_var_key,
94 };
95 local_var_req_builder = local_var_req_builder.header("authorization", local_var_value);
96 };
97
98 let local_var_req = local_var_req_builder.build()?;
99 let local_var_resp = local_var_client.execute(local_var_req).await?;
100
101 let local_var_status = local_var_resp.status();
102 let local_var_content = local_var_resp.text().await?;
103
104 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
105 serde_json::from_str(&local_var_content).map_err(Error::from)
106 } else {
107 let local_var_entity: Option<JobRemoveHandlerJobUidDeleteError> = serde_json::from_str(&local_var_content).ok();
108 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
109 Err(Error::ResponseError(local_var_error))
110 }
111}
112
113pub async fn job_restart_handler_job_uid_post(configuration: &configuration::Configuration, uid: &str) -> Result<crate::models::JobModel, Error<JobRestartHandlerJobUidPostError>> {
114 let local_var_configuration = configuration;
115
116 let local_var_client = &local_var_configuration.client;
117
118 let local_var_uri_str = format!("{}/job/{uid}", local_var_configuration.base_path, uid=crate::apis::urlencode(uid));
119 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
120
121 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
122 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
123 }
124 if let Some(ref local_var_apikey) = local_var_configuration.api_key {
125 let local_var_key = local_var_apikey.key.clone();
126 let local_var_value = match local_var_apikey.prefix {
127 Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
128 None => local_var_key,
129 };
130 local_var_req_builder = local_var_req_builder.header("authorization", local_var_value);
131 };
132
133 let local_var_req = local_var_req_builder.build()?;
134 let local_var_resp = local_var_client.execute(local_var_req).await?;
135
136 let local_var_status = local_var_resp.status();
137 let local_var_content = local_var_resp.text().await?;
138
139 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
140 serde_json::from_str(&local_var_content).map_err(Error::from)
141 } else {
142 let local_var_entity: Option<JobRestartHandlerJobUidPostError> = serde_json::from_str(&local_var_content).ok();
143 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
144 Err(Error::ResponseError(local_var_error))
145 }
146}
147
148pub async fn running_job_status_handler_job_uid_status_put(configuration: &configuration::Configuration, uid: &str) -> Result<crate::models::JobModel, Error<RunningJobStatusHandlerJobUidStatusPutError>> {
149 let local_var_configuration = configuration;
150
151 let local_var_client = &local_var_configuration.client;
152
153 let local_var_uri_str = format!("{}/job/{uid}/status", local_var_configuration.base_path, uid=crate::apis::urlencode(uid));
154 let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
155
156 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
157 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
158 }
159
160 let local_var_req = local_var_req_builder.build()?;
161 let local_var_resp = local_var_client.execute(local_var_req).await?;
162
163 let local_var_status = local_var_resp.status();
164 let local_var_content = local_var_resp.text().await?;
165
166 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
167 serde_json::from_str(&local_var_content).map_err(Error::from)
168 } else {
169 let local_var_entity: Option<RunningJobStatusHandlerJobUidStatusPutError> = serde_json::from_str(&local_var_content).ok();
170 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
171 Err(Error::ResponseError(local_var_error))
172 }
173}
174