use super::{ContentType, Error, configuration};
use crate::clients::rest::{apis::ResponseContent, models};
use reqwest;
use serde::{Deserialize, Serialize, de::Error as _};
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InfoGetVersionError {
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum MonitoringPostRunProbeError {
Status403(models::V1TaskGet400Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum TenantInviteDeleteError {
Status400(models::V1TaskGet400Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum TenantInviteUpdateError {
Status400(models::V1TaskGet400Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum WebhookCreateError {
Status400(models::V1TaskGet400Response),
Status401(models::V1TaskGet400Response),
Status405(models::V1TaskGet400Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum WebhookDeleteError {
Status400(models::V1TaskGet400Response),
Status401(models::V1TaskGet400Response),
Status405(models::V1TaskGet400Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum WebhookListError {
Status400(models::V1TaskGet400Response),
Status401(models::V1TaskGet400Response),
Status405(models::V1TaskGet400Response),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum WebhookRequestsListError {
Status400(models::V1TaskGet400Response),
Status401(models::V1TaskGet400Response),
Status405(models::V1TaskGet400Response),
UnknownValue(serde_json::Value),
}
pub async fn info_get_version(
configuration: &configuration::Configuration,
) -> Result<models::InfoGetVersion200Response, Error<InfoGetVersionError>> {
let uri_str = format!("{}/api/v1/version", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => {
return Err(Error::from(serde_json::Error::custom(
"Received `text/plain` content type response that cannot be converted to `models::InfoGetVersion200Response`",
)));
}
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::InfoGetVersion200Response`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<InfoGetVersionError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn monitoring_post_run_probe(
configuration: &configuration::Configuration,
tenant: &str,
) -> Result<(), Error<MonitoringPostRunProbeError>> {
let p_tenant = tenant;
let uri_str = format!(
"{}/api/v1/monitoring/{tenant}/probe",
configuration.base_path,
tenant = crate::clients::rest::apis::urlencode(p_tenant)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<MonitoringPostRunProbeError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn tenant_invite_delete(
configuration: &configuration::Configuration,
tenant: &str,
tenant_invite: &str,
) -> Result<models::UserListTenantInvites200ResponseRowsInner, Error<TenantInviteDeleteError>> {
let p_tenant = tenant;
let p_tenant_invite = tenant_invite;
let uri_str = format!(
"{}/api/v1/tenants/{tenant}/invites/{tenant_invite}",
configuration.base_path,
tenant = crate::clients::rest::apis::urlencode(p_tenant),
tenant_invite = crate::clients::rest::apis::urlencode(p_tenant_invite)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => {
return Err(Error::from(serde_json::Error::custom(
"Received `text/plain` content type response that cannot be converted to `models::UserListTenantInvites200ResponseRowsInner`",
)));
}
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::UserListTenantInvites200ResponseRowsInner`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<TenantInviteDeleteError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn tenant_invite_update(
configuration: &configuration::Configuration,
tenant: &str,
tenant_invite: &str,
tenant_invite_update_request: models::TenantInviteUpdateRequest,
) -> Result<models::UserListTenantInvites200ResponseRowsInner, Error<TenantInviteUpdateError>> {
let p_tenant = tenant;
let p_tenant_invite = tenant_invite;
let p_tenant_invite_update_request = tenant_invite_update_request;
let uri_str = format!(
"{}/api/v1/tenants/{tenant}/invites/{tenant_invite}",
configuration.base_path,
tenant = crate::clients::rest::apis::urlencode(p_tenant),
tenant_invite = crate::clients::rest::apis::urlencode(p_tenant_invite)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::PATCH, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_tenant_invite_update_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => {
return Err(Error::from(serde_json::Error::custom(
"Received `text/plain` content type response that cannot be converted to `models::UserListTenantInvites200ResponseRowsInner`",
)));
}
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::UserListTenantInvites200ResponseRowsInner`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<TenantInviteUpdateError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn webhook_create(
configuration: &configuration::Configuration,
tenant: &str,
webhook_create_request: Option<models::WebhookCreateRequest>,
) -> Result<models::WebhookCreate200Response, Error<WebhookCreateError>> {
let p_tenant = tenant;
let p_webhook_create_request = webhook_create_request;
let uri_str = format!(
"{}/api/v1/tenants/{tenant}/webhook-workers",
configuration.base_path,
tenant = crate::clients::rest::apis::urlencode(p_tenant)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_webhook_create_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => {
return Err(Error::from(serde_json::Error::custom(
"Received `text/plain` content type response that cannot be converted to `models::WebhookCreate200Response`",
)));
}
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::WebhookCreate200Response`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<WebhookCreateError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn webhook_delete(
configuration: &configuration::Configuration,
webhook: &str,
) -> Result<(), Error<WebhookDeleteError>> {
let p_webhook = webhook;
let uri_str = format!(
"{}/api/v1/webhook-workers/{webhook}",
configuration.base_path,
webhook = crate::clients::rest::apis::urlencode(p_webhook)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<WebhookDeleteError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn webhook_list(
configuration: &configuration::Configuration,
tenant: &str,
) -> Result<models::WebhookList200Response, Error<WebhookListError>> {
let p_tenant = tenant;
let uri_str = format!(
"{}/api/v1/tenants/{tenant}/webhook-workers",
configuration.base_path,
tenant = crate::clients::rest::apis::urlencode(p_tenant)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => {
return Err(Error::from(serde_json::Error::custom(
"Received `text/plain` content type response that cannot be converted to `models::WebhookList200Response`",
)));
}
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::WebhookList200Response`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<WebhookListError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn webhook_requests_list(
configuration: &configuration::Configuration,
webhook: &str,
) -> Result<models::WebhookRequestsList200Response, Error<WebhookRequestsListError>> {
let p_webhook = webhook;
let uri_str = format!(
"{}/api/v1/webhook-workers/{webhook}/requests",
configuration.base_path,
webhook = crate::clients::rest::apis::urlencode(p_webhook)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => {
return Err(Error::from(serde_json::Error::custom(
"Received `text/plain` content type response that cannot be converted to `models::WebhookRequestsList200Response`",
)));
}
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::WebhookRequestsList200Response`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<WebhookRequestsListError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}