use super::types;
use crate::{
ByteStream, ClientHooks, ClientInfo, Error, OperationInfo, RequestBuilderExt,
ResponseValue, encode_path,
};
#[derive(Debug, Clone)]
pub struct SpeedListTestHistory<'a> {
client: &'a crate::Client,
zone_id: Result<types::ObservatoryIdentifier, String>,
url: Result<types::ObservatoryUrl, String>,
page: Result<i64, String>,
per_page: Result<i64, String>,
region: Result<types::ObservatoryRegion, String>,
}
impl<'a> SpeedListTestHistory<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
url: Err("url was not initialized".to_string()),
page: Err("page was not initialized".to_string()),
per_page: Err("per_page was not initialized".to_string()),
region: Err("region was not initialized".to_string()),
}
}
pub fn zone_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ObservatoryIdentifier>,
{
self.zone_id = value.try_into().map_err(|_| {
"conversion to `ObservatoryIdentifier` for zone_id failed".to_string()
});
self
}
pub fn url<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ObservatoryUrl>,
{
self.url = value
.try_into()
.map_err(|_| "conversion to `ObservatoryUrl` for url failed".to_string());
self
}
pub fn page<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<i64>,
{
self.page = value
.try_into()
.map_err(|_| "conversion to `i64` for page failed".to_string());
self
}
pub fn per_page<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<i64>,
{
self.per_page = value
.try_into()
.map_err(|_| "conversion to `i64` for per_page failed".to_string());
self
}
pub fn region<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ObservatoryRegion>,
{
self.region = value
.try_into()
.map_err(|_| "conversion to `ObservatoryRegion` for region 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,
url,
page,
per_page,
region,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let url = url.map_err(Error::InvalidRequest)?;
let page = page.map_err(Error::InvalidRequest)?;
let per_page = per_page.map_err(Error::InvalidRequest)?;
let region = region.map_err(Error::InvalidRequest)?;
let _url = format!(
"{}/zones/{}/speed_api/pages/{}/tests",
client.baseurl,
encode_path(&zone_id.to_string()),
encode_path(&url.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("page", &page))
.query(&progenitor_client::QueryParam::new("per_page", &per_page))
.query(&progenitor_client::QueryParam::new("region", ®ion))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "speed_list_test_history",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct SpeedCreateTest<'a> {
client: &'a crate::Client,
zone_id: Result<types::ObservatoryIdentifier, String>,
url: Result<types::ObservatoryUrl, String>,
body: Result<types::builder::SpeedCreateTestBody, String>,
}
impl<'a> SpeedCreateTest<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
url: Err("url 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::ObservatoryIdentifier>,
{
self.zone_id = value.try_into().map_err(|_| {
"conversion to `ObservatoryIdentifier` for zone_id failed".to_string()
});
self
}
pub fn url<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ObservatoryUrl>,
{
self.url = value
.try_into()
.map_err(|_| "conversion to `ObservatoryUrl` for url failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::SpeedCreateTestBody>,
<V as std::convert::TryInto<types::SpeedCreateTestBody>>::Error: std::fmt::Display,
{
self.body = value
.try_into()
.map(From::from)
.map_err(|s| format!("conversion to `SpeedCreateTestBody` for body failed: {}", s));
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::SpeedCreateTestBody,
) -> types::builder::SpeedCreateTestBody,
{
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,
url,
body,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let url = url.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| types::SpeedCreateTestBody::try_from(v).map_err(|e| e.to_string()))
.map_err(Error::InvalidRequest)?;
let _url = format!(
"{}/zones/{}/speed_api/pages/{}/tests",
client.baseurl,
encode_path(&zone_id.to_string()),
encode_path(&url.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: "speed_create_test",
};
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 SpeedDeleteTests<'a> {
client: &'a crate::Client,
zone_id: Result<types::ObservatoryIdentifier, String>,
url: Result<types::ObservatoryUrl, String>,
region: Result<types::ObservatoryRegion, String>,
}
impl<'a> SpeedDeleteTests<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
url: Err("url was not initialized".to_string()),
region: Err("region was not initialized".to_string()),
}
}
pub fn zone_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ObservatoryIdentifier>,
{
self.zone_id = value.try_into().map_err(|_| {
"conversion to `ObservatoryIdentifier` for zone_id failed".to_string()
});
self
}
pub fn url<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ObservatoryUrl>,
{
self.url = value
.try_into()
.map_err(|_| "conversion to `ObservatoryUrl` for url failed".to_string());
self
}
pub fn region<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ObservatoryRegion>,
{
self.region = value
.try_into()
.map_err(|_| "conversion to `ObservatoryRegion` for region 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,
url,
region,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let url = url.map_err(Error::InvalidRequest)?;
let region = region.map_err(Error::InvalidRequest)?;
let _url = format!(
"{}/zones/{}/speed_api/pages/{}/tests",
client.baseurl,
encode_path(&zone_id.to_string()),
encode_path(&url.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"),
)
.query(&progenitor_client::QueryParam::new("region", ®ion))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "speed_delete_tests",
};
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 SpeedGetTest<'a> {
client: &'a crate::Client,
zone_id: Result<types::ObservatoryIdentifier, String>,
url: Result<types::ObservatoryUrl, String>,
test_id: Result<::std::string::String, String>,
}
impl<'a> SpeedGetTest<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
url: Err("url was not initialized".to_string()),
test_id: Err("test_id was not initialized".to_string()),
}
}
pub fn zone_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ObservatoryIdentifier>,
{
self.zone_id = value.try_into().map_err(|_| {
"conversion to `ObservatoryIdentifier` for zone_id failed".to_string()
});
self
}
pub fn url<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ObservatoryUrl>,
{
self.url = value
.try_into()
.map_err(|_| "conversion to `ObservatoryUrl` for url failed".to_string());
self
}
pub fn test_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.test_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for test_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,
url,
test_id,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let url = url.map_err(Error::InvalidRequest)?;
let test_id = test_id.map_err(Error::InvalidRequest)?;
let _url = format!(
"{}/zones/{}/speed_api/pages/{}/tests/{}",
client.baseurl,
encode_path(&zone_id.to_string()),
encode_path(&url.to_string()),
encode_path(&test_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: "speed_get_test",
};
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 SpeedListPageTrend<'a> {
client: &'a crate::Client,
zone_id: Result<types::ObservatoryIdentifier, String>,
url: Result<types::ObservatoryUrl, String>,
device_type: Result<types::ObservatoryDeviceType, String>,
end: Result<types::ObservatoryTimestamp, String>,
metrics: Result<::std::string::String, String>,
region: Result<types::ObservatoryRegion, String>,
start: Result<types::ObservatoryTimestamp, String>,
tz: Result<::std::string::String, String>,
}
impl<'a> SpeedListPageTrend<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
url: Err("url was not initialized".to_string()),
device_type: Err("device_type was not initialized".to_string()),
end: Err("end was not initialized".to_string()),
metrics: Err("metrics was not initialized".to_string()),
region: Err("region was not initialized".to_string()),
start: Err("start was not initialized".to_string()),
tz: Err("tz was not initialized".to_string()),
}
}
pub fn zone_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ObservatoryIdentifier>,
{
self.zone_id = value.try_into().map_err(|_| {
"conversion to `ObservatoryIdentifier` for zone_id failed".to_string()
});
self
}
pub fn url<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ObservatoryUrl>,
{
self.url = value
.try_into()
.map_err(|_| "conversion to `ObservatoryUrl` for url failed".to_string());
self
}
pub fn device_type<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ObservatoryDeviceType>,
{
self.device_type = value.try_into().map_err(|_| {
"conversion to `ObservatoryDeviceType` for device_type failed".to_string()
});
self
}
pub fn end<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ObservatoryTimestamp>,
{
self.end = value
.try_into()
.map_err(|_| "conversion to `ObservatoryTimestamp` for end failed".to_string());
self
}
pub fn metrics<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.metrics = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for metrics failed".to_string()
});
self
}
pub fn region<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ObservatoryRegion>,
{
self.region = value
.try_into()
.map_err(|_| "conversion to `ObservatoryRegion` for region failed".to_string());
self
}
pub fn start<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ObservatoryTimestamp>,
{
self.start = value
.try_into()
.map_err(|_| "conversion to `ObservatoryTimestamp` for start failed".to_string());
self
}
pub fn tz<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.tz = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for tz 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,
url,
device_type,
end,
metrics,
region,
start,
tz,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let url = url.map_err(Error::InvalidRequest)?;
let device_type = device_type.map_err(Error::InvalidRequest)?;
let end = end.map_err(Error::InvalidRequest)?;
let metrics = metrics.map_err(Error::InvalidRequest)?;
let region = region.map_err(Error::InvalidRequest)?;
let start = start.map_err(Error::InvalidRequest)?;
let tz = tz.map_err(Error::InvalidRequest)?;
let _url = format!(
"{}/zones/{}/speed_api/pages/{}/trend",
client.baseurl,
encode_path(&zone_id.to_string()),
encode_path(&url.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(
"deviceType",
&device_type,
))
.query(&progenitor_client::QueryParam::new("end", &end))
.query(&progenitor_client::QueryParam::new("metrics", &metrics))
.query(&progenitor_client::QueryParam::new("region", ®ion))
.query(&progenitor_client::QueryParam::new("start", &start))
.query(&progenitor_client::QueryParam::new("tz", &tz))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "speed_list_page_trend",
};
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 SpeedCreateScheduledTest<'a> {
client: &'a crate::Client,
zone_id: Result<types::ObservatoryIdentifier, String>,
url: Result<types::ObservatoryUrl, String>,
region: Result<types::ObservatoryRegion, String>,
}
impl<'a> SpeedCreateScheduledTest<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
url: Err("url was not initialized".to_string()),
region: Err("region was not initialized".to_string()),
}
}
pub fn zone_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ObservatoryIdentifier>,
{
self.zone_id = value.try_into().map_err(|_| {
"conversion to `ObservatoryIdentifier` for zone_id failed".to_string()
});
self
}
pub fn url<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ObservatoryUrl>,
{
self.url = value
.try_into()
.map_err(|_| "conversion to `ObservatoryUrl` for url failed".to_string());
self
}
pub fn region<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ObservatoryRegion>,
{
self.region = value
.try_into()
.map_err(|_| "conversion to `ObservatoryRegion` for region 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,
url,
region,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let url = url.map_err(Error::InvalidRequest)?;
let region = region.map_err(Error::InvalidRequest)?;
let _url = format!(
"{}/zones/{}/speed_api/schedule/{}",
client.baseurl,
encode_path(&zone_id.to_string()),
encode_path(&url.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"),
)
.query(&progenitor_client::QueryParam::new("region", ®ion))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "speed_create_scheduled_test",
};
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 SpeedDeleteTestSchedule<'a> {
client: &'a crate::Client,
zone_id: Result<types::ObservatoryIdentifier, String>,
url: Result<types::ObservatoryUrl, String>,
region: Result<types::ObservatoryRegion, String>,
}
impl<'a> SpeedDeleteTestSchedule<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
url: Err("url was not initialized".to_string()),
region: Err("region was not initialized".to_string()),
}
}
pub fn zone_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ObservatoryIdentifier>,
{
self.zone_id = value.try_into().map_err(|_| {
"conversion to `ObservatoryIdentifier` for zone_id failed".to_string()
});
self
}
pub fn url<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ObservatoryUrl>,
{
self.url = value
.try_into()
.map_err(|_| "conversion to `ObservatoryUrl` for url failed".to_string());
self
}
pub fn region<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ObservatoryRegion>,
{
self.region = value
.try_into()
.map_err(|_| "conversion to `ObservatoryRegion` for region 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,
url,
region,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let url = url.map_err(Error::InvalidRequest)?;
let region = region.map_err(Error::InvalidRequest)?;
let _url = format!(
"{}/zones/{}/speed_api/schedule/{}",
client.baseurl,
encode_path(&zone_id.to_string()),
encode_path(&url.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"),
)
.query(&progenitor_client::QueryParam::new("region", ®ion))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "speed_delete_test_schedule",
};
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)),
}
}
}