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