use super::types;
use crate::{
ByteStream, ClientHooks, ClientInfo, Error, OperationInfo, RequestBuilderExt,
ResponseValue, encode_path,
};
#[derive(Debug, Clone)]
pub struct OnrampsList<'a> {
client: &'a crate::Client,
account_id: Result<types::McnAccountId, String>,
desc: Result<bool, String>,
order_by: Result<::std::string::String, String>,
status: Result<bool, String>,
vpcs: Result<bool, String>,
}
impl<'a> OnrampsList<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
desc: Err("desc was not initialized".to_string()),
order_by: Err("order_by was not initialized".to_string()),
status: Err("status was not initialized".to_string()),
vpcs: Err("vpcs was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::McnAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `McnAccountId` for account_id failed".to_string());
self
}
pub fn desc<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<bool>,
{
self.desc = value
.try_into()
.map_err(|_| "conversion to `bool` for desc failed".to_string());
self
}
pub fn order_by<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.order_by = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for order_by failed".to_string()
});
self
}
pub fn status<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<bool>,
{
self.status = value
.try_into()
.map_err(|_| "conversion to `bool` for status failed".to_string());
self
}
pub fn vpcs<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<bool>,
{
self.vpcs = value
.try_into()
.map_err(|_| "conversion to `bool` for vpcs 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,
desc,
order_by,
status,
vpcs,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let desc = desc.map_err(Error::InvalidRequest)?;
let order_by = order_by.map_err(Error::InvalidRequest)?;
let status = status.map_err(Error::InvalidRequest)?;
let vpcs = vpcs.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/cloud/onramps",
client.baseurl,
encode_path(&account_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.get(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.query(&progenitor_client::QueryParam::new("desc", &desc))
.query(&progenitor_client::QueryParam::new("order_by", &order_by))
.query(&progenitor_client::QueryParam::new("status", &status))
.query(&progenitor_client::QueryParam::new("vpcs", &vpcs))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "onramps_list",
};
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 OnrampsCreate<'a> {
client: &'a crate::Client,
account_id: Result<types::McnAccountId, String>,
forwarded: Result<::std::string::String, String>,
body: Result<types::builder::McnCreateOnrampRequest, String>,
}
impl<'a> OnrampsCreate<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
forwarded: Err("forwarded 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::McnAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `McnAccountId` for account_id failed".to_string());
self
}
pub fn forwarded<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.forwarded = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for forwarded failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::McnCreateOnrampRequest>,
<V as std::convert::TryInto<types::McnCreateOnrampRequest>>::Error: std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `McnCreateOnrampRequest` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::McnCreateOnrampRequest,
) -> types::builder::McnCreateOnrampRequest,
{
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,
forwarded,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let forwarded = forwarded.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| types::McnCreateOnrampRequest::try_from(v).map_err(|e| e.to_string()))
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/cloud/onramps",
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("forwarded", forwarded.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: "onramps_create",
};
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 OnrampsRead<'a> {
client: &'a crate::Client,
account_id: Result<types::McnAccountId, String>,
onramp_id: Result<types::McnOnrampId, String>,
planned_resources: Result<bool, String>,
post_apply_resources: Result<bool, String>,
status: Result<bool, String>,
vpcs: Result<bool, String>,
}
impl<'a> OnrampsRead<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
onramp_id: Err("onramp_id was not initialized".to_string()),
planned_resources: Err("planned_resources was not initialized".to_string()),
post_apply_resources: Err("post_apply_resources was not initialized".to_string()),
status: Err("status was not initialized".to_string()),
vpcs: Err("vpcs was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::McnAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `McnAccountId` for account_id failed".to_string());
self
}
pub fn onramp_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::McnOnrampId>,
{
self.onramp_id = value
.try_into()
.map_err(|_| "conversion to `McnOnrampId` for onramp_id failed".to_string());
self
}
pub fn planned_resources<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<bool>,
{
self.planned_resources = value
.try_into()
.map_err(|_| "conversion to `bool` for planned_resources failed".to_string());
self
}
pub fn post_apply_resources<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<bool>,
{
self.post_apply_resources = value
.try_into()
.map_err(|_| "conversion to `bool` for post_apply_resources failed".to_string());
self
}
pub fn status<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<bool>,
{
self.status = value
.try_into()
.map_err(|_| "conversion to `bool` for status failed".to_string());
self
}
pub fn vpcs<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<bool>,
{
self.vpcs = value
.try_into()
.map_err(|_| "conversion to `bool` for vpcs 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,
onramp_id,
planned_resources,
post_apply_resources,
status,
vpcs,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let onramp_id = onramp_id.map_err(Error::InvalidRequest)?;
let planned_resources = planned_resources.map_err(Error::InvalidRequest)?;
let post_apply_resources = post_apply_resources.map_err(Error::InvalidRequest)?;
let status = status.map_err(Error::InvalidRequest)?;
let vpcs = vpcs.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/cloud/onramps/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&onramp_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"),
)
.query(&progenitor_client::QueryParam::new(
"planned_resources",
&planned_resources,
))
.query(&progenitor_client::QueryParam::new(
"post_apply_resources",
&post_apply_resources,
))
.query(&progenitor_client::QueryParam::new("status", &status))
.query(&progenitor_client::QueryParam::new("vpcs", &vpcs))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "onramps_read",
};
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 OnrampsUpdate<'a> {
client: &'a crate::Client,
account_id: Result<types::McnAccountId, String>,
onramp_id: Result<types::McnOnrampId, String>,
body: Result<types::builder::McnUpdateOnrampRequest, String>,
}
impl<'a> OnrampsUpdate<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
onramp_id: Err("onramp_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::McnAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `McnAccountId` for account_id failed".to_string());
self
}
pub fn onramp_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::McnOnrampId>,
{
self.onramp_id = value
.try_into()
.map_err(|_| "conversion to `McnOnrampId` for onramp_id failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::McnUpdateOnrampRequest>,
<V as std::convert::TryInto<types::McnUpdateOnrampRequest>>::Error: std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `McnUpdateOnrampRequest` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::McnUpdateOnrampRequest,
) -> types::builder::McnUpdateOnrampRequest,
{
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,
onramp_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let onramp_id = onramp_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| types::McnUpdateOnrampRequest::try_from(v).map_err(|e| e.to_string()))
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/cloud/onramps/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&onramp_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: "onramps_update",
};
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 OnrampsDelete<'a> {
client: &'a crate::Client,
account_id: Result<types::McnAccountId, String>,
onramp_id: Result<types::McnOnrampId, String>,
destroy: Result<bool, String>,
force: Result<bool, String>,
}
impl<'a> OnrampsDelete<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
onramp_id: Err("onramp_id was not initialized".to_string()),
destroy: Err("destroy was not initialized".to_string()),
force: Err("force was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::McnAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `McnAccountId` for account_id failed".to_string());
self
}
pub fn onramp_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::McnOnrampId>,
{
self.onramp_id = value
.try_into()
.map_err(|_| "conversion to `McnOnrampId` for onramp_id failed".to_string());
self
}
pub fn destroy<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<bool>,
{
self.destroy = value
.try_into()
.map_err(|_| "conversion to `bool` for destroy failed".to_string());
self
}
pub fn force<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<bool>,
{
self.force = value
.try_into()
.map_err(|_| "conversion to `bool` for force 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,
onramp_id,
destroy,
force,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let onramp_id = onramp_id.map_err(Error::InvalidRequest)?;
let destroy = destroy.map_err(Error::InvalidRequest)?;
let force = force.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/cloud/onramps/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&onramp_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"),
)
.query(&progenitor_client::QueryParam::new("destroy", &destroy))
.query(&progenitor_client::QueryParam::new("force", &force))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "onramps_delete",
};
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 OnrampsPatch<'a> {
client: &'a crate::Client,
account_id: Result<types::McnAccountId, String>,
onramp_id: Result<types::McnOnrampId, String>,
body: Result<types::builder::McnUpdateOnrampRequest, String>,
}
impl<'a> OnrampsPatch<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
onramp_id: Err("onramp_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::McnAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `McnAccountId` for account_id failed".to_string());
self
}
pub fn onramp_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::McnOnrampId>,
{
self.onramp_id = value
.try_into()
.map_err(|_| "conversion to `McnOnrampId` for onramp_id failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::McnUpdateOnrampRequest>,
<V as std::convert::TryInto<types::McnUpdateOnrampRequest>>::Error: std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `McnUpdateOnrampRequest` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::McnUpdateOnrampRequest,
) -> types::builder::McnUpdateOnrampRequest,
{
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,
onramp_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let onramp_id = onramp_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| types::McnUpdateOnrampRequest::try_from(v).map_err(|e| e.to_string()))
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/cloud/onramps/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&onramp_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: "onramps_patch",
};
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 OnrampsApply<'a> {
client: &'a crate::Client,
account_id: Result<types::McnAccountId, String>,
onramp_id: Result<types::McnOnrampId, String>,
}
impl<'a> OnrampsApply<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
onramp_id: Err("onramp_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::McnAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `McnAccountId` for account_id failed".to_string());
self
}
pub fn onramp_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::McnOnrampId>,
{
self.onramp_id = value
.try_into()
.map_err(|_| "conversion to `McnOnrampId` for onramp_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,
onramp_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let onramp_id = onramp_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/cloud/onramps/{}/apply",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&onramp_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.post(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "onramps_apply",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
202u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct OnrampsExport<'a> {
client: &'a crate::Client,
account_id: Result<types::McnAccountId, String>,
onramp_id: Result<types::McnOnrampId, String>,
}
impl<'a> OnrampsExport<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
onramp_id: Err("onramp_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::McnAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `McnAccountId` for account_id failed".to_string());
self
}
pub fn onramp_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::McnOnrampId>,
{
self.onramp_id = value
.try_into()
.map_err(|_| "conversion to `McnOnrampId` for onramp_id failed".to_string());
self
}
pub async fn send(self) -> Result<ResponseValue<ByteStream>, Error<()>> {
let Self {
client,
account_id,
onramp_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let onramp_id = onramp_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/cloud/onramps/{}/export",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&onramp_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).headers(header_map).build()?;
let info = OperationInfo {
operation_id: "onramps_export",
};
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 => Ok(ResponseValue::stream(response)),
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct OnrampsPlan<'a> {
client: &'a crate::Client,
account_id: Result<types::McnAccountId, String>,
onramp_id: Result<types::McnOnrampId, String>,
}
impl<'a> OnrampsPlan<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
onramp_id: Err("onramp_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::McnAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `McnAccountId` for account_id failed".to_string());
self
}
pub fn onramp_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::McnOnrampId>,
{
self.onramp_id = value
.try_into()
.map_err(|_| "conversion to `McnOnrampId` for onramp_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,
onramp_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let onramp_id = onramp_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/cloud/onramps/{}/plan",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&onramp_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.post(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "onramps_plan",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
202u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct OnrampsMwanAddrSpaceRead<'a> {
client: &'a crate::Client,
account_id: Result<types::McnAccountId, String>,
}
impl<'a> OnrampsMwanAddrSpaceRead<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::McnAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `McnAccountId` for account_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 } = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/cloud/onramps/magic_wan_address_space",
client.baseurl,
encode_path(&account_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.get(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "onramps_mwan_addr_space_read",
};
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 OnrampsMwanAddrSpaceUpdate<'a> {
client: &'a crate::Client,
account_id: Result<types::McnAccountId, String>,
body: Result<types::builder::McnUpdateMagicWanAddressSpaceRequest, String>,
}
impl<'a> OnrampsMwanAddrSpaceUpdate<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
body: Ok(::std::default::Default::default()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::McnAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `McnAccountId` for account_id failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::McnUpdateMagicWanAddressSpaceRequest>,
<V as std::convert::TryInto<types::McnUpdateMagicWanAddressSpaceRequest>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `McnUpdateMagicWanAddressSpaceRequest` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::McnUpdateMagicWanAddressSpaceRequest,
)
-> types::builder::McnUpdateMagicWanAddressSpaceRequest,
{
self.body = self.body.map(f);
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::McnUpdateMagicWanAddressSpaceRequest::try_from(v)
.map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/cloud/onramps/magic_wan_address_space",
client.baseurl,
encode_path(&account_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.put(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "onramps_mwan_addr_space_update",
};
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 OnrampsMwanAddrSpacePatch<'a> {
client: &'a crate::Client,
account_id: Result<types::McnAccountId, String>,
body: Result<types::builder::McnUpdateMagicWanAddressSpaceRequest, String>,
}
impl<'a> OnrampsMwanAddrSpacePatch<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
body: Ok(::std::default::Default::default()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::McnAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `McnAccountId` for account_id failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::McnUpdateMagicWanAddressSpaceRequest>,
<V as std::convert::TryInto<types::McnUpdateMagicWanAddressSpaceRequest>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `McnUpdateMagicWanAddressSpaceRequest` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::McnUpdateMagicWanAddressSpaceRequest,
)
-> types::builder::McnUpdateMagicWanAddressSpaceRequest,
{
self.body = self.body.map(f);
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::McnUpdateMagicWanAddressSpaceRequest::try_from(v)
.map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/magic/cloud/onramps/magic_wan_address_space",
client.baseurl,
encode_path(&account_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.patch(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "onramps_mwan_addr_space_patch",
};
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)),
}
}
}