use super::types;
use crate::{
ByteStream, ClientHooks, ClientInfo, Error, OperationInfo, RequestBuilderExt,
ResponseValue, encode_path,
};
#[derive(Debug, Clone)]
pub struct NotificationAlertTypesGetAlertTypes<'a> {
client: &'a crate::Client,
account_id: Result<types::AaaAccountId, String>,
}
impl<'a> NotificationAlertTypesGetAlertTypes<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AaaAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `AaaAccountId` for account_id failed".to_string());
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self { client, account_id } = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/alerting/v3/available_alerts",
client.baseurl,
encode_path(&account_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.get(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "notification_alert_types_get_alert_types",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct NotificationWebhooksListWebhooks<'a> {
client: &'a crate::Client,
account_id: Result<types::AaaAccountId, String>,
}
impl<'a> NotificationWebhooksListWebhooks<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AaaAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `AaaAccountId` for account_id failed".to_string());
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self { client, account_id } = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/alerting/v3/destinations/webhooks",
client.baseurl,
encode_path(&account_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.get(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "notification_webhooks_list_webhooks",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct NotificationWebhooksCreateAWebhook<'a> {
client: &'a crate::Client,
account_id: Result<types::AaaAccountId, String>,
body: Result<types::builder::NotificationWebhooksCreateAWebhookBody, String>,
}
impl<'a> NotificationWebhooksCreateAWebhook<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
body: Ok(::std::default::Default::default()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AaaAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `AaaAccountId` for account_id failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::NotificationWebhooksCreateAWebhookBody>,
<V as std::convert::TryInto<types::NotificationWebhooksCreateAWebhookBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `NotificationWebhooksCreateAWebhookBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::NotificationWebhooksCreateAWebhookBody,
)
-> types::builder::NotificationWebhooksCreateAWebhookBody,
{
self.body = self.body.map(f);
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::NotificationWebhooksCreateAWebhookBody::try_from(v)
.map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/alerting/v3/destinations/webhooks",
client.baseurl,
encode_path(&account_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.post(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "notification_webhooks_create_a_webhook",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
201u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct NotificationWebhooksGetAWebhook<'a> {
client: &'a crate::Client,
account_id: Result<types::AaaAccountId, String>,
webhook_id: Result<types::AaaWebhookId, String>,
}
impl<'a> NotificationWebhooksGetAWebhook<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
webhook_id: Err("webhook_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AaaAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `AaaAccountId` for account_id failed".to_string());
self
}
pub fn webhook_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AaaWebhookId>,
{
self.webhook_id = value
.try_into()
.map_err(|_| "conversion to `AaaWebhookId` for webhook_id failed".to_string());
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
webhook_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let webhook_id = webhook_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/alerting/v3/destinations/webhooks/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&webhook_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.get(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "notification_webhooks_get_a_webhook",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct NotificationWebhooksUpdateAWebhook<'a> {
client: &'a crate::Client,
account_id: Result<types::AaaAccountId, String>,
webhook_id: Result<types::AaaWebhookId, String>,
body: Result<types::builder::NotificationWebhooksUpdateAWebhookBody, String>,
}
impl<'a> NotificationWebhooksUpdateAWebhook<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
webhook_id: Err("webhook_id was not initialized".to_string()),
body: Ok(::std::default::Default::default()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AaaAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `AaaAccountId` for account_id failed".to_string());
self
}
pub fn webhook_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AaaWebhookId>,
{
self.webhook_id = value
.try_into()
.map_err(|_| "conversion to `AaaWebhookId` for webhook_id failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::NotificationWebhooksUpdateAWebhookBody>,
<V as std::convert::TryInto<types::NotificationWebhooksUpdateAWebhookBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `NotificationWebhooksUpdateAWebhookBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::NotificationWebhooksUpdateAWebhookBody,
)
-> types::builder::NotificationWebhooksUpdateAWebhookBody,
{
self.body = self.body.map(f);
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
webhook_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let webhook_id = webhook_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::NotificationWebhooksUpdateAWebhookBody::try_from(v)
.map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/alerting/v3/destinations/webhooks/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&webhook_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.put(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "notification_webhooks_update_a_webhook",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct NotificationWebhooksDeleteAWebhook<'a> {
client: &'a crate::Client,
account_id: Result<types::AaaAccountId, String>,
webhook_id: Result<types::AaaWebhookId, String>,
}
impl<'a> NotificationWebhooksDeleteAWebhook<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
webhook_id: Err("webhook_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AaaAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `AaaAccountId` for account_id failed".to_string());
self
}
pub fn webhook_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AaaWebhookId>,
{
self.webhook_id = value
.try_into()
.map_err(|_| "conversion to `AaaWebhookId` for webhook_id failed".to_string());
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
webhook_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let webhook_id = webhook_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/alerting/v3/destinations/webhooks/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&webhook_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.delete(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "notification_webhooks_delete_a_webhook",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct NotificationHistoryListHistory<'a> {
client: &'a crate::Client,
account_id: Result<types::AaaAccountId, String>,
before: Result<types::AaaBefore, String>,
page: Result<f64, String>,
per_page: Result<types::AaaPerPage, String>,
since: Result<::chrono::DateTime<::chrono::offset::Utc>, String>,
}
impl<'a> NotificationHistoryListHistory<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
before: Err("before was not initialized".to_string()),
page: Err("page was not initialized".to_string()),
per_page: Err("per_page was not initialized".to_string()),
since: Err("since was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AaaAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `AaaAccountId` for account_id failed".to_string());
self
}
pub fn before<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AaaBefore>,
{
self.before = value
.try_into()
.map_err(|_| "conversion to `AaaBefore` for before failed".to_string());
self
}
pub fn page<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<f64>,
{
self.page = value
.try_into()
.map_err(|_| "conversion to `f64` for page failed".to_string());
self
}
pub fn per_page<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AaaPerPage>,
{
self.per_page = value
.try_into()
.map_err(|_| "conversion to `AaaPerPage` for per_page failed".to_string());
self
}
pub fn since<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>,
{
self . since = value . try_into () . map_err (| _ | "conversion to `:: chrono :: DateTime < :: chrono :: offset :: Utc >` for since failed" . to_string ()) ;
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
before,
page,
per_page,
since,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let before = before.map_err(Error::InvalidRequest)?;
let page = page.map_err(Error::InvalidRequest)?;
let per_page = per_page.map_err(Error::InvalidRequest)?;
let since = since.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/alerting/v3/history",
client.baseurl,
encode_path(&account_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.get(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.query(&progenitor_client::QueryParam::new("before", &before))
.query(&progenitor_client::QueryParam::new("page", &page))
.query(&progenitor_client::QueryParam::new("per_page", &per_page))
.query(&progenitor_client::QueryParam::new("since", &since))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "notification_history_list_history",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct NotificationPoliciesListNotificationPolicies<'a> {
client: &'a crate::Client,
account_id: Result<types::AaaAccountId, String>,
}
impl<'a> NotificationPoliciesListNotificationPolicies<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AaaAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `AaaAccountId` for account_id failed".to_string());
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self { client, account_id } = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/alerting/v3/policies",
client.baseurl,
encode_path(&account_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.get(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "notification_policies_list_notification_policies",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct NotificationPoliciesGetANotificationPolicy<'a> {
client: &'a crate::Client,
account_id: Result<types::AaaAccountId, String>,
policy_id: Result<types::AaaPolicyId, String>,
}
impl<'a> NotificationPoliciesGetANotificationPolicy<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
policy_id: Err("policy_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AaaAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `AaaAccountId` for account_id failed".to_string());
self
}
pub fn policy_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AaaPolicyId>,
{
self.policy_id = value
.try_into()
.map_err(|_| "conversion to `AaaPolicyId` for policy_id failed".to_string());
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
policy_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let policy_id = policy_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/alerting/v3/policies/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&policy_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.get(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "notification_policies_get_a_notification_policy",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct NotificationSilencesListSilences<'a> {
client: &'a crate::Client,
account_id: Result<types::AaaAccountId, String>,
}
impl<'a> NotificationSilencesListSilences<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AaaAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `AaaAccountId` for account_id failed".to_string());
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self { client, account_id } = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/alerting/v3/silences",
client.baseurl,
encode_path(&account_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.get(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "notification_silences_list_silences",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct NotificationSilencesUpdateSilences<'a> {
client: &'a crate::Client,
account_id: Result<types::AaaAccountId, String>,
body: Result<::std::vec::Vec<types::AaaSilenceUpdateRequest>, String>,
}
impl<'a> NotificationSilencesUpdateSilences<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
body: Err("body was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AaaAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `AaaAccountId` for account_id failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::vec::Vec<types::AaaSilenceUpdateRequest>>,
{
self . body = value . try_into () . map_err (| _ | "conversion to `:: std :: vec :: Vec < AaaSilenceUpdateRequest >` for body failed" . to_string ()) ;
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/alerting/v3/silences",
client.baseurl,
encode_path(&account_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.put(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "notification_silences_update_silences",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct NotificationSilencesCreateSilences<'a> {
client: &'a crate::Client,
account_id: Result<types::AaaAccountId, String>,
body: Result<::std::vec::Vec<types::AaaSilenceCreateRequest>, String>,
}
impl<'a> NotificationSilencesCreateSilences<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
body: Err("body was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AaaAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `AaaAccountId` for account_id failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::vec::Vec<types::AaaSilenceCreateRequest>>,
{
self . body = value . try_into () . map_err (| _ | "conversion to `:: std :: vec :: Vec < AaaSilenceCreateRequest >` for body failed" . to_string ()) ;
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/alerting/v3/silences",
client.baseurl,
encode_path(&account_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.post(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "notification_silences_create_silences",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct NotificationSilencesGetSilence<'a> {
client: &'a crate::Client,
account_id: Result<types::AaaAccountId, String>,
silence_id: Result<types::AaaSilenceId, String>,
}
impl<'a> NotificationSilencesGetSilence<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
silence_id: Err("silence_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AaaAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `AaaAccountId` for account_id failed".to_string());
self
}
pub fn silence_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AaaSilenceId>,
{
self.silence_id = value
.try_into()
.map_err(|_| "conversion to `AaaSilenceId` for silence_id failed".to_string());
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
silence_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let silence_id = silence_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/alerting/v3/silences/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&silence_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.get(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "notification_silences_get_silence",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct NotificationSilencesDeleteSilences<'a> {
client: &'a crate::Client,
account_id: Result<types::AaaAccountId, String>,
silence_id: Result<types::AaaSilenceId, String>,
}
impl<'a> NotificationSilencesDeleteSilences<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
silence_id: Err("silence_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AaaAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `AaaAccountId` for account_id failed".to_string());
self
}
pub fn silence_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AaaSilenceId>,
{
self.silence_id = value
.try_into()
.map_err(|_| "conversion to `AaaSilenceId` for silence_id failed".to_string());
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
silence_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let silence_id = silence_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/alerting/v3/silences/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&silence_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.delete(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "notification_silences_delete_silences",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}