#![allow(rustdoc::redundant_explicit_links)]
#![allow(rustdoc::broken_intra_doc_links)]
#[derive(Clone, Debug)]
pub struct OrgPolicy {
inner: std::sync::Arc<dyn super::stub::dynamic::OrgPolicy>,
}
impl OrgPolicy {
pub fn builder() -> super::builder::org_policy::ClientBuilder {
crate::new_client_builder(super::builder::org_policy::client::Factory)
}
pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
where
T: super::stub::OrgPolicy + 'static,
{
Self { inner: stub.into() }
}
pub(crate) async fn new(
config: gaxi::options::ClientConfig,
) -> crate::ClientBuilderResult<Self> {
let inner = Self::build_inner(config).await?;
Ok(Self { inner })
}
async fn build_inner(
conf: gaxi::options::ClientConfig,
) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::OrgPolicy>> {
if gaxi::options::tracing_enabled(&conf) {
return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
}
Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
}
async fn build_transport(
conf: gaxi::options::ClientConfig,
) -> crate::ClientBuilderResult<impl super::stub::OrgPolicy> {
super::transport::OrgPolicy::new(conf).await
}
async fn build_with_tracing(
conf: gaxi::options::ClientConfig,
) -> crate::ClientBuilderResult<impl super::stub::OrgPolicy> {
Self::build_transport(conf)
.await
.map(super::tracing::OrgPolicy::new)
}
pub fn list_constraints(&self) -> super::builder::org_policy::ListConstraints {
super::builder::org_policy::ListConstraints::new(self.inner.clone())
}
pub fn list_policies(&self) -> super::builder::org_policy::ListPolicies {
super::builder::org_policy::ListPolicies::new(self.inner.clone())
}
pub fn get_policy(&self) -> super::builder::org_policy::GetPolicy {
super::builder::org_policy::GetPolicy::new(self.inner.clone())
}
pub fn get_effective_policy(&self) -> super::builder::org_policy::GetEffectivePolicy {
super::builder::org_policy::GetEffectivePolicy::new(self.inner.clone())
}
pub fn create_policy(&self) -> super::builder::org_policy::CreatePolicy {
super::builder::org_policy::CreatePolicy::new(self.inner.clone())
}
pub fn update_policy(&self) -> super::builder::org_policy::UpdatePolicy {
super::builder::org_policy::UpdatePolicy::new(self.inner.clone())
}
pub fn delete_policy(&self) -> super::builder::org_policy::DeletePolicy {
super::builder::org_policy::DeletePolicy::new(self.inner.clone())
}
pub fn create_custom_constraint(&self) -> super::builder::org_policy::CreateCustomConstraint {
super::builder::org_policy::CreateCustomConstraint::new(self.inner.clone())
}
pub fn update_custom_constraint(&self) -> super::builder::org_policy::UpdateCustomConstraint {
super::builder::org_policy::UpdateCustomConstraint::new(self.inner.clone())
}
pub fn get_custom_constraint(&self) -> super::builder::org_policy::GetCustomConstraint {
super::builder::org_policy::GetCustomConstraint::new(self.inner.clone())
}
pub fn list_custom_constraints(&self) -> super::builder::org_policy::ListCustomConstraints {
super::builder::org_policy::ListCustomConstraints::new(self.inner.clone())
}
pub fn delete_custom_constraint(&self) -> super::builder::org_policy::DeleteCustomConstraint {
super::builder::org_policy::DeleteCustomConstraint::new(self.inner.clone())
}
}