use super::types;
use crate::{
ByteStream, ClientHooks, ClientInfo, Error, OperationInfo, RequestBuilderExt,
ResponseValue, encode_path,
};
#[derive(Debug, Clone)]
pub struct ZoneLevelAccessPoliciesListAccessPolicies<'a> {
client: &'a crate::Client,
zone_id: Result<types::AccessIdentifier, String>,
app_id: Result<types::AccessUuid, String>,
}
impl<'a> ZoneLevelAccessPoliciesListAccessPolicies<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
app_id: Err("app_id was not initialized".to_string()),
}
}
pub fn zone_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AccessIdentifier>,
{
self.zone_id = value
.try_into()
.map_err(|_| "conversion to `AccessIdentifier` for zone_id failed".to_string());
self
}
pub fn app_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AccessUuid>,
{
self.app_id = value
.try_into()
.map_err(|_| "conversion to `AccessUuid` for app_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,
app_id,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let app_id = app_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/access/apps/{}/policies",
client.baseurl,
encode_path(&zone_id.to_string()),
encode_path(&app_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: "zone_level_access_policies_list_access_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 ZoneLevelAccessPoliciesGetAnAccessPolicy<'a> {
client: &'a crate::Client,
zone_id: Result<types::AccessIdentifier, String>,
app_id: Result<types::AccessUuid, String>,
policy_id: Result<types::AccessUuid, String>,
}
impl<'a> ZoneLevelAccessPoliciesGetAnAccessPolicy<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
app_id: Err("app_id was not initialized".to_string()),
policy_id: Err("policy_id was not initialized".to_string()),
}
}
pub fn zone_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AccessIdentifier>,
{
self.zone_id = value
.try_into()
.map_err(|_| "conversion to `AccessIdentifier` for zone_id failed".to_string());
self
}
pub fn app_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AccessUuid>,
{
self.app_id = value
.try_into()
.map_err(|_| "conversion to `AccessUuid` for app_id failed".to_string());
self
}
pub fn policy_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AccessUuid>,
{
self.policy_id = value
.try_into()
.map_err(|_| "conversion to `AccessUuid` 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,
zone_id,
app_id,
policy_id,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let app_id = app_id.map_err(Error::InvalidRequest)?;
let policy_id = policy_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/access/apps/{}/policies/{}",
client.baseurl,
encode_path(&zone_id.to_string()),
encode_path(&app_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: "zone_level_access_policies_get_an_access_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 ZoneLevelAccessGroupsDeleteAnAccessGroup<'a> {
client: &'a crate::Client,
zone_id: Result<types::AccessIdentifier, String>,
group_id: Result<types::AccessUuid, String>,
}
impl<'a> ZoneLevelAccessGroupsDeleteAnAccessGroup<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_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::AccessIdentifier>,
{
self.zone_id = value
.try_into()
.map_err(|_| "conversion to `AccessIdentifier` for zone_id failed".to_string());
self
}
pub fn group_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AccessUuid>,
{
self.group_id = value
.try_into()
.map_err(|_| "conversion to `AccessUuid` 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,
group_id,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let group_id = group_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/access/groups/{}",
client.baseurl,
encode_path(&zone_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
.delete(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "zone_level_access_groups_delete_an_access_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() {
202u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct ZoneRatePlanAvailablePlanDetails<'a> {
client: &'a crate::Client,
zone_id: Result<types::BillSubsApiIdentifier, String>,
plan_identifier: Result<types::BillSubsApiIdentifier, String>,
}
impl<'a> ZoneRatePlanAvailablePlanDetails<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
plan_identifier: Err("plan_identifier was not initialized".to_string()),
}
}
pub fn zone_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::BillSubsApiIdentifier>,
{
self.zone_id = value.try_into().map_err(|_| {
"conversion to `BillSubsApiIdentifier` for zone_id failed".to_string()
});
self
}
pub fn plan_identifier<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::BillSubsApiIdentifier>,
{
self.plan_identifier = value.try_into().map_err(|_| {
"conversion to `BillSubsApiIdentifier` for plan_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,
plan_identifier,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let plan_identifier = plan_identifier.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/available_plans/{}",
client.baseurl,
encode_path(&zone_id.to_string()),
encode_path(&plan_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: "zone_rate_plan_available_plan_details",
};
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 ZoneCacheSettingsGetCacheReserveClear<'a> {
client: &'a crate::Client,
zone_id: Result<types::CacheRulesIdentifier, String>,
}
impl<'a> ZoneCacheSettingsGetCacheReserveClear<'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::CacheRulesIdentifier>,
{
self.zone_id = value
.try_into()
.map_err(|_| "conversion to `CacheRulesIdentifier` 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/{}/cache/cache_reserve_clear",
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: "zone_cache_settings_get_cache_reserve_clear",
};
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 ZoneCacheSettingsStartCacheReserveClear<'a> {
client: &'a crate::Client,
zone_id: Result<types::CacheRulesIdentifier, String>,
body: Result<::serde_json::Map<::std::string::String, ::serde_json::Value>, String>,
}
impl<'a> ZoneCacheSettingsStartCacheReserveClear<'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::CacheRulesIdentifier>,
{
self.zone_id = value
.try_into()
.map_err(|_| "conversion to `CacheRulesIdentifier` 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/{}/cache/cache_reserve_clear",
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: "zone_cache_settings_start_cache_reserve_clear",
};
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 ZoneLockdownGetAZoneLockdownRule<'a> {
client: &'a crate::Client,
zone_id: Result<types::FirewallIdentifier, String>,
lock_downs_id: Result<types::FirewallLockdownsComponentsSchemasId, String>,
}
impl<'a> ZoneLockdownGetAZoneLockdownRule<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
lock_downs_id: Err("lock_downs_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 lock_downs_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::FirewallLockdownsComponentsSchemasId>,
{
self.lock_downs_id = value.try_into().map_err(|_| {
"conversion to `FirewallLockdownsComponentsSchemasId` for lock_downs_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,
lock_downs_id,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let lock_downs_id = lock_downs_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/firewall/lockdowns/{}",
client.baseurl,
encode_path(&zone_id.to_string()),
encode_path(&lock_downs_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: "zone_lockdown_get_a_zone_lockdown_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 ZoneLockdownUpdateAZoneLockdownRule<'a> {
client: &'a crate::Client,
zone_id: Result<types::FirewallIdentifier, String>,
lock_downs_id: Result<types::FirewallLockdownsComponentsSchemasId, String>,
body: Result<types::builder::ZoneLockdownUpdateAZoneLockdownRuleBody, String>,
}
impl<'a> ZoneLockdownUpdateAZoneLockdownRule<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
lock_downs_id: Err("lock_downs_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 lock_downs_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::FirewallLockdownsComponentsSchemasId>,
{
self.lock_downs_id = value.try_into().map_err(|_| {
"conversion to `FirewallLockdownsComponentsSchemasId` for lock_downs_id failed"
.to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ZoneLockdownUpdateAZoneLockdownRuleBody>,
<V as std::convert::TryInto<types::ZoneLockdownUpdateAZoneLockdownRuleBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `ZoneLockdownUpdateAZoneLockdownRuleBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::ZoneLockdownUpdateAZoneLockdownRuleBody,
)
-> types::builder::ZoneLockdownUpdateAZoneLockdownRuleBody,
{
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,
lock_downs_id,
body,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let lock_downs_id = lock_downs_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::ZoneLockdownUpdateAZoneLockdownRuleBody::try_from(v)
.map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/firewall/lockdowns/{}",
client.baseurl,
encode_path(&zone_id.to_string()),
encode_path(&lock_downs_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: "zone_lockdown_update_a_zone_lockdown_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 ZoneLockdownDeleteAZoneLockdownRule<'a> {
client: &'a crate::Client,
zone_id: Result<types::FirewallIdentifier, String>,
lock_downs_id: Result<types::FirewallLockdownsComponentsSchemasId, String>,
body: Result<::serde_json::Map<::std::string::String, ::serde_json::Value>, String>,
}
impl<'a> ZoneLockdownDeleteAZoneLockdownRule<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
lock_downs_id: Err("lock_downs_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 lock_downs_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::FirewallLockdownsComponentsSchemasId>,
{
self.lock_downs_id = value.try_into().map_err(|_| {
"conversion to `FirewallLockdownsComponentsSchemasId` for lock_downs_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,
lock_downs_id,
body,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let lock_downs_id = lock_downs_id.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/firewall/lockdowns/{}",
client.baseurl,
encode_path(&zone_id.to_string()),
encode_path(&lock_downs_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: "zone_lockdown_delete_a_zone_lockdown_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 ZoneAnalyticsDeprecatedGetDashboard<'a> {
client: &'a crate::Client,
zone_identifier: Result<types::ZoneAnalyticsApiIdentifier, String>,
continuous: Result<bool, String>,
since: Result<types::ZoneAnalyticsDeprecatedGetDashboardSince, String>,
until: Result<types::ZoneAnalyticsApiUntil, String>,
}
impl<'a> ZoneAnalyticsDeprecatedGetDashboard<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_identifier: Err("zone_identifier was not initialized".to_string()),
continuous: Err("continuous was not initialized".to_string()),
since: Err("since was not initialized".to_string()),
until: Err("until was not initialized".to_string()),
}
}
pub fn zone_identifier<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ZoneAnalyticsApiIdentifier>,
{
self.zone_identifier = value.try_into().map_err(|_| {
"conversion to `ZoneAnalyticsApiIdentifier` for zone_identifier failed".to_string()
});
self
}
pub fn continuous<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<bool>,
{
self.continuous = value
.try_into()
.map_err(|_| "conversion to `bool` for continuous failed".to_string());
self
}
pub fn since<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ZoneAnalyticsDeprecatedGetDashboardSince>,
{
self.since = value.try_into().map_err(|_| {
"conversion to `ZoneAnalyticsDeprecatedGetDashboardSince` for since failed"
.to_string()
});
self
}
pub fn until<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ZoneAnalyticsApiUntil>,
{
self.until = value
.try_into()
.map_err(|_| "conversion to `ZoneAnalyticsApiUntil` for until 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_identifier,
continuous,
since,
until,
} = self;
let zone_identifier = zone_identifier.map_err(Error::InvalidRequest)?;
let continuous = continuous.map_err(Error::InvalidRequest)?;
let since = since.map_err(Error::InvalidRequest)?;
let until = until.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/analytics/dashboard",
client.baseurl,
encode_path(&zone_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"),
)
.query(&progenitor_client::QueryParam::new(
"continuous",
&continuous,
))
.query(&progenitor_client::QueryParam::new("since", &since))
.query(&progenitor_client::QueryParam::new("until", &until))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "zone_analytics_deprecated_get_dashboard",
};
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)),
}
}
}