Skip to main content

unitycatalog_client/codegen/policies/
resource.rs

1// @generated — do not edit by hand.
2#![allow(unused_imports)]
3use super::builders::*;
4use super::client::PolicyServiceClient;
5use unitycatalog_common::models::policies::v1::*;
6/// A client scoped to a single `policy`.
7#[derive(Clone)]
8pub struct PolicyClient {
9    pub(crate) policy_name: String,
10    pub(crate) client: PolicyServiceClient,
11}
12impl PolicyClient {
13    /// Create a client bound to the resource's name components.
14    pub fn new(policy_name: impl Into<String>, client: PolicyServiceClient) -> Self {
15        Self {
16            policy_name: policy_name.into(),
17            client,
18        }
19    }
20    /// This resource's own name (the leaf component).
21    pub fn name(&self) -> &str {
22        &self.policy_name
23    }
24    /// The fully-qualified name of this resource.
25    pub fn full_name(&self) -> String {
26        self.policy_name.clone()
27    }
28    /// Create a new policy
29    ///
30    /// Creates a new row-filter or column-mask policy on the specified securable.
31    pub fn create_policy(&self, policy_info: PolicyInfo) -> CreatePolicyBuilder {
32        CreatePolicyBuilder::new(
33            self.client.clone(),
34            &self.policy_name,
35            &self.policy_name,
36            policy_info,
37        )
38    }
39    /// Get a policy
40    ///
41    /// Gets the policy that matches the supplied name, defined on the specified securable.
42    pub fn get(&self) -> GetPolicyBuilder {
43        GetPolicyBuilder::new(
44            self.client.clone(),
45            &self.policy_name,
46            &self.policy_name,
47            &self.policy_name,
48        )
49    }
50    /// Update a policy
51    ///
52    /// Updates the policy that matches the supplied name, defined on the specified securable.
53    pub fn update(&self, policy_info: PolicyInfo) -> UpdatePolicyBuilder {
54        UpdatePolicyBuilder::new(
55            self.client.clone(),
56            &self.policy_name,
57            &self.policy_name,
58            &self.policy_name,
59            policy_info,
60        )
61    }
62    /// Delete a policy
63    ///
64    /// Deletes the policy that matches the supplied name, defined on the specified securable.
65    pub fn delete(&self) -> DeletePolicyBuilder {
66        DeletePolicyBuilder::new(
67            self.client.clone(),
68            &self.policy_name,
69            &self.policy_name,
70            &self.policy_name,
71        )
72    }
73}