unitycatalog_client/codegen/credentials/
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>;
8#[cfg(not(target_arch = "wasm32"))]
9type BoxStr<'a, T> = ::futures::stream::BoxStream<'a, T>;
10#[cfg(target_arch = "wasm32")]
11type BoxStr<'a, T> = ::futures::stream::LocalBoxStream<'a, T>;
12use super::super::stream_paginated;
13use super::client::*;
14use crate::Result;
15use futures::{StreamExt, TryStreamExt};
16use std::future::IntoFuture;
17use unitycatalog_common::models::credentials::v1::*;
18pub struct ListCredentialsBuilder {
20 client: CredentialServiceClient,
21 request: ListCredentialsRequest,
22}
23impl ListCredentialsBuilder {
24 pub(crate) fn new(client: CredentialServiceClient) -> Self {
27 let request = ListCredentialsRequest {
28 ..Default::default()
29 };
30 Self { client, request }
31 }
32 pub fn with_purpose(mut self, purpose: impl Into<Option<Purpose>>) -> Self {
34 self.request.purpose = purpose.into().map(buffa::EnumValue::Known);
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 pub fn into_stream(self) -> BoxStr<'static, Result<Credential>> {
49 let remaining = self.request.max_results;
50 let stream = stream_paginated(
51 (self, remaining),
52 move |(mut builder, mut remaining), page_token| async move {
53 builder.request.page_token = page_token;
54 let res = builder.client.list_credentials(&builder.request).await?;
55 if let Some(ref mut rem) = remaining {
56 *rem -= res.credentials.len() as i32;
57 }
58 let next_page_token = if remaining.is_some_and(|r| r <= 0) {
59 None
60 } else {
61 res.next_page_token.clone()
62 };
63 Ok((res, (builder, remaining), next_page_token))
64 },
65 )
66 .map_ok(|resp| futures::stream::iter(resp.credentials.into_iter().map(Ok)))
67 .try_flatten();
68 #[cfg(not(target_arch = "wasm32"))]
69 let stream = stream.boxed();
70 #[cfg(target_arch = "wasm32")]
71 let stream = stream.boxed_local();
72 stream
73 }
74}
75impl IntoFuture for ListCredentialsBuilder {
76 type Output = Result<ListCredentialsResponse>;
77 type IntoFuture = BoxFut<'static, Self::Output>;
78 fn into_future(self) -> Self::IntoFuture {
79 let client = self.client;
80 let request = self.request;
81 Box::pin(async move { client.list_credentials(&request).await })
82 }
83}
84pub struct CreateCredentialBuilder {
86 client: CredentialServiceClient,
87 request: CreateCredentialRequest,
88}
89impl CreateCredentialBuilder {
90 pub(crate) fn new(
93 client: CredentialServiceClient,
94 name: impl Into<String>,
95 purpose: Purpose,
96 ) -> Self {
97 let request = CreateCredentialRequest {
98 name: name.into(),
99 purpose: buffa::EnumValue::Known(purpose),
100 ..Default::default()
101 };
102 Self { client, request }
103 }
104 pub fn with_comment(mut self, comment: impl Into<Option<String>>) -> Self {
106 self.request.comment = comment.into();
107 self
108 }
109 pub fn with_read_only(mut self, read_only: impl Into<Option<bool>>) -> Self {
111 self.request.read_only = read_only.into();
112 self
113 }
114 pub fn with_skip_validation(mut self, skip_validation: impl Into<Option<bool>>) -> Self {
116 self.request.skip_validation = skip_validation.into();
117 self
118 }
119 pub fn with_azure_service_principal(
121 mut self,
122 azure_service_principal: impl Into<Option<AzureServicePrincipal>>,
123 ) -> Self {
124 self.request.azure_service_principal = {
125 let azure_service_principal: ::core::option::Option<_> = azure_service_principal.into();
126 buffa::MessageField::from(azure_service_principal)
127 };
128 self
129 }
130 pub fn with_azure_managed_identity(
132 mut self,
133 azure_managed_identity: impl Into<Option<AzureManagedIdentity>>,
134 ) -> Self {
135 self.request.azure_managed_identity = {
136 let azure_managed_identity: ::core::option::Option<_> = azure_managed_identity.into();
137 buffa::MessageField::from(azure_managed_identity)
138 };
139 self
140 }
141 pub fn with_azure_storage_key(
143 mut self,
144 azure_storage_key: impl Into<Option<AzureStorageKey>>,
145 ) -> Self {
146 self.request.azure_storage_key = {
147 let azure_storage_key: ::core::option::Option<_> = azure_storage_key.into();
148 buffa::MessageField::from(azure_storage_key)
149 };
150 self
151 }
152 pub fn with_aws_iam_role(mut self, aws_iam_role: impl Into<Option<AwsIamRoleConfig>>) -> Self {
154 self.request.aws_iam_role = {
155 let aws_iam_role: ::core::option::Option<_> = aws_iam_role.into();
156 buffa::MessageField::from(aws_iam_role)
157 };
158 self
159 }
160 pub fn with_databricks_gcp_service_account(
162 mut self,
163 databricks_gcp_service_account: impl Into<Option<DatabricksGcpServiceAccount>>,
164 ) -> Self {
165 self.request.databricks_gcp_service_account = {
166 let databricks_gcp_service_account: ::core::option::Option<_> =
167 databricks_gcp_service_account.into();
168 buffa::MessageField::from(databricks_gcp_service_account)
169 };
170 self
171 }
172}
173impl IntoFuture for CreateCredentialBuilder {
174 type Output = Result<Credential>;
175 type IntoFuture = BoxFut<'static, Self::Output>;
176 fn into_future(self) -> Self::IntoFuture {
177 let client = self.client;
178 let request = self.request;
179 Box::pin(async move { client.create_credential(&request).await })
180 }
181}
182pub struct GetCredentialBuilder {
184 client: CredentialServiceClient,
185 request: GetCredentialRequest,
186}
187impl GetCredentialBuilder {
188 pub(crate) fn new(client: CredentialServiceClient, name: impl Into<String>) -> Self {
191 let request = GetCredentialRequest {
192 name: name.into(),
193 ..Default::default()
194 };
195 Self { client, request }
196 }
197}
198impl IntoFuture for GetCredentialBuilder {
199 type Output = Result<Credential>;
200 type IntoFuture = BoxFut<'static, Self::Output>;
201 fn into_future(self) -> Self::IntoFuture {
202 let client = self.client;
203 let request = self.request;
204 Box::pin(async move { client.get_credential(&request).await })
205 }
206}
207pub struct UpdateCredentialBuilder {
209 client: CredentialServiceClient,
210 request: UpdateCredentialRequest,
211}
212impl UpdateCredentialBuilder {
213 pub(crate) fn new(client: CredentialServiceClient, name: impl Into<String>) -> Self {
216 let request = UpdateCredentialRequest {
217 name: name.into(),
218 ..Default::default()
219 };
220 Self { client, request }
221 }
222 pub fn with_new_name(mut self, new_name: impl Into<Option<String>>) -> Self {
224 self.request.new_name = new_name.into();
225 self
226 }
227 pub fn with_comment(mut self, comment: impl Into<Option<String>>) -> Self {
229 self.request.comment = comment.into();
230 self
231 }
232 pub fn with_read_only(mut self, read_only: impl Into<Option<bool>>) -> Self {
234 self.request.read_only = read_only.into();
235 self
236 }
237 pub fn with_owner(mut self, owner: impl Into<Option<String>>) -> Self {
239 self.request.owner = owner.into();
240 self
241 }
242 pub fn with_skip_validation(mut self, skip_validation: impl Into<Option<bool>>) -> Self {
244 self.request.skip_validation = skip_validation.into();
245 self
246 }
247 pub fn with_force(mut self, force: impl Into<Option<bool>>) -> Self {
250 self.request.force = force.into();
251 self
252 }
253 pub fn with_azure_service_principal(
255 mut self,
256 azure_service_principal: impl Into<Option<AzureServicePrincipal>>,
257 ) -> Self {
258 self.request.azure_service_principal = {
259 let azure_service_principal: ::core::option::Option<_> = azure_service_principal.into();
260 buffa::MessageField::from(azure_service_principal)
261 };
262 self
263 }
264 pub fn with_azure_managed_identity(
266 mut self,
267 azure_managed_identity: impl Into<Option<AzureManagedIdentity>>,
268 ) -> Self {
269 self.request.azure_managed_identity = {
270 let azure_managed_identity: ::core::option::Option<_> = azure_managed_identity.into();
271 buffa::MessageField::from(azure_managed_identity)
272 };
273 self
274 }
275 pub fn with_azure_storage_key(
277 mut self,
278 azure_storage_key: impl Into<Option<AzureStorageKey>>,
279 ) -> Self {
280 self.request.azure_storage_key = {
281 let azure_storage_key: ::core::option::Option<_> = azure_storage_key.into();
282 buffa::MessageField::from(azure_storage_key)
283 };
284 self
285 }
286 pub fn with_aws_iam_role(mut self, aws_iam_role: impl Into<Option<AwsIamRoleConfig>>) -> Self {
288 self.request.aws_iam_role = {
289 let aws_iam_role: ::core::option::Option<_> = aws_iam_role.into();
290 buffa::MessageField::from(aws_iam_role)
291 };
292 self
293 }
294 pub fn with_databricks_gcp_service_account(
296 mut self,
297 databricks_gcp_service_account: impl Into<Option<DatabricksGcpServiceAccount>>,
298 ) -> Self {
299 self.request.databricks_gcp_service_account = {
300 let databricks_gcp_service_account: ::core::option::Option<_> =
301 databricks_gcp_service_account.into();
302 buffa::MessageField::from(databricks_gcp_service_account)
303 };
304 self
305 }
306}
307impl IntoFuture for UpdateCredentialBuilder {
308 type Output = Result<Credential>;
309 type IntoFuture = BoxFut<'static, Self::Output>;
310 fn into_future(self) -> Self::IntoFuture {
311 let client = self.client;
312 let request = self.request;
313 Box::pin(async move { client.update_credential(&request).await })
314 }
315}
316pub struct DeleteCredentialBuilder {
318 client: CredentialServiceClient,
319 request: DeleteCredentialRequest,
320}
321impl DeleteCredentialBuilder {
322 pub(crate) fn new(client: CredentialServiceClient, name: impl Into<String>) -> Self {
325 let request = DeleteCredentialRequest {
326 name: name.into(),
327 ..Default::default()
328 };
329 Self { client, request }
330 }
331}
332impl IntoFuture for DeleteCredentialBuilder {
333 type Output = Result<()>;
334 type IntoFuture = BoxFut<'static, Self::Output>;
335 fn into_future(self) -> Self::IntoFuture {
336 let client = self.client;
337 let request = self.request;
338 Box::pin(async move { client.delete_credential(&request).await })
339 }
340}