use super::types;
use crate::{
ByteStream, ClientHooks, ClientInfo, Error, OperationInfo, RequestBuilderExt,
ResponseValue, encode_path,
};
#[derive(Debug, Clone)]
pub struct WafContentScanningDisable<'a> {
client: &'a crate::Client,
zone_id: Result<types::WafProductApiBundleIdentifier, String>,
}
impl<'a> WafContentScanningDisable<'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::WafProductApiBundleIdentifier>,
{
self.zone_id = value.try_into().map_err(|_| {
"conversion to `WafProductApiBundleIdentifier` 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/{}/content-upload-scan/disable",
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
.post(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "waf_content_scanning_disable",
};
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 WafContentScanningEnable<'a> {
client: &'a crate::Client,
zone_id: Result<types::WafProductApiBundleIdentifier, String>,
}
impl<'a> WafContentScanningEnable<'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::WafProductApiBundleIdentifier>,
{
self.zone_id = value.try_into().map_err(|_| {
"conversion to `WafProductApiBundleIdentifier` 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/{}/content-upload-scan/enable",
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
.post(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "waf_content_scanning_enable",
};
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 WafContentScanningAddCustomScanExpressions<'a> {
client: &'a crate::Client,
zone_id: Result<types::WafProductApiBundleIdentifier, String>,
body: Result<::serde_json::Map<::std::string::String, ::serde_json::Value>, String>,
}
impl<'a> WafContentScanningAddCustomScanExpressions<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
body: Err("body was not initialized".to_string()),
}
}
pub fn zone_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WafProductApiBundleIdentifier>,
{
self.zone_id = value.try_into().map_err(|_| {
"conversion to `WafProductApiBundleIdentifier` for zone_id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
{
self . body = value . try_into () . map_err (| _ | "conversion to `:: serde_json :: Map < :: std :: string :: String , :: serde_json :: Value >` 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,
zone_id,
body,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/content-upload-scan/payloads",
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
.post(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "waf_content_scanning_add_custom_scan_expressions",
};
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 WafContentScanningGetStatus<'a> {
client: &'a crate::Client,
zone_id: Result<types::WafProductApiBundleIdentifier, String>,
}
impl<'a> WafContentScanningGetStatus<'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::WafProductApiBundleIdentifier>,
{
self.zone_id = value.try_into().map_err(|_| {
"conversion to `WafProductApiBundleIdentifier` 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/{}/content-upload-scan/settings",
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: "waf_content_scanning_get_status",
};
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 WafContentScanningUpdateSettings<'a> {
client: &'a crate::Client,
zone_id: Result<types::WafProductApiBundleIdentifier, String>,
body: Result<::serde_json::Map<::std::string::String, ::serde_json::Value>, String>,
}
impl<'a> WafContentScanningUpdateSettings<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
body: Err("body was not initialized".to_string()),
}
}
pub fn zone_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WafProductApiBundleIdentifier>,
{
self.zone_id = value.try_into().map_err(|_| {
"conversion to `WafProductApiBundleIdentifier` for zone_id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
{
self . body = value . try_into () . map_err (| _ | "conversion to `:: serde_json :: Map < :: std :: string :: String , :: serde_json :: Value >` 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,
zone_id,
body,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/content-upload-scan/settings",
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
.put(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "waf_content_scanning_update_settings",
};
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 WafOverridesGetAWafOverride<'a> {
client: &'a crate::Client,
zone_id: Result<types::FirewallIdentifier, String>,
overrides_id: Result<types::FirewallOverridesId, String>,
}
impl<'a> WafOverridesGetAWafOverride<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
overrides_id: Err("overrides_id was not initialized".to_string()),
}
}
pub fn zone_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::FirewallIdentifier>,
{
self.zone_id = value
.try_into()
.map_err(|_| "conversion to `FirewallIdentifier` for zone_id failed".to_string());
self
}
pub fn overrides_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::FirewallOverridesId>,
{
self.overrides_id = value.try_into().map_err(|_| {
"conversion to `FirewallOverridesId` for overrides_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,
overrides_id,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let overrides_id = overrides_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/firewall/waf/overrides/{}",
client.baseurl,
encode_path(&zone_id.to_string()),
encode_path(&overrides_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: "waf_overrides_get_a_waf_override",
};
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 WafOverridesUpdateWafOverride<'a> {
client: &'a crate::Client,
zone_id: Result<types::FirewallIdentifier, String>,
overrides_id: Result<types::FirewallOverridesId, String>,
body: Result<types::builder::WafOverridesUpdateWafOverrideBody, String>,
}
impl<'a> WafOverridesUpdateWafOverride<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
overrides_id: Err("overrides_id 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::FirewallIdentifier>,
{
self.zone_id = value
.try_into()
.map_err(|_| "conversion to `FirewallIdentifier` for zone_id failed".to_string());
self
}
pub fn overrides_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::FirewallOverridesId>,
{
self.overrides_id = value.try_into().map_err(|_| {
"conversion to `FirewallOverridesId` for overrides_id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WafOverridesUpdateWafOverrideBody>,
<V as std::convert::TryInto<types::WafOverridesUpdateWafOverrideBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `WafOverridesUpdateWafOverrideBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::WafOverridesUpdateWafOverrideBody,
) -> types::builder::WafOverridesUpdateWafOverrideBody,
{
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,
overrides_id,
body,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let overrides_id = overrides_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::WafOverridesUpdateWafOverrideBody::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/firewall/waf/overrides/{}",
client.baseurl,
encode_path(&zone_id.to_string()),
encode_path(&overrides_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.put(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "waf_overrides_update_waf_override",
};
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 WafOverridesDeleteAWafOverride<'a> {
client: &'a crate::Client,
zone_id: Result<types::FirewallIdentifier, String>,
overrides_id: Result<types::FirewallOverridesId, String>,
body: Result<::serde_json::Map<::std::string::String, ::serde_json::Value>, String>,
}
impl<'a> WafOverridesDeleteAWafOverride<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
overrides_id: Err("overrides_id was not initialized".to_string()),
body: Err("body was not initialized".to_string()),
}
}
pub fn zone_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::FirewallIdentifier>,
{
self.zone_id = value
.try_into()
.map_err(|_| "conversion to `FirewallIdentifier` for zone_id failed".to_string());
self
}
pub fn overrides_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::FirewallOverridesId>,
{
self.overrides_id = value.try_into().map_err(|_| {
"conversion to `FirewallOverridesId` for overrides_id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
{
self . body = value . try_into () . map_err (| _ | "conversion to `:: serde_json :: Map < :: std :: string :: String , :: serde_json :: Value >` 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,
zone_id,
overrides_id,
body,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let overrides_id = overrides_id.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/firewall/waf/overrides/{}",
client.baseurl,
encode_path(&zone_id.to_string()),
encode_path(&overrides_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: "waf_overrides_delete_a_waf_override",
};
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 WafPackagesGetAWafPackage<'a> {
client: &'a crate::Client,
zone_id: Result<types::FirewallIdentifier, String>,
package_id: Result<types::FirewallPackageId, String>,
}
impl<'a> WafPackagesGetAWafPackage<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
package_id: Err("package_id was not initialized".to_string()),
}
}
pub fn zone_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::FirewallIdentifier>,
{
self.zone_id = value
.try_into()
.map_err(|_| "conversion to `FirewallIdentifier` for zone_id failed".to_string());
self
}
pub fn package_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::FirewallPackageId>,
{
self.package_id = value
.try_into()
.map_err(|_| "conversion to `FirewallPackageId` for package_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,
package_id,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let package_id = package_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/firewall/waf/packages/{}",
client.baseurl,
encode_path(&zone_id.to_string()),
encode_path(&package_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: "waf_packages_get_a_waf_package",
};
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 WafPackagesUpdateAWafPackage<'a> {
client: &'a crate::Client,
zone_id: Result<types::FirewallIdentifier, String>,
package_id: Result<types::FirewallPackageId, String>,
body: Result<types::builder::WafPackagesUpdateAWafPackageBody, String>,
}
impl<'a> WafPackagesUpdateAWafPackage<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
package_id: Err("package_id 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::FirewallIdentifier>,
{
self.zone_id = value
.try_into()
.map_err(|_| "conversion to `FirewallIdentifier` for zone_id failed".to_string());
self
}
pub fn package_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::FirewallPackageId>,
{
self.package_id = value
.try_into()
.map_err(|_| "conversion to `FirewallPackageId` for package_id failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WafPackagesUpdateAWafPackageBody>,
<V as std::convert::TryInto<types::WafPackagesUpdateAWafPackageBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `WafPackagesUpdateAWafPackageBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::WafPackagesUpdateAWafPackageBody,
) -> types::builder::WafPackagesUpdateAWafPackageBody,
{
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,
package_id,
body,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let package_id = package_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::WafPackagesUpdateAWafPackageBody::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/firewall/waf/packages/{}",
client.baseurl,
encode_path(&zone_id.to_string()),
encode_path(&package_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: "waf_packages_update_a_waf_package",
};
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 WafRuleGroupsListWafRuleGroups<'a> {
client: &'a crate::Client,
zone_id: Result<types::WafManagedRulesSchemasIdentifier, String>,
package_id: Result<types::WafManagedRulesIdentifier, String>,
direction: Result<types::WafRuleGroupsListWafRuleGroupsDirection, String>,
pattern: Result<types::WafRuleGroupsListWafRuleGroupsMatch, String>,
mode: Result<types::WafManagedRulesMode, String>,
name: Result<::std::string::String, String>,
order: Result<types::WafRuleGroupsListWafRuleGroupsOrder, String>,
page: Result<f64, String>,
per_page: Result<f64, String>,
rules_count: Result<f64, String>,
}
impl<'a> WafRuleGroupsListWafRuleGroups<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
package_id: Err("package_id was not initialized".to_string()),
direction: Err("direction was not initialized".to_string()),
pattern: Err("pattern was not initialized".to_string()),
mode: Err("mode was not initialized".to_string()),
name: Err("name 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()),
rules_count: Err("rules_count was not initialized".to_string()),
}
}
pub fn zone_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WafManagedRulesSchemasIdentifier>,
{
self.zone_id = value.try_into().map_err(|_| {
"conversion to `WafManagedRulesSchemasIdentifier` for zone_id failed".to_string()
});
self
}
pub fn package_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WafManagedRulesIdentifier>,
{
self.package_id = value.try_into().map_err(|_| {
"conversion to `WafManagedRulesIdentifier` for package_id failed".to_string()
});
self
}
pub fn direction<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WafRuleGroupsListWafRuleGroupsDirection>,
{
self.direction = value.try_into().map_err(|_| {
"conversion to `WafRuleGroupsListWafRuleGroupsDirection` for direction failed"
.to_string()
});
self
}
pub fn pattern<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WafRuleGroupsListWafRuleGroupsMatch>,
{
self.pattern = value.try_into().map_err(|_| {
"conversion to `WafRuleGroupsListWafRuleGroupsMatch` for pattern failed".to_string()
});
self
}
pub fn mode<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WafManagedRulesMode>,
{
self.mode = value
.try_into()
.map_err(|_| "conversion to `WafManagedRulesMode` for mode failed".to_string());
self
}
pub fn name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.name = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for name failed".to_string()
});
self
}
pub fn order<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WafRuleGroupsListWafRuleGroupsOrder>,
{
self.order = value.try_into().map_err(|_| {
"conversion to `WafRuleGroupsListWafRuleGroupsOrder` for order failed".to_string()
});
self
}
pub fn page<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<f64>,
{
self.page = value
.try_into()
.map_err(|_| "conversion to `f64` for page failed".to_string());
self
}
pub fn per_page<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<f64>,
{
self.per_page = value
.try_into()
.map_err(|_| "conversion to `f64` for per_page failed".to_string());
self
}
pub fn rules_count<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<f64>,
{
self.rules_count = value
.try_into()
.map_err(|_| "conversion to `f64` for rules_count 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,
package_id,
direction,
pattern,
mode,
name,
order,
page,
per_page,
rules_count,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let package_id = package_id.map_err(Error::InvalidRequest)?;
let direction = direction.map_err(Error::InvalidRequest)?;
let pattern = pattern.map_err(Error::InvalidRequest)?;
let mode = mode.map_err(Error::InvalidRequest)?;
let name = name.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 rules_count = rules_count.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/firewall/waf/packages/{}/groups",
client.baseurl,
encode_path(&zone_id.to_string()),
encode_path(&package_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("match", &pattern))
.query(&progenitor_client::QueryParam::new("mode", &mode))
.query(&progenitor_client::QueryParam::new("name", &name))
.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(
"rules_count",
&rules_count,
))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "waf_rule_groups_list_waf_rule_groups",
};
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 WafRuleGroupsGetAWafRuleGroup<'a> {
client: &'a crate::Client,
zone_id: Result<types::WafManagedRulesSchemasIdentifier, String>,
package_id: Result<types::WafManagedRulesIdentifier, String>,
group_id: Result<types::WafManagedRulesIdentifier, String>,
}
impl<'a> WafRuleGroupsGetAWafRuleGroup<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
package_id: Err("package_id was not initialized".to_string()),
group_id: Err("group_id was not initialized".to_string()),
}
}
pub fn zone_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WafManagedRulesSchemasIdentifier>,
{
self.zone_id = value.try_into().map_err(|_| {
"conversion to `WafManagedRulesSchemasIdentifier` for zone_id failed".to_string()
});
self
}
pub fn package_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WafManagedRulesIdentifier>,
{
self.package_id = value.try_into().map_err(|_| {
"conversion to `WafManagedRulesIdentifier` for package_id failed".to_string()
});
self
}
pub fn group_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WafManagedRulesIdentifier>,
{
self.group_id = value.try_into().map_err(|_| {
"conversion to `WafManagedRulesIdentifier` for group_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,
package_id,
group_id,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let package_id = package_id.map_err(Error::InvalidRequest)?;
let group_id = group_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/firewall/waf/packages/{}/groups/{}",
client.baseurl,
encode_path(&zone_id.to_string()),
encode_path(&package_id.to_string()),
encode_path(&group_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: "waf_rule_groups_get_a_waf_rule_group",
};
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 WafRuleGroupsUpdateAWafRuleGroup<'a> {
client: &'a crate::Client,
zone_id: Result<types::WafManagedRulesSchemasIdentifier, String>,
package_id: Result<types::WafManagedRulesIdentifier, String>,
group_id: Result<types::WafManagedRulesIdentifier, String>,
body: Result<types::builder::WafRuleGroupsUpdateAWafRuleGroupBody, String>,
}
impl<'a> WafRuleGroupsUpdateAWafRuleGroup<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
package_id: Err("package_id was not initialized".to_string()),
group_id: Err("group_id 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::WafManagedRulesSchemasIdentifier>,
{
self.zone_id = value.try_into().map_err(|_| {
"conversion to `WafManagedRulesSchemasIdentifier` for zone_id failed".to_string()
});
self
}
pub fn package_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WafManagedRulesIdentifier>,
{
self.package_id = value.try_into().map_err(|_| {
"conversion to `WafManagedRulesIdentifier` for package_id failed".to_string()
});
self
}
pub fn group_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WafManagedRulesIdentifier>,
{
self.group_id = value.try_into().map_err(|_| {
"conversion to `WafManagedRulesIdentifier` for group_id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WafRuleGroupsUpdateAWafRuleGroupBody>,
<V as std::convert::TryInto<types::WafRuleGroupsUpdateAWafRuleGroupBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `WafRuleGroupsUpdateAWafRuleGroupBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::WafRuleGroupsUpdateAWafRuleGroupBody,
)
-> types::builder::WafRuleGroupsUpdateAWafRuleGroupBody,
{
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,
package_id,
group_id,
body,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let package_id = package_id.map_err(Error::InvalidRequest)?;
let group_id = group_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::WafRuleGroupsUpdateAWafRuleGroupBody::try_from(v)
.map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/firewall/waf/packages/{}/groups/{}",
client.baseurl,
encode_path(&zone_id.to_string()),
encode_path(&package_id.to_string()),
encode_path(&group_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: "waf_rule_groups_update_a_waf_rule_group",
};
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 WafRulesListWafRules<'a> {
client: &'a crate::Client,
zone_id: Result<types::WafManagedRulesSchemasIdentifier, String>,
package_id: Result<types::WafManagedRulesIdentifier, String>,
description: Result<::std::string::String, String>,
direction: Result<types::WafRulesListWafRulesDirection, String>,
group_id: Result<types::WafManagedRulesComponentsSchemasIdentifier, String>,
pattern: Result<types::WafRulesListWafRulesMatch, String>,
mode: Result<types::WafRulesListWafRulesMode, String>,
order: Result<types::WafRulesListWafRulesOrder, String>,
page: Result<f64, String>,
per_page: Result<f64, String>,
priority: Result<::std::string::String, String>,
}
impl<'a> WafRulesListWafRules<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
package_id: Err("package_id was not initialized".to_string()),
description: Err("description was not initialized".to_string()),
direction: Err("direction was not initialized".to_string()),
group_id: Err("group_id was not initialized".to_string()),
pattern: Err("pattern was not initialized".to_string()),
mode: Err("mode 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()),
priority: Err("priority was not initialized".to_string()),
}
}
pub fn zone_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WafManagedRulesSchemasIdentifier>,
{
self.zone_id = value.try_into().map_err(|_| {
"conversion to `WafManagedRulesSchemasIdentifier` for zone_id failed".to_string()
});
self
}
pub fn package_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WafManagedRulesIdentifier>,
{
self.package_id = value.try_into().map_err(|_| {
"conversion to `WafManagedRulesIdentifier` for package_id failed".to_string()
});
self
}
pub fn description<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.description = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for description failed".to_string()
});
self
}
pub fn direction<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WafRulesListWafRulesDirection>,
{
self.direction = value.try_into().map_err(|_| {
"conversion to `WafRulesListWafRulesDirection` for direction failed".to_string()
});
self
}
pub fn group_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WafManagedRulesComponentsSchemasIdentifier>,
{
self.group_id = value.try_into().map_err(|_| {
"conversion to `WafManagedRulesComponentsSchemasIdentifier` for group_id failed"
.to_string()
});
self
}
pub fn pattern<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WafRulesListWafRulesMatch>,
{
self.pattern = value.try_into().map_err(|_| {
"conversion to `WafRulesListWafRulesMatch` for pattern failed".to_string()
});
self
}
pub fn mode<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WafRulesListWafRulesMode>,
{
self.mode = value.try_into().map_err(|_| {
"conversion to `WafRulesListWafRulesMode` for mode failed".to_string()
});
self
}
pub fn order<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WafRulesListWafRulesOrder>,
{
self.order = value.try_into().map_err(|_| {
"conversion to `WafRulesListWafRulesOrder` for order failed".to_string()
});
self
}
pub fn page<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<f64>,
{
self.page = value
.try_into()
.map_err(|_| "conversion to `f64` for page failed".to_string());
self
}
pub fn per_page<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<f64>,
{
self.per_page = value
.try_into()
.map_err(|_| "conversion to `f64` for per_page failed".to_string());
self
}
pub fn priority<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.priority = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for priority 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,
package_id,
description,
direction,
group_id,
pattern,
mode,
order,
page,
per_page,
priority,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let package_id = package_id.map_err(Error::InvalidRequest)?;
let description = description.map_err(Error::InvalidRequest)?;
let direction = direction.map_err(Error::InvalidRequest)?;
let group_id = group_id.map_err(Error::InvalidRequest)?;
let pattern = pattern.map_err(Error::InvalidRequest)?;
let mode = mode.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 priority = priority.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/firewall/waf/packages/{}/rules",
client.baseurl,
encode_path(&zone_id.to_string()),
encode_path(&package_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(
"description",
&description,
))
.query(&progenitor_client::QueryParam::new("direction", &direction))
.query(&progenitor_client::QueryParam::new("group_id", &group_id))
.query(&progenitor_client::QueryParam::new("match", &pattern))
.query(&progenitor_client::QueryParam::new("mode", &mode))
.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("priority", &priority))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "waf_rules_list_waf_rules",
};
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 WafRulesGetAWafRule<'a> {
client: &'a crate::Client,
zone_id: Result<types::WafManagedRulesSchemasIdentifier, String>,
package_id: Result<types::WafManagedRulesIdentifier, String>,
rule_id: Result<types::WafManagedRulesIdentifier, String>,
}
impl<'a> WafRulesGetAWafRule<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
package_id: Err("package_id was not initialized".to_string()),
rule_id: Err("rule_id was not initialized".to_string()),
}
}
pub fn zone_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WafManagedRulesSchemasIdentifier>,
{
self.zone_id = value.try_into().map_err(|_| {
"conversion to `WafManagedRulesSchemasIdentifier` for zone_id failed".to_string()
});
self
}
pub fn package_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WafManagedRulesIdentifier>,
{
self.package_id = value.try_into().map_err(|_| {
"conversion to `WafManagedRulesIdentifier` for package_id failed".to_string()
});
self
}
pub fn rule_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WafManagedRulesIdentifier>,
{
self.rule_id = value.try_into().map_err(|_| {
"conversion to `WafManagedRulesIdentifier` for rule_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,
package_id,
rule_id,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let package_id = package_id.map_err(Error::InvalidRequest)?;
let rule_id = rule_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/firewall/waf/packages/{}/rules/{}",
client.baseurl,
encode_path(&zone_id.to_string()),
encode_path(&package_id.to_string()),
encode_path(&rule_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: "waf_rules_get_a_waf_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 WafRulesUpdateAWafRule<'a> {
client: &'a crate::Client,
zone_id: Result<types::WafManagedRulesSchemasIdentifier, String>,
package_id: Result<types::WafManagedRulesIdentifier, String>,
rule_id: Result<types::WafManagedRulesIdentifier, String>,
body: Result<types::builder::WafRulesUpdateAWafRuleBody, String>,
}
impl<'a> WafRulesUpdateAWafRule<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
package_id: Err("package_id was not initialized".to_string()),
rule_id: Err("rule_id 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::WafManagedRulesSchemasIdentifier>,
{
self.zone_id = value.try_into().map_err(|_| {
"conversion to `WafManagedRulesSchemasIdentifier` for zone_id failed".to_string()
});
self
}
pub fn package_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WafManagedRulesIdentifier>,
{
self.package_id = value.try_into().map_err(|_| {
"conversion to `WafManagedRulesIdentifier` for package_id failed".to_string()
});
self
}
pub fn rule_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WafManagedRulesIdentifier>,
{
self.rule_id = value.try_into().map_err(|_| {
"conversion to `WafManagedRulesIdentifier` for rule_id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WafRulesUpdateAWafRuleBody>,
<V as std::convert::TryInto<types::WafRulesUpdateAWafRuleBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `WafRulesUpdateAWafRuleBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::WafRulesUpdateAWafRuleBody,
) -> types::builder::WafRulesUpdateAWafRuleBody,
{
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,
package_id,
rule_id,
body,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let package_id = package_id.map_err(Error::InvalidRequest)?;
let rule_id = rule_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::WafRulesUpdateAWafRuleBody::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/firewall/waf/packages/{}/rules/{}",
client.baseurl,
encode_path(&zone_id.to_string()),
encode_path(&package_id.to_string()),
encode_path(&rule_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: "waf_rules_update_a_waf_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 WafProductApiLeakedCredentialsSetStatus<'a> {
client: &'a crate::Client,
zone_id: Result<types::WafProductApiBundleIdentifier, String>,
body: Result<types::builder::WafProductApiBundleStatus, String>,
}
impl<'a> WafProductApiLeakedCredentialsSetStatus<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id 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::WafProductApiBundleIdentifier>,
{
self.zone_id = value.try_into().map_err(|_| {
"conversion to `WafProductApiBundleIdentifier` for zone_id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WafProductApiBundleStatus>,
<V as std::convert::TryInto<types::WafProductApiBundleStatus>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `WafProductApiBundleStatus` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::WafProductApiBundleStatus,
) -> types::builder::WafProductApiBundleStatus,
{
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,
body,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::WafProductApiBundleStatus::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/leaked-credential-checks",
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
.post(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "waf_product_api_leaked_credentials_set_status",
};
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 WafProductApiLeakedCredentialsGetDetection<'a> {
client: &'a crate::Client,
zone_id: Result<types::WafProductApiBundleIdentifier, String>,
detection_id: Result<types::WafProductApiBundleDetectionId, String>,
}
impl<'a> WafProductApiLeakedCredentialsGetDetection<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
detection_id: Err("detection_id was not initialized".to_string()),
}
}
pub fn zone_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WafProductApiBundleIdentifier>,
{
self.zone_id = value.try_into().map_err(|_| {
"conversion to `WafProductApiBundleIdentifier` for zone_id failed".to_string()
});
self
}
pub fn detection_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WafProductApiBundleDetectionId>,
{
self.detection_id = value.try_into().map_err(|_| {
"conversion to `WafProductApiBundleDetectionId` for detection_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,
detection_id,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let detection_id = detection_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/leaked-credential-checks/detections/{}",
client.baseurl,
encode_path(&zone_id.to_string()),
encode_path(&detection_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: "waf_product_api_leaked_credentials_get_detection",
};
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)),
}
}
}