unitycatalog_client/codegen/credentials/
builders.rs1#![allow(unused_mut)]
3#![allow(unused_imports)]
4type BoxFut<'a, T> = ::futures::future::BoxFuture<'a, T>;
5type BoxStr<'a, T> = ::futures::stream::BoxStream<'a, T>;
6use super::super::stream_paginated;
7use super::client::*;
8use crate::Result;
9use futures::{StreamExt, TryStreamExt};
10use std::future::IntoFuture;
11use unitycatalog_common::models::credentials::v1::*;
12pub struct ListCredentialsBuilder {
14 client: CredentialServiceClient,
15 request: ListCredentialsRequest,
16}
17impl ListCredentialsBuilder {
18 pub(crate) fn new(client: CredentialServiceClient) -> Self {
21 let request = ListCredentialsRequest {
22 ..Default::default()
23 };
24 Self { client, request }
25 }
26 pub fn with_purpose(mut self, purpose: impl Into<Option<Purpose>>) -> Self {
28 self.request.purpose = purpose.into().map(buffa::EnumValue::Known);
29 self
30 }
31 pub fn with_max_results(mut self, max_results: impl Into<Option<i32>>) -> Self {
33 self.request.max_results = max_results.into();
34 self
35 }
36 pub fn with_page_token(mut self, page_token: impl Into<Option<String>>) -> Self {
38 self.request.page_token = page_token.into();
39 self
40 }
41 pub fn into_stream(self) -> BoxStr<'static, Result<Credential>> {
43 let remaining = self.request.max_results;
44 let stream = stream_paginated(
45 (self, remaining),
46 move |(mut builder, mut remaining), page_token| async move {
47 builder.request.page_token = page_token;
48 let res = builder.client.list_credentials(&builder.request).await?;
49 if let Some(ref mut rem) = remaining {
50 *rem -= res.credentials.len() as i32;
51 }
52 let next_page_token = if remaining.is_some_and(|r| r <= 0) {
53 None
54 } else {
55 res.next_page_token.clone()
56 };
57 Ok((res, (builder, remaining), next_page_token))
58 },
59 )
60 .map_ok(|resp| futures::stream::iter(resp.credentials.into_iter().map(Ok)))
61 .try_flatten();
62 stream.boxed()
63 }
64}
65impl IntoFuture for ListCredentialsBuilder {
66 type Output = Result<ListCredentialsResponse>;
67 type IntoFuture = BoxFut<'static, Self::Output>;
68 fn into_future(self) -> Self::IntoFuture {
69 let client = self.client;
70 let request = self.request;
71 Box::pin(async move { client.list_credentials(&request).await })
72 }
73}
74pub struct CreateCredentialBuilder {
76 client: CredentialServiceClient,
77 request: CreateCredentialRequest,
78}
79impl CreateCredentialBuilder {
80 pub(crate) fn new(
83 client: CredentialServiceClient,
84 name: impl Into<String>,
85 purpose: Purpose,
86 ) -> Self {
87 let request = CreateCredentialRequest {
88 name: name.into(),
89 purpose: buffa::EnumValue::Known(purpose),
90 ..Default::default()
91 };
92 Self { client, request }
93 }
94 pub fn with_comment(mut self, comment: impl Into<Option<String>>) -> Self {
96 self.request.comment = comment.into();
97 self
98 }
99 pub fn with_read_only(mut self, read_only: impl Into<Option<bool>>) -> Self {
101 self.request.read_only = read_only.into();
102 self
103 }
104 pub fn with_skip_validation(mut self, skip_validation: impl Into<Option<bool>>) -> Self {
106 self.request.skip_validation = skip_validation.into();
107 self
108 }
109 pub fn with_azure_service_principal(
111 mut self,
112 azure_service_principal: impl Into<Option<AzureServicePrincipal>>,
113 ) -> Self {
114 self.request.azure_service_principal = {
115 let azure_service_principal: ::core::option::Option<_> = azure_service_principal.into();
116 buffa::MessageField::from(azure_service_principal)
117 };
118 self
119 }
120 pub fn with_azure_managed_identity(
122 mut self,
123 azure_managed_identity: impl Into<Option<AzureManagedIdentity>>,
124 ) -> Self {
125 self.request.azure_managed_identity = {
126 let azure_managed_identity: ::core::option::Option<_> = azure_managed_identity.into();
127 buffa::MessageField::from(azure_managed_identity)
128 };
129 self
130 }
131 pub fn with_azure_storage_key(
133 mut self,
134 azure_storage_key: impl Into<Option<AzureStorageKey>>,
135 ) -> Self {
136 self.request.azure_storage_key = {
137 let azure_storage_key: ::core::option::Option<_> = azure_storage_key.into();
138 buffa::MessageField::from(azure_storage_key)
139 };
140 self
141 }
142 pub fn with_aws_iam_role(mut self, aws_iam_role: impl Into<Option<AwsIamRoleConfig>>) -> Self {
144 self.request.aws_iam_role = {
145 let aws_iam_role: ::core::option::Option<_> = aws_iam_role.into();
146 buffa::MessageField::from(aws_iam_role)
147 };
148 self
149 }
150 pub fn with_databricks_gcp_service_account(
152 mut self,
153 databricks_gcp_service_account: impl Into<Option<DatabricksGcpServiceAccount>>,
154 ) -> Self {
155 self.request.databricks_gcp_service_account = {
156 let databricks_gcp_service_account: ::core::option::Option<_> =
157 databricks_gcp_service_account.into();
158 buffa::MessageField::from(databricks_gcp_service_account)
159 };
160 self
161 }
162}
163impl IntoFuture for CreateCredentialBuilder {
164 type Output = Result<Credential>;
165 type IntoFuture = BoxFut<'static, Self::Output>;
166 fn into_future(self) -> Self::IntoFuture {
167 let client = self.client;
168 let request = self.request;
169 Box::pin(async move { client.create_credential(&request).await })
170 }
171}
172pub struct GetCredentialBuilder {
174 client: CredentialServiceClient,
175 request: GetCredentialRequest,
176}
177impl GetCredentialBuilder {
178 pub(crate) fn new(client: CredentialServiceClient, name: impl Into<String>) -> Self {
181 let request = GetCredentialRequest {
182 name: name.into(),
183 ..Default::default()
184 };
185 Self { client, request }
186 }
187}
188impl IntoFuture for GetCredentialBuilder {
189 type Output = Result<Credential>;
190 type IntoFuture = BoxFut<'static, Self::Output>;
191 fn into_future(self) -> Self::IntoFuture {
192 let client = self.client;
193 let request = self.request;
194 Box::pin(async move { client.get_credential(&request).await })
195 }
196}
197pub struct UpdateCredentialBuilder {
199 client: CredentialServiceClient,
200 request: UpdateCredentialRequest,
201}
202impl UpdateCredentialBuilder {
203 pub(crate) fn new(client: CredentialServiceClient, name: impl Into<String>) -> Self {
206 let request = UpdateCredentialRequest {
207 name: name.into(),
208 ..Default::default()
209 };
210 Self { client, request }
211 }
212 pub fn with_new_name(mut self, new_name: impl Into<Option<String>>) -> Self {
214 self.request.new_name = new_name.into();
215 self
216 }
217 pub fn with_comment(mut self, comment: impl Into<Option<String>>) -> Self {
219 self.request.comment = comment.into();
220 self
221 }
222 pub fn with_read_only(mut self, read_only: impl Into<Option<bool>>) -> Self {
224 self.request.read_only = read_only.into();
225 self
226 }
227 pub fn with_owner(mut self, owner: impl Into<Option<String>>) -> Self {
229 self.request.owner = owner.into();
230 self
231 }
232 pub fn with_skip_validation(mut self, skip_validation: impl Into<Option<bool>>) -> Self {
234 self.request.skip_validation = skip_validation.into();
235 self
236 }
237 pub fn with_force(mut self, force: impl Into<Option<bool>>) -> Self {
240 self.request.force = force.into();
241 self
242 }
243 pub fn with_azure_service_principal(
245 mut self,
246 azure_service_principal: impl Into<Option<AzureServicePrincipal>>,
247 ) -> Self {
248 self.request.azure_service_principal = {
249 let azure_service_principal: ::core::option::Option<_> = azure_service_principal.into();
250 buffa::MessageField::from(azure_service_principal)
251 };
252 self
253 }
254 pub fn with_azure_managed_identity(
256 mut self,
257 azure_managed_identity: impl Into<Option<AzureManagedIdentity>>,
258 ) -> Self {
259 self.request.azure_managed_identity = {
260 let azure_managed_identity: ::core::option::Option<_> = azure_managed_identity.into();
261 buffa::MessageField::from(azure_managed_identity)
262 };
263 self
264 }
265 pub fn with_azure_storage_key(
267 mut self,
268 azure_storage_key: impl Into<Option<AzureStorageKey>>,
269 ) -> Self {
270 self.request.azure_storage_key = {
271 let azure_storage_key: ::core::option::Option<_> = azure_storage_key.into();
272 buffa::MessageField::from(azure_storage_key)
273 };
274 self
275 }
276 pub fn with_aws_iam_role(mut self, aws_iam_role: impl Into<Option<AwsIamRoleConfig>>) -> Self {
278 self.request.aws_iam_role = {
279 let aws_iam_role: ::core::option::Option<_> = aws_iam_role.into();
280 buffa::MessageField::from(aws_iam_role)
281 };
282 self
283 }
284 pub fn with_databricks_gcp_service_account(
286 mut self,
287 databricks_gcp_service_account: impl Into<Option<DatabricksGcpServiceAccount>>,
288 ) -> Self {
289 self.request.databricks_gcp_service_account = {
290 let databricks_gcp_service_account: ::core::option::Option<_> =
291 databricks_gcp_service_account.into();
292 buffa::MessageField::from(databricks_gcp_service_account)
293 };
294 self
295 }
296}
297impl IntoFuture for UpdateCredentialBuilder {
298 type Output = Result<Credential>;
299 type IntoFuture = BoxFut<'static, Self::Output>;
300 fn into_future(self) -> Self::IntoFuture {
301 let client = self.client;
302 let request = self.request;
303 Box::pin(async move { client.update_credential(&request).await })
304 }
305}
306pub struct DeleteCredentialBuilder {
308 client: CredentialServiceClient,
309 request: DeleteCredentialRequest,
310}
311impl DeleteCredentialBuilder {
312 pub(crate) fn new(client: CredentialServiceClient, name: impl Into<String>) -> Self {
315 let request = DeleteCredentialRequest {
316 name: name.into(),
317 ..Default::default()
318 };
319 Self { client, request }
320 }
321}
322impl IntoFuture for DeleteCredentialBuilder {
323 type Output = Result<()>;
324 type IntoFuture = BoxFut<'static, Self::Output>;
325 fn into_future(self) -> Self::IntoFuture {
326 let client = self.client;
327 let request = self.request;
328 Box::pin(async move { client.delete_credential(&request).await })
329 }
330}