use super::types;
use crate::{
ByteStream, ClientHooks, ClientInfo, Error, OperationInfo, RequestBuilderExt,
ResponseValue, encode_path,
};
#[derive(Debug, Clone)]
pub struct MagicAccountAppsUpdateApp<'a> {
client: &'a crate::Client,
account_id: Result<types::MagicIdentifier, String>,
account_app_id: Result<types::MagicIdentifier, String>,
body: Result<types::MagicAppUpdateRequest, String>,
}
impl<'a> MagicAccountAppsUpdateApp<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
account_app_id: Err("account_app_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::MagicIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for account_id failed".to_string());
self
}
pub fn account_app_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.account_app_id = value.try_into().map_err(|_| {
"conversion to `MagicIdentifier` for account_app_id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicAppUpdateRequest>,
{
self.body = value
.try_into()
.map_err(|_| "conversion to `MagicAppUpdateRequest` 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,
account_app_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let account_app_id = account_app_id.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/apps/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&account_app_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.put(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "magic_account_apps_update_app",
};
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 MagicAccountAppsDeleteApp<'a> {
client: &'a crate::Client,
account_id: Result<types::MagicIdentifier, String>,
account_app_id: Result<types::MagicIdentifier, String>,
}
impl<'a> MagicAccountAppsDeleteApp<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
account_app_id: Err("account_app_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for account_id failed".to_string());
self
}
pub fn account_app_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.account_app_id = value.try_into().map_err(|_| {
"conversion to `MagicIdentifier` for account_app_id failed".to_string()
});
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
account_app_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let account_app_id = account_app_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/apps/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&account_app_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.delete(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "magic_account_apps_delete_app",
};
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 MagicAccountAppsPatchApp<'a> {
client: &'a crate::Client,
account_id: Result<types::MagicIdentifier, String>,
account_app_id: Result<types::MagicIdentifier, String>,
body: Result<types::MagicAppUpdateRequest, String>,
}
impl<'a> MagicAccountAppsPatchApp<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
account_app_id: Err("account_app_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::MagicIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for account_id failed".to_string());
self
}
pub fn account_app_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.account_app_id = value.try_into().map_err(|_| {
"conversion to `MagicIdentifier` for account_app_id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicAppUpdateRequest>,
{
self.body = value
.try_into()
.map_err(|_| "conversion to `MagicAppUpdateRequest` 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,
account_app_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let account_app_id = account_app_id.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/apps/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&account_app_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.patch(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "magic_account_apps_patch_app",
};
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 MagicInterconnectsListInterconnects<'a> {
client: &'a crate::Client,
account_id: Result<types::MagicIdentifier, String>,
x_magic_new_hc_target: Result<bool, String>,
}
impl<'a> MagicInterconnectsListInterconnects<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
x_magic_new_hc_target: Err("x_magic_new_hc_target was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for account_id failed".to_string());
self
}
pub fn x_magic_new_hc_target<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<bool>,
{
self.x_magic_new_hc_target = value
.try_into()
.map_err(|_| "conversion to `bool` for x_magic_new_hc_target 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,
x_magic_new_hc_target,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let x_magic_new_hc_target = x_magic_new_hc_target.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/cf_interconnects",
client.baseurl,
encode_path(&account_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(2usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
header_map.append(
"x-magic-new-hc-target",
x_magic_new_hc_target.to_string().try_into()?,
);
#[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: "magic_interconnects_list_interconnects",
};
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 MagicInterconnectsListInterconnectDetails<'a> {
client: &'a crate::Client,
account_id: Result<types::MagicIdentifier, String>,
cf_interconnect_id: Result<types::MagicIdentifier, String>,
x_magic_new_hc_target: Result<bool, String>,
}
impl<'a> MagicInterconnectsListInterconnectDetails<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
cf_interconnect_id: Err("cf_interconnect_id was not initialized".to_string()),
x_magic_new_hc_target: Err("x_magic_new_hc_target was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for account_id failed".to_string());
self
}
pub fn cf_interconnect_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.cf_interconnect_id = value.try_into().map_err(|_| {
"conversion to `MagicIdentifier` for cf_interconnect_id failed".to_string()
});
self
}
pub fn x_magic_new_hc_target<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<bool>,
{
self.x_magic_new_hc_target = value
.try_into()
.map_err(|_| "conversion to `bool` for x_magic_new_hc_target 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,
cf_interconnect_id,
x_magic_new_hc_target,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let cf_interconnect_id = cf_interconnect_id.map_err(Error::InvalidRequest)?;
let x_magic_new_hc_target = x_magic_new_hc_target.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/cf_interconnects/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&cf_interconnect_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(2usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
header_map.append(
"x-magic-new-hc-target",
x_magic_new_hc_target.to_string().try_into()?,
);
#[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: "magic_interconnects_list_interconnect_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 MagicInterconnectsUpdateInterconnect<'a> {
client: &'a crate::Client,
account_id: Result<types::MagicIdentifier, String>,
cf_interconnect_id: Result<types::MagicIdentifier, String>,
x_magic_new_hc_target: Result<bool, String>,
body: Result<types::builder::MagicInterconnectTunnelUpdateRequest, String>,
}
impl<'a> MagicInterconnectsUpdateInterconnect<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
cf_interconnect_id: Err("cf_interconnect_id was not initialized".to_string()),
x_magic_new_hc_target: Err("x_magic_new_hc_target 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::MagicIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for account_id failed".to_string());
self
}
pub fn cf_interconnect_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.cf_interconnect_id = value.try_into().map_err(|_| {
"conversion to `MagicIdentifier` for cf_interconnect_id failed".to_string()
});
self
}
pub fn x_magic_new_hc_target<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<bool>,
{
self.x_magic_new_hc_target = value
.try_into()
.map_err(|_| "conversion to `bool` for x_magic_new_hc_target failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicInterconnectTunnelUpdateRequest>,
<V as std::convert::TryInto<types::MagicInterconnectTunnelUpdateRequest>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `MagicInterconnectTunnelUpdateRequest` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::MagicInterconnectTunnelUpdateRequest,
)
-> types::builder::MagicInterconnectTunnelUpdateRequest,
{
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,
cf_interconnect_id,
x_magic_new_hc_target,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let cf_interconnect_id = cf_interconnect_id.map_err(Error::InvalidRequest)?;
let x_magic_new_hc_target = x_magic_new_hc_target.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::MagicInterconnectTunnelUpdateRequest::try_from(v)
.map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/cf_interconnects/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&cf_interconnect_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(2usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
header_map.append(
"x-magic-new-hc-target",
x_magic_new_hc_target.to_string().try_into()?,
);
#[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: "magic_interconnects_update_interconnect",
};
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 MagicGreTunnelsListGreTunnelDetails<'a> {
client: &'a crate::Client,
account_id: Result<types::MagicIdentifier, String>,
gre_tunnel_id: Result<types::MagicIdentifier, String>,
x_magic_new_hc_target: Result<bool, String>,
}
impl<'a> MagicGreTunnelsListGreTunnelDetails<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
gre_tunnel_id: Err("gre_tunnel_id was not initialized".to_string()),
x_magic_new_hc_target: Err("x_magic_new_hc_target was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for account_id failed".to_string());
self
}
pub fn gre_tunnel_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.gre_tunnel_id = value.try_into().map_err(|_| {
"conversion to `MagicIdentifier` for gre_tunnel_id failed".to_string()
});
self
}
pub fn x_magic_new_hc_target<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<bool>,
{
self.x_magic_new_hc_target = value
.try_into()
.map_err(|_| "conversion to `bool` for x_magic_new_hc_target 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,
gre_tunnel_id,
x_magic_new_hc_target,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let gre_tunnel_id = gre_tunnel_id.map_err(Error::InvalidRequest)?;
let x_magic_new_hc_target = x_magic_new_hc_target.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/gre_tunnels/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&gre_tunnel_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(2usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
header_map.append(
"x-magic-new-hc-target",
x_magic_new_hc_target.to_string().try_into()?,
);
#[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: "magic_gre_tunnels_list_gre_tunnel_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 MagicGreTunnelsUpdateGreTunnel<'a> {
client: &'a crate::Client,
account_id: Result<types::MagicIdentifier, String>,
gre_tunnel_id: Result<types::MagicIdentifier, String>,
x_magic_new_hc_target: Result<bool, String>,
body: Result<types::MagicGreTunnelUpdateRequest, String>,
}
impl<'a> MagicGreTunnelsUpdateGreTunnel<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
gre_tunnel_id: Err("gre_tunnel_id was not initialized".to_string()),
x_magic_new_hc_target: Err("x_magic_new_hc_target 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::MagicIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for account_id failed".to_string());
self
}
pub fn gre_tunnel_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.gre_tunnel_id = value.try_into().map_err(|_| {
"conversion to `MagicIdentifier` for gre_tunnel_id failed".to_string()
});
self
}
pub fn x_magic_new_hc_target<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<bool>,
{
self.x_magic_new_hc_target = value
.try_into()
.map_err(|_| "conversion to `bool` for x_magic_new_hc_target failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicGreTunnelUpdateRequest>,
{
self.body = value.try_into().map_err(|_| {
"conversion to `MagicGreTunnelUpdateRequest` 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,
gre_tunnel_id,
x_magic_new_hc_target,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let gre_tunnel_id = gre_tunnel_id.map_err(Error::InvalidRequest)?;
let x_magic_new_hc_target = x_magic_new_hc_target.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/gre_tunnels/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&gre_tunnel_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(2usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
header_map.append(
"x-magic-new-hc-target",
x_magic_new_hc_target.to_string().try_into()?,
);
#[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: "magic_gre_tunnels_update_gre_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 MagicGreTunnelsDeleteGreTunnel<'a> {
client: &'a crate::Client,
account_id: Result<types::MagicIdentifier, String>,
gre_tunnel_id: Result<types::MagicIdentifier, String>,
x_magic_new_hc_target: Result<bool, String>,
body: Result<::serde_json::Map<::std::string::String, ::serde_json::Value>, String>,
}
impl<'a> MagicGreTunnelsDeleteGreTunnel<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
gre_tunnel_id: Err("gre_tunnel_id was not initialized".to_string()),
x_magic_new_hc_target: Err("x_magic_new_hc_target 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::MagicIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for account_id failed".to_string());
self
}
pub fn gre_tunnel_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.gre_tunnel_id = value.try_into().map_err(|_| {
"conversion to `MagicIdentifier` for gre_tunnel_id failed".to_string()
});
self
}
pub fn x_magic_new_hc_target<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<bool>,
{
self.x_magic_new_hc_target = value
.try_into()
.map_err(|_| "conversion to `bool` for x_magic_new_hc_target 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,
gre_tunnel_id,
x_magic_new_hc_target,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let gre_tunnel_id = gre_tunnel_id.map_err(Error::InvalidRequest)?;
let x_magic_new_hc_target = x_magic_new_hc_target.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/gre_tunnels/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&gre_tunnel_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(2usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
header_map.append(
"x-magic-new-hc-target",
x_magic_new_hc_target.to_string().try_into()?,
);
#[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: "magic_gre_tunnels_delete_gre_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 MagicIpsecTunnelsListIpsecTunnels<'a> {
client: &'a crate::Client,
account_id: Result<types::MagicIdentifier, String>,
x_magic_new_hc_target: Result<bool, String>,
}
impl<'a> MagicIpsecTunnelsListIpsecTunnels<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
x_magic_new_hc_target: Err("x_magic_new_hc_target was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for account_id failed".to_string());
self
}
pub fn x_magic_new_hc_target<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<bool>,
{
self.x_magic_new_hc_target = value
.try_into()
.map_err(|_| "conversion to `bool` for x_magic_new_hc_target 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,
x_magic_new_hc_target,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let x_magic_new_hc_target = x_magic_new_hc_target.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/ipsec_tunnels",
client.baseurl,
encode_path(&account_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(2usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
header_map.append(
"x-magic-new-hc-target",
x_magic_new_hc_target.to_string().try_into()?,
);
#[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: "magic_ipsec_tunnels_list_ipsec_tunnels",
};
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 MagicIpsecTunnelsCreateIpsecTunnels<'a> {
client: &'a crate::Client,
account_id: Result<types::MagicIdentifier, String>,
x_magic_new_hc_target: Result<bool, String>,
body: Result<types::MagicIpsecTunnelAddRequest, String>,
}
impl<'a> MagicIpsecTunnelsCreateIpsecTunnels<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
x_magic_new_hc_target: Err("x_magic_new_hc_target 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::MagicIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for account_id failed".to_string());
self
}
pub fn x_magic_new_hc_target<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<bool>,
{
self.x_magic_new_hc_target = value
.try_into()
.map_err(|_| "conversion to `bool` for x_magic_new_hc_target failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIpsecTunnelAddRequest>,
{
self.body = value.try_into().map_err(|_| {
"conversion to `MagicIpsecTunnelAddRequest` 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,
x_magic_new_hc_target,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let x_magic_new_hc_target = x_magic_new_hc_target.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/ipsec_tunnels",
client.baseurl,
encode_path(&account_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(2usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
header_map.append(
"x-magic-new-hc-target",
x_magic_new_hc_target.to_string().try_into()?,
);
#[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: "magic_ipsec_tunnels_create_ipsec_tunnels",
};
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 MagicIpsecTunnelsListIpsecTunnelDetails<'a> {
client: &'a crate::Client,
account_id: Result<types::MagicIdentifier, String>,
ipsec_tunnel_id: Result<types::MagicIdentifier, String>,
x_magic_new_hc_target: Result<bool, String>,
}
impl<'a> MagicIpsecTunnelsListIpsecTunnelDetails<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
ipsec_tunnel_id: Err("ipsec_tunnel_id was not initialized".to_string()),
x_magic_new_hc_target: Err("x_magic_new_hc_target was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for account_id failed".to_string());
self
}
pub fn ipsec_tunnel_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.ipsec_tunnel_id = value.try_into().map_err(|_| {
"conversion to `MagicIdentifier` for ipsec_tunnel_id failed".to_string()
});
self
}
pub fn x_magic_new_hc_target<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<bool>,
{
self.x_magic_new_hc_target = value
.try_into()
.map_err(|_| "conversion to `bool` for x_magic_new_hc_target 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,
ipsec_tunnel_id,
x_magic_new_hc_target,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let ipsec_tunnel_id = ipsec_tunnel_id.map_err(Error::InvalidRequest)?;
let x_magic_new_hc_target = x_magic_new_hc_target.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/ipsec_tunnels/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&ipsec_tunnel_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(2usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
header_map.append(
"x-magic-new-hc-target",
x_magic_new_hc_target.to_string().try_into()?,
);
#[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: "magic_ipsec_tunnels_list_ipsec_tunnel_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 MagicIpsecTunnelsUpdateIpsecTunnel<'a> {
client: &'a crate::Client,
account_id: Result<types::MagicIdentifier, String>,
ipsec_tunnel_id: Result<types::MagicIdentifier, String>,
x_magic_new_hc_target: Result<bool, String>,
body: Result<types::builder::MagicIpsecTunnelAddSingleRequest, String>,
}
impl<'a> MagicIpsecTunnelsUpdateIpsecTunnel<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
ipsec_tunnel_id: Err("ipsec_tunnel_id was not initialized".to_string()),
x_magic_new_hc_target: Err("x_magic_new_hc_target 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::MagicIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for account_id failed".to_string());
self
}
pub fn ipsec_tunnel_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.ipsec_tunnel_id = value.try_into().map_err(|_| {
"conversion to `MagicIdentifier` for ipsec_tunnel_id failed".to_string()
});
self
}
pub fn x_magic_new_hc_target<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<bool>,
{
self.x_magic_new_hc_target = value
.try_into()
.map_err(|_| "conversion to `bool` for x_magic_new_hc_target failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIpsecTunnelAddSingleRequest>,
<V as std::convert::TryInto<types::MagicIpsecTunnelAddSingleRequest>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `MagicIpsecTunnelAddSingleRequest` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::MagicIpsecTunnelAddSingleRequest,
) -> types::builder::MagicIpsecTunnelAddSingleRequest,
{
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,
ipsec_tunnel_id,
x_magic_new_hc_target,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let ipsec_tunnel_id = ipsec_tunnel_id.map_err(Error::InvalidRequest)?;
let x_magic_new_hc_target = x_magic_new_hc_target.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::MagicIpsecTunnelAddSingleRequest::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/ipsec_tunnels/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&ipsec_tunnel_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(2usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
header_map.append(
"x-magic-new-hc-target",
x_magic_new_hc_target.to_string().try_into()?,
);
#[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: "magic_ipsec_tunnels_update_ipsec_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 MagicIpsecTunnelsDeleteIpsecTunnel<'a> {
client: &'a crate::Client,
account_id: Result<types::MagicIdentifier, String>,
ipsec_tunnel_id: Result<types::MagicIdentifier, String>,
x_magic_new_hc_target: Result<bool, String>,
body: Result<::serde_json::Map<::std::string::String, ::serde_json::Value>, String>,
}
impl<'a> MagicIpsecTunnelsDeleteIpsecTunnel<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
ipsec_tunnel_id: Err("ipsec_tunnel_id was not initialized".to_string()),
x_magic_new_hc_target: Err("x_magic_new_hc_target 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::MagicIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for account_id failed".to_string());
self
}
pub fn ipsec_tunnel_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.ipsec_tunnel_id = value.try_into().map_err(|_| {
"conversion to `MagicIdentifier` for ipsec_tunnel_id failed".to_string()
});
self
}
pub fn x_magic_new_hc_target<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<bool>,
{
self.x_magic_new_hc_target = value
.try_into()
.map_err(|_| "conversion to `bool` for x_magic_new_hc_target 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,
ipsec_tunnel_id,
x_magic_new_hc_target,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let ipsec_tunnel_id = ipsec_tunnel_id.map_err(Error::InvalidRequest)?;
let x_magic_new_hc_target = x_magic_new_hc_target.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/ipsec_tunnels/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&ipsec_tunnel_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(2usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
header_map.append(
"x-magic-new-hc-target",
x_magic_new_hc_target.to_string().try_into()?,
);
#[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: "magic_ipsec_tunnels_delete_ipsec_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 MagicStaticRoutesRouteDetails<'a> {
client: &'a crate::Client,
account_id: Result<types::MagicIdentifier, String>,
route_id: Result<types::MagicIdentifier, String>,
}
impl<'a> MagicStaticRoutesRouteDetails<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
route_id: Err("route_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for account_id failed".to_string());
self
}
pub fn route_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.route_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for route_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,
route_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let route_id = route_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/routes/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&route_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: "magic_static_routes_route_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 MagicStaticRoutesUpdateRoute<'a> {
client: &'a crate::Client,
account_id: Result<types::MagicIdentifier, String>,
route_id: Result<types::MagicIdentifier, String>,
body: Result<types::MagicRouteUpdateRequest, String>,
}
impl<'a> MagicStaticRoutesUpdateRoute<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
route_id: Err("route_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::MagicIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for account_id failed".to_string());
self
}
pub fn route_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.route_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for route_id failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicRouteUpdateRequest>,
{
self.body = value
.try_into()
.map_err(|_| "conversion to `MagicRouteUpdateRequest` 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,
route_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let route_id = route_id.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/routes/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&route_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: "magic_static_routes_update_route",
};
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 MagicStaticRoutesDeleteRoute<'a> {
client: &'a crate::Client,
account_id: Result<types::MagicIdentifier, String>,
route_id: Result<types::MagicIdentifier, String>,
body: Result<::serde_json::Map<::std::string::String, ::serde_json::Value>, String>,
}
impl<'a> MagicStaticRoutesDeleteRoute<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
route_id: Err("route_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::MagicIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for account_id failed".to_string());
self
}
pub fn route_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.route_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for route_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,
route_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let route_id = route_id.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/routes/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&route_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: "magic_static_routes_delete_route",
};
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 MagicSitesSiteDetails<'a> {
client: &'a crate::Client,
account_id: Result<types::MagicIdentifier, String>,
site_id: Result<types::MagicIdentifier, String>,
x_magic_new_hc_target: Result<bool, String>,
}
impl<'a> MagicSitesSiteDetails<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
site_id: Err("site_id was not initialized".to_string()),
x_magic_new_hc_target: Err("x_magic_new_hc_target was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for account_id failed".to_string());
self
}
pub fn site_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.site_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for site_id failed".to_string());
self
}
pub fn x_magic_new_hc_target<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<bool>,
{
self.x_magic_new_hc_target = value
.try_into()
.map_err(|_| "conversion to `bool` for x_magic_new_hc_target 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,
site_id,
x_magic_new_hc_target,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let site_id = site_id.map_err(Error::InvalidRequest)?;
let x_magic_new_hc_target = x_magic_new_hc_target.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/sites/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&site_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(2usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
header_map.append(
"x-magic-new-hc-target",
x_magic_new_hc_target.to_string().try_into()?,
);
#[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: "magic_sites_site_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 MagicSitesUpdateSite<'a> {
client: &'a crate::Client,
account_id: Result<types::MagicIdentifier, String>,
site_id: Result<types::MagicIdentifier, String>,
body: Result<types::builder::MagicSiteUpdateRequest, String>,
}
impl<'a> MagicSitesUpdateSite<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
site_id: Err("site_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::MagicIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for account_id failed".to_string());
self
}
pub fn site_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.site_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for site_id failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicSiteUpdateRequest>,
<V as std::convert::TryInto<types::MagicSiteUpdateRequest>>::Error: std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `MagicSiteUpdateRequest` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::MagicSiteUpdateRequest,
) -> types::builder::MagicSiteUpdateRequest,
{
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,
site_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let site_id = site_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| types::MagicSiteUpdateRequest::try_from(v).map_err(|e| e.to_string()))
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/sites/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&site_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: "magic_sites_update_site",
};
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 MagicSitesDeleteSite<'a> {
client: &'a crate::Client,
account_id: Result<types::MagicIdentifier, String>,
site_id: Result<types::MagicIdentifier, String>,
body: Result<::serde_json::Map<::std::string::String, ::serde_json::Value>, String>,
}
impl<'a> MagicSitesDeleteSite<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
site_id: Err("site_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::MagicIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for account_id failed".to_string());
self
}
pub fn site_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.site_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for site_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,
site_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let site_id = site_id.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/sites/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&site_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: "magic_sites_delete_site",
};
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 MagicSitesPatchSite<'a> {
client: &'a crate::Client,
account_id: Result<types::MagicIdentifier, String>,
site_id: Result<types::MagicIdentifier, String>,
body: Result<types::builder::MagicSiteUpdateRequest, String>,
}
impl<'a> MagicSitesPatchSite<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
site_id: Err("site_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::MagicIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for account_id failed".to_string());
self
}
pub fn site_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.site_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for site_id failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicSiteUpdateRequest>,
<V as std::convert::TryInto<types::MagicSiteUpdateRequest>>::Error: std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `MagicSiteUpdateRequest` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::MagicSiteUpdateRequest,
) -> types::builder::MagicSiteUpdateRequest,
{
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,
site_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let site_id = site_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| types::MagicSiteUpdateRequest::try_from(v).map_err(|e| e.to_string()))
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/sites/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&site_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: "magic_sites_patch_site",
};
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 MagicSiteAclsListAcls<'a> {
client: &'a crate::Client,
account_id: Result<types::MagicIdentifier, String>,
site_id: Result<types::MagicIdentifier, String>,
}
impl<'a> MagicSiteAclsListAcls<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
site_id: Err("site_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for account_id failed".to_string());
self
}
pub fn site_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.site_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for site_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,
site_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let site_id = site_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/sites/{}/acls",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&site_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: "magic_site_acls_list_acls",
};
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 MagicSiteAclsCreateAcl<'a> {
client: &'a crate::Client,
account_id: Result<types::MagicIdentifier, String>,
site_id: Result<types::MagicIdentifier, String>,
body: Result<types::builder::MagicAclsAddSingleRequest, String>,
}
impl<'a> MagicSiteAclsCreateAcl<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
site_id: Err("site_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::MagicIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for account_id failed".to_string());
self
}
pub fn site_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.site_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for site_id failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicAclsAddSingleRequest>,
<V as std::convert::TryInto<types::MagicAclsAddSingleRequest>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `MagicAclsAddSingleRequest` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::MagicAclsAddSingleRequest,
) -> types::builder::MagicAclsAddSingleRequest,
{
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,
site_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let site_id = site_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::MagicAclsAddSingleRequest::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/sites/{}/acls",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&site_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: "magic_site_acls_create_acl",
};
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 MagicSiteAclsAclDetails<'a> {
client: &'a crate::Client,
account_id: Result<types::MagicIdentifier, String>,
site_id: Result<types::MagicIdentifier, String>,
acl_id: Result<types::MagicIdentifier, String>,
}
impl<'a> MagicSiteAclsAclDetails<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
site_id: Err("site_id was not initialized".to_string()),
acl_id: Err("acl_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for account_id failed".to_string());
self
}
pub fn site_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.site_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for site_id failed".to_string());
self
}
pub fn acl_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.acl_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for acl_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,
site_id,
acl_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let site_id = site_id.map_err(Error::InvalidRequest)?;
let acl_id = acl_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/sites/{}/acls/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&site_id.to_string()),
encode_path(&acl_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: "magic_site_acls_acl_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 MagicSiteAclsUpdateAcl<'a> {
client: &'a crate::Client,
account_id: Result<types::MagicIdentifier, String>,
site_id: Result<types::MagicIdentifier, String>,
acl_id: Result<types::MagicIdentifier, String>,
body: Result<types::builder::MagicAclUpdateRequest, String>,
}
impl<'a> MagicSiteAclsUpdateAcl<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
site_id: Err("site_id was not initialized".to_string()),
acl_id: Err("acl_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::MagicIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for account_id failed".to_string());
self
}
pub fn site_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.site_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for site_id failed".to_string());
self
}
pub fn acl_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.acl_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for acl_id failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicAclUpdateRequest>,
<V as std::convert::TryInto<types::MagicAclUpdateRequest>>::Error: std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `MagicAclUpdateRequest` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::MagicAclUpdateRequest,
) -> types::builder::MagicAclUpdateRequest,
{
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,
site_id,
acl_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let site_id = site_id.map_err(Error::InvalidRequest)?;
let acl_id = acl_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| types::MagicAclUpdateRequest::try_from(v).map_err(|e| e.to_string()))
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/sites/{}/acls/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&site_id.to_string()),
encode_path(&acl_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: "magic_site_acls_update_acl",
};
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 MagicSiteAclsDeleteAcl<'a> {
client: &'a crate::Client,
account_id: Result<types::MagicIdentifier, String>,
site_id: Result<types::MagicIdentifier, String>,
acl_id: Result<types::MagicIdentifier, String>,
body: Result<::serde_json::Map<::std::string::String, ::serde_json::Value>, String>,
}
impl<'a> MagicSiteAclsDeleteAcl<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
site_id: Err("site_id was not initialized".to_string()),
acl_id: Err("acl_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::MagicIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for account_id failed".to_string());
self
}
pub fn site_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.site_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for site_id failed".to_string());
self
}
pub fn acl_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.acl_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for acl_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,
site_id,
acl_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let site_id = site_id.map_err(Error::InvalidRequest)?;
let acl_id = acl_id.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/sites/{}/acls/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&site_id.to_string()),
encode_path(&acl_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: "magic_site_acls_delete_acl",
};
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 MagicSiteAclsPatchAcl<'a> {
client: &'a crate::Client,
account_id: Result<types::MagicIdentifier, String>,
site_id: Result<types::MagicIdentifier, String>,
acl_id: Result<types::MagicIdentifier, String>,
body: Result<types::builder::MagicAclUpdateRequest, String>,
}
impl<'a> MagicSiteAclsPatchAcl<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
site_id: Err("site_id was not initialized".to_string()),
acl_id: Err("acl_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::MagicIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for account_id failed".to_string());
self
}
pub fn site_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.site_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for site_id failed".to_string());
self
}
pub fn acl_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.acl_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for acl_id failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicAclUpdateRequest>,
<V as std::convert::TryInto<types::MagicAclUpdateRequest>>::Error: std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `MagicAclUpdateRequest` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::MagicAclUpdateRequest,
) -> types::builder::MagicAclUpdateRequest,
{
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,
site_id,
acl_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let site_id = site_id.map_err(Error::InvalidRequest)?;
let acl_id = acl_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| types::MagicAclUpdateRequest::try_from(v).map_err(|e| e.to_string()))
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/sites/{}/acls/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&site_id.to_string()),
encode_path(&acl_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: "magic_site_acls_patch_acl",
};
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 MagicSiteAppConfigsListAppConfigs<'a> {
client: &'a crate::Client,
account_id: Result<types::MagicIdentifier, String>,
site_id: Result<types::MagicIdentifier, String>,
}
impl<'a> MagicSiteAppConfigsListAppConfigs<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
site_id: Err("site_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for account_id failed".to_string());
self
}
pub fn site_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.site_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for site_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,
site_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let site_id = site_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/sites/{}/app_configs",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&site_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: "magic_site_app_configs_list_app_configs",
};
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 MagicSiteAppConfigsAddAppConfig<'a> {
client: &'a crate::Client,
account_id: Result<types::MagicIdentifier, String>,
site_id: Result<types::MagicIdentifier, String>,
body: Result<types::MagicAppConfigAddSingleRequest, String>,
}
impl<'a> MagicSiteAppConfigsAddAppConfig<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
site_id: Err("site_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::MagicIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for account_id failed".to_string());
self
}
pub fn site_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.site_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for site_id failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicAppConfigAddSingleRequest>,
{
self.body = value.try_into().map_err(|_| {
"conversion to `MagicAppConfigAddSingleRequest` 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,
site_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let site_id = site_id.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/sites/{}/app_configs",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&site_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: "magic_site_app_configs_add_app_config",
};
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() {
201u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct MagicSiteAppConfigsUpdateAppConfig<'a> {
client: &'a crate::Client,
account_id: Result<types::MagicIdentifier, String>,
site_id: Result<types::MagicIdentifier, String>,
app_config_id: Result<types::MagicIdentifier, String>,
body: Result<types::builder::MagicAppConfigUpdateRequest, String>,
}
impl<'a> MagicSiteAppConfigsUpdateAppConfig<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
site_id: Err("site_id was not initialized".to_string()),
app_config_id: Err("app_config_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::MagicIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for account_id failed".to_string());
self
}
pub fn site_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.site_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for site_id failed".to_string());
self
}
pub fn app_config_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.app_config_id = value.try_into().map_err(|_| {
"conversion to `MagicIdentifier` for app_config_id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicAppConfigUpdateRequest>,
<V as std::convert::TryInto<types::MagicAppConfigUpdateRequest>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `MagicAppConfigUpdateRequest` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::MagicAppConfigUpdateRequest,
) -> types::builder::MagicAppConfigUpdateRequest,
{
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,
site_id,
app_config_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let site_id = site_id.map_err(Error::InvalidRequest)?;
let app_config_id = app_config_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::MagicAppConfigUpdateRequest::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/sites/{}/app_configs/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&site_id.to_string()),
encode_path(&app_config_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: "magic_site_app_configs_update_app_config",
};
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 MagicSiteAppConfigsDeleteAppConfig<'a> {
client: &'a crate::Client,
account_id: Result<types::MagicIdentifier, String>,
site_id: Result<types::MagicIdentifier, String>,
app_config_id: Result<types::MagicIdentifier, String>,
}
impl<'a> MagicSiteAppConfigsDeleteAppConfig<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
site_id: Err("site_id was not initialized".to_string()),
app_config_id: Err("app_config_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for account_id failed".to_string());
self
}
pub fn site_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.site_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for site_id failed".to_string());
self
}
pub fn app_config_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.app_config_id = value.try_into().map_err(|_| {
"conversion to `MagicIdentifier` for app_config_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,
site_id,
app_config_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let site_id = site_id.map_err(Error::InvalidRequest)?;
let app_config_id = app_config_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/sites/{}/app_configs/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&site_id.to_string()),
encode_path(&app_config_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: "magic_site_app_configs_delete_app_config",
};
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 MagicSiteAppConfigsPatchAppConfig<'a> {
client: &'a crate::Client,
account_id: Result<types::MagicIdentifier, String>,
site_id: Result<types::MagicIdentifier, String>,
app_config_id: Result<types::MagicIdentifier, String>,
body: Result<types::builder::MagicAppConfigUpdateRequest, String>,
}
impl<'a> MagicSiteAppConfigsPatchAppConfig<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
site_id: Err("site_id was not initialized".to_string()),
app_config_id: Err("app_config_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::MagicIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for account_id failed".to_string());
self
}
pub fn site_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.site_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for site_id failed".to_string());
self
}
pub fn app_config_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.app_config_id = value.try_into().map_err(|_| {
"conversion to `MagicIdentifier` for app_config_id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicAppConfigUpdateRequest>,
<V as std::convert::TryInto<types::MagicAppConfigUpdateRequest>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `MagicAppConfigUpdateRequest` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::MagicAppConfigUpdateRequest,
) -> types::builder::MagicAppConfigUpdateRequest,
{
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,
site_id,
app_config_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let site_id = site_id.map_err(Error::InvalidRequest)?;
let app_config_id = app_config_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::MagicAppConfigUpdateRequest::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/sites/{}/app_configs/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&site_id.to_string()),
encode_path(&app_config_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: "magic_site_app_configs_patch_app_config",
};
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 MagicSiteLansListLans<'a> {
client: &'a crate::Client,
account_id: Result<types::MagicIdentifier, String>,
site_id: Result<types::MagicIdentifier, String>,
}
impl<'a> MagicSiteLansListLans<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
site_id: Err("site_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for account_id failed".to_string());
self
}
pub fn site_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.site_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for site_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,
site_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let site_id = site_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/sites/{}/lans",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&site_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: "magic_site_lans_list_lans",
};
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 MagicSiteLansCreateLan<'a> {
client: &'a crate::Client,
account_id: Result<types::MagicIdentifier, String>,
site_id: Result<types::MagicIdentifier, String>,
body: Result<types::builder::MagicLansAddSingleRequest, String>,
}
impl<'a> MagicSiteLansCreateLan<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
site_id: Err("site_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::MagicIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for account_id failed".to_string());
self
}
pub fn site_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.site_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for site_id failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicLansAddSingleRequest>,
<V as std::convert::TryInto<types::MagicLansAddSingleRequest>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `MagicLansAddSingleRequest` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::MagicLansAddSingleRequest,
) -> types::builder::MagicLansAddSingleRequest,
{
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,
site_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let site_id = site_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::MagicLansAddSingleRequest::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/sites/{}/lans",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&site_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: "magic_site_lans_create_lan",
};
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 MagicSiteLansLanDetails<'a> {
client: &'a crate::Client,
account_id: Result<types::MagicIdentifier, String>,
site_id: Result<types::MagicIdentifier, String>,
lan_id: Result<types::MagicIdentifier, String>,
}
impl<'a> MagicSiteLansLanDetails<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
site_id: Err("site_id was not initialized".to_string()),
lan_id: Err("lan_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for account_id failed".to_string());
self
}
pub fn site_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.site_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for site_id failed".to_string());
self
}
pub fn lan_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.lan_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for lan_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,
site_id,
lan_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let site_id = site_id.map_err(Error::InvalidRequest)?;
let lan_id = lan_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/sites/{}/lans/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&site_id.to_string()),
encode_path(&lan_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: "magic_site_lans_lan_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 MagicSiteLansUpdateLan<'a> {
client: &'a crate::Client,
account_id: Result<types::MagicIdentifier, String>,
site_id: Result<types::MagicIdentifier, String>,
lan_id: Result<types::MagicIdentifier, String>,
body: Result<types::builder::MagicLanUpdateRequest, String>,
}
impl<'a> MagicSiteLansUpdateLan<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
site_id: Err("site_id was not initialized".to_string()),
lan_id: Err("lan_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::MagicIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for account_id failed".to_string());
self
}
pub fn site_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.site_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for site_id failed".to_string());
self
}
pub fn lan_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.lan_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for lan_id failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicLanUpdateRequest>,
<V as std::convert::TryInto<types::MagicLanUpdateRequest>>::Error: std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `MagicLanUpdateRequest` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::MagicLanUpdateRequest,
) -> types::builder::MagicLanUpdateRequest,
{
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,
site_id,
lan_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let site_id = site_id.map_err(Error::InvalidRequest)?;
let lan_id = lan_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| types::MagicLanUpdateRequest::try_from(v).map_err(|e| e.to_string()))
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/sites/{}/lans/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&site_id.to_string()),
encode_path(&lan_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: "magic_site_lans_update_lan",
};
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 MagicSiteLansDeleteLan<'a> {
client: &'a crate::Client,
account_id: Result<types::MagicIdentifier, String>,
site_id: Result<types::MagicIdentifier, String>,
lan_id: Result<types::MagicIdentifier, String>,
body: Result<::serde_json::Map<::std::string::String, ::serde_json::Value>, String>,
}
impl<'a> MagicSiteLansDeleteLan<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
site_id: Err("site_id was not initialized".to_string()),
lan_id: Err("lan_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::MagicIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for account_id failed".to_string());
self
}
pub fn site_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.site_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for site_id failed".to_string());
self
}
pub fn lan_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.lan_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for lan_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,
site_id,
lan_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let site_id = site_id.map_err(Error::InvalidRequest)?;
let lan_id = lan_id.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/sites/{}/lans/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&site_id.to_string()),
encode_path(&lan_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: "magic_site_lans_delete_lan",
};
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 MagicSiteLansPatchLan<'a> {
client: &'a crate::Client,
account_id: Result<types::MagicIdentifier, String>,
site_id: Result<types::MagicIdentifier, String>,
lan_id: Result<types::MagicIdentifier, String>,
body: Result<types::builder::MagicLanUpdateRequest, String>,
}
impl<'a> MagicSiteLansPatchLan<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
site_id: Err("site_id was not initialized".to_string()),
lan_id: Err("lan_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::MagicIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for account_id failed".to_string());
self
}
pub fn site_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.site_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for site_id failed".to_string());
self
}
pub fn lan_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.lan_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for lan_id failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicLanUpdateRequest>,
<V as std::convert::TryInto<types::MagicLanUpdateRequest>>::Error: std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `MagicLanUpdateRequest` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::MagicLanUpdateRequest,
) -> types::builder::MagicLanUpdateRequest,
{
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,
site_id,
lan_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let site_id = site_id.map_err(Error::InvalidRequest)?;
let lan_id = lan_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| types::MagicLanUpdateRequest::try_from(v).map_err(|e| e.to_string()))
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/sites/{}/lans/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&site_id.to_string()),
encode_path(&lan_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: "magic_site_lans_patch_lan",
};
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 MagicSiteNetflowConfigDetails<'a> {
client: &'a crate::Client,
account_id: Result<types::MagicIdentifier, String>,
site_id: Result<types::MagicIdentifier, String>,
}
impl<'a> MagicSiteNetflowConfigDetails<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
site_id: Err("site_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for account_id failed".to_string());
self
}
pub fn site_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.site_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for site_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,
site_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let site_id = site_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/sites/{}/netflow_config",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&site_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: "magic_site_netflow_config_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 MagicSiteNetflowConfigUpdateNetflowConfig<'a> {
client: &'a crate::Client,
account_id: Result<types::MagicIdentifier, String>,
site_id: Result<types::MagicIdentifier, String>,
body: Result<types::builder::MagicNetflowConfigRequest, String>,
}
impl<'a> MagicSiteNetflowConfigUpdateNetflowConfig<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
site_id: Err("site_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::MagicIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for account_id failed".to_string());
self
}
pub fn site_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.site_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for site_id failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicNetflowConfigRequest>,
<V as std::convert::TryInto<types::MagicNetflowConfigRequest>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `MagicNetflowConfigRequest` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::MagicNetflowConfigRequest,
) -> types::builder::MagicNetflowConfigRequest,
{
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,
site_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let site_id = site_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::MagicNetflowConfigRequest::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/sites/{}/netflow_config",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&site_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: "magic_site_netflow_config_update_netflow_config",
};
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 MagicSiteNetflowConfigCreateNetflowConfig<'a> {
client: &'a crate::Client,
account_id: Result<types::MagicIdentifier, String>,
site_id: Result<types::MagicIdentifier, String>,
body: Result<types::builder::MagicNetflowConfigRequest, String>,
}
impl<'a> MagicSiteNetflowConfigCreateNetflowConfig<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
site_id: Err("site_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::MagicIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for account_id failed".to_string());
self
}
pub fn site_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.site_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for site_id failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicNetflowConfigRequest>,
<V as std::convert::TryInto<types::MagicNetflowConfigRequest>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `MagicNetflowConfigRequest` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::MagicNetflowConfigRequest,
) -> types::builder::MagicNetflowConfigRequest,
{
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,
site_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let site_id = site_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::MagicNetflowConfigRequest::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/sites/{}/netflow_config",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&site_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: "magic_site_netflow_config_create_netflow_config",
};
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() {
201u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct MagicSiteNetflowConfigDeleteNetflowConfig<'a> {
client: &'a crate::Client,
account_id: Result<types::MagicIdentifier, String>,
site_id: Result<types::MagicIdentifier, String>,
body: Result<::serde_json::Map<::std::string::String, ::serde_json::Value>, String>,
}
impl<'a> MagicSiteNetflowConfigDeleteNetflowConfig<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
site_id: Err("site_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::MagicIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for account_id failed".to_string());
self
}
pub fn site_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.site_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for site_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,
site_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let site_id = site_id.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/sites/{}/netflow_config",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&site_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: "magic_site_netflow_config_delete_netflow_config",
};
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 MagicSiteNetflowConfigPatchNetflowConfig<'a> {
client: &'a crate::Client,
account_id: Result<types::MagicIdentifier, String>,
site_id: Result<types::MagicIdentifier, String>,
body: Result<types::builder::MagicNetflowConfigRequest, String>,
}
impl<'a> MagicSiteNetflowConfigPatchNetflowConfig<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
site_id: Err("site_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::MagicIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for account_id failed".to_string());
self
}
pub fn site_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.site_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for site_id failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicNetflowConfigRequest>,
<V as std::convert::TryInto<types::MagicNetflowConfigRequest>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `MagicNetflowConfigRequest` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::MagicNetflowConfigRequest,
) -> types::builder::MagicNetflowConfigRequest,
{
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,
site_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let site_id = site_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::MagicNetflowConfigRequest::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/sites/{}/netflow_config",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&site_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: "magic_site_netflow_config_patch_netflow_config",
};
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 MagicSiteWansListWans<'a> {
client: &'a crate::Client,
account_id: Result<types::MagicIdentifier, String>,
site_id: Result<types::MagicIdentifier, String>,
}
impl<'a> MagicSiteWansListWans<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
site_id: Err("site_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for account_id failed".to_string());
self
}
pub fn site_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.site_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for site_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,
site_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let site_id = site_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/sites/{}/wans",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&site_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: "magic_site_wans_list_wans",
};
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 MagicSiteWansCreateWan<'a> {
client: &'a crate::Client,
account_id: Result<types::MagicIdentifier, String>,
site_id: Result<types::MagicIdentifier, String>,
body: Result<types::builder::MagicWansAddSingleRequest, String>,
}
impl<'a> MagicSiteWansCreateWan<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
site_id: Err("site_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::MagicIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for account_id failed".to_string());
self
}
pub fn site_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.site_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for site_id failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicWansAddSingleRequest>,
<V as std::convert::TryInto<types::MagicWansAddSingleRequest>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `MagicWansAddSingleRequest` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::MagicWansAddSingleRequest,
) -> types::builder::MagicWansAddSingleRequest,
{
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,
site_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let site_id = site_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::MagicWansAddSingleRequest::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/sites/{}/wans",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&site_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: "magic_site_wans_create_wan",
};
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 MagicSiteWansWanDetails<'a> {
client: &'a crate::Client,
account_id: Result<types::MagicIdentifier, String>,
site_id: Result<types::MagicIdentifier, String>,
wan_id: Result<types::MagicIdentifier, String>,
}
impl<'a> MagicSiteWansWanDetails<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
site_id: Err("site_id was not initialized".to_string()),
wan_id: Err("wan_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for account_id failed".to_string());
self
}
pub fn site_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.site_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for site_id failed".to_string());
self
}
pub fn wan_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.wan_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for wan_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,
site_id,
wan_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let site_id = site_id.map_err(Error::InvalidRequest)?;
let wan_id = wan_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/sites/{}/wans/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&site_id.to_string()),
encode_path(&wan_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: "magic_site_wans_wan_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 MagicSiteWansUpdateWan<'a> {
client: &'a crate::Client,
account_id: Result<types::MagicIdentifier, String>,
site_id: Result<types::MagicIdentifier, String>,
wan_id: Result<types::MagicIdentifier, String>,
body: Result<types::builder::MagicWanUpdateRequest, String>,
}
impl<'a> MagicSiteWansUpdateWan<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
site_id: Err("site_id was not initialized".to_string()),
wan_id: Err("wan_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::MagicIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for account_id failed".to_string());
self
}
pub fn site_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.site_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for site_id failed".to_string());
self
}
pub fn wan_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.wan_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for wan_id failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicWanUpdateRequest>,
<V as std::convert::TryInto<types::MagicWanUpdateRequest>>::Error: std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `MagicWanUpdateRequest` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::MagicWanUpdateRequest,
) -> types::builder::MagicWanUpdateRequest,
{
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,
site_id,
wan_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let site_id = site_id.map_err(Error::InvalidRequest)?;
let wan_id = wan_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| types::MagicWanUpdateRequest::try_from(v).map_err(|e| e.to_string()))
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/sites/{}/wans/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&site_id.to_string()),
encode_path(&wan_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: "magic_site_wans_update_wan",
};
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 MagicSiteWansDeleteWan<'a> {
client: &'a crate::Client,
account_id: Result<types::MagicIdentifier, String>,
site_id: Result<types::MagicIdentifier, String>,
wan_id: Result<types::MagicIdentifier, String>,
body: Result<::serde_json::Map<::std::string::String, ::serde_json::Value>, String>,
}
impl<'a> MagicSiteWansDeleteWan<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
site_id: Err("site_id was not initialized".to_string()),
wan_id: Err("wan_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::MagicIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for account_id failed".to_string());
self
}
pub fn site_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.site_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for site_id failed".to_string());
self
}
pub fn wan_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.wan_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for wan_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,
site_id,
wan_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let site_id = site_id.map_err(Error::InvalidRequest)?;
let wan_id = wan_id.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/sites/{}/wans/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&site_id.to_string()),
encode_path(&wan_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: "magic_site_wans_delete_wan",
};
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 MagicSiteWansPatchWan<'a> {
client: &'a crate::Client,
account_id: Result<types::MagicIdentifier, String>,
site_id: Result<types::MagicIdentifier, String>,
wan_id: Result<types::MagicIdentifier, String>,
body: Result<types::builder::MagicWanUpdateRequest, String>,
}
impl<'a> MagicSiteWansPatchWan<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
site_id: Err("site_id was not initialized".to_string()),
wan_id: Err("wan_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::MagicIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for account_id failed".to_string());
self
}
pub fn site_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.site_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for site_id failed".to_string());
self
}
pub fn wan_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicIdentifier>,
{
self.wan_id = value
.try_into()
.map_err(|_| "conversion to `MagicIdentifier` for wan_id failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicWanUpdateRequest>,
<V as std::convert::TryInto<types::MagicWanUpdateRequest>>::Error: std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `MagicWanUpdateRequest` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::MagicWanUpdateRequest,
) -> types::builder::MagicWanUpdateRequest,
{
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,
site_id,
wan_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let site_id = site_id.map_err(Error::InvalidRequest)?;
let wan_id = wan_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| types::MagicWanUpdateRequest::try_from(v).map_err(|e| e.to_string()))
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/sites/{}/wans/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&site_id.to_string()),
encode_path(&wan_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: "magic_site_wans_patch_wan",
};
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 MagicNetworkMonitoringRulesGetRule<'a> {
client: &'a crate::Client,
account_id: Result<types::MagicVisibilityMnmAccountIdentifier, String>,
rule_id: Result<types::MagicVisibilityMnmRuleIdentifier, String>,
}
impl<'a> MagicNetworkMonitoringRulesGetRule<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
rule_id: Err("rule_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicVisibilityMnmAccountIdentifier>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `MagicVisibilityMnmAccountIdentifier` for account_id failed"
.to_string()
});
self
}
pub fn rule_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicVisibilityMnmRuleIdentifier>,
{
self.rule_id = value.try_into().map_err(|_| {
"conversion to `MagicVisibilityMnmRuleIdentifier` for rule_id failed".to_string()
});
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
rule_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let rule_id = rule_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/mnm/rules/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&rule_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.get(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "magic_network_monitoring_rules_get_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 MagicNetworkMonitoringRulesDeleteRule<'a> {
client: &'a crate::Client,
account_id: Result<types::MagicVisibilityMnmAccountIdentifier, String>,
rule_id: Result<types::MagicVisibilityMnmRuleIdentifier, String>,
body: Result<::serde_json::Map<::std::string::String, ::serde_json::Value>, String>,
}
impl<'a> MagicNetworkMonitoringRulesDeleteRule<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
rule_id: Err("rule_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::MagicVisibilityMnmAccountIdentifier>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `MagicVisibilityMnmAccountIdentifier` for account_id failed"
.to_string()
});
self
}
pub fn rule_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicVisibilityMnmRuleIdentifier>,
{
self.rule_id = value.try_into().map_err(|_| {
"conversion to `MagicVisibilityMnmRuleIdentifier` for rule_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,
rule_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let rule_id = rule_id.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/mnm/rules/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&rule_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.delete(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "magic_network_monitoring_rules_delete_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 MagicNetworkMonitoringRulesUpdateRule<'a> {
client: &'a crate::Client,
account_id: Result<types::MagicVisibilityMnmAccountIdentifier, String>,
rule_id: Result<types::MagicVisibilityMnmRuleIdentifier, String>,
body: Result<types::builder::MagicNetworkMonitoringRulesUpdateRuleBody, String>,
}
impl<'a> MagicNetworkMonitoringRulesUpdateRule<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
rule_id: Err("rule_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::MagicVisibilityMnmAccountIdentifier>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `MagicVisibilityMnmAccountIdentifier` for account_id failed"
.to_string()
});
self
}
pub fn rule_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicVisibilityMnmRuleIdentifier>,
{
self.rule_id = value.try_into().map_err(|_| {
"conversion to `MagicVisibilityMnmRuleIdentifier` for rule_id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicNetworkMonitoringRulesUpdateRuleBody>,
<V as std::convert::TryInto<types::MagicNetworkMonitoringRulesUpdateRuleBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `MagicNetworkMonitoringRulesUpdateRuleBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::MagicNetworkMonitoringRulesUpdateRuleBody,
)
-> types::builder::MagicNetworkMonitoringRulesUpdateRuleBody,
{
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,
rule_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let rule_id = rule_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::MagicNetworkMonitoringRulesUpdateRuleBody::try_from(v)
.map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/mnm/rules/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&rule_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.patch(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "magic_network_monitoring_rules_update_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 MagicPcapCollectionDownloadSimplePcap<'a> {
client: &'a crate::Client,
account_id: Result<types::MagicVisibilityPcapsIdentifier, String>,
pcap_id: Result<types::MagicVisibilityPcapsIdentifier, String>,
}
impl<'a> MagicPcapCollectionDownloadSimplePcap<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
pcap_id: Err("pcap_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicVisibilityPcapsIdentifier>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `MagicVisibilityPcapsIdentifier` for account_id failed".to_string()
});
self
}
pub fn pcap_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicVisibilityPcapsIdentifier>,
{
self.pcap_id = value.try_into().map_err(|_| {
"conversion to `MagicVisibilityPcapsIdentifier` for pcap_id failed".to_string()
});
self
}
pub async fn send(self) -> Result<ResponseValue<ByteStream>, Error<()>> {
let Self {
client,
account_id,
pcap_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let pcap_id = pcap_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/pcaps/{}/download",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&pcap_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: "magic_pcap_collection_download_simple_pcap",
};
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 MagicPcapCollectionStopFullPcap<'a> {
client: &'a crate::Client,
account_id: Result<types::MagicVisibilityPcapsIdentifier, String>,
pcap_id: Result<types::MagicVisibilityPcapsIdentifier, String>,
}
impl<'a> MagicPcapCollectionStopFullPcap<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
pcap_id: Err("pcap_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicVisibilityPcapsIdentifier>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `MagicVisibilityPcapsIdentifier` for account_id failed".to_string()
});
self
}
pub fn pcap_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::MagicVisibilityPcapsIdentifier>,
{
self.pcap_id = value.try_into().map_err(|_| {
"conversion to `MagicVisibilityPcapsIdentifier` for pcap_id failed".to_string()
});
self
}
pub async fn send(self) -> Result<ResponseValue<()>, Error<()>> {
let Self {
client,
account_id,
pcap_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let pcap_id = pcap_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/pcaps/{}/stop",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&pcap_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).headers(header_map).build()?;
let info = OperationInfo {
operation_id: "magic_pcap_collection_stop_full_pcap",
};
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)),
}
}
}