Skip to main content

unitycatalog_client/codegen/shares/
builders.rs

1// @generated — do not edit by hand.
2#![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::shares::v1::*;
18/// Builder for listing shares
19pub struct ListSharesBuilder {
20    client: ShareServiceClient,
21    request: ListSharesRequest,
22}
23impl ListSharesBuilder {
24    /// Create a new builder instance.
25    /// Obtain via the corresponding method on `ShareServiceClient`.
26    pub(crate) fn new(client: ShareServiceClient) -> Self {
27        let request = ListSharesRequest {
28            ..Default::default()
29        };
30        Self { client, request }
31    }
32    /// The maximum number of results per page that should be returned.
33    pub fn with_max_results(mut self, max_results: impl Into<Option<i32>>) -> Self {
34        self.request.max_results = max_results.into();
35        self
36    }
37    /// Opaque pagination token to go to next page based on previous query.
38    pub fn with_page_token(mut self, page_token: impl Into<Option<String>>) -> Self {
39        self.request.page_token = page_token.into();
40        self
41    }
42    /// Convert paginated request into stream of results
43    pub fn into_stream(self) -> BoxStr<'static, Result<Share>> {
44        let remaining = self.request.max_results;
45        let stream = stream_paginated(
46            (self, remaining),
47            move |(mut builder, mut remaining), page_token| async move {
48                builder.request.page_token = page_token;
49                let res = builder.client.list_shares(&builder.request).await?;
50                if let Some(ref mut rem) = remaining {
51                    *rem -= res.shares.len() as i32;
52                }
53                let next_page_token = if remaining.is_some_and(|r| r <= 0) {
54                    None
55                } else {
56                    res.next_page_token.clone()
57                };
58                Ok((res, (builder, remaining), next_page_token))
59            },
60        )
61        .map_ok(|resp| futures::stream::iter(resp.shares.into_iter().map(Ok)))
62        .try_flatten();
63        #[cfg(not(target_arch = "wasm32"))]
64        let stream = stream.boxed();
65        #[cfg(target_arch = "wasm32")]
66        let stream = stream.boxed_local();
67        stream
68    }
69}
70impl IntoFuture for ListSharesBuilder {
71    type Output = Result<ListSharesResponse>;
72    type IntoFuture = BoxFut<'static, Self::Output>;
73    fn into_future(self) -> Self::IntoFuture {
74        let client = self.client;
75        let request = self.request;
76        Box::pin(async move { client.list_shares(&request).await })
77    }
78}
79/// Builder for creating a share
80pub struct CreateShareBuilder {
81    client: ShareServiceClient,
82    request: CreateShareRequest,
83}
84impl CreateShareBuilder {
85    /// Create a new builder instance.
86    /// Obtain via the corresponding method on `ShareServiceClient`.
87    pub(crate) fn new(client: ShareServiceClient, name: impl Into<String>) -> Self {
88        let request = CreateShareRequest {
89            name: name.into(),
90            ..Default::default()
91        };
92        Self { client, request }
93    }
94    /// User-provided free-form text description.
95    pub fn with_comment(mut self, comment: impl Into<Option<String>>) -> Self {
96        self.request.comment = comment.into();
97        self
98    }
99}
100impl IntoFuture for CreateShareBuilder {
101    type Output = Result<Share>;
102    type IntoFuture = BoxFut<'static, Self::Output>;
103    fn into_future(self) -> Self::IntoFuture {
104        let client = self.client;
105        let request = self.request;
106        Box::pin(async move { client.create_share(&request).await })
107    }
108}
109/// Builder for getting a share
110pub struct GetShareBuilder {
111    client: ShareServiceClient,
112    request: GetShareRequest,
113}
114impl GetShareBuilder {
115    /// Create a new builder instance.
116    /// Obtain via the corresponding method on `ShareServiceClient`.
117    pub(crate) fn new(client: ShareServiceClient, name: impl Into<String>) -> Self {
118        let request = GetShareRequest {
119            name: name.into(),
120            ..Default::default()
121        };
122        Self { client, request }
123    }
124    /// Query for data to include in the share.
125    pub fn with_include_shared_data(
126        mut self,
127        include_shared_data: impl Into<Option<bool>>,
128    ) -> Self {
129        self.request.include_shared_data = include_shared_data.into();
130        self
131    }
132}
133impl IntoFuture for GetShareBuilder {
134    type Output = Result<Share>;
135    type IntoFuture = BoxFut<'static, Self::Output>;
136    fn into_future(self) -> Self::IntoFuture {
137        let client = self.client;
138        let request = self.request;
139        Box::pin(async move { client.get_share(&request).await })
140    }
141}
142/// Builder for updating a share
143pub struct UpdateShareBuilder {
144    client: ShareServiceClient,
145    request: UpdateShareRequest,
146}
147impl UpdateShareBuilder {
148    /// Create a new builder instance.
149    /// Obtain via the corresponding method on `ShareServiceClient`.
150    pub(crate) fn new(client: ShareServiceClient, name: impl Into<String>) -> Self {
151        let request = UpdateShareRequest {
152            name: name.into(),
153            ..Default::default()
154        };
155        Self { client, request }
156    }
157    /// Array of shared data object updates.
158    pub fn with_updates<I>(mut self, updates: I) -> Self
159    where
160        I: IntoIterator<Item = DataObjectUpdate>,
161    {
162        self.request.updates = updates.into_iter().collect();
163        self
164    }
165    /// A new name for the share.
166    pub fn with_new_name(mut self, new_name: impl Into<Option<String>>) -> Self {
167        self.request.new_name = new_name.into();
168        self
169    }
170    /// Owner of the share.
171    pub fn with_owner(mut self, owner: impl Into<Option<String>>) -> Self {
172        self.request.owner = owner.into();
173        self
174    }
175    /// User-provided free-form text description.
176    pub fn with_comment(mut self, comment: impl Into<Option<String>>) -> Self {
177        self.request.comment = comment.into();
178        self
179    }
180}
181impl IntoFuture for UpdateShareBuilder {
182    type Output = Result<Share>;
183    type IntoFuture = BoxFut<'static, Self::Output>;
184    fn into_future(self) -> Self::IntoFuture {
185        let client = self.client;
186        let request = self.request;
187        Box::pin(async move { client.update_share(&request).await })
188    }
189}
190/// Builder for deleting a share
191pub struct DeleteShareBuilder {
192    client: ShareServiceClient,
193    request: DeleteShareRequest,
194}
195impl DeleteShareBuilder {
196    /// Create a new builder instance.
197    /// Obtain via the corresponding method on `ShareServiceClient`.
198    pub(crate) fn new(client: ShareServiceClient, name: impl Into<String>) -> Self {
199        let request = DeleteShareRequest {
200            name: name.into(),
201            ..Default::default()
202        };
203        Self { client, request }
204    }
205}
206impl IntoFuture for DeleteShareBuilder {
207    type Output = Result<()>;
208    type IntoFuture = BoxFut<'static, Self::Output>;
209    fn into_future(self) -> Self::IntoFuture {
210        let client = self.client;
211        let request = self.request;
212        Box::pin(async move { client.delete_share(&request).await })
213    }
214}
215/// Builder for permissions
216pub struct GetPermissionsBuilder {
217    client: ShareServiceClient,
218    request: GetPermissionsRequest,
219}
220impl GetPermissionsBuilder {
221    /// Create a new builder instance.
222    /// Obtain via the corresponding method on `ShareServiceClient`.
223    pub(crate) fn new(client: ShareServiceClient, name: impl Into<String>) -> Self {
224        let request = GetPermissionsRequest {
225            name: name.into(),
226            ..Default::default()
227        };
228        Self { client, request }
229    }
230    /// The maximum number of results per page that should be returned.
231    pub fn with_max_results(mut self, max_results: impl Into<Option<i32>>) -> Self {
232        self.request.max_results = max_results.into();
233        self
234    }
235    /// Opaque pagination token to go to next page based on previous query.
236    pub fn with_page_token(mut self, page_token: impl Into<Option<String>>) -> Self {
237        self.request.page_token = page_token.into();
238        self
239    }
240}
241impl IntoFuture for GetPermissionsBuilder {
242    type Output = Result<GetPermissionsResponse>;
243    type IntoFuture = BoxFut<'static, Self::Output>;
244    fn into_future(self) -> Self::IntoFuture {
245        let client = self.client;
246        let request = self.request;
247        Box::pin(async move { client.get_permissions(&request).await })
248    }
249}
250/// Builder for permissions
251pub struct UpdatePermissionsBuilder {
252    client: ShareServiceClient,
253    request: UpdatePermissionsRequest,
254}
255impl UpdatePermissionsBuilder {
256    /// Create a new builder instance.
257    /// Obtain via the corresponding method on `ShareServiceClient`.
258    pub(crate) fn new(client: ShareServiceClient, name: impl Into<String>) -> Self {
259        let request = UpdatePermissionsRequest {
260            name: name.into(),
261            ..Default::default()
262        };
263        Self { client, request }
264    }
265    /// Array of permissions change objects.
266    pub fn with_changes<I>(mut self, changes: I) -> Self
267    where
268        I: IntoIterator<Item = PermissionsChange>,
269    {
270        self.request.changes = changes.into_iter().collect();
271        self
272    }
273    /// Whether to return the latest permissions list of the share in the response.
274    pub fn with_omit_permissions_list(
275        mut self,
276        omit_permissions_list: impl Into<Option<bool>>,
277    ) -> Self {
278        self.request.omit_permissions_list = omit_permissions_list.into();
279        self
280    }
281}
282impl IntoFuture for UpdatePermissionsBuilder {
283    type Output = Result<UpdatePermissionsResponse>;
284    type IntoFuture = BoxFut<'static, Self::Output>;
285    fn into_future(self) -> Self::IntoFuture {
286        let client = self.client;
287        let request = self.request;
288        Box::pin(async move { client.update_permissions(&request).await })
289    }
290}