use super::types;
use crate::{
ByteStream, ClientHooks, ClientInfo, Error, OperationInfo, RequestBuilderExt,
ResponseValue, encode_path,
};
#[derive(Debug, Clone)]
pub struct EmailSecurityInvestigate<'a> {
client: &'a crate::Client,
account_id: Result<types::EmailSecurityAccountId, String>,
action_log: Result<bool, String>,
alert_id: Result<::std::string::String, String>,
cursor: Result<::std::string::String, String>,
detections_only: Result<bool, String>,
domain: Result<::std::string::String, String>,
end: Result<::chrono::DateTime<::chrono::offset::Utc>, String>,
final_disposition: Result<types::EmailSecurityInvestigateFinalDisposition, String>,
message_action: Result<types::EmailSecurityInvestigateMessageAction, String>,
message_id: Result<::std::string::String, String>,
metric: Result<::std::string::String, String>,
page: Result<Option<::std::num::NonZeroU32>, String>,
per_page: Result<::std::num::NonZeroU32, String>,
query: Result<::std::string::String, String>,
recipient: Result<::std::string::String, String>,
sender: Result<::std::string::String, String>,
start: Result<::chrono::DateTime<::chrono::offset::Utc>, String>,
subject: Result<::std::string::String, String>,
}
impl<'a> EmailSecurityInvestigate<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
action_log: Err("action_log was not initialized".to_string()),
alert_id: Err("alert_id was not initialized".to_string()),
cursor: Err("cursor was not initialized".to_string()),
detections_only: Err("detections_only was not initialized".to_string()),
domain: Err("domain was not initialized".to_string()),
end: Err("end was not initialized".to_string()),
final_disposition: Err("final_disposition was not initialized".to_string()),
message_action: Err("message_action was not initialized".to_string()),
message_id: Err("message_id was not initialized".to_string()),
metric: Err("metric was not initialized".to_string()),
page: Ok(None),
per_page: Err("per_page was not initialized".to_string()),
query: Err("query was not initialized".to_string()),
recipient: Err("recipient was not initialized".to_string()),
sender: Err("sender was not initialized".to_string()),
start: Err("start was not initialized".to_string()),
subject: Err("subject was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityAccountId>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `EmailSecurityAccountId` for account_id failed".to_string()
});
self
}
pub fn action_log<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<bool>,
{
self.action_log = value
.try_into()
.map_err(|_| "conversion to `bool` for action_log failed".to_string());
self
}
pub fn alert_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.alert_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for alert_id failed".to_string()
});
self
}
pub fn cursor<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.cursor = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for cursor failed".to_string()
});
self
}
pub fn detections_only<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<bool>,
{
self.detections_only = value
.try_into()
.map_err(|_| "conversion to `bool` for detections_only failed".to_string());
self
}
pub fn domain<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.domain = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for domain failed".to_string()
});
self
}
pub fn end<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>,
{
self . end = value . try_into () . map_err (| _ | "conversion to `:: chrono :: DateTime < :: chrono :: offset :: Utc >` for end failed" . to_string ()) ;
self
}
pub fn final_disposition<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityInvestigateFinalDisposition>,
{
self . final_disposition = value . try_into () . map_err (| _ | "conversion to `EmailSecurityInvestigateFinalDisposition` for final_disposition failed" . to_string ()) ;
self
}
pub fn message_action<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityInvestigateMessageAction>,
{
self . message_action = value . try_into () . map_err (| _ | "conversion to `EmailSecurityInvestigateMessageAction` for message_action failed" . to_string ()) ;
self
}
pub fn message_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.message_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for message_id failed".to_string()
});
self
}
pub fn metric<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.metric = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for metric failed".to_string()
});
self
}
pub fn page<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::num::NonZeroU32>,
{
self.page = value.try_into().map(Some).map_err(|_| {
"conversion to `:: std :: num :: NonZeroU32` for page failed".to_string()
});
self
}
pub fn per_page<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::num::NonZeroU32>,
{
self.per_page = value.try_into().map_err(|_| {
"conversion to `:: std :: num :: NonZeroU32` for per_page failed".to_string()
});
self
}
pub fn query<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.query = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for query failed".to_string()
});
self
}
pub fn recipient<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.recipient = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for recipient failed".to_string()
});
self
}
pub fn sender<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.sender = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for sender failed".to_string()
});
self
}
pub fn start<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>,
{
self . start = value . try_into () . map_err (| _ | "conversion to `:: chrono :: DateTime < :: chrono :: offset :: Utc >` for start failed" . to_string ()) ;
self
}
pub fn subject<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.subject = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for subject 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,
action_log,
alert_id,
cursor,
detections_only,
domain,
end,
final_disposition,
message_action,
message_id,
metric,
page,
per_page,
query,
recipient,
sender,
start,
subject,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let action_log = action_log.map_err(Error::InvalidRequest)?;
let alert_id = alert_id.map_err(Error::InvalidRequest)?;
let cursor = cursor.map_err(Error::InvalidRequest)?;
let detections_only = detections_only.map_err(Error::InvalidRequest)?;
let domain = domain.map_err(Error::InvalidRequest)?;
let end = end.map_err(Error::InvalidRequest)?;
let final_disposition = final_disposition.map_err(Error::InvalidRequest)?;
let message_action = message_action.map_err(Error::InvalidRequest)?;
let message_id = message_id.map_err(Error::InvalidRequest)?;
let metric = metric.map_err(Error::InvalidRequest)?;
let page = page.map_err(Error::InvalidRequest)?;
let per_page = per_page.map_err(Error::InvalidRequest)?;
let query = query.map_err(Error::InvalidRequest)?;
let recipient = recipient.map_err(Error::InvalidRequest)?;
let sender = sender.map_err(Error::InvalidRequest)?;
let start = start.map_err(Error::InvalidRequest)?;
let subject = subject.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/email-security/investigate",
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(
"action_log",
&action_log,
))
.query(&progenitor_client::QueryParam::new("alert_id", &alert_id))
.query(&progenitor_client::QueryParam::new("cursor", &cursor))
.query(&progenitor_client::QueryParam::new(
"detections_only",
&detections_only,
))
.query(&progenitor_client::QueryParam::new("domain", &domain))
.query(&progenitor_client::QueryParam::new("end", &end))
.query(&progenitor_client::QueryParam::new(
"final_disposition",
&final_disposition,
))
.query(&progenitor_client::QueryParam::new(
"message_action",
&message_action,
))
.query(&progenitor_client::QueryParam::new(
"message_id",
&message_id,
))
.query(&progenitor_client::QueryParam::new("metric", &metric))
.query(&progenitor_client::QueryParam::new("page", &page))
.query(&progenitor_client::QueryParam::new("per_page", &per_page))
.query(&progenitor_client::QueryParam::new("query", &query))
.query(&progenitor_client::QueryParam::new("recipient", &recipient))
.query(&progenitor_client::QueryParam::new("sender", &sender))
.query(&progenitor_client::QueryParam::new("start", &start))
.query(&progenitor_client::QueryParam::new("subject", &subject))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "email_security_investigate",
};
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 EmailSecurityGetMessage<'a> {
client: &'a crate::Client,
account_id: Result<types::EmailSecurityAccountId, String>,
postfix_id: Result<types::EmailSecurityPostfixId, String>,
}
impl<'a> EmailSecurityGetMessage<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
postfix_id: Err("postfix_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityAccountId>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `EmailSecurityAccountId` for account_id failed".to_string()
});
self
}
pub fn postfix_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityPostfixId>,
{
self.postfix_id = value.try_into().map_err(|_| {
"conversion to `EmailSecurityPostfixId` for postfix_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,
postfix_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let postfix_id = postfix_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/email-security/investigate/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&postfix_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: "email_security_get_message",
};
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 EmailSecurityGetMessageDetections<'a> {
client: &'a crate::Client,
account_id: Result<types::EmailSecurityAccountId, String>,
postfix_id: Result<types::EmailSecurityPostfixId, String>,
}
impl<'a> EmailSecurityGetMessageDetections<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
postfix_id: Err("postfix_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityAccountId>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `EmailSecurityAccountId` for account_id failed".to_string()
});
self
}
pub fn postfix_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityPostfixId>,
{
self.postfix_id = value.try_into().map_err(|_| {
"conversion to `EmailSecurityPostfixId` for postfix_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,
postfix_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let postfix_id = postfix_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/email-security/investigate/{}/detections",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&postfix_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: "email_security_get_message_detections",
};
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 EmailSecurityPostMessageMove<'a> {
client: &'a crate::Client,
account_id: Result<types::EmailSecurityAccountId, String>,
postfix_id: Result<types::EmailSecurityPostfixId, String>,
body: Result<types::builder::EmailSecurityPostMessageMoveBody, String>,
}
impl<'a> EmailSecurityPostMessageMove<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
postfix_id: Err("postfix_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::EmailSecurityAccountId>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `EmailSecurityAccountId` for account_id failed".to_string()
});
self
}
pub fn postfix_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityPostfixId>,
{
self.postfix_id = value.try_into().map_err(|_| {
"conversion to `EmailSecurityPostfixId` for postfix_id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityPostMessageMoveBody>,
<V as std::convert::TryInto<types::EmailSecurityPostMessageMoveBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `EmailSecurityPostMessageMoveBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::EmailSecurityPostMessageMoveBody,
) -> types::builder::EmailSecurityPostMessageMoveBody,
{
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,
postfix_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let postfix_id = postfix_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::EmailSecurityPostMessageMoveBody::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/email-security/investigate/{}/move",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&postfix_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: "email_security_post_message_move",
};
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 EmailSecurityGetMessagePreview<'a> {
client: &'a crate::Client,
account_id: Result<types::EmailSecurityAccountId, String>,
postfix_id: Result<types::EmailSecurityPostfixId, String>,
}
impl<'a> EmailSecurityGetMessagePreview<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
postfix_id: Err("postfix_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityAccountId>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `EmailSecurityAccountId` for account_id failed".to_string()
});
self
}
pub fn postfix_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityPostfixId>,
{
self.postfix_id = value.try_into().map_err(|_| {
"conversion to `EmailSecurityPostfixId` for postfix_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,
postfix_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let postfix_id = postfix_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/email-security/investigate/{}/preview",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&postfix_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: "email_security_get_message_preview",
};
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 EmailSecurityGetMessageRaw<'a> {
client: &'a crate::Client,
account_id: Result<types::EmailSecurityAccountId, String>,
postfix_id: Result<types::EmailSecurityPostfixId, String>,
}
impl<'a> EmailSecurityGetMessageRaw<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
postfix_id: Err("postfix_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityAccountId>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `EmailSecurityAccountId` for account_id failed".to_string()
});
self
}
pub fn postfix_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityPostfixId>,
{
self.postfix_id = value.try_into().map_err(|_| {
"conversion to `EmailSecurityPostfixId` for postfix_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,
postfix_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let postfix_id = postfix_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/email-security/investigate/{}/raw",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&postfix_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: "email_security_get_message_raw",
};
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 EmailSecurityPostReclassify<'a> {
client: &'a crate::Client,
account_id: Result<types::EmailSecurityAccountId, String>,
postfix_id: Result<types::EmailSecurityPostfixId, String>,
body: Result<types::builder::EmailSecurityPostReclassifyBody, String>,
}
impl<'a> EmailSecurityPostReclassify<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
postfix_id: Err("postfix_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::EmailSecurityAccountId>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `EmailSecurityAccountId` for account_id failed".to_string()
});
self
}
pub fn postfix_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityPostfixId>,
{
self.postfix_id = value.try_into().map_err(|_| {
"conversion to `EmailSecurityPostfixId` for postfix_id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityPostReclassifyBody>,
<V as std::convert::TryInto<types::EmailSecurityPostReclassifyBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `EmailSecurityPostReclassifyBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::EmailSecurityPostReclassifyBody,
) -> types::builder::EmailSecurityPostReclassifyBody,
{
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,
postfix_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let postfix_id = postfix_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::EmailSecurityPostReclassifyBody::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/email-security/investigate/{}/reclassify",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&postfix_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: "email_security_post_reclassify",
};
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() {
202u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct EmailSecurityGetMessageTrace<'a> {
client: &'a crate::Client,
account_id: Result<types::EmailSecurityAccountId, String>,
postfix_id: Result<types::EmailSecurityPostfixId, String>,
}
impl<'a> EmailSecurityGetMessageTrace<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
postfix_id: Err("postfix_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityAccountId>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `EmailSecurityAccountId` for account_id failed".to_string()
});
self
}
pub fn postfix_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityPostfixId>,
{
self.postfix_id = value.try_into().map_err(|_| {
"conversion to `EmailSecurityPostfixId` for postfix_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,
postfix_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let postfix_id = postfix_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/email-security/investigate/{}/trace",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&postfix_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: "email_security_get_message_trace",
};
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 EmailSecurityPostBulkMessageMove<'a> {
client: &'a crate::Client,
account_id: Result<types::EmailSecurityAccountId, String>,
body: Result<types::builder::EmailSecurityPostBulkMessageMoveBody, String>,
}
impl<'a> EmailSecurityPostBulkMessageMove<'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::EmailSecurityAccountId>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `EmailSecurityAccountId` for account_id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityPostBulkMessageMoveBody>,
<V as std::convert::TryInto<types::EmailSecurityPostBulkMessageMoveBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `EmailSecurityPostBulkMessageMoveBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::EmailSecurityPostBulkMessageMoveBody,
)
-> types::builder::EmailSecurityPostBulkMessageMoveBody,
{
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::EmailSecurityPostBulkMessageMoveBody::try_from(v)
.map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/email-security/investigate/move",
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: "email_security_post_bulk_message_move",
};
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 EmailSecurityPostPreview<'a> {
client: &'a crate::Client,
account_id: Result<types::EmailSecurityAccountId, String>,
body: Result<types::builder::EmailSecurityPostPreviewBody, String>,
}
impl<'a> EmailSecurityPostPreview<'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::EmailSecurityAccountId>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `EmailSecurityAccountId` for account_id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityPostPreviewBody>,
<V as std::convert::TryInto<types::EmailSecurityPostPreviewBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `EmailSecurityPostPreviewBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::EmailSecurityPostPreviewBody,
) -> types::builder::EmailSecurityPostPreviewBody,
{
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::EmailSecurityPostPreviewBody::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/email-security/investigate/preview",
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: "email_security_post_preview",
};
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 EmailSecurityPostRelease<'a> {
client: &'a crate::Client,
account_id: Result<types::EmailSecurityAccountId, String>,
body: Result<::std::vec::Vec<types::EmailSecurityPostfixId>, String>,
}
impl<'a> EmailSecurityPostRelease<'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::EmailSecurityAccountId>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `EmailSecurityAccountId` 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::EmailSecurityPostfixId>>,
{
self . body = value . try_into () . map_err (| _ | "conversion to `:: std :: vec :: Vec < EmailSecurityPostfixId >` 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/{}/email-security/investigate/release",
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: "email_security_post_release",
};
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 EmailSecurityGetPhishguardReports<'a> {
client: &'a crate::Client,
account_id: Result<types::EmailSecurityAccountId, String>,
end: Result<::chrono::DateTime<::chrono::offset::Utc>, String>,
from_date: Result<::chrono::naive::NaiveDate, String>,
start: Result<::chrono::DateTime<::chrono::offset::Utc>, String>,
to_date: Result<::chrono::naive::NaiveDate, String>,
}
impl<'a> EmailSecurityGetPhishguardReports<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
end: Err("end was not initialized".to_string()),
from_date: Err("from_date was not initialized".to_string()),
start: Err("start was not initialized".to_string()),
to_date: Err("to_date was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityAccountId>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `EmailSecurityAccountId` for account_id failed".to_string()
});
self
}
pub fn end<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>,
{
self . end = value . try_into () . map_err (| _ | "conversion to `:: chrono :: DateTime < :: chrono :: offset :: Utc >` for end failed" . to_string ()) ;
self
}
pub fn from_date<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::chrono::naive::NaiveDate>,
{
self.from_date = value.try_into().map_err(|_| {
"conversion to `:: chrono :: naive :: NaiveDate` for from_date failed".to_string()
});
self
}
pub fn start<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>,
{
self . start = value . try_into () . map_err (| _ | "conversion to `:: chrono :: DateTime < :: chrono :: offset :: Utc >` for start failed" . to_string ()) ;
self
}
pub fn to_date<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::chrono::naive::NaiveDate>,
{
self.to_date = value.try_into().map_err(|_| {
"conversion to `:: chrono :: naive :: NaiveDate` for to_date 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,
end,
from_date,
start,
to_date,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let end = end.map_err(Error::InvalidRequest)?;
let from_date = from_date.map_err(Error::InvalidRequest)?;
let start = start.map_err(Error::InvalidRequest)?;
let to_date = to_date.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/email-security/phishguard/reports",
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("end", &end))
.query(&progenitor_client::QueryParam::new("from_date", &from_date))
.query(&progenitor_client::QueryParam::new("start", &start))
.query(&progenitor_client::QueryParam::new("to_date", &to_date))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "email_security_get_phishguard_reports",
};
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 EmailSecurityListAllowPolicies<'a> {
client: &'a crate::Client,
account_id: Result<types::EmailSecurityAccountId, String>,
direction: Result<types::EmailSecuritySortingDirection, String>,
is_acceptable_sender: Result<bool, String>,
is_exempt_recipient: Result<bool, String>,
is_recipient: Result<bool, String>,
is_sender: Result<bool, String>,
is_spoof: Result<bool, String>,
is_trusted_sender: Result<bool, String>,
order: Result<types::EmailSecurityListAllowPoliciesOrder, String>,
page: Result<::std::num::NonZeroU32, String>,
pattern: Result<::std::string::String, String>,
pattern_type: Result<types::EmailSecurityPatternType, String>,
per_page: Result<::std::num::NonZeroU32, String>,
search: Result<::std::string::String, String>,
verify_sender: Result<bool, String>,
}
impl<'a> EmailSecurityListAllowPolicies<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
direction: Err("direction was not initialized".to_string()),
is_acceptable_sender: Err("is_acceptable_sender was not initialized".to_string()),
is_exempt_recipient: Err("is_exempt_recipient was not initialized".to_string()),
is_recipient: Err("is_recipient was not initialized".to_string()),
is_sender: Err("is_sender was not initialized".to_string()),
is_spoof: Err("is_spoof was not initialized".to_string()),
is_trusted_sender: Err("is_trusted_sender was not initialized".to_string()),
order: Err("order was not initialized".to_string()),
page: Err("page was not initialized".to_string()),
pattern: Err("pattern was not initialized".to_string()),
pattern_type: Err("pattern_type was not initialized".to_string()),
per_page: Err("per_page was not initialized".to_string()),
search: Err("search was not initialized".to_string()),
verify_sender: Err("verify_sender was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityAccountId>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `EmailSecurityAccountId` for account_id failed".to_string()
});
self
}
pub fn direction<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecuritySortingDirection>,
{
self.direction = value.try_into().map_err(|_| {
"conversion to `EmailSecuritySortingDirection` for direction failed".to_string()
});
self
}
pub fn is_acceptable_sender<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<bool>,
{
self.is_acceptable_sender = value
.try_into()
.map_err(|_| "conversion to `bool` for is_acceptable_sender failed".to_string());
self
}
pub fn is_exempt_recipient<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<bool>,
{
self.is_exempt_recipient = value
.try_into()
.map_err(|_| "conversion to `bool` for is_exempt_recipient failed".to_string());
self
}
pub fn is_recipient<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<bool>,
{
self.is_recipient = value
.try_into()
.map_err(|_| "conversion to `bool` for is_recipient failed".to_string());
self
}
pub fn is_sender<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<bool>,
{
self.is_sender = value
.try_into()
.map_err(|_| "conversion to `bool` for is_sender failed".to_string());
self
}
pub fn is_spoof<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<bool>,
{
self.is_spoof = value
.try_into()
.map_err(|_| "conversion to `bool` for is_spoof failed".to_string());
self
}
pub fn is_trusted_sender<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<bool>,
{
self.is_trusted_sender = value
.try_into()
.map_err(|_| "conversion to `bool` for is_trusted_sender failed".to_string());
self
}
pub fn order<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityListAllowPoliciesOrder>,
{
self.order = value.try_into().map_err(|_| {
"conversion to `EmailSecurityListAllowPoliciesOrder` for order failed".to_string()
});
self
}
pub fn page<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::num::NonZeroU32>,
{
self.page = value.try_into().map_err(|_| {
"conversion to `:: std :: num :: NonZeroU32` for page failed".to_string()
});
self
}
pub fn pattern<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.pattern = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for pattern failed".to_string()
});
self
}
pub fn pattern_type<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityPatternType>,
{
self.pattern_type = value.try_into().map_err(|_| {
"conversion to `EmailSecurityPatternType` for pattern_type failed".to_string()
});
self
}
pub fn per_page<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::num::NonZeroU32>,
{
self.per_page = value.try_into().map_err(|_| {
"conversion to `:: std :: num :: NonZeroU32` for per_page failed".to_string()
});
self
}
pub fn search<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.search = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for search failed".to_string()
});
self
}
pub fn verify_sender<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<bool>,
{
self.verify_sender = value
.try_into()
.map_err(|_| "conversion to `bool` for verify_sender 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,
direction,
is_acceptable_sender,
is_exempt_recipient,
is_recipient,
is_sender,
is_spoof,
is_trusted_sender,
order,
page,
pattern,
pattern_type,
per_page,
search,
verify_sender,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let direction = direction.map_err(Error::InvalidRequest)?;
let is_acceptable_sender = is_acceptable_sender.map_err(Error::InvalidRequest)?;
let is_exempt_recipient = is_exempt_recipient.map_err(Error::InvalidRequest)?;
let is_recipient = is_recipient.map_err(Error::InvalidRequest)?;
let is_sender = is_sender.map_err(Error::InvalidRequest)?;
let is_spoof = is_spoof.map_err(Error::InvalidRequest)?;
let is_trusted_sender = is_trusted_sender.map_err(Error::InvalidRequest)?;
let order = order.map_err(Error::InvalidRequest)?;
let page = page.map_err(Error::InvalidRequest)?;
let pattern = pattern.map_err(Error::InvalidRequest)?;
let pattern_type = pattern_type.map_err(Error::InvalidRequest)?;
let per_page = per_page.map_err(Error::InvalidRequest)?;
let search = search.map_err(Error::InvalidRequest)?;
let verify_sender = verify_sender.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/email-security/settings/allow_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"),
)
.query(&progenitor_client::QueryParam::new("direction", &direction))
.query(&progenitor_client::QueryParam::new(
"is_acceptable_sender",
&is_acceptable_sender,
))
.query(&progenitor_client::QueryParam::new(
"is_exempt_recipient",
&is_exempt_recipient,
))
.query(&progenitor_client::QueryParam::new(
"is_recipient",
&is_recipient,
))
.query(&progenitor_client::QueryParam::new("is_sender", &is_sender))
.query(&progenitor_client::QueryParam::new("is_spoof", &is_spoof))
.query(&progenitor_client::QueryParam::new(
"is_trusted_sender",
&is_trusted_sender,
))
.query(&progenitor_client::QueryParam::new("order", &order))
.query(&progenitor_client::QueryParam::new("page", &page))
.query(&progenitor_client::QueryParam::new("pattern", &pattern))
.query(&progenitor_client::QueryParam::new(
"pattern_type",
&pattern_type,
))
.query(&progenitor_client::QueryParam::new("per_page", &per_page))
.query(&progenitor_client::QueryParam::new("search", &search))
.query(&progenitor_client::QueryParam::new(
"verify_sender",
&verify_sender,
))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "email_security_list_allow_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 EmailSecurityCreateAllowPolicy<'a> {
client: &'a crate::Client,
account_id: Result<types::EmailSecurityAccountId, String>,
body: Result<types::builder::EmailSecurityCreateAllowPolicy, String>,
}
impl<'a> EmailSecurityCreateAllowPolicy<'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::EmailSecurityAccountId>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `EmailSecurityAccountId` for account_id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityCreateAllowPolicy>,
<V as std::convert::TryInto<types::EmailSecurityCreateAllowPolicy>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `EmailSecurityCreateAllowPolicy` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::EmailSecurityCreateAllowPolicy,
) -> types::builder::EmailSecurityCreateAllowPolicy,
{
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::EmailSecurityCreateAllowPolicy::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/email-security/settings/allow_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
.post(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "email_security_create_allow_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() {
201u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct EmailSecurityGetAllowPolicy<'a> {
client: &'a crate::Client,
account_id: Result<types::EmailSecurityAccountId, String>,
policy_id: Result<types::EmailSecurityAllowPolicyId, String>,
}
impl<'a> EmailSecurityGetAllowPolicy<'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::EmailSecurityAccountId>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `EmailSecurityAccountId` for account_id failed".to_string()
});
self
}
pub fn policy_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityAllowPolicyId>,
{
self.policy_id = value.try_into().map_err(|_| {
"conversion to `EmailSecurityAllowPolicyId` 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/{}/email-security/settings/allow_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: "email_security_get_allow_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 EmailSecurityDeleteAllowPolicy<'a> {
client: &'a crate::Client,
account_id: Result<types::EmailSecurityAccountId, String>,
policy_id: Result<types::EmailSecurityAllowPolicyId, String>,
}
impl<'a> EmailSecurityDeleteAllowPolicy<'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::EmailSecurityAccountId>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `EmailSecurityAccountId` for account_id failed".to_string()
});
self
}
pub fn policy_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityAllowPolicyId>,
{
self.policy_id = value.try_into().map_err(|_| {
"conversion to `EmailSecurityAllowPolicyId` 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/{}/email-security/settings/allow_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
.delete(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "email_security_delete_allow_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 EmailSecurityUpdateAllowPolicy<'a> {
client: &'a crate::Client,
account_id: Result<types::EmailSecurityAccountId, String>,
policy_id: Result<types::EmailSecurityAllowPolicyId, String>,
body: Result<types::builder::EmailSecurityUpdateAllowPolicy, String>,
}
impl<'a> EmailSecurityUpdateAllowPolicy<'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()),
body: Ok(::std::default::Default::default()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityAccountId>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `EmailSecurityAccountId` for account_id failed".to_string()
});
self
}
pub fn policy_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityAllowPolicyId>,
{
self.policy_id = value.try_into().map_err(|_| {
"conversion to `EmailSecurityAllowPolicyId` for policy_id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityUpdateAllowPolicy>,
<V as std::convert::TryInto<types::EmailSecurityUpdateAllowPolicy>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `EmailSecurityUpdateAllowPolicy` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::EmailSecurityUpdateAllowPolicy,
) -> types::builder::EmailSecurityUpdateAllowPolicy,
{
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,
policy_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let policy_id = policy_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::EmailSecurityUpdateAllowPolicy::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/email-security/settings/allow_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
.patch(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "email_security_update_allow_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 EmailSecurityBatchAllowPolicies<'a> {
client: &'a crate::Client,
account_id: Result<types::EmailSecurityAccountId, String>,
body: Result<types::builder::EmailSecurityBatchAllowPoliciesBody, String>,
}
impl<'a> EmailSecurityBatchAllowPolicies<'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::EmailSecurityAccountId>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `EmailSecurityAccountId` for account_id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityBatchAllowPoliciesBody>,
<V as std::convert::TryInto<types::EmailSecurityBatchAllowPoliciesBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `EmailSecurityBatchAllowPoliciesBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::EmailSecurityBatchAllowPoliciesBody,
) -> types::builder::EmailSecurityBatchAllowPoliciesBody,
{
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::EmailSecurityBatchAllowPoliciesBody::try_from(v)
.map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/email-security/settings/allow_policies/batch",
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: "email_security_batch_allow_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 EmailSecurityListBlockedSenders<'a> {
client: &'a crate::Client,
account_id: Result<types::EmailSecurityAccountId, String>,
direction: Result<types::EmailSecuritySortingDirection, String>,
order: Result<types::EmailSecurityListBlockedSendersOrder, String>,
page: Result<::std::num::NonZeroU32, String>,
pattern: Result<::std::string::String, String>,
pattern_type: Result<types::EmailSecurityPatternType, String>,
per_page: Result<::std::num::NonZeroU32, String>,
search: Result<::std::string::String, String>,
}
impl<'a> EmailSecurityListBlockedSenders<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
direction: Err("direction was not initialized".to_string()),
order: Err("order was not initialized".to_string()),
page: Err("page was not initialized".to_string()),
pattern: Err("pattern was not initialized".to_string()),
pattern_type: Err("pattern_type was not initialized".to_string()),
per_page: Err("per_page was not initialized".to_string()),
search: Err("search was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityAccountId>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `EmailSecurityAccountId` for account_id failed".to_string()
});
self
}
pub fn direction<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecuritySortingDirection>,
{
self.direction = value.try_into().map_err(|_| {
"conversion to `EmailSecuritySortingDirection` for direction failed".to_string()
});
self
}
pub fn order<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityListBlockedSendersOrder>,
{
self.order = value.try_into().map_err(|_| {
"conversion to `EmailSecurityListBlockedSendersOrder` for order failed".to_string()
});
self
}
pub fn page<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::num::NonZeroU32>,
{
self.page = value.try_into().map_err(|_| {
"conversion to `:: std :: num :: NonZeroU32` for page failed".to_string()
});
self
}
pub fn pattern<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.pattern = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for pattern failed".to_string()
});
self
}
pub fn pattern_type<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityPatternType>,
{
self.pattern_type = value.try_into().map_err(|_| {
"conversion to `EmailSecurityPatternType` for pattern_type failed".to_string()
});
self
}
pub fn per_page<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::num::NonZeroU32>,
{
self.per_page = value.try_into().map_err(|_| {
"conversion to `:: std :: num :: NonZeroU32` for per_page failed".to_string()
});
self
}
pub fn search<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.search = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for search 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,
direction,
order,
page,
pattern,
pattern_type,
per_page,
search,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let direction = direction.map_err(Error::InvalidRequest)?;
let order = order.map_err(Error::InvalidRequest)?;
let page = page.map_err(Error::InvalidRequest)?;
let pattern = pattern.map_err(Error::InvalidRequest)?;
let pattern_type = pattern_type.map_err(Error::InvalidRequest)?;
let per_page = per_page.map_err(Error::InvalidRequest)?;
let search = search.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/email-security/settings/block_senders",
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("direction", &direction))
.query(&progenitor_client::QueryParam::new("order", &order))
.query(&progenitor_client::QueryParam::new("page", &page))
.query(&progenitor_client::QueryParam::new("pattern", &pattern))
.query(&progenitor_client::QueryParam::new(
"pattern_type",
&pattern_type,
))
.query(&progenitor_client::QueryParam::new("per_page", &per_page))
.query(&progenitor_client::QueryParam::new("search", &search))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "email_security_list_blocked_senders",
};
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 EmailSecurityCreateBlockedSender<'a> {
client: &'a crate::Client,
account_id: Result<types::EmailSecurityAccountId, String>,
body: Result<types::builder::EmailSecurityCreateBlockedSender, String>,
}
impl<'a> EmailSecurityCreateBlockedSender<'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::EmailSecurityAccountId>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `EmailSecurityAccountId` for account_id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityCreateBlockedSender>,
<V as std::convert::TryInto<types::EmailSecurityCreateBlockedSender>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `EmailSecurityCreateBlockedSender` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::EmailSecurityCreateBlockedSender,
) -> types::builder::EmailSecurityCreateBlockedSender,
{
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::EmailSecurityCreateBlockedSender::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/email-security/settings/block_senders",
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: "email_security_create_blocked_sender",
};
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 EmailSecurityGetBlockedSender<'a> {
client: &'a crate::Client,
account_id: Result<types::EmailSecurityAccountId, String>,
pattern_id: Result<types::EmailSecurityBlockedSenderId, String>,
}
impl<'a> EmailSecurityGetBlockedSender<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
pattern_id: Err("pattern_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityAccountId>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `EmailSecurityAccountId` for account_id failed".to_string()
});
self
}
pub fn pattern_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityBlockedSenderId>,
{
self.pattern_id = value.try_into().map_err(|_| {
"conversion to `EmailSecurityBlockedSenderId` for pattern_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,
pattern_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let pattern_id = pattern_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/email-security/settings/block_senders/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&pattern_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: "email_security_get_blocked_sender",
};
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 EmailSecurityDeleteBlockedSender<'a> {
client: &'a crate::Client,
account_id: Result<types::EmailSecurityAccountId, String>,
pattern_id: Result<types::EmailSecurityBlockedSenderId, String>,
}
impl<'a> EmailSecurityDeleteBlockedSender<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
pattern_id: Err("pattern_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityAccountId>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `EmailSecurityAccountId` for account_id failed".to_string()
});
self
}
pub fn pattern_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityBlockedSenderId>,
{
self.pattern_id = value.try_into().map_err(|_| {
"conversion to `EmailSecurityBlockedSenderId` for pattern_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,
pattern_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let pattern_id = pattern_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/email-security/settings/block_senders/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&pattern_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: "email_security_delete_blocked_sender",
};
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 EmailSecurityUpdateBlockedSender<'a> {
client: &'a crate::Client,
account_id: Result<types::EmailSecurityAccountId, String>,
pattern_id: Result<types::EmailSecurityBlockedSenderId, String>,
body: Result<types::builder::EmailSecurityUpdateBlockedSender, String>,
}
impl<'a> EmailSecurityUpdateBlockedSender<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
pattern_id: Err("pattern_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::EmailSecurityAccountId>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `EmailSecurityAccountId` for account_id failed".to_string()
});
self
}
pub fn pattern_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityBlockedSenderId>,
{
self.pattern_id = value.try_into().map_err(|_| {
"conversion to `EmailSecurityBlockedSenderId` for pattern_id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityUpdateBlockedSender>,
<V as std::convert::TryInto<types::EmailSecurityUpdateBlockedSender>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `EmailSecurityUpdateBlockedSender` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::EmailSecurityUpdateBlockedSender,
) -> types::builder::EmailSecurityUpdateBlockedSender,
{
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,
pattern_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let pattern_id = pattern_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::EmailSecurityUpdateBlockedSender::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/email-security/settings/block_senders/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&pattern_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
.patch(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "email_security_update_blocked_sender",
};
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 EmailSecurityBatchBlockedSenders<'a> {
client: &'a crate::Client,
account_id: Result<types::EmailSecurityAccountId, String>,
body: Result<types::builder::EmailSecurityBatchBlockedSendersBody, String>,
}
impl<'a> EmailSecurityBatchBlockedSenders<'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::EmailSecurityAccountId>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `EmailSecurityAccountId` for account_id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityBatchBlockedSendersBody>,
<V as std::convert::TryInto<types::EmailSecurityBatchBlockedSendersBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `EmailSecurityBatchBlockedSendersBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::EmailSecurityBatchBlockedSendersBody,
)
-> types::builder::EmailSecurityBatchBlockedSendersBody,
{
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::EmailSecurityBatchBlockedSendersBody::try_from(v)
.map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/email-security/settings/block_senders/batch",
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: "email_security_batch_blocked_senders",
};
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 EmailSecurityListDomains<'a> {
client: &'a crate::Client,
account_id: Result<types::EmailSecurityAccountId, String>,
active_delivery_mode: Result<types::EmailSecurityDeliveryMode, String>,
allowed_delivery_mode: Result<types::EmailSecurityDeliveryMode, String>,
direction: Result<types::EmailSecuritySortingDirection, String>,
domain: Result<::std::vec::Vec<::std::string::String>, String>,
integration_id: Result<::uuid::Uuid, String>,
order: Result<types::EmailSecurityListDomainsOrder, String>,
page: Result<::std::num::NonZeroU32, String>,
per_page: Result<::std::num::NonZeroU32, String>,
search: Result<::std::string::String, String>,
}
impl<'a> EmailSecurityListDomains<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
active_delivery_mode: Err("active_delivery_mode was not initialized".to_string()),
allowed_delivery_mode: Err("allowed_delivery_mode was not initialized".to_string()),
direction: Err("direction was not initialized".to_string()),
domain: Err("domain was not initialized".to_string()),
integration_id: Err("integration_id was not initialized".to_string()),
order: Err("order was not initialized".to_string()),
page: Err("page was not initialized".to_string()),
per_page: Err("per_page was not initialized".to_string()),
search: Err("search was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityAccountId>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `EmailSecurityAccountId` for account_id failed".to_string()
});
self
}
pub fn active_delivery_mode<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityDeliveryMode>,
{
self.active_delivery_mode = value.try_into().map_err(|_| {
"conversion to `EmailSecurityDeliveryMode` for active_delivery_mode failed"
.to_string()
});
self
}
pub fn allowed_delivery_mode<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityDeliveryMode>,
{
self.allowed_delivery_mode = value.try_into().map_err(|_| {
"conversion to `EmailSecurityDeliveryMode` for allowed_delivery_mode failed"
.to_string()
});
self
}
pub fn direction<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecuritySortingDirection>,
{
self.direction = value.try_into().map_err(|_| {
"conversion to `EmailSecuritySortingDirection` for direction failed".to_string()
});
self
}
pub fn domain<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::vec::Vec<::std::string::String>>,
{
self . domain = value . try_into () . map_err (| _ | "conversion to `:: std :: vec :: Vec < :: std :: string :: String >` for domain failed" . to_string ()) ;
self
}
pub fn integration_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::uuid::Uuid>,
{
self.integration_id = value.try_into().map_err(|_| {
"conversion to `:: uuid :: Uuid` for integration_id failed".to_string()
});
self
}
pub fn order<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityListDomainsOrder>,
{
self.order = value.try_into().map_err(|_| {
"conversion to `EmailSecurityListDomainsOrder` for order failed".to_string()
});
self
}
pub fn page<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::num::NonZeroU32>,
{
self.page = value.try_into().map_err(|_| {
"conversion to `:: std :: num :: NonZeroU32` for page failed".to_string()
});
self
}
pub fn per_page<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::num::NonZeroU32>,
{
self.per_page = value.try_into().map_err(|_| {
"conversion to `:: std :: num :: NonZeroU32` for per_page failed".to_string()
});
self
}
pub fn search<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.search = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for search 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,
active_delivery_mode,
allowed_delivery_mode,
direction,
domain,
integration_id,
order,
page,
per_page,
search,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let active_delivery_mode = active_delivery_mode.map_err(Error::InvalidRequest)?;
let allowed_delivery_mode = allowed_delivery_mode.map_err(Error::InvalidRequest)?;
let direction = direction.map_err(Error::InvalidRequest)?;
let domain = domain.map_err(Error::InvalidRequest)?;
let integration_id = integration_id.map_err(Error::InvalidRequest)?;
let order = order.map_err(Error::InvalidRequest)?;
let page = page.map_err(Error::InvalidRequest)?;
let per_page = per_page.map_err(Error::InvalidRequest)?;
let search = search.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/email-security/settings/domains",
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(
"active_delivery_mode",
&active_delivery_mode,
))
.query(&progenitor_client::QueryParam::new(
"allowed_delivery_mode",
&allowed_delivery_mode,
))
.query(&progenitor_client::QueryParam::new("direction", &direction))
.query(&progenitor_client::QueryParam::new("domain", &domain))
.query(&progenitor_client::QueryParam::new(
"integration_id",
&integration_id,
))
.query(&progenitor_client::QueryParam::new("order", &order))
.query(&progenitor_client::QueryParam::new("page", &page))
.query(&progenitor_client::QueryParam::new("per_page", &per_page))
.query(&progenitor_client::QueryParam::new("search", &search))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "email_security_list_domains",
};
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 EmailSecurityDeleteDomains<'a> {
client: &'a crate::Client,
account_id: Result<types::EmailSecurityAccountId, String>,
body: Result<::std::vec::Vec<types::EmailSecurityDeleteDomainsBodyItem>, String>,
}
impl<'a> EmailSecurityDeleteDomains<'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::EmailSecurityAccountId>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `EmailSecurityAccountId` 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::EmailSecurityDeleteDomainsBodyItem>>,
{
self . body = value . try_into () . map_err (| _ | "conversion to `:: std :: vec :: Vec < EmailSecurityDeleteDomainsBodyItem >` 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/{}/email-security/settings/domains",
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
.delete(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "email_security_delete_domains",
};
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 EmailSecurityGetDomain<'a> {
client: &'a crate::Client,
account_id: Result<types::EmailSecurityAccountId, String>,
domain_id: Result<i32, String>,
}
impl<'a> EmailSecurityGetDomain<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
domain_id: Err("domain_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityAccountId>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `EmailSecurityAccountId` for account_id failed".to_string()
});
self
}
pub fn domain_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<i32>,
{
self.domain_id = value
.try_into()
.map_err(|_| "conversion to `i32` for domain_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,
domain_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let domain_id = domain_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/email-security/settings/domains/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&domain_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: "email_security_get_domain",
};
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 EmailSecurityDeleteDomain<'a> {
client: &'a crate::Client,
account_id: Result<types::EmailSecurityAccountId, String>,
domain_id: Result<i32, String>,
}
impl<'a> EmailSecurityDeleteDomain<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
domain_id: Err("domain_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityAccountId>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `EmailSecurityAccountId` for account_id failed".to_string()
});
self
}
pub fn domain_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<i32>,
{
self.domain_id = value
.try_into()
.map_err(|_| "conversion to `i32` for domain_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,
domain_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let domain_id = domain_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/email-security/settings/domains/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&domain_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: "email_security_delete_domain",
};
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 EmailSecurityUpdateDomain<'a> {
client: &'a crate::Client,
account_id: Result<types::EmailSecurityAccountId, String>,
domain_id: Result<i32, String>,
body: Result<types::builder::EmailSecurityUpdateDomainBody, String>,
}
impl<'a> EmailSecurityUpdateDomain<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
domain_id: Err("domain_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::EmailSecurityAccountId>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `EmailSecurityAccountId` for account_id failed".to_string()
});
self
}
pub fn domain_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<i32>,
{
self.domain_id = value
.try_into()
.map_err(|_| "conversion to `i32` for domain_id failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityUpdateDomainBody>,
<V as std::convert::TryInto<types::EmailSecurityUpdateDomainBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `EmailSecurityUpdateDomainBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::EmailSecurityUpdateDomainBody,
) -> types::builder::EmailSecurityUpdateDomainBody,
{
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,
domain_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let domain_id = domain_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::EmailSecurityUpdateDomainBody::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/email-security/settings/domains/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&domain_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
.patch(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "email_security_update_domain",
};
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 EmailSecurityListDisplayNames<'a> {
client: &'a crate::Client,
account_id: Result<types::EmailSecurityAccountId, String>,
direction: Result<types::EmailSecuritySortingDirection, String>,
order: Result<types::EmailSecurityListDisplayNamesOrder, String>,
page: Result<::std::num::NonZeroU32, String>,
per_page: Result<::std::num::NonZeroU32, String>,
provenance: Result<types::EmailSecurityListDisplayNamesProvenance, String>,
search: Result<::std::string::String, String>,
}
impl<'a> EmailSecurityListDisplayNames<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
direction: Err("direction was not initialized".to_string()),
order: Err("order was not initialized".to_string()),
page: Err("page was not initialized".to_string()),
per_page: Err("per_page was not initialized".to_string()),
provenance: Err("provenance was not initialized".to_string()),
search: Err("search was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityAccountId>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `EmailSecurityAccountId` for account_id failed".to_string()
});
self
}
pub fn direction<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecuritySortingDirection>,
{
self.direction = value.try_into().map_err(|_| {
"conversion to `EmailSecuritySortingDirection` for direction failed".to_string()
});
self
}
pub fn order<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityListDisplayNamesOrder>,
{
self.order = value.try_into().map_err(|_| {
"conversion to `EmailSecurityListDisplayNamesOrder` for order failed".to_string()
});
self
}
pub fn page<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::num::NonZeroU32>,
{
self.page = value.try_into().map_err(|_| {
"conversion to `:: std :: num :: NonZeroU32` for page failed".to_string()
});
self
}
pub fn per_page<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::num::NonZeroU32>,
{
self.per_page = value.try_into().map_err(|_| {
"conversion to `:: std :: num :: NonZeroU32` for per_page failed".to_string()
});
self
}
pub fn provenance<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityListDisplayNamesProvenance>,
{
self.provenance = value.try_into().map_err(|_| {
"conversion to `EmailSecurityListDisplayNamesProvenance` for provenance failed"
.to_string()
});
self
}
pub fn search<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.search = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for search 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,
direction,
order,
page,
per_page,
provenance,
search,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let direction = direction.map_err(Error::InvalidRequest)?;
let order = order.map_err(Error::InvalidRequest)?;
let page = page.map_err(Error::InvalidRequest)?;
let per_page = per_page.map_err(Error::InvalidRequest)?;
let provenance = provenance.map_err(Error::InvalidRequest)?;
let search = search.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/email-security/settings/impersonation_registry",
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("direction", &direction))
.query(&progenitor_client::QueryParam::new("order", &order))
.query(&progenitor_client::QueryParam::new("page", &page))
.query(&progenitor_client::QueryParam::new("per_page", &per_page))
.query(&progenitor_client::QueryParam::new(
"provenance",
&provenance,
))
.query(&progenitor_client::QueryParam::new("search", &search))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "email_security_list_display_names",
};
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 EmailSecurityCreateDisplayName<'a> {
client: &'a crate::Client,
account_id: Result<types::EmailSecurityAccountId, String>,
body: Result<types::builder::EmailSecurityCreateDisplayName, String>,
}
impl<'a> EmailSecurityCreateDisplayName<'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::EmailSecurityAccountId>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `EmailSecurityAccountId` for account_id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityCreateDisplayName>,
<V as std::convert::TryInto<types::EmailSecurityCreateDisplayName>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `EmailSecurityCreateDisplayName` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::EmailSecurityCreateDisplayName,
) -> types::builder::EmailSecurityCreateDisplayName,
{
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::EmailSecurityCreateDisplayName::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/email-security/settings/impersonation_registry",
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: "email_security_create_display_name",
};
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 EmailSecurityGetDisplayName<'a> {
client: &'a crate::Client,
account_id: Result<types::EmailSecurityAccountId, String>,
display_name_id: Result<i32, String>,
}
impl<'a> EmailSecurityGetDisplayName<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
display_name_id: Err("display_name_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityAccountId>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `EmailSecurityAccountId` for account_id failed".to_string()
});
self
}
pub fn display_name_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<i32>,
{
self.display_name_id = value
.try_into()
.map_err(|_| "conversion to `i32` for display_name_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,
display_name_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let display_name_id = display_name_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/email-security/settings/impersonation_registry/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&display_name_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: "email_security_get_display_name",
};
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 EmailSecurityDeleteDisplayName<'a> {
client: &'a crate::Client,
account_id: Result<types::EmailSecurityAccountId, String>,
display_name_id: Result<i32, String>,
}
impl<'a> EmailSecurityDeleteDisplayName<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
display_name_id: Err("display_name_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityAccountId>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `EmailSecurityAccountId` for account_id failed".to_string()
});
self
}
pub fn display_name_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<i32>,
{
self.display_name_id = value
.try_into()
.map_err(|_| "conversion to `i32` for display_name_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,
display_name_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let display_name_id = display_name_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/email-security/settings/impersonation_registry/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&display_name_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: "email_security_delete_display_name",
};
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 EmailSecurityUpdateDisplayName<'a> {
client: &'a crate::Client,
account_id: Result<types::EmailSecurityAccountId, String>,
display_name_id: Result<i32, String>,
body: Result<types::builder::EmailSecurityUpdateDisplayNameBody, String>,
}
impl<'a> EmailSecurityUpdateDisplayName<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
display_name_id: Err("display_name_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::EmailSecurityAccountId>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `EmailSecurityAccountId` for account_id failed".to_string()
});
self
}
pub fn display_name_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<i32>,
{
self.display_name_id = value
.try_into()
.map_err(|_| "conversion to `i32` for display_name_id failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityUpdateDisplayNameBody>,
<V as std::convert::TryInto<types::EmailSecurityUpdateDisplayNameBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `EmailSecurityUpdateDisplayNameBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::EmailSecurityUpdateDisplayNameBody,
) -> types::builder::EmailSecurityUpdateDisplayNameBody,
{
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,
display_name_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let display_name_id = display_name_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::EmailSecurityUpdateDisplayNameBody::try_from(v)
.map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/email-security/settings/impersonation_registry/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&display_name_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
.patch(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "email_security_update_display_name",
};
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 EmailSecurityBatchSendingDomainRestrictions<'a> {
client: &'a crate::Client,
account_id: Result<types::EmailSecurityAccountId, String>,
body: Result<types::builder::EmailSecurityBatchSendingDomainRestrictionsBody, String>,
}
impl<'a> EmailSecurityBatchSendingDomainRestrictions<'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::EmailSecurityAccountId>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `EmailSecurityAccountId` for account_id failed".to_string()
});
self
} pub fn body < V > (mut self , value : V) -> Self where V : std :: convert :: TryInto < types :: EmailSecurityBatchSendingDomainRestrictionsBody > , < V as std :: convert :: TryInto < types :: EmailSecurityBatchSendingDomainRestrictionsBody >> :: Error : std :: fmt :: Display ,{
self . body = value . try_into () . map (From :: from) . map_err (| s | format ! ("conversion to `EmailSecurityBatchSendingDomainRestrictionsBody` for body failed: {}" , s)) ;
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::EmailSecurityBatchSendingDomainRestrictionsBody,
)
-> types::builder::EmailSecurityBatchSendingDomainRestrictionsBody,
{
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::EmailSecurityBatchSendingDomainRestrictionsBody::try_from(v)
.map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/email-security/settings/sending_domain_restrictions/batch",
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: "email_security_batch_sending_domain_restrictions",
};
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 EmailSecurityListTrustedDomains<'a> {
client: &'a crate::Client,
account_id: Result<types::EmailSecurityAccountId, String>,
direction: Result<types::EmailSecuritySortingDirection, String>,
is_recent: Result<bool, String>,
is_similarity: Result<bool, String>,
order: Result<types::EmailSecurityListTrustedDomainsOrder, String>,
page: Result<::std::num::NonZeroU32, String>,
pattern: Result<::std::string::String, String>,
per_page: Result<::std::num::NonZeroU32, String>,
search: Result<::std::string::String, String>,
}
impl<'a> EmailSecurityListTrustedDomains<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
direction: Err("direction was not initialized".to_string()),
is_recent: Err("is_recent was not initialized".to_string()),
is_similarity: Err("is_similarity was not initialized".to_string()),
order: Err("order was not initialized".to_string()),
page: Err("page was not initialized".to_string()),
pattern: Err("pattern was not initialized".to_string()),
per_page: Err("per_page was not initialized".to_string()),
search: Err("search was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityAccountId>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `EmailSecurityAccountId` for account_id failed".to_string()
});
self
}
pub fn direction<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecuritySortingDirection>,
{
self.direction = value.try_into().map_err(|_| {
"conversion to `EmailSecuritySortingDirection` for direction failed".to_string()
});
self
}
pub fn is_recent<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<bool>,
{
self.is_recent = value
.try_into()
.map_err(|_| "conversion to `bool` for is_recent failed".to_string());
self
}
pub fn is_similarity<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<bool>,
{
self.is_similarity = value
.try_into()
.map_err(|_| "conversion to `bool` for is_similarity failed".to_string());
self
}
pub fn order<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityListTrustedDomainsOrder>,
{
self.order = value.try_into().map_err(|_| {
"conversion to `EmailSecurityListTrustedDomainsOrder` for order failed".to_string()
});
self
}
pub fn page<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::num::NonZeroU32>,
{
self.page = value.try_into().map_err(|_| {
"conversion to `:: std :: num :: NonZeroU32` for page failed".to_string()
});
self
}
pub fn pattern<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.pattern = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for pattern failed".to_string()
});
self
}
pub fn per_page<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::num::NonZeroU32>,
{
self.per_page = value.try_into().map_err(|_| {
"conversion to `:: std :: num :: NonZeroU32` for per_page failed".to_string()
});
self
}
pub fn search<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.search = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for search 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,
direction,
is_recent,
is_similarity,
order,
page,
pattern,
per_page,
search,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let direction = direction.map_err(Error::InvalidRequest)?;
let is_recent = is_recent.map_err(Error::InvalidRequest)?;
let is_similarity = is_similarity.map_err(Error::InvalidRequest)?;
let order = order.map_err(Error::InvalidRequest)?;
let page = page.map_err(Error::InvalidRequest)?;
let pattern = pattern.map_err(Error::InvalidRequest)?;
let per_page = per_page.map_err(Error::InvalidRequest)?;
let search = search.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/email-security/settings/trusted_domains",
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("direction", &direction))
.query(&progenitor_client::QueryParam::new("is_recent", &is_recent))
.query(&progenitor_client::QueryParam::new(
"is_similarity",
&is_similarity,
))
.query(&progenitor_client::QueryParam::new("order", &order))
.query(&progenitor_client::QueryParam::new("page", &page))
.query(&progenitor_client::QueryParam::new("pattern", &pattern))
.query(&progenitor_client::QueryParam::new("per_page", &per_page))
.query(&progenitor_client::QueryParam::new("search", &search))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "email_security_list_trusted_domains",
};
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 EmailSecurityCreateTrustedDomain<'a> {
client: &'a crate::Client,
account_id: Result<types::EmailSecurityAccountId, String>,
body: Result<types::EmailSecurityCreateTrustedDomainBody, String>,
}
impl<'a> EmailSecurityCreateTrustedDomain<'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::EmailSecurityAccountId>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `EmailSecurityAccountId` for account_id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityCreateTrustedDomainBody>,
{
self.body = value.try_into().map_err(|_| {
"conversion to `EmailSecurityCreateTrustedDomainBody` 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/{}/email-security/settings/trusted_domains",
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: "email_security_create_trusted_domain",
};
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 EmailSecurityGetTrustedDomain<'a> {
client: &'a crate::Client,
account_id: Result<types::EmailSecurityAccountId, String>,
trusted_domain_id: Result<types::EmailSecurityTrustedDomainId, String>,
}
impl<'a> EmailSecurityGetTrustedDomain<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
trusted_domain_id: Err("trusted_domain_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityAccountId>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `EmailSecurityAccountId` for account_id failed".to_string()
});
self
}
pub fn trusted_domain_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityTrustedDomainId>,
{
self.trusted_domain_id = value.try_into().map_err(|_| {
"conversion to `EmailSecurityTrustedDomainId` for trusted_domain_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,
trusted_domain_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let trusted_domain_id = trusted_domain_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/email-security/settings/trusted_domains/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&trusted_domain_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: "email_security_get_trusted_domain",
};
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 EmailSecurityDeleteTrustedDomain<'a> {
client: &'a crate::Client,
account_id: Result<types::EmailSecurityAccountId, String>,
trusted_domain_id: Result<types::EmailSecurityTrustedDomainId, String>,
}
impl<'a> EmailSecurityDeleteTrustedDomain<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
trusted_domain_id: Err("trusted_domain_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityAccountId>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `EmailSecurityAccountId` for account_id failed".to_string()
});
self
}
pub fn trusted_domain_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityTrustedDomainId>,
{
self.trusted_domain_id = value.try_into().map_err(|_| {
"conversion to `EmailSecurityTrustedDomainId` for trusted_domain_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,
trusted_domain_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let trusted_domain_id = trusted_domain_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/email-security/settings/trusted_domains/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&trusted_domain_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: "email_security_delete_trusted_domain",
};
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 EmailSecurityUpdateTrustedDomain<'a> {
client: &'a crate::Client,
account_id: Result<types::EmailSecurityAccountId, String>,
trusted_domain_id: Result<types::EmailSecurityTrustedDomainId, String>,
body: Result<types::builder::EmailSecurityUpdateTrustedDomainBody, String>,
}
impl<'a> EmailSecurityUpdateTrustedDomain<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
trusted_domain_id: Err("trusted_domain_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::EmailSecurityAccountId>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `EmailSecurityAccountId` for account_id failed".to_string()
});
self
}
pub fn trusted_domain_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityTrustedDomainId>,
{
self.trusted_domain_id = value.try_into().map_err(|_| {
"conversion to `EmailSecurityTrustedDomainId` for trusted_domain_id failed"
.to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityUpdateTrustedDomainBody>,
<V as std::convert::TryInto<types::EmailSecurityUpdateTrustedDomainBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `EmailSecurityUpdateTrustedDomainBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::EmailSecurityUpdateTrustedDomainBody,
)
-> types::builder::EmailSecurityUpdateTrustedDomainBody,
{
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,
trusted_domain_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let trusted_domain_id = trusted_domain_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::EmailSecurityUpdateTrustedDomainBody::try_from(v)
.map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/email-security/settings/trusted_domains/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&trusted_domain_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
.patch(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "email_security_update_trusted_domain",
};
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 EmailSecurityBatchTrustedDomains<'a> {
client: &'a crate::Client,
account_id: Result<types::EmailSecurityAccountId, String>,
body: Result<types::builder::EmailSecurityBatchTrustedDomainsBody, String>,
}
impl<'a> EmailSecurityBatchTrustedDomains<'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::EmailSecurityAccountId>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `EmailSecurityAccountId` for account_id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityBatchTrustedDomainsBody>,
<V as std::convert::TryInto<types::EmailSecurityBatchTrustedDomainsBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `EmailSecurityBatchTrustedDomainsBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::EmailSecurityBatchTrustedDomainsBody,
)
-> types::builder::EmailSecurityBatchTrustedDomainsBody,
{
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::EmailSecurityBatchTrustedDomainsBody::try_from(v)
.map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/email-security/settings/trusted_domains/batch",
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: "email_security_batch_trusted_domains",
};
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 EmailSecuritySubmissions<'a> {
client: &'a crate::Client,
account_id: Result<types::EmailSecurityAccountId, String>,
end: Result<::chrono::DateTime<::chrono::offset::Utc>, String>,
original_disposition: Result<types::EmailSecuritySubmissionsOriginalDisposition, String>,
outcome_disposition: Result<types::EmailSecuritySubmissionsOutcomeDisposition, String>,
page: Result<::std::num::NonZeroU32, String>,
per_page: Result<::std::num::NonZeroU32, String>,
query: Result<Option<::std::string::String>, String>,
requested_disposition: Result<types::EmailSecuritySubmissionsRequestedDisposition, String>,
start: Result<::chrono::DateTime<::chrono::offset::Utc>, String>,
status: Result<::std::string::String, String>,
submission_id: Result<::std::string::String, String>,
kind: Result<types::EmailSecuritySubmissionsType, String>,
}
impl<'a> EmailSecuritySubmissions<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
end: Err("end was not initialized".to_string()),
original_disposition: Err("original_disposition was not initialized".to_string()),
outcome_disposition: Err("outcome_disposition was not initialized".to_string()),
page: Err("page was not initialized".to_string()),
per_page: Err("per_page was not initialized".to_string()),
query: Ok(None),
requested_disposition: Err("requested_disposition was not initialized".to_string()),
start: Err("start was not initialized".to_string()),
status: Err("status was not initialized".to_string()),
submission_id: Err("submission_id was not initialized".to_string()),
kind: Err("kind was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecurityAccountId>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `EmailSecurityAccountId` for account_id failed".to_string()
});
self
}
pub fn end<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>,
{
self . end = value . try_into () . map_err (| _ | "conversion to `:: chrono :: DateTime < :: chrono :: offset :: Utc >` for end failed" . to_string ()) ;
self
}
pub fn original_disposition<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecuritySubmissionsOriginalDisposition>,
{
self . original_disposition = value . try_into () . map_err (| _ | "conversion to `EmailSecuritySubmissionsOriginalDisposition` for original_disposition failed" . to_string ()) ;
self
}
pub fn outcome_disposition<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecuritySubmissionsOutcomeDisposition>,
{
self . outcome_disposition = value . try_into () . map_err (| _ | "conversion to `EmailSecuritySubmissionsOutcomeDisposition` for outcome_disposition failed" . to_string ()) ;
self
}
pub fn page<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::num::NonZeroU32>,
{
self.page = value.try_into().map_err(|_| {
"conversion to `:: std :: num :: NonZeroU32` for page failed".to_string()
});
self
}
pub fn per_page<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::num::NonZeroU32>,
{
self.per_page = value.try_into().map_err(|_| {
"conversion to `:: std :: num :: NonZeroU32` for per_page failed".to_string()
});
self
}
pub fn query<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.query = value.try_into().map(Some).map_err(|_| {
"conversion to `:: std :: string :: String` for query failed".to_string()
});
self
}
pub fn requested_disposition<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecuritySubmissionsRequestedDisposition>,
{
self . requested_disposition = value . try_into () . map_err (| _ | "conversion to `EmailSecuritySubmissionsRequestedDisposition` for requested_disposition failed" . to_string ()) ;
self
}
pub fn start<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>,
{
self . start = value . try_into () . map_err (| _ | "conversion to `:: chrono :: DateTime < :: chrono :: offset :: Utc >` for start failed" . to_string ()) ;
self
}
pub fn status<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.status = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for status failed".to_string()
});
self
}
pub fn submission_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.submission_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for submission_id failed".to_string()
});
self
}
pub fn kind<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailSecuritySubmissionsType>,
{
self.kind = value.try_into().map_err(|_| {
"conversion to `EmailSecuritySubmissionsType` for kind 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,
end,
original_disposition,
outcome_disposition,
page,
per_page,
query,
requested_disposition,
start,
status,
submission_id,
kind,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let end = end.map_err(Error::InvalidRequest)?;
let original_disposition = original_disposition.map_err(Error::InvalidRequest)?;
let outcome_disposition = outcome_disposition.map_err(Error::InvalidRequest)?;
let page = page.map_err(Error::InvalidRequest)?;
let per_page = per_page.map_err(Error::InvalidRequest)?;
let query = query.map_err(Error::InvalidRequest)?;
let requested_disposition = requested_disposition.map_err(Error::InvalidRequest)?;
let start = start.map_err(Error::InvalidRequest)?;
let status = status.map_err(Error::InvalidRequest)?;
let submission_id = submission_id.map_err(Error::InvalidRequest)?;
let kind = kind.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/email-security/submissions",
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("end", &end))
.query(&progenitor_client::QueryParam::new(
"original_disposition",
&original_disposition,
))
.query(&progenitor_client::QueryParam::new(
"outcome_disposition",
&outcome_disposition,
))
.query(&progenitor_client::QueryParam::new("page", &page))
.query(&progenitor_client::QueryParam::new("per_page", &per_page))
.query(&progenitor_client::QueryParam::new("query", &query))
.query(&progenitor_client::QueryParam::new(
"requested_disposition",
&requested_disposition,
))
.query(&progenitor_client::QueryParam::new("start", &start))
.query(&progenitor_client::QueryParam::new("status", &status))
.query(&progenitor_client::QueryParam::new(
"submission_id",
&submission_id,
))
.query(&progenitor_client::QueryParam::new("type", &kind))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "email_security_submissions",
};
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 EmailRoutingRoutingRulesGetRoutingRule<'a> {
client: &'a crate::Client,
zone_id: Result<types::EmailIdentifier, String>,
rule_identifier: Result<types::EmailRuleIdentifier, String>,
}
impl<'a> EmailRoutingRoutingRulesGetRoutingRule<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
rule_identifier: Err("rule_identifier was not initialized".to_string()),
}
}
pub fn zone_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailIdentifier>,
{
self.zone_id = value
.try_into()
.map_err(|_| "conversion to `EmailIdentifier` for zone_id failed".to_string());
self
}
pub fn rule_identifier<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailRuleIdentifier>,
{
self.rule_identifier = value.try_into().map_err(|_| {
"conversion to `EmailRuleIdentifier` for rule_identifier failed".to_string()
});
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
zone_id,
rule_identifier,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let rule_identifier = rule_identifier.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/email/routing/rules/{}",
client.baseurl,
encode_path(&zone_id.to_string()),
encode_path(&rule_identifier.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: "email_routing_routing_rules_get_routing_rule",
};
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 EmailRoutingRoutingRulesUpdateRoutingRule<'a> {
client: &'a crate::Client,
zone_id: Result<types::EmailIdentifier, String>,
rule_identifier: Result<types::EmailRuleIdentifier, String>,
body: Result<types::builder::EmailUpdateRuleProperties, String>,
}
impl<'a> EmailRoutingRoutingRulesUpdateRoutingRule<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
rule_identifier: Err("rule_identifier was not initialized".to_string()),
body: Ok(::std::default::Default::default()),
}
}
pub fn zone_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailIdentifier>,
{
self.zone_id = value
.try_into()
.map_err(|_| "conversion to `EmailIdentifier` for zone_id failed".to_string());
self
}
pub fn rule_identifier<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailRuleIdentifier>,
{
self.rule_identifier = value.try_into().map_err(|_| {
"conversion to `EmailRuleIdentifier` for rule_identifier failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailUpdateRuleProperties>,
<V as std::convert::TryInto<types::EmailUpdateRuleProperties>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `EmailUpdateRuleProperties` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::EmailUpdateRuleProperties,
) -> types::builder::EmailUpdateRuleProperties,
{
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,
zone_id,
rule_identifier,
body,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let rule_identifier = rule_identifier.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::EmailUpdateRuleProperties::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/email/routing/rules/{}",
client.baseurl,
encode_path(&zone_id.to_string()),
encode_path(&rule_identifier.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: "email_routing_routing_rules_update_routing_rule",
};
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 EmailRoutingRoutingRulesDeleteRoutingRule<'a> {
client: &'a crate::Client,
zone_id: Result<types::EmailIdentifier, String>,
rule_identifier: Result<types::EmailRuleIdentifier, String>,
}
impl<'a> EmailRoutingRoutingRulesDeleteRoutingRule<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
rule_identifier: Err("rule_identifier was not initialized".to_string()),
}
}
pub fn zone_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailIdentifier>,
{
self.zone_id = value
.try_into()
.map_err(|_| "conversion to `EmailIdentifier` for zone_id failed".to_string());
self
}
pub fn rule_identifier<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailRuleIdentifier>,
{
self.rule_identifier = value.try_into().map_err(|_| {
"conversion to `EmailRuleIdentifier` for rule_identifier failed".to_string()
});
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
zone_id,
rule_identifier,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let rule_identifier = rule_identifier.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/email/routing/rules/{}",
client.baseurl,
encode_path(&zone_id.to_string()),
encode_path(&rule_identifier.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: "email_routing_routing_rules_delete_routing_rule",
};
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 EmailRoutingRoutingRulesGetCatchAllRule<'a> {
client: &'a crate::Client,
zone_id: Result<types::EmailIdentifier, String>,
}
impl<'a> EmailRoutingRoutingRulesGetCatchAllRule<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
}
}
pub fn zone_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::EmailIdentifier>,
{
self.zone_id = value
.try_into()
.map_err(|_| "conversion to `EmailIdentifier` for zone_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, zone_id } = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/email/routing/rules/catch_all",
client.baseurl,
encode_path(&zone_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: "email_routing_routing_rules_get_catch_all_rule",
};
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)),
}
}
}