unitycatalog_client/codegen/policies/
builders.rs1#![allow(unused_mut)]
3#![allow(unused_imports)]
4#[cfg(not(target_arch = "wasm32"))]
5type BoxFut<'a, T> = ::futures::future::BoxFuture<'a, T>;
6#[cfg(target_arch = "wasm32")]
7type BoxFut<'a, T> = ::futures::future::LocalBoxFuture<'a, T>;
8use super::client::*;
9use crate::Result;
10use std::future::IntoFuture;
11use unitycatalog_common::models::policies::v1::*;
12pub struct ListPoliciesBuilder {
14 client: PolicyServiceClient,
15 request: ListPoliciesRequest,
16}
17impl ListPoliciesBuilder {
18 pub(crate) fn new(
21 client: PolicyServiceClient,
22 on_securable_type: impl Into<String>,
23 on_securable_fullname: impl Into<String>,
24 ) -> Self {
25 let request = ListPoliciesRequest {
26 on_securable_type: on_securable_type.into(),
27 on_securable_fullname: on_securable_fullname.into(),
28 ..Default::default()
29 };
30 Self { client, request }
31 }
32 pub fn with_include_inherited(mut self, include_inherited: impl Into<Option<bool>>) -> Self {
37 self.request.include_inherited = include_inherited.into();
38 self
39 }
40 pub fn with_max_results(mut self, max_results: impl Into<Option<i32>>) -> Self {
42 self.request.max_results = max_results.into();
43 self
44 }
45 pub fn with_page_token(mut self, page_token: impl Into<Option<String>>) -> Self {
47 self.request.page_token = page_token.into();
48 self
49 }
50}
51impl IntoFuture for ListPoliciesBuilder {
52 type Output = Result<ListPoliciesResponse>;
53 type IntoFuture = BoxFut<'static, Self::Output>;
54 fn into_future(self) -> Self::IntoFuture {
55 let client = self.client;
56 let request = self.request;
57 Box::pin(async move { client.list_policies(&request).await })
58 }
59}
60pub struct CreatePolicyBuilder {
62 client: PolicyServiceClient,
63 request: CreatePolicyRequest,
64}
65impl CreatePolicyBuilder {
66 pub(crate) fn new(
69 client: PolicyServiceClient,
70 on_securable_type: impl Into<String>,
71 on_securable_fullname: impl Into<String>,
72 policy_info: PolicyInfo,
73 ) -> Self {
74 let request = CreatePolicyRequest {
75 on_securable_type: on_securable_type.into(),
76 on_securable_fullname: on_securable_fullname.into(),
77 policy_info: buffa::MessageField::some(policy_info),
78 ..Default::default()
79 };
80 Self { client, request }
81 }
82}
83impl IntoFuture for CreatePolicyBuilder {
84 type Output = Result<PolicyInfo>;
85 type IntoFuture = BoxFut<'static, Self::Output>;
86 fn into_future(self) -> Self::IntoFuture {
87 let client = self.client;
88 let request = self.request;
89 Box::pin(async move { client.create_policy(&request).await })
90 }
91}
92pub struct GetPolicyBuilder {
94 client: PolicyServiceClient,
95 request: GetPolicyRequest,
96}
97impl GetPolicyBuilder {
98 pub(crate) fn new(
101 client: PolicyServiceClient,
102 on_securable_type: impl Into<String>,
103 on_securable_fullname: impl Into<String>,
104 name: impl Into<String>,
105 ) -> Self {
106 let request = GetPolicyRequest {
107 on_securable_type: on_securable_type.into(),
108 on_securable_fullname: on_securable_fullname.into(),
109 name: name.into(),
110 ..Default::default()
111 };
112 Self { client, request }
113 }
114}
115impl IntoFuture for GetPolicyBuilder {
116 type Output = Result<PolicyInfo>;
117 type IntoFuture = BoxFut<'static, Self::Output>;
118 fn into_future(self) -> Self::IntoFuture {
119 let client = self.client;
120 let request = self.request;
121 Box::pin(async move { client.get_policy(&request).await })
122 }
123}
124pub struct UpdatePolicyBuilder {
126 client: PolicyServiceClient,
127 request: UpdatePolicyRequest,
128}
129impl UpdatePolicyBuilder {
130 pub(crate) fn new(
133 client: PolicyServiceClient,
134 on_securable_type: impl Into<String>,
135 on_securable_fullname: impl Into<String>,
136 name: impl Into<String>,
137 policy_info: PolicyInfo,
138 ) -> Self {
139 let request = UpdatePolicyRequest {
140 on_securable_type: on_securable_type.into(),
141 on_securable_fullname: on_securable_fullname.into(),
142 name: name.into(),
143 policy_info: buffa::MessageField::some(policy_info),
144 ..Default::default()
145 };
146 Self { client, request }
147 }
148 pub fn with_update_mask(mut self, update_mask: impl Into<Option<String>>) -> Self {
150 self.request.update_mask = update_mask.into();
151 self
152 }
153}
154impl IntoFuture for UpdatePolicyBuilder {
155 type Output = Result<PolicyInfo>;
156 type IntoFuture = BoxFut<'static, Self::Output>;
157 fn into_future(self) -> Self::IntoFuture {
158 let client = self.client;
159 let request = self.request;
160 Box::pin(async move { client.update_policy(&request).await })
161 }
162}
163pub struct DeletePolicyBuilder {
165 client: PolicyServiceClient,
166 request: DeletePolicyRequest,
167}
168impl DeletePolicyBuilder {
169 pub(crate) fn new(
172 client: PolicyServiceClient,
173 on_securable_type: impl Into<String>,
174 on_securable_fullname: impl Into<String>,
175 name: impl Into<String>,
176 ) -> Self {
177 let request = DeletePolicyRequest {
178 on_securable_type: on_securable_type.into(),
179 on_securable_fullname: on_securable_fullname.into(),
180 name: name.into(),
181 ..Default::default()
182 };
183 Self { client, request }
184 }
185}
186impl IntoFuture for DeletePolicyBuilder {
187 type Output = Result<()>;
188 type IntoFuture = BoxFut<'static, Self::Output>;
189 fn into_future(self) -> Self::IntoFuture {
190 let client = self.client;
191 let request = self.request;
192 Box::pin(async move { client.delete_policy(&request).await })
193 }
194}