use super::types;
use crate::{
ByteStream, ClientHooks, ClientInfo, Error, OperationInfo, RequestBuilderExt,
ResponseValue, encode_path,
};
#[derive(Debug, Clone)]
pub struct UserSAccountMembershipsListMemberships<'a> {
client: &'a crate::Client,
account_name: Result<types::IamPropertiesName, String>,
direction: Result<types::UserSAccountMembershipsListMembershipsDirection, String>,
name: Result<types::IamPropertiesName, String>,
order: Result<types::UserSAccountMembershipsListMembershipsOrder, String>,
page: Result<f64, String>,
per_page: Result<f64, String>,
status: Result<types::UserSAccountMembershipsListMembershipsStatus, String>,
}
impl<'a> UserSAccountMembershipsListMemberships<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_name: Err("account_name was not initialized".to_string()),
direction: Err("direction was not initialized".to_string()),
name: Err("name was not initialized".to_string()),
order: Err("order was not initialized".to_string()),
page: Err("page was not initialized".to_string()),
per_page: Err("per_page was not initialized".to_string()),
status: Err("status was not initialized".to_string()),
}
}
pub fn account_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::IamPropertiesName>,
{
self.account_name = value.try_into().map_err(|_| {
"conversion to `IamPropertiesName` for account_name failed".to_string()
});
self
}
pub fn direction<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::UserSAccountMembershipsListMembershipsDirection>,
{
self . direction = value . try_into () . map_err (| _ | "conversion to `UserSAccountMembershipsListMembershipsDirection` for direction failed" . to_string ()) ;
self
}
pub fn name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::IamPropertiesName>,
{
self.name = value
.try_into()
.map_err(|_| "conversion to `IamPropertiesName` for name failed".to_string());
self
}
pub fn order<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::UserSAccountMembershipsListMembershipsOrder>,
{
self.order = value.try_into().map_err(|_| {
"conversion to `UserSAccountMembershipsListMembershipsOrder` for order failed"
.to_string()
});
self
}
pub fn page<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<f64>,
{
self.page = value
.try_into()
.map_err(|_| "conversion to `f64` for page failed".to_string());
self
}
pub fn per_page<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<f64>,
{
self.per_page = value
.try_into()
.map_err(|_| "conversion to `f64` for per_page failed".to_string());
self
}
pub fn status<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::UserSAccountMembershipsListMembershipsStatus>,
{
self.status = value.try_into().map_err(|_| {
"conversion to `UserSAccountMembershipsListMembershipsStatus` for status 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_name,
direction,
name,
order,
page,
per_page,
status,
} = self;
let account_name = account_name.map_err(Error::InvalidRequest)?;
let direction = direction.map_err(Error::InvalidRequest)?;
let name = name.map_err(Error::InvalidRequest)?;
let order = order.map_err(Error::InvalidRequest)?;
let page = page.map_err(Error::InvalidRequest)?;
let per_page = per_page.map_err(Error::InvalidRequest)?;
let status = status.map_err(Error::InvalidRequest)?;
let url = format!("{}/memberships", client.baseurl,);
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(
"account.name",
&account_name,
))
.query(&progenitor_client::QueryParam::new("direction", &direction))
.query(&progenitor_client::QueryParam::new("name", &name))
.query(&progenitor_client::QueryParam::new("order", &order))
.query(&progenitor_client::QueryParam::new("page", &page))
.query(&progenitor_client::QueryParam::new("per_page", &per_page))
.query(&progenitor_client::QueryParam::new("status", &status))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "user_s_account_memberships_list_memberships",
};
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)),
}
}
}
mod by;
pub use by::*;