unitycatalog_client/codegen/tables/
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::tables::v1::*;
18pub struct ListTableSummariesBuilder {
20 client: TableServiceClient,
21 request: ListTableSummariesRequest,
22}
23impl ListTableSummariesBuilder {
24 pub(crate) fn new(client: TableServiceClient, catalog_name: impl Into<String>) -> Self {
27 let request = ListTableSummariesRequest {
28 catalog_name: catalog_name.into(),
29 ..Default::default()
30 };
31 Self { client, request }
32 }
33 pub fn with_schema_name_pattern(
35 mut self,
36 schema_name_pattern: impl Into<Option<String>>,
37 ) -> Self {
38 self.request.schema_name_pattern = schema_name_pattern.into();
39 self
40 }
41 pub fn with_table_name_pattern(
43 mut self,
44 table_name_pattern: impl Into<Option<String>>,
45 ) -> Self {
46 self.request.table_name_pattern = table_name_pattern.into();
47 self
48 }
49 pub fn with_max_results(mut self, max_results: impl Into<Option<i32>>) -> Self {
51 self.request.max_results = max_results.into();
52 self
53 }
54 pub fn with_page_token(mut self, page_token: impl Into<Option<String>>) -> Self {
56 self.request.page_token = page_token.into();
57 self
58 }
59 pub fn with_include_manifest_capabilities(
61 mut self,
62 include_manifest_capabilities: impl Into<Option<bool>>,
63 ) -> Self {
64 self.request.include_manifest_capabilities = include_manifest_capabilities.into();
65 self
66 }
67}
68impl IntoFuture for ListTableSummariesBuilder {
69 type Output = Result<ListTableSummariesResponse>;
70 type IntoFuture = BoxFut<'static, Self::Output>;
71 fn into_future(self) -> Self::IntoFuture {
72 let client = self.client;
73 let request = self.request;
74 Box::pin(async move { client.list_table_summaries(&request).await })
75 }
76}
77pub struct ListTablesBuilder {
79 client: TableServiceClient,
80 request: ListTablesRequest,
81}
82impl ListTablesBuilder {
83 pub(crate) fn new(
86 client: TableServiceClient,
87 catalog_name: impl Into<String>,
88 schema_name: impl Into<String>,
89 ) -> Self {
90 let request = ListTablesRequest {
91 catalog_name: catalog_name.into(),
92 schema_name: schema_name.into(),
93 ..Default::default()
94 };
95 Self { client, request }
96 }
97 pub fn with_max_results(mut self, max_results: impl Into<Option<i32>>) -> Self {
99 self.request.max_results = max_results.into();
100 self
101 }
102 pub fn with_page_token(mut self, page_token: impl Into<Option<String>>) -> Self {
104 self.request.page_token = page_token.into();
105 self
106 }
107 pub fn with_include_delta_metadata(
109 mut self,
110 include_delta_metadata: impl Into<Option<bool>>,
111 ) -> Self {
112 self.request.include_delta_metadata = include_delta_metadata.into();
113 self
114 }
115 pub fn with_omit_columns(mut self, omit_columns: impl Into<Option<bool>>) -> Self {
117 self.request.omit_columns = omit_columns.into();
118 self
119 }
120 pub fn with_omit_properties(mut self, omit_properties: impl Into<Option<bool>>) -> Self {
122 self.request.omit_properties = omit_properties.into();
123 self
124 }
125 pub fn with_omit_username(mut self, omit_username: impl Into<Option<bool>>) -> Self {
127 self.request.omit_username = omit_username.into();
128 self
129 }
130 pub fn with_include_browse(mut self, include_browse: impl Into<Option<bool>>) -> Self {
132 self.request.include_browse = include_browse.into();
133 self
134 }
135 pub fn with_include_manifest_capabilities(
137 mut self,
138 include_manifest_capabilities: impl Into<Option<bool>>,
139 ) -> Self {
140 self.request.include_manifest_capabilities = include_manifest_capabilities.into();
141 self
142 }
143 pub fn into_stream(self) -> BoxStr<'static, Result<Table>> {
145 let remaining = self.request.max_results;
146 let stream = stream_paginated(
147 (self, remaining),
148 move |(mut builder, mut remaining), page_token| async move {
149 builder.request.page_token = page_token;
150 let res = builder.client.list_tables(&builder.request).await?;
151 if let Some(ref mut rem) = remaining {
152 *rem -= res.tables.len() as i32;
153 }
154 let next_page_token = if remaining.is_some_and(|r| r <= 0) {
155 None
156 } else {
157 res.next_page_token.clone()
158 };
159 Ok((res, (builder, remaining), next_page_token))
160 },
161 )
162 .map_ok(|resp| futures::stream::iter(resp.tables.into_iter().map(Ok)))
163 .try_flatten();
164 #[cfg(not(target_arch = "wasm32"))]
165 let stream = stream.boxed();
166 #[cfg(target_arch = "wasm32")]
167 let stream = stream.boxed_local();
168 stream
169 }
170}
171impl IntoFuture for ListTablesBuilder {
172 type Output = Result<ListTablesResponse>;
173 type IntoFuture = BoxFut<'static, Self::Output>;
174 fn into_future(self) -> Self::IntoFuture {
175 let client = self.client;
176 let request = self.request;
177 Box::pin(async move { client.list_tables(&request).await })
178 }
179}
180pub struct CreateTableBuilder {
182 client: TableServiceClient,
183 request: CreateTableRequest,
184}
185impl CreateTableBuilder {
186 pub(crate) fn new(
189 client: TableServiceClient,
190 name: impl Into<String>,
191 schema_name: impl Into<String>,
192 catalog_name: impl Into<String>,
193 table_type: TableType,
194 data_source_format: DataSourceFormat,
195 ) -> Self {
196 let request = CreateTableRequest {
197 name: name.into(),
198 schema_name: schema_name.into(),
199 catalog_name: catalog_name.into(),
200 table_type: buffa::EnumValue::Known(table_type),
201 data_source_format: buffa::EnumValue::Known(data_source_format),
202 ..Default::default()
203 };
204 Self { client, request }
205 }
206 pub fn with_columns<I>(mut self, columns: I) -> Self
208 where
209 I: IntoIterator<Item = Column>,
210 {
211 self.request.columns = columns.into_iter().collect();
212 self
213 }
214 pub fn with_storage_location(mut self, storage_location: impl Into<Option<String>>) -> Self {
216 self.request.storage_location = storage_location.into();
217 self
218 }
219 pub fn with_comment(mut self, comment: impl Into<Option<String>>) -> Self {
221 self.request.comment = comment.into();
222 self
223 }
224 pub fn with_properties<I, K, V>(mut self, properties: I) -> Self
226 where
227 I: IntoIterator<Item = (K, V)>,
228 K: Into<String>,
229 V: Into<String>,
230 {
231 self.request.properties = properties
232 .into_iter()
233 .map(|(k, v)| (k.into(), v.into()))
234 .collect();
235 self
236 }
237 pub fn with_view_definition(mut self, view_definition: impl Into<Option<String>>) -> Self {
241 self.request.view_definition = view_definition.into();
242 self
243 }
244 pub fn with_view_dependencies(
248 mut self,
249 view_dependencies: impl Into<Option<DependencyList>>,
250 ) -> Self {
251 self.request.view_dependencies = {
252 let view_dependencies: ::core::option::Option<_> = view_dependencies.into();
253 buffa::MessageField::from(view_dependencies)
254 };
255 self
256 }
257}
258impl IntoFuture for CreateTableBuilder {
259 type Output = Result<Table>;
260 type IntoFuture = BoxFut<'static, Self::Output>;
261 fn into_future(self) -> Self::IntoFuture {
262 let client = self.client;
263 let request = self.request;
264 Box::pin(async move { client.create_table(&request).await })
265 }
266}
267pub struct GetTableBuilder {
269 client: TableServiceClient,
270 request: GetTableRequest,
271}
272impl GetTableBuilder {
273 pub(crate) fn new(client: TableServiceClient, full_name: impl Into<String>) -> Self {
276 let request = GetTableRequest {
277 full_name: full_name.into(),
278 ..Default::default()
279 };
280 Self { client, request }
281 }
282 pub fn with_include_delta_metadata(
284 mut self,
285 include_delta_metadata: impl Into<Option<bool>>,
286 ) -> Self {
287 self.request.include_delta_metadata = include_delta_metadata.into();
288 self
289 }
290 pub fn with_include_browse(mut self, include_browse: impl Into<Option<bool>>) -> Self {
292 self.request.include_browse = include_browse.into();
293 self
294 }
295 pub fn with_include_manifest_capabilities(
297 mut self,
298 include_manifest_capabilities: impl Into<Option<bool>>,
299 ) -> Self {
300 self.request.include_manifest_capabilities = include_manifest_capabilities.into();
301 self
302 }
303}
304impl IntoFuture for GetTableBuilder {
305 type Output = Result<Table>;
306 type IntoFuture = BoxFut<'static, Self::Output>;
307 fn into_future(self) -> Self::IntoFuture {
308 let client = self.client;
309 let request = self.request;
310 Box::pin(async move { client.get_table(&request).await })
311 }
312}
313pub struct GetTableExistsBuilder {
315 client: TableServiceClient,
316 request: GetTableExistsRequest,
317}
318impl GetTableExistsBuilder {
319 pub(crate) fn new(client: TableServiceClient, full_name: impl Into<String>) -> Self {
322 let request = GetTableExistsRequest {
323 full_name: full_name.into(),
324 ..Default::default()
325 };
326 Self { client, request }
327 }
328}
329impl IntoFuture for GetTableExistsBuilder {
330 type Output = Result<GetTableExistsResponse>;
331 type IntoFuture = BoxFut<'static, Self::Output>;
332 fn into_future(self) -> Self::IntoFuture {
333 let client = self.client;
334 let request = self.request;
335 Box::pin(async move { client.get_table_exists(&request).await })
336 }
337}
338pub struct DeleteTableBuilder {
340 client: TableServiceClient,
341 request: DeleteTableRequest,
342}
343impl DeleteTableBuilder {
344 pub(crate) fn new(client: TableServiceClient, full_name: impl Into<String>) -> Self {
347 let request = DeleteTableRequest {
348 full_name: full_name.into(),
349 ..Default::default()
350 };
351 Self { client, request }
352 }
353}
354impl IntoFuture for DeleteTableBuilder {
355 type Output = Result<()>;
356 type IntoFuture = BoxFut<'static, Self::Output>;
357 fn into_future(self) -> Self::IntoFuture {
358 let client = self.client;
359 let request = self.request;
360 Box::pin(async move { client.delete_table(&request).await })
361 }
362}