use super::types;
use crate::{
ByteStream, ClientHooks, ClientInfo, Error, OperationInfo, RequestBuilderExt,
ResponseValue, encode_path,
};
#[derive(Debug, Clone)]
pub struct CloudflareTunnelGetACloudflareTunnel<'a> {
client: &'a crate::Client,
account_id: Result<types::TunnelAccountId, String>,
tunnel_id: Result<types::TunnelTunnelId, String>,
}
impl<'a> CloudflareTunnelGetACloudflareTunnel<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
tunnel_id: Err("tunnel_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::TunnelAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `TunnelAccountId` for account_id failed".to_string());
self
}
pub fn tunnel_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::TunnelTunnelId>,
{
self.tunnel_id = value
.try_into()
.map_err(|_| "conversion to `TunnelTunnelId` for tunnel_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,
tunnel_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let tunnel_id = tunnel_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/cfd_tunnel/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&tunnel_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: "cloudflare_tunnel_get_a_cloudflare_tunnel",
};
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 CloudflareTunnelDeleteACloudflareTunnel<'a> {
client: &'a crate::Client,
account_id: Result<types::TunnelAccountId, String>,
tunnel_id: Result<types::TunnelTunnelId, String>,
body: Result<::serde_json::Map<::std::string::String, ::serde_json::Value>, String>,
}
impl<'a> CloudflareTunnelDeleteACloudflareTunnel<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
tunnel_id: Err("tunnel_id was not initialized".to_string()),
body: Err("body was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::TunnelAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `TunnelAccountId` for account_id failed".to_string());
self
}
pub fn tunnel_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::TunnelTunnelId>,
{
self.tunnel_id = value
.try_into()
.map_err(|_| "conversion to `TunnelTunnelId` for tunnel_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,
account_id,
tunnel_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let tunnel_id = tunnel_id.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/cfd_tunnel/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&tunnel_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: "cloudflare_tunnel_delete_a_cloudflare_tunnel",
};
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 CloudflareTunnelUpdateACloudflareTunnel<'a> {
client: &'a crate::Client,
account_id: Result<types::TunnelAccountId, String>,
tunnel_id: Result<types::TunnelTunnelId, String>,
body: Result<types::builder::CloudflareTunnelUpdateACloudflareTunnelBody, String>,
}
impl<'a> CloudflareTunnelUpdateACloudflareTunnel<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
tunnel_id: Err("tunnel_id was not initialized".to_string()),
body: Ok(::std::default::Default::default()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::TunnelAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `TunnelAccountId` for account_id failed".to_string());
self
}
pub fn tunnel_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::TunnelTunnelId>,
{
self.tunnel_id = value
.try_into()
.map_err(|_| "conversion to `TunnelTunnelId` for tunnel_id failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::CloudflareTunnelUpdateACloudflareTunnelBody>,
<V as std::convert::TryInto<types::CloudflareTunnelUpdateACloudflareTunnelBody>>::Error:
std::fmt::Display,
{
self . body = value . try_into () . map (From :: from) . map_err (| s | format ! ("conversion to `CloudflareTunnelUpdateACloudflareTunnelBody` for body failed: {}" , s)) ;
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::CloudflareTunnelUpdateACloudflareTunnelBody,
)
-> types::builder::CloudflareTunnelUpdateACloudflareTunnelBody,
{
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,
tunnel_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let tunnel_id = tunnel_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::CloudflareTunnelUpdateACloudflareTunnelBody::try_from(v)
.map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/cfd_tunnel/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&tunnel_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: "cloudflare_tunnel_update_a_cloudflare_tunnel",
};
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 CloudflareTunnelGetACloudflareTunnelToken<'a> {
client: &'a crate::Client,
account_id: Result<types::TunnelAccountId, String>,
tunnel_id: Result<types::TunnelTunnelId, String>,
}
impl<'a> CloudflareTunnelGetACloudflareTunnelToken<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
tunnel_id: Err("tunnel_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::TunnelAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `TunnelAccountId` for account_id failed".to_string());
self
}
pub fn tunnel_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::TunnelTunnelId>,
{
self.tunnel_id = value
.try_into()
.map_err(|_| "conversion to `TunnelTunnelId` for tunnel_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,
tunnel_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let tunnel_id = tunnel_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/cfd_tunnel/{}/token",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&tunnel_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: "cloudflare_tunnel_get_a_cloudflare_tunnel_token",
};
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 CloudflareImagesImageDetails<'a> {
client: &'a crate::Client,
account_id: Result<types::ImagesAccountIdentifier, String>,
image_id: Result<types::ImagesImageIdentifier, String>,
}
impl<'a> CloudflareImagesImageDetails<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
image_id: Err("image_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ImagesAccountIdentifier>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `ImagesAccountIdentifier` for account_id failed".to_string()
});
self
}
pub fn image_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ImagesImageIdentifier>,
{
self.image_id = value.try_into().map_err(|_| {
"conversion to `ImagesImageIdentifier` for image_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,
image_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let image_id = image_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/images/v1/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&image_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: "cloudflare_images_image_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 CloudflareImagesDeleteImage<'a> {
client: &'a crate::Client,
account_id: Result<types::ImagesAccountIdentifier, String>,
image_id: Result<types::ImagesImageIdentifier, String>,
body: Result<::serde_json::Map<::std::string::String, ::serde_json::Value>, String>,
}
impl<'a> CloudflareImagesDeleteImage<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
image_id: Err("image_id was not initialized".to_string()),
body: Err("body was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ImagesAccountIdentifier>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `ImagesAccountIdentifier` for account_id failed".to_string()
});
self
}
pub fn image_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ImagesImageIdentifier>,
{
self.image_id = value.try_into().map_err(|_| {
"conversion to `ImagesImageIdentifier` for image_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,
account_id,
image_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let image_id = image_id.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/images/v1/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&image_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: "cloudflare_images_delete_image",
};
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 CloudflareImagesUpdateImage<'a> {
client: &'a crate::Client,
account_id: Result<types::ImagesAccountIdentifier, String>,
image_id: Result<types::ImagesImageIdentifier, String>,
body: Result<types::builder::ImagesImagePatchRequest, String>,
}
impl<'a> CloudflareImagesUpdateImage<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
image_id: Err("image_id was not initialized".to_string()),
body: Ok(::std::default::Default::default()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ImagesAccountIdentifier>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `ImagesAccountIdentifier` for account_id failed".to_string()
});
self
}
pub fn image_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ImagesImageIdentifier>,
{
self.image_id = value.try_into().map_err(|_| {
"conversion to `ImagesImageIdentifier` for image_id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ImagesImagePatchRequest>,
<V as std::convert::TryInto<types::ImagesImagePatchRequest>>::Error: std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `ImagesImagePatchRequest` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::ImagesImagePatchRequest,
) -> types::builder::ImagesImagePatchRequest,
{
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,
image_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let image_id = image_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::ImagesImagePatchRequest::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/images/v1/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&image_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: "cloudflare_images_update_image",
};
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 CloudflareImagesBaseImage<'a> {
client: &'a crate::Client,
account_id: Result<types::ImagesAccountIdentifier, String>,
image_id: Result<types::ImagesImageIdentifier, String>,
}
impl<'a> CloudflareImagesBaseImage<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
image_id: Err("image_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ImagesAccountIdentifier>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `ImagesAccountIdentifier` for account_id failed".to_string()
});
self
}
pub fn image_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ImagesImageIdentifier>,
{
self.image_id = value.try_into().map_err(|_| {
"conversion to `ImagesImageIdentifier` for image_id failed".to_string()
});
self
}
pub async fn send(self) -> Result<ResponseValue<ByteStream>, Error<()>> {
let Self {
client,
account_id,
image_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let image_id = image_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/images/v1/{}/blob",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&image_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).headers(header_map).build()?;
let info = OperationInfo {
operation_id: "cloudflare_images_base_image",
};
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 => Ok(ResponseValue::stream(response)),
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct CloudflareImagesKeysAddSigningKey<'a> {
client: &'a crate::Client,
account_id: Result<types::ImagesAccountIdentifier, String>,
signing_key_name: Result<types::ImagesSigningKeyIdentifier, String>,
}
impl<'a> CloudflareImagesKeysAddSigningKey<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
signing_key_name: Err("signing_key_name was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ImagesAccountIdentifier>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `ImagesAccountIdentifier` for account_id failed".to_string()
});
self
}
pub fn signing_key_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ImagesSigningKeyIdentifier>,
{
self.signing_key_name = value.try_into().map_err(|_| {
"conversion to `ImagesSigningKeyIdentifier` for signing_key_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,
signing_key_name,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let signing_key_name = signing_key_name.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/images/v1/keys/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&signing_key_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
.put(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "cloudflare_images_keys_add_signing_key",
};
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 CloudflareImagesKeysDeleteSigningKey<'a> {
client: &'a crate::Client,
account_id: Result<types::ImagesAccountIdentifier, String>,
signing_key_name: Result<types::ImagesSigningKeyIdentifier, String>,
}
impl<'a> CloudflareImagesKeysDeleteSigningKey<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
signing_key_name: Err("signing_key_name was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ImagesAccountIdentifier>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `ImagesAccountIdentifier` for account_id failed".to_string()
});
self
}
pub fn signing_key_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ImagesSigningKeyIdentifier>,
{
self.signing_key_name = value.try_into().map_err(|_| {
"conversion to `ImagesSigningKeyIdentifier` for signing_key_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,
signing_key_name,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let signing_key_name = signing_key_name.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/images/v1/keys/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&signing_key_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: "cloudflare_images_keys_delete_signing_key",
};
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 CloudflareImagesVariantsCreateAVariant<'a> {
client: &'a crate::Client,
account_id: Result<types::ImagesAccountIdentifier, String>,
body: Result<types::builder::ImagesImageVariantDefinition, String>,
}
impl<'a> CloudflareImagesVariantsCreateAVariant<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
body: Ok(::std::default::Default::default()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ImagesAccountIdentifier>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `ImagesAccountIdentifier` for account_id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ImagesImageVariantDefinition>,
<V as std::convert::TryInto<types::ImagesImageVariantDefinition>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `ImagesImageVariantDefinition` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::ImagesImageVariantDefinition,
) -> types::builder::ImagesImageVariantDefinition,
{
self.body = self.body.map(f);
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::ImagesImageVariantDefinition::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/images/v1/variants",
client.baseurl,
encode_path(&account_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.post(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "cloudflare_images_variants_create_a_variant",
};
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 CloudflareImagesVariantsVariantDetails<'a> {
client: &'a crate::Client,
account_id: Result<types::ImagesAccountIdentifier, String>,
variant_id: Result<types::ImagesImageVariantIdentifier, String>,
}
impl<'a> CloudflareImagesVariantsVariantDetails<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
variant_id: Err("variant_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ImagesAccountIdentifier>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `ImagesAccountIdentifier` for account_id failed".to_string()
});
self
}
pub fn variant_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ImagesImageVariantIdentifier>,
{
self.variant_id = value.try_into().map_err(|_| {
"conversion to `ImagesImageVariantIdentifier` for variant_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,
variant_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let variant_id = variant_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/images/v1/variants/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&variant_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: "cloudflare_images_variants_variant_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 CloudflareImagesVariantsDeleteAVariant<'a> {
client: &'a crate::Client,
account_id: Result<types::ImagesAccountIdentifier, String>,
variant_id: Result<types::ImagesImageVariantIdentifier, String>,
body: Result<::serde_json::Map<::std::string::String, ::serde_json::Value>, String>,
}
impl<'a> CloudflareImagesVariantsDeleteAVariant<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
variant_id: Err("variant_id was not initialized".to_string()),
body: Err("body was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ImagesAccountIdentifier>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `ImagesAccountIdentifier` for account_id failed".to_string()
});
self
}
pub fn variant_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ImagesImageVariantIdentifier>,
{
self.variant_id = value.try_into().map_err(|_| {
"conversion to `ImagesImageVariantIdentifier` for variant_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,
account_id,
variant_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let variant_id = variant_id.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/images/v1/variants/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&variant_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: "cloudflare_images_variants_delete_a_variant",
};
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 CloudflareImagesVariantsUpdateAVariant<'a> {
client: &'a crate::Client,
account_id: Result<types::ImagesAccountIdentifier, String>,
variant_id: Result<types::ImagesImageVariantIdentifier, String>,
body: Result<types::builder::ImagesImageVariantPatchRequest, String>,
}
impl<'a> CloudflareImagesVariantsUpdateAVariant<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
variant_id: Err("variant_id was not initialized".to_string()),
body: Ok(::std::default::Default::default()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ImagesAccountIdentifier>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `ImagesAccountIdentifier` for account_id failed".to_string()
});
self
}
pub fn variant_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ImagesImageVariantIdentifier>,
{
self.variant_id = value.try_into().map_err(|_| {
"conversion to `ImagesImageVariantIdentifier` for variant_id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::ImagesImageVariantPatchRequest>,
<V as std::convert::TryInto<types::ImagesImageVariantPatchRequest>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `ImagesImageVariantPatchRequest` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::ImagesImageVariantPatchRequest,
) -> types::builder::ImagesImageVariantPatchRequest,
{
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,
variant_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let variant_id = variant_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::ImagesImageVariantPatchRequest::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/images/v1/variants/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&variant_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: "cloudflare_images_variants_update_a_variant",
};
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 CloudflareTunnelGetAWarpConnectorTunnel<'a> {
client: &'a crate::Client,
account_id: Result<types::TunnelAccountId, String>,
tunnel_id: Result<types::TunnelTunnelId, String>,
}
impl<'a> CloudflareTunnelGetAWarpConnectorTunnel<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
tunnel_id: Err("tunnel_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::TunnelAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `TunnelAccountId` for account_id failed".to_string());
self
}
pub fn tunnel_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::TunnelTunnelId>,
{
self.tunnel_id = value
.try_into()
.map_err(|_| "conversion to `TunnelTunnelId` for tunnel_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,
tunnel_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let tunnel_id = tunnel_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/warp_connector/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&tunnel_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: "cloudflare_tunnel_get_a_warp_connector_tunnel",
};
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 CloudflareTunnelDeleteAWarpConnectorTunnel<'a> {
client: &'a crate::Client,
account_id: Result<types::TunnelAccountId, String>,
tunnel_id: Result<types::TunnelTunnelId, String>,
body: Result<::serde_json::Map<::std::string::String, ::serde_json::Value>, String>,
}
impl<'a> CloudflareTunnelDeleteAWarpConnectorTunnel<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
tunnel_id: Err("tunnel_id was not initialized".to_string()),
body: Err("body was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::TunnelAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `TunnelAccountId` for account_id failed".to_string());
self
}
pub fn tunnel_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::TunnelTunnelId>,
{
self.tunnel_id = value
.try_into()
.map_err(|_| "conversion to `TunnelTunnelId` for tunnel_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,
account_id,
tunnel_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let tunnel_id = tunnel_id.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/warp_connector/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&tunnel_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: "cloudflare_tunnel_delete_a_warp_connector_tunnel",
};
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 CloudflareTunnelUpdateAWarpConnectorTunnel<'a> {
client: &'a crate::Client,
account_id: Result<types::TunnelAccountId, String>,
tunnel_id: Result<types::TunnelTunnelId, String>,
body: Result<types::builder::CloudflareTunnelUpdateAWarpConnectorTunnelBody, String>,
}
impl<'a> CloudflareTunnelUpdateAWarpConnectorTunnel<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
tunnel_id: Err("tunnel_id was not initialized".to_string()),
body: Ok(::std::default::Default::default()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::TunnelAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `TunnelAccountId` for account_id failed".to_string());
self
}
pub fn tunnel_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::TunnelTunnelId>,
{
self.tunnel_id = value
.try_into()
.map_err(|_| "conversion to `TunnelTunnelId` for tunnel_id failed".to_string());
self
} pub fn body < V > (mut self , value : V) -> Self where V : std :: convert :: TryInto < types :: CloudflareTunnelUpdateAWarpConnectorTunnelBody > , < V as std :: convert :: TryInto < types :: CloudflareTunnelUpdateAWarpConnectorTunnelBody >> :: Error : std :: fmt :: Display ,{
self . body = value . try_into () . map (From :: from) . map_err (| s | format ! ("conversion to `CloudflareTunnelUpdateAWarpConnectorTunnelBody` for body failed: {}" , s)) ;
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::CloudflareTunnelUpdateAWarpConnectorTunnelBody,
)
-> types::builder::CloudflareTunnelUpdateAWarpConnectorTunnelBody,
{
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,
tunnel_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let tunnel_id = tunnel_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::CloudflareTunnelUpdateAWarpConnectorTunnelBody::try_from(v)
.map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/warp_connector/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&tunnel_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: "cloudflare_tunnel_update_a_warp_connector_tunnel",
};
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)),
}
}
}