use super::types;
use crate::{
ByteStream, ClientHooks, ClientInfo, Error, OperationInfo, RequestBuilderExt,
ResponseValue, encode_path,
};
#[derive(Debug, Clone)]
pub struct PagesProjectGetProject<'a> {
client: &'a crate::Client,
account_id: Result<types::PagesIdentifier, String>,
project_name: Result<types::PagesProjectName, String>,
}
impl<'a> PagesProjectGetProject<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
project_name: Err("project_name was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::PagesIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `PagesIdentifier` for account_id failed".to_string());
self
}
pub fn project_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::PagesProjectName>,
{
self.project_name = value.try_into().map_err(|_| {
"conversion to `PagesProjectName` for project_name failed".to_string()
});
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
project_name,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let project_name = project_name.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/pages/projects/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&project_name.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: "pages_project_get_project",
};
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 PagesProjectDeleteProject<'a> {
client: &'a crate::Client,
account_id: Result<types::PagesIdentifier, String>,
project_name: Result<types::PagesProjectName, String>,
}
impl<'a> PagesProjectDeleteProject<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
project_name: Err("project_name was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::PagesIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `PagesIdentifier` for account_id failed".to_string());
self
}
pub fn project_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::PagesProjectName>,
{
self.project_name = value.try_into().map_err(|_| {
"conversion to `PagesProjectName` for project_name failed".to_string()
});
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
project_name,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let project_name = project_name.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/pages/projects/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&project_name.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: "pages_project_delete_project",
};
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 PagesProjectUpdateProject<'a> {
client: &'a crate::Client,
account_id: Result<types::PagesIdentifier, String>,
project_name: Result<types::PagesProjectName, String>,
body: Result<types::builder::PagesProjectUpdateProjectBody, String>,
}
impl<'a> PagesProjectUpdateProject<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
project_name: Err("project_name was not initialized".to_string()),
body: Ok(::std::default::Default::default()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::PagesIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `PagesIdentifier` for account_id failed".to_string());
self
}
pub fn project_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::PagesProjectName>,
{
self.project_name = value.try_into().map_err(|_| {
"conversion to `PagesProjectName` for project_name failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::PagesProjectUpdateProjectBody>,
<V as std::convert::TryInto<types::PagesProjectUpdateProjectBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `PagesProjectUpdateProjectBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::PagesProjectUpdateProjectBody,
) -> types::builder::PagesProjectUpdateProjectBody,
{
self.body = self.body.map(f);
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
project_name,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let project_name = project_name.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::PagesProjectUpdateProjectBody::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/pages/projects/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&project_name.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: "pages_project_update_project",
};
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 PagesDeploymentGetDeployments<'a> {
client: &'a crate::Client,
account_id: Result<types::PagesIdentifier, String>,
project_name: Result<types::PagesProjectName, String>,
env: Result<types::PagesDeploymentGetDeploymentsEnv, String>,
page: Result<i64, String>,
per_page: Result<i64, String>,
}
impl<'a> PagesDeploymentGetDeployments<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
project_name: Err("project_name was not initialized".to_string()),
env: Err("env was not initialized".to_string()),
page: Err("page was not initialized".to_string()),
per_page: Err("per_page was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::PagesIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `PagesIdentifier` for account_id failed".to_string());
self
}
pub fn project_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::PagesProjectName>,
{
self.project_name = value.try_into().map_err(|_| {
"conversion to `PagesProjectName` for project_name failed".to_string()
});
self
}
pub fn env<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::PagesDeploymentGetDeploymentsEnv>,
{
self.env = value.try_into().map_err(|_| {
"conversion to `PagesDeploymentGetDeploymentsEnv` for env 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 async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
project_name,
env,
page,
per_page,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let project_name = project_name.map_err(Error::InvalidRequest)?;
let env = env.map_err(Error::InvalidRequest)?;
let page = page.map_err(Error::InvalidRequest)?;
let per_page = per_page.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/pages/projects/{}/deployments",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&project_name.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("env", &env))
.query(&progenitor_client::QueryParam::new("page", &page))
.query(&progenitor_client::QueryParam::new("per_page", &per_page))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "pages_deployment_get_deployments",
};
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 PagesDeploymentCreateDeployment<'a> {
client: &'a crate::Client,
account_id: Result<types::PagesIdentifier, String>,
project_name: Result<types::PagesProjectName, String>,
body: Result<types::builder::PagesDeploymentCreateDeploymentBody, String>,
}
impl<'a> PagesDeploymentCreateDeployment<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
project_name: Err("project_name was not initialized".to_string()),
body: Ok(::std::default::Default::default()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::PagesIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `PagesIdentifier` for account_id failed".to_string());
self
}
pub fn project_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::PagesProjectName>,
{
self.project_name = value.try_into().map_err(|_| {
"conversion to `PagesProjectName` for project_name failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::PagesDeploymentCreateDeploymentBody>,
<V as std::convert::TryInto<types::PagesDeploymentCreateDeploymentBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `PagesDeploymentCreateDeploymentBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::PagesDeploymentCreateDeploymentBody,
) -> types::builder::PagesDeploymentCreateDeploymentBody,
{
self.body = self.body.map(f);
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
project_name,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let project_name = project_name.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::PagesDeploymentCreateDeploymentBody::try_from(v)
.map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/pages/projects/{}/deployments",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&project_name.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: "pages_deployment_create_deployment",
};
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 PagesDeploymentGetDeploymentInfo<'a> {
client: &'a crate::Client,
account_id: Result<types::PagesIdentifier, String>,
project_name: Result<types::PagesProjectName, String>,
deployment_id: Result<types::PagesIdentifier, String>,
}
impl<'a> PagesDeploymentGetDeploymentInfo<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
project_name: Err("project_name was not initialized".to_string()),
deployment_id: Err("deployment_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::PagesIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `PagesIdentifier` for account_id failed".to_string());
self
}
pub fn project_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::PagesProjectName>,
{
self.project_name = value.try_into().map_err(|_| {
"conversion to `PagesProjectName` for project_name failed".to_string()
});
self
}
pub fn deployment_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::PagesIdentifier>,
{
self.deployment_id = value.try_into().map_err(|_| {
"conversion to `PagesIdentifier` for deployment_id failed".to_string()
});
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
project_name,
deployment_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let project_name = project_name.map_err(Error::InvalidRequest)?;
let deployment_id = deployment_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/pages/projects/{}/deployments/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&project_name.to_string()),
encode_path(&deployment_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: "pages_deployment_get_deployment_info",
};
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 PagesDeploymentDeleteDeployment<'a> {
client: &'a crate::Client,
account_id: Result<types::PagesIdentifier, String>,
project_name: Result<types::PagesProjectName, String>,
deployment_id: Result<types::PagesIdentifier, String>,
}
impl<'a> PagesDeploymentDeleteDeployment<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
project_name: Err("project_name was not initialized".to_string()),
deployment_id: Err("deployment_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::PagesIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `PagesIdentifier` for account_id failed".to_string());
self
}
pub fn project_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::PagesProjectName>,
{
self.project_name = value.try_into().map_err(|_| {
"conversion to `PagesProjectName` for project_name failed".to_string()
});
self
}
pub fn deployment_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::PagesIdentifier>,
{
self.deployment_id = value.try_into().map_err(|_| {
"conversion to `PagesIdentifier` for deployment_id failed".to_string()
});
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
project_name,
deployment_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let project_name = project_name.map_err(Error::InvalidRequest)?;
let deployment_id = deployment_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/pages/projects/{}/deployments/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&project_name.to_string()),
encode_path(&deployment_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: "pages_deployment_delete_deployment",
};
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 PagesDeploymentGetDeploymentLogs<'a> {
client: &'a crate::Client,
account_id: Result<types::PagesIdentifier, String>,
project_name: Result<types::PagesProjectName, String>,
deployment_id: Result<types::PagesIdentifier, String>,
}
impl<'a> PagesDeploymentGetDeploymentLogs<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
project_name: Err("project_name was not initialized".to_string()),
deployment_id: Err("deployment_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::PagesIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `PagesIdentifier` for account_id failed".to_string());
self
}
pub fn project_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::PagesProjectName>,
{
self.project_name = value.try_into().map_err(|_| {
"conversion to `PagesProjectName` for project_name failed".to_string()
});
self
}
pub fn deployment_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::PagesIdentifier>,
{
self.deployment_id = value.try_into().map_err(|_| {
"conversion to `PagesIdentifier` for deployment_id failed".to_string()
});
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
project_name,
deployment_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let project_name = project_name.map_err(Error::InvalidRequest)?;
let deployment_id = deployment_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/pages/projects/{}/deployments/{}/history/logs",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&project_name.to_string()),
encode_path(&deployment_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: "pages_deployment_get_deployment_logs",
};
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 PagesDeploymentRetryDeployment<'a> {
client: &'a crate::Client,
account_id: Result<types::PagesIdentifier, String>,
project_name: Result<types::PagesProjectName, String>,
deployment_id: Result<types::PagesIdentifier, String>,
}
impl<'a> PagesDeploymentRetryDeployment<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
project_name: Err("project_name was not initialized".to_string()),
deployment_id: Err("deployment_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::PagesIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `PagesIdentifier` for account_id failed".to_string());
self
}
pub fn project_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::PagesProjectName>,
{
self.project_name = value.try_into().map_err(|_| {
"conversion to `PagesProjectName` for project_name failed".to_string()
});
self
}
pub fn deployment_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::PagesIdentifier>,
{
self.deployment_id = value.try_into().map_err(|_| {
"conversion to `PagesIdentifier` for deployment_id failed".to_string()
});
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
project_name,
deployment_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let project_name = project_name.map_err(Error::InvalidRequest)?;
let deployment_id = deployment_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/pages/projects/{}/deployments/{}/retry",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&project_name.to_string()),
encode_path(&deployment_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: "pages_deployment_retry_deployment",
};
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 PagesDeploymentRollbackDeployment<'a> {
client: &'a crate::Client,
account_id: Result<types::PagesIdentifier, String>,
project_name: Result<types::PagesProjectName, String>,
deployment_id: Result<types::PagesIdentifier, String>,
}
impl<'a> PagesDeploymentRollbackDeployment<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
project_name: Err("project_name was not initialized".to_string()),
deployment_id: Err("deployment_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::PagesIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `PagesIdentifier` for account_id failed".to_string());
self
}
pub fn project_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::PagesProjectName>,
{
self.project_name = value.try_into().map_err(|_| {
"conversion to `PagesProjectName` for project_name failed".to_string()
});
self
}
pub fn deployment_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::PagesIdentifier>,
{
self.deployment_id = value.try_into().map_err(|_| {
"conversion to `PagesIdentifier` for deployment_id failed".to_string()
});
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
project_name,
deployment_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let project_name = project_name.map_err(Error::InvalidRequest)?;
let deployment_id = deployment_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/pages/projects/{}/deployments/{}/rollback",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&project_name.to_string()),
encode_path(&deployment_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: "pages_deployment_rollback_deployment",
};
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 PagesDomainsGetDomains<'a> {
client: &'a crate::Client,
account_id: Result<types::PagesIdentifier, String>,
project_name: Result<types::PagesProjectName, String>,
}
impl<'a> PagesDomainsGetDomains<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
project_name: Err("project_name was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::PagesIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `PagesIdentifier` for account_id failed".to_string());
self
}
pub fn project_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::PagesProjectName>,
{
self.project_name = value.try_into().map_err(|_| {
"conversion to `PagesProjectName` for project_name failed".to_string()
});
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
project_name,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let project_name = project_name.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/pages/projects/{}/domains",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&project_name.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: "pages_domains_get_domains",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct PagesDomainsAddDomain<'a> {
client: &'a crate::Client,
account_id: Result<types::PagesIdentifier, String>,
project_name: Result<types::PagesProjectName, String>,
body: Result<types::builder::PagesDomainsAddDomainBody, String>,
}
impl<'a> PagesDomainsAddDomain<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
project_name: Err("project_name was not initialized".to_string()),
body: Ok(::std::default::Default::default()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::PagesIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `PagesIdentifier` for account_id failed".to_string());
self
}
pub fn project_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::PagesProjectName>,
{
self.project_name = value.try_into().map_err(|_| {
"conversion to `PagesProjectName` for project_name failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::PagesDomainsAddDomainBody>,
<V as std::convert::TryInto<types::PagesDomainsAddDomainBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `PagesDomainsAddDomainBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::PagesDomainsAddDomainBody,
) -> types::builder::PagesDomainsAddDomainBody,
{
self.body = self.body.map(f);
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
project_name,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let project_name = project_name.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::PagesDomainsAddDomainBody::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/pages/projects/{}/domains",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&project_name.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: "pages_domains_add_domain",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct PagesDomainsGetDomain<'a> {
client: &'a crate::Client,
account_id: Result<types::PagesIdentifier, String>,
project_name: Result<types::PagesProjectName, String>,
domain_name: Result<types::PagesDomainName, String>,
}
impl<'a> PagesDomainsGetDomain<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
project_name: Err("project_name was not initialized".to_string()),
domain_name: Err("domain_name was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::PagesIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `PagesIdentifier` for account_id failed".to_string());
self
}
pub fn project_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::PagesProjectName>,
{
self.project_name = value.try_into().map_err(|_| {
"conversion to `PagesProjectName` for project_name failed".to_string()
});
self
}
pub fn domain_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::PagesDomainName>,
{
self.domain_name = value
.try_into()
.map_err(|_| "conversion to `PagesDomainName` for domain_name failed".to_string());
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
project_name,
domain_name,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let project_name = project_name.map_err(Error::InvalidRequest)?;
let domain_name = domain_name.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/pages/projects/{}/domains/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&project_name.to_string()),
encode_path(&domain_name.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: "pages_domains_get_domain",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct PagesDomainsDeleteDomain<'a> {
client: &'a crate::Client,
account_id: Result<types::PagesIdentifier, String>,
project_name: Result<types::PagesProjectName, String>,
domain_name: Result<types::PagesDomainName, String>,
}
impl<'a> PagesDomainsDeleteDomain<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
project_name: Err("project_name was not initialized".to_string()),
domain_name: Err("domain_name was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::PagesIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `PagesIdentifier` for account_id failed".to_string());
self
}
pub fn project_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::PagesProjectName>,
{
self.project_name = value.try_into().map_err(|_| {
"conversion to `PagesProjectName` for project_name failed".to_string()
});
self
}
pub fn domain_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::PagesDomainName>,
{
self.domain_name = value
.try_into()
.map_err(|_| "conversion to `PagesDomainName` for domain_name failed".to_string());
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
project_name,
domain_name,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let project_name = project_name.map_err(Error::InvalidRequest)?;
let domain_name = domain_name.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/pages/projects/{}/domains/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&project_name.to_string()),
encode_path(&domain_name.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: "pages_domains_delete_domain",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct PagesDomainsPatchDomain<'a> {
client: &'a crate::Client,
account_id: Result<types::PagesIdentifier, String>,
project_name: Result<types::PagesProjectName, String>,
domain_name: Result<types::PagesDomainName, String>,
}
impl<'a> PagesDomainsPatchDomain<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
project_name: Err("project_name was not initialized".to_string()),
domain_name: Err("domain_name was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::PagesIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `PagesIdentifier` for account_id failed".to_string());
self
}
pub fn project_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::PagesProjectName>,
{
self.project_name = value.try_into().map_err(|_| {
"conversion to `PagesProjectName` for project_name failed".to_string()
});
self
}
pub fn domain_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::PagesDomainName>,
{
self.domain_name = value
.try_into()
.map_err(|_| "conversion to `PagesDomainName` for domain_name failed".to_string());
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
project_name,
domain_name,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let project_name = project_name.map_err(Error::InvalidRequest)?;
let domain_name = domain_name.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/pages/projects/{}/domains/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&project_name.to_string()),
encode_path(&domain_name.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"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "pages_domains_patch_domain",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct PagesPurgeBuildCache<'a> {
client: &'a crate::Client,
account_id: Result<types::PagesIdentifier, String>,
project_name: Result<types::PagesProjectName, String>,
}
impl<'a> PagesPurgeBuildCache<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
project_name: Err("project_name was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::PagesIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `PagesIdentifier` for account_id failed".to_string());
self
}
pub fn project_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::PagesProjectName>,
{
self.project_name = value.try_into().map_err(|_| {
"conversion to `PagesProjectName` for project_name failed".to_string()
});
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
project_name,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let project_name = project_name.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/pages/projects/{}/purge_build_cache",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&project_name.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: "pages_purge_build_cache",
};
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 PageShieldGetConnection<'a> {
client: &'a crate::Client,
zone_id: Result<types::PageShieldId, String>,
connection_id: Result<types::PageShieldId, String>,
}
impl<'a> PageShieldGetConnection<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
connection_id: Err("connection_id was not initialized".to_string()),
}
}
pub fn zone_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::PageShieldId>,
{
self.zone_id = value
.try_into()
.map_err(|_| "conversion to `PageShieldId` for zone_id failed".to_string());
self
}
pub fn connection_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::PageShieldId>,
{
self.connection_id = value
.try_into()
.map_err(|_| "conversion to `PageShieldId` for connection_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,
connection_id,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let connection_id = connection_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/page_shield/connections/{}",
client.baseurl,
encode_path(&zone_id.to_string()),
encode_path(&connection_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: "page_shield_get_connection",
};
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 PageShieldGetCookie<'a> {
client: &'a crate::Client,
zone_id: Result<types::PageShieldId, String>,
cookie_id: Result<types::PageShieldId, String>,
}
impl<'a> PageShieldGetCookie<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
cookie_id: Err("cookie_id was not initialized".to_string()),
}
}
pub fn zone_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::PageShieldId>,
{
self.zone_id = value
.try_into()
.map_err(|_| "conversion to `PageShieldId` for zone_id failed".to_string());
self
}
pub fn cookie_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::PageShieldId>,
{
self.cookie_id = value
.try_into()
.map_err(|_| "conversion to `PageShieldId` for cookie_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,
cookie_id,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let cookie_id = cookie_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/page_shield/cookies/{}",
client.baseurl,
encode_path(&zone_id.to_string()),
encode_path(&cookie_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: "page_shield_get_cookie",
};
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 PageShieldGetPolicy<'a> {
client: &'a crate::Client,
zone_id: Result<types::PageShieldId, String>,
policy_id: Result<types::PageShieldId, String>,
}
impl<'a> PageShieldGetPolicy<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_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::PageShieldId>,
{
self.zone_id = value
.try_into()
.map_err(|_| "conversion to `PageShieldId` for zone_id failed".to_string());
self
}
pub fn policy_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::PageShieldId>,
{
self.policy_id = value
.try_into()
.map_err(|_| "conversion to `PageShieldId` 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,
policy_id,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let policy_id = policy_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/page_shield/policies/{}",
client.baseurl,
encode_path(&zone_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: "page_shield_get_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 PageShieldUpdatePolicy<'a> {
client: &'a crate::Client,
zone_id: Result<types::PageShieldId, String>,
policy_id: Result<types::PageShieldId, String>,
body: Result<types::builder::PageShieldUpdatePolicyBody, String>,
}
impl<'a> PageShieldUpdatePolicy<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
policy_id: Err("policy_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::PageShieldId>,
{
self.zone_id = value
.try_into()
.map_err(|_| "conversion to `PageShieldId` for zone_id failed".to_string());
self
}
pub fn policy_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::PageShieldId>,
{
self.policy_id = value
.try_into()
.map_err(|_| "conversion to `PageShieldId` for policy_id failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::PageShieldUpdatePolicyBody>,
<V as std::convert::TryInto<types::PageShieldUpdatePolicyBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `PageShieldUpdatePolicyBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::PageShieldUpdatePolicyBody,
) -> types::builder::PageShieldUpdatePolicyBody,
{
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,
policy_id,
body,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let policy_id = policy_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::PageShieldUpdatePolicyBody::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/page_shield/policies/{}",
client.baseurl,
encode_path(&zone_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
.put(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "page_shield_update_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 PageShieldDeletePolicy<'a> {
client: &'a crate::Client,
zone_id: Result<types::PageShieldId, String>,
policy_id: Result<types::PageShieldId, String>,
}
impl<'a> PageShieldDeletePolicy<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_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::PageShieldId>,
{
self.zone_id = value
.try_into()
.map_err(|_| "conversion to `PageShieldId` for zone_id failed".to_string());
self
}
pub fn policy_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::PageShieldId>,
{
self.policy_id = value
.try_into()
.map_err(|_| "conversion to `PageShieldId` for policy_id failed".to_string());
self
}
pub async fn send(self) -> Result<ResponseValue<()>, Error<()>> {
let Self {
client,
zone_id,
policy_id,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let policy_id = policy_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/page_shield/policies/{}",
client.baseurl,
encode_path(&zone_id.to_string()),
encode_path(&policy_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client.client.delete(url).headers(header_map).build()?;
let info = OperationInfo {
operation_id: "page_shield_delete_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() {
204u16 => Ok(ResponseValue::empty(response)),
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct PageShieldGetScript<'a> {
client: &'a crate::Client,
zone_id: Result<types::PageShieldId, String>,
script_id: Result<types::PageShieldId, String>,
}
impl<'a> PageShieldGetScript<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
script_id: Err("script_id was not initialized".to_string()),
}
}
pub fn zone_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::PageShieldId>,
{
self.zone_id = value
.try_into()
.map_err(|_| "conversion to `PageShieldId` for zone_id failed".to_string());
self
}
pub fn script_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::PageShieldId>,
{
self.script_id = value
.try_into()
.map_err(|_| "conversion to `PageShieldId` for script_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,
script_id,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let script_id = script_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/page_shield/scripts/{}",
client.baseurl,
encode_path(&zone_id.to_string()),
encode_path(&script_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: "page_shield_get_script",
};
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 PageRulesDeleteAPageRule<'a> {
client: &'a crate::Client,
zone_id: Result<types::ZonesSchemasIdentifier, String>,
pagerule_id: Result<types::ZonesSchemasIdentifier, String>,
}
impl<'a> PageRulesDeleteAPageRule<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
pagerule_id: Err("pagerule_id was not initialized".to_string()),
}
}
pub fn zone_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ZonesSchemasIdentifier>,
{
self.zone_id = value.try_into().map_err(|_| {
"conversion to `ZonesSchemasIdentifier` for zone_id failed".to_string()
});
self
}
pub fn pagerule_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ZonesSchemasIdentifier>,
{
self.pagerule_id = value.try_into().map_err(|_| {
"conversion to `ZonesSchemasIdentifier` for pagerule_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,
pagerule_id,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let pagerule_id = pagerule_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/pagerules/{}",
client.baseurl,
encode_path(&zone_id.to_string()),
encode_path(&pagerule_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: "page_rules_delete_a_page_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 PageRulesEditAPageRule<'a> {
client: &'a crate::Client,
zone_id: Result<types::ZonesSchemasIdentifier, String>,
pagerule_id: Result<types::ZonesSchemasIdentifier, String>,
body: Result<types::builder::PageRulesEditAPageRuleBody, String>,
}
impl<'a> PageRulesEditAPageRule<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
pagerule_id: Err("pagerule_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::ZonesSchemasIdentifier>,
{
self.zone_id = value.try_into().map_err(|_| {
"conversion to `ZonesSchemasIdentifier` for zone_id failed".to_string()
});
self
}
pub fn pagerule_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ZonesSchemasIdentifier>,
{
self.pagerule_id = value.try_into().map_err(|_| {
"conversion to `ZonesSchemasIdentifier` for pagerule_id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::PageRulesEditAPageRuleBody>,
<V as std::convert::TryInto<types::PageRulesEditAPageRuleBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `PageRulesEditAPageRuleBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::PageRulesEditAPageRuleBody,
) -> types::builder::PageRulesEditAPageRuleBody,
{
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,
pagerule_id,
body,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let pagerule_id = pagerule_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::PageRulesEditAPageRuleBody::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/pagerules/{}",
client.baseurl,
encode_path(&zone_id.to_string()),
encode_path(&pagerule_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: "page_rules_edit_a_page_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)),
}
}
}