#![allow(unused_mut)]
#![allow(unused_imports)]
type BoxFut<'a, T> = ::futures::future::BoxFuture<'a, T>;
use super::client::*;
use crate::Result;
use std::future::IntoFuture;
use unitycatalog_common::models::policies::v1::*;
pub struct ListPoliciesBuilder {
client: PolicyServiceClient,
request: ListPoliciesRequest,
}
impl ListPoliciesBuilder {
pub(crate) fn new(
client: PolicyServiceClient,
on_securable_type: impl Into<String>,
on_securable_fullname: impl Into<String>,
) -> Self {
let request = ListPoliciesRequest {
on_securable_type: on_securable_type.into(),
on_securable_fullname: on_securable_fullname.into(),
..Default::default()
};
Self { client, request }
}
pub fn with_include_inherited(mut self, include_inherited: impl Into<Option<bool>>) -> Self {
self.request.include_inherited = include_inherited.into();
self
}
pub fn with_max_results(mut self, max_results: impl Into<Option<i32>>) -> Self {
self.request.max_results = max_results.into();
self
}
pub fn with_page_token(mut self, page_token: impl Into<Option<String>>) -> Self {
self.request.page_token = page_token.into();
self
}
}
impl IntoFuture for ListPoliciesBuilder {
type Output = Result<ListPoliciesResponse>;
type IntoFuture = BoxFut<'static, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
let client = self.client;
let request = self.request;
Box::pin(async move { client.list_policies(&request).await })
}
}
pub struct CreatePolicyBuilder {
client: PolicyServiceClient,
request: CreatePolicyRequest,
}
impl CreatePolicyBuilder {
pub(crate) fn new(
client: PolicyServiceClient,
on_securable_type: impl Into<String>,
on_securable_fullname: impl Into<String>,
policy_info: PolicyInfo,
) -> Self {
let request = CreatePolicyRequest {
on_securable_type: on_securable_type.into(),
on_securable_fullname: on_securable_fullname.into(),
policy_info: buffa::MessageField::some(policy_info),
..Default::default()
};
Self { client, request }
}
}
impl IntoFuture for CreatePolicyBuilder {
type Output = Result<PolicyInfo>;
type IntoFuture = BoxFut<'static, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
let client = self.client;
let request = self.request;
Box::pin(async move { client.create_policy(&request).await })
}
}
pub struct GetPolicyBuilder {
client: PolicyServiceClient,
request: GetPolicyRequest,
}
impl GetPolicyBuilder {
pub(crate) fn new(
client: PolicyServiceClient,
on_securable_type: impl Into<String>,
on_securable_fullname: impl Into<String>,
name: impl Into<String>,
) -> Self {
let request = GetPolicyRequest {
on_securable_type: on_securable_type.into(),
on_securable_fullname: on_securable_fullname.into(),
name: name.into(),
..Default::default()
};
Self { client, request }
}
}
impl IntoFuture for GetPolicyBuilder {
type Output = Result<PolicyInfo>;
type IntoFuture = BoxFut<'static, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
let client = self.client;
let request = self.request;
Box::pin(async move { client.get_policy(&request).await })
}
}
pub struct UpdatePolicyBuilder {
client: PolicyServiceClient,
request: UpdatePolicyRequest,
}
impl UpdatePolicyBuilder {
pub(crate) fn new(
client: PolicyServiceClient,
on_securable_type: impl Into<String>,
on_securable_fullname: impl Into<String>,
name: impl Into<String>,
policy_info: PolicyInfo,
) -> Self {
let request = UpdatePolicyRequest {
on_securable_type: on_securable_type.into(),
on_securable_fullname: on_securable_fullname.into(),
name: name.into(),
policy_info: buffa::MessageField::some(policy_info),
..Default::default()
};
Self { client, request }
}
pub fn with_update_mask(mut self, update_mask: impl Into<Option<String>>) -> Self {
self.request.update_mask = update_mask.into();
self
}
}
impl IntoFuture for UpdatePolicyBuilder {
type Output = Result<PolicyInfo>;
type IntoFuture = BoxFut<'static, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
let client = self.client;
let request = self.request;
Box::pin(async move { client.update_policy(&request).await })
}
}
pub struct DeletePolicyBuilder {
client: PolicyServiceClient,
request: DeletePolicyRequest,
}
impl DeletePolicyBuilder {
pub(crate) fn new(
client: PolicyServiceClient,
on_securable_type: impl Into<String>,
on_securable_fullname: impl Into<String>,
name: impl Into<String>,
) -> Self {
let request = DeletePolicyRequest {
on_securable_type: on_securable_type.into(),
on_securable_fullname: on_securable_fullname.into(),
name: name.into(),
..Default::default()
};
Self { client, request }
}
}
impl IntoFuture for DeletePolicyBuilder {
type Output = Result<()>;
type IntoFuture = BoxFut<'static, Self::Output>;
fn into_future(self) -> Self::IntoFuture {
let client = self.client;
let request = self.request;
Box::pin(async move { client.delete_policy(&request).await })
}
}