vaultrs/identity/
group_alias.rsuse crate::{
api::{
self,
identity::group_alias::{
requests::{
CreateGroupAliasRequest, CreateGroupAliasRequestBuilder,
DeleteGroupAliasByIdRequest, ListGroupAliasesByIdRequest,
ReadGroupAliasByIdRequest, UpdateGroupAliasByIdRequest,
UpdateGroupAliasByIdRequestBuilder,
},
responses::{
CreateGroupAliasResponse, ListGroupAliasesByIdResponse, ReadGroupAliasByIdResponse,
},
},
},
client::Client,
error::ClientError,
};
pub async fn create(
client: &impl Client,
name: &str,
mount_accessor: &str,
opts: Option<&mut CreateGroupAliasRequestBuilder>,
) -> Result<CreateGroupAliasResponse, ClientError> {
let mut t = CreateGroupAliasRequest::builder();
let endpoint = opts
.unwrap_or(&mut t)
.name(name)
.mount_accessor(mount_accessor)
.build()
.unwrap();
api::exec_with_result(client, endpoint)
.await
.map_err(|err| {
if matches!(
err,
ClientError::RestClientError {
source: rustify::errors::ClientError::ResponseParseError { .. }
}
) {
return ClientError::InvalidUpdateParameter;
}
err
})
}
pub async fn read_by_id(
client: &impl Client,
id: &str,
) -> Result<ReadGroupAliasByIdResponse, ClientError> {
let endpoint = ReadGroupAliasByIdRequest::builder().id(id).build().unwrap();
api::exec_with_result(client, endpoint).await
}
pub async fn update_by_id(
client: &impl Client,
id: &str,
mount_accessor: &str,
opts: Option<&mut UpdateGroupAliasByIdRequestBuilder>,
) -> Result<(), ClientError> {
let mut t = UpdateGroupAliasByIdRequest::builder();
let endpoint = opts
.unwrap_or(&mut t)
.id(id)
.mount_accessor(mount_accessor)
.build()
.unwrap();
api::exec_with_empty(client, endpoint).await
}
pub async fn delete_by_id(client: &impl Client, id: &str) -> Result<(), ClientError> {
let endpoint = DeleteGroupAliasByIdRequest::builder()
.id(id)
.build()
.unwrap();
api::exec_with_empty(client, endpoint).await
}
pub async fn list_by_id(client: &impl Client) -> Result<ListGroupAliasesByIdResponse, ClientError> {
let endpoint = ListGroupAliasesByIdRequest::builder().build().unwrap();
api::exec_with_result(client, endpoint).await
}