unitycatalog_client/codegen/tables/
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::tables::v1::*;
12pub struct ListTableSummariesBuilder {
14 client: TableServiceClient,
15 request: ListTableSummariesRequest,
16}
17impl ListTableSummariesBuilder {
18 pub(crate) fn new(client: TableServiceClient, catalog_name: impl Into<String>) -> Self {
21 let request = ListTableSummariesRequest {
22 catalog_name: catalog_name.into(),
23 ..Default::default()
24 };
25 Self { client, request }
26 }
27 pub fn with_schema_name_pattern(
29 mut self,
30 schema_name_pattern: impl Into<Option<String>>,
31 ) -> Self {
32 self.request.schema_name_pattern = schema_name_pattern.into();
33 self
34 }
35 pub fn with_table_name_pattern(
37 mut self,
38 table_name_pattern: impl Into<Option<String>>,
39 ) -> Self {
40 self.request.table_name_pattern = table_name_pattern.into();
41 self
42 }
43 pub fn with_max_results(mut self, max_results: impl Into<Option<i32>>) -> Self {
45 self.request.max_results = max_results.into();
46 self
47 }
48 pub fn with_page_token(mut self, page_token: impl Into<Option<String>>) -> Self {
50 self.request.page_token = page_token.into();
51 self
52 }
53 pub fn with_include_manifest_capabilities(
55 mut self,
56 include_manifest_capabilities: impl Into<Option<bool>>,
57 ) -> Self {
58 self.request.include_manifest_capabilities = include_manifest_capabilities.into();
59 self
60 }
61}
62impl IntoFuture for ListTableSummariesBuilder {
63 type Output = Result<ListTableSummariesResponse>;
64 type IntoFuture = BoxFut<'static, Self::Output>;
65 fn into_future(self) -> Self::IntoFuture {
66 let client = self.client;
67 let request = self.request;
68 Box::pin(async move { client.list_table_summaries(&request).await })
69 }
70}
71pub struct ListTablesBuilder {
73 client: TableServiceClient,
74 request: ListTablesRequest,
75}
76impl ListTablesBuilder {
77 pub(crate) fn new(
80 client: TableServiceClient,
81 catalog_name: impl Into<String>,
82 schema_name: impl Into<String>,
83 ) -> Self {
84 let request = ListTablesRequest {
85 catalog_name: catalog_name.into(),
86 schema_name: schema_name.into(),
87 ..Default::default()
88 };
89 Self { client, request }
90 }
91 pub fn with_max_results(mut self, max_results: impl Into<Option<i32>>) -> Self {
93 self.request.max_results = max_results.into();
94 self
95 }
96 pub fn with_page_token(mut self, page_token: impl Into<Option<String>>) -> Self {
98 self.request.page_token = page_token.into();
99 self
100 }
101 pub fn with_include_delta_metadata(
103 mut self,
104 include_delta_metadata: impl Into<Option<bool>>,
105 ) -> Self {
106 self.request.include_delta_metadata = include_delta_metadata.into();
107 self
108 }
109 pub fn with_omit_columns(mut self, omit_columns: impl Into<Option<bool>>) -> Self {
111 self.request.omit_columns = omit_columns.into();
112 self
113 }
114 pub fn with_omit_properties(mut self, omit_properties: impl Into<Option<bool>>) -> Self {
116 self.request.omit_properties = omit_properties.into();
117 self
118 }
119 pub fn with_omit_username(mut self, omit_username: impl Into<Option<bool>>) -> Self {
121 self.request.omit_username = omit_username.into();
122 self
123 }
124 pub fn with_include_browse(mut self, include_browse: impl Into<Option<bool>>) -> Self {
126 self.request.include_browse = include_browse.into();
127 self
128 }
129 pub fn with_include_manifest_capabilities(
131 mut self,
132 include_manifest_capabilities: impl Into<Option<bool>>,
133 ) -> Self {
134 self.request.include_manifest_capabilities = include_manifest_capabilities.into();
135 self
136 }
137 pub fn into_stream(self) -> BoxStr<'static, Result<Table>> {
139 let remaining = self.request.max_results;
140 let stream = stream_paginated(
141 (self, remaining),
142 move |(mut builder, mut remaining), page_token| async move {
143 builder.request.page_token = page_token;
144 let res = builder.client.list_tables(&builder.request).await?;
145 if let Some(ref mut rem) = remaining {
146 *rem -= res.tables.len() as i32;
147 }
148 let next_page_token = if remaining.is_some_and(|r| r <= 0) {
149 None
150 } else {
151 res.next_page_token.clone()
152 };
153 Ok((res, (builder, remaining), next_page_token))
154 },
155 )
156 .map_ok(|resp| futures::stream::iter(resp.tables.into_iter().map(Ok)))
157 .try_flatten();
158 stream.boxed()
159 }
160}
161impl IntoFuture for ListTablesBuilder {
162 type Output = Result<ListTablesResponse>;
163 type IntoFuture = BoxFut<'static, Self::Output>;
164 fn into_future(self) -> Self::IntoFuture {
165 let client = self.client;
166 let request = self.request;
167 Box::pin(async move { client.list_tables(&request).await })
168 }
169}
170pub struct CreateTableBuilder {
172 client: TableServiceClient,
173 request: CreateTableRequest,
174}
175impl CreateTableBuilder {
176 pub(crate) fn new(
179 client: TableServiceClient,
180 name: impl Into<String>,
181 schema_name: impl Into<String>,
182 catalog_name: impl Into<String>,
183 table_type: TableType,
184 data_source_format: DataSourceFormat,
185 ) -> Self {
186 let request = CreateTableRequest {
187 name: name.into(),
188 schema_name: schema_name.into(),
189 catalog_name: catalog_name.into(),
190 table_type: table_type as i32,
191 data_source_format: data_source_format as i32,
192 ..Default::default()
193 };
194 Self { client, request }
195 }
196 pub fn with_columns<I>(mut self, columns: I) -> Self
198 where
199 I: IntoIterator<Item = Column>,
200 {
201 self.request.columns = columns.into_iter().collect();
202 self
203 }
204 pub fn with_storage_location(mut self, storage_location: impl Into<Option<String>>) -> Self {
206 self.request.storage_location = storage_location.into();
207 self
208 }
209 pub fn with_comment(mut self, comment: impl Into<Option<String>>) -> Self {
211 self.request.comment = comment.into();
212 self
213 }
214 pub fn with_properties<I, K, V>(mut self, properties: I) -> Self
216 where
217 I: IntoIterator<Item = (K, V)>,
218 K: Into<String>,
219 V: Into<String>,
220 {
221 self.request.properties = properties
222 .into_iter()
223 .map(|(k, v)| (k.into(), v.into()))
224 .collect();
225 self
226 }
227 pub fn with_view_definition(mut self, view_definition: impl Into<Option<String>>) -> Self {
231 self.request.view_definition = view_definition.into();
232 self
233 }
234 pub fn with_view_dependencies(
238 mut self,
239 view_dependencies: impl Into<Option<DependencyList>>,
240 ) -> Self {
241 self.request.view_dependencies = view_dependencies.into();
242 self
243 }
244}
245impl IntoFuture for CreateTableBuilder {
246 type Output = Result<Table>;
247 type IntoFuture = BoxFut<'static, Self::Output>;
248 fn into_future(self) -> Self::IntoFuture {
249 let client = self.client;
250 let request = self.request;
251 Box::pin(async move { client.create_table(&request).await })
252 }
253}
254pub struct GetTableBuilder {
256 client: TableServiceClient,
257 request: GetTableRequest,
258}
259impl GetTableBuilder {
260 pub(crate) fn new(client: TableServiceClient, full_name: impl Into<String>) -> Self {
263 let request = GetTableRequest {
264 full_name: full_name.into(),
265 ..Default::default()
266 };
267 Self { client, request }
268 }
269 pub fn with_include_delta_metadata(
271 mut self,
272 include_delta_metadata: impl Into<Option<bool>>,
273 ) -> Self {
274 self.request.include_delta_metadata = include_delta_metadata.into();
275 self
276 }
277 pub fn with_include_browse(mut self, include_browse: impl Into<Option<bool>>) -> Self {
279 self.request.include_browse = include_browse.into();
280 self
281 }
282 pub fn with_include_manifest_capabilities(
284 mut self,
285 include_manifest_capabilities: impl Into<Option<bool>>,
286 ) -> Self {
287 self.request.include_manifest_capabilities = include_manifest_capabilities.into();
288 self
289 }
290}
291impl IntoFuture for GetTableBuilder {
292 type Output = Result<Table>;
293 type IntoFuture = BoxFut<'static, Self::Output>;
294 fn into_future(self) -> Self::IntoFuture {
295 let client = self.client;
296 let request = self.request;
297 Box::pin(async move { client.get_table(&request).await })
298 }
299}
300pub struct GetTableExistsBuilder {
302 client: TableServiceClient,
303 request: GetTableExistsRequest,
304}
305impl GetTableExistsBuilder {
306 pub(crate) fn new(client: TableServiceClient, full_name: impl Into<String>) -> Self {
309 let request = GetTableExistsRequest {
310 full_name: full_name.into(),
311 };
312 Self { client, request }
313 }
314}
315impl IntoFuture for GetTableExistsBuilder {
316 type Output = Result<GetTableExistsResponse>;
317 type IntoFuture = BoxFut<'static, Self::Output>;
318 fn into_future(self) -> Self::IntoFuture {
319 let client = self.client;
320 let request = self.request;
321 Box::pin(async move { client.get_table_exists(&request).await })
322 }
323}
324pub struct DeleteTableBuilder {
326 client: TableServiceClient,
327 request: DeleteTableRequest,
328}
329impl DeleteTableBuilder {
330 pub(crate) fn new(client: TableServiceClient, full_name: impl Into<String>) -> Self {
333 let request = DeleteTableRequest {
334 full_name: full_name.into(),
335 };
336 Self { client, request }
337 }
338}
339impl IntoFuture for DeleteTableBuilder {
340 type Output = Result<()>;
341 type IntoFuture = BoxFut<'static, Self::Output>;
342 fn into_future(self) -> Self::IntoFuture {
343 let client = self.client;
344 let request = self.request;
345 Box::pin(async move { client.delete_table(&request).await })
346 }
347}