Skip to main content

unitycatalog_client/codegen/external_locations/
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::external_locations::v1::*;
18/// Builder for listing external locations
19pub struct ListExternalLocationsBuilder {
20    client: ExternalLocationServiceClient,
21    request: ListExternalLocationsRequest,
22}
23impl ListExternalLocationsBuilder {
24    /// Create a new builder instance.
25    /// Obtain via the corresponding method on `ExternalLocationServiceClient`.
26    pub(crate) fn new(client: ExternalLocationServiceClient) -> Self {
27        let request = ListExternalLocationsRequest {
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    /// Whether to include schemas in the response for which the principal can only access selective metadata for
43    pub fn with_include_browse(mut self, include_browse: impl Into<Option<bool>>) -> Self {
44        self.request.include_browse = include_browse.into();
45        self
46    }
47    /// Convert paginated request into stream of results
48    pub fn into_stream(self) -> BoxStr<'static, Result<ExternalLocation>> {
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
55                    .client
56                    .list_external_locations(&builder.request)
57                    .await?;
58                if let Some(ref mut rem) = remaining {
59                    *rem -= res.external_locations.len() as i32;
60                }
61                let next_page_token = if remaining.is_some_and(|r| r <= 0) {
62                    None
63                } else {
64                    res.next_page_token.clone()
65                };
66                Ok((res, (builder, remaining), next_page_token))
67            },
68        )
69        .map_ok(|resp| futures::stream::iter(resp.external_locations.into_iter().map(Ok)))
70        .try_flatten();
71        #[cfg(not(target_arch = "wasm32"))]
72        let stream = stream.boxed();
73        #[cfg(target_arch = "wasm32")]
74        let stream = stream.boxed_local();
75        stream
76    }
77}
78impl IntoFuture for ListExternalLocationsBuilder {
79    type Output = Result<ListExternalLocationsResponse>;
80    type IntoFuture = BoxFut<'static, Self::Output>;
81    fn into_future(self) -> Self::IntoFuture {
82        let client = self.client;
83        let request = self.request;
84        Box::pin(async move { client.list_external_locations(&request).await })
85    }
86}
87/// Builder for creating a external location
88pub struct CreateExternalLocationBuilder {
89    client: ExternalLocationServiceClient,
90    request: CreateExternalLocationRequest,
91}
92impl CreateExternalLocationBuilder {
93    /// Create a new builder instance.
94    /// Obtain via the corresponding method on `ExternalLocationServiceClient`.
95    pub(crate) fn new(
96        client: ExternalLocationServiceClient,
97        name: impl Into<String>,
98        url: impl Into<String>,
99        credential_name: impl Into<String>,
100    ) -> Self {
101        let request = CreateExternalLocationRequest {
102            name: name.into(),
103            url: url.into(),
104            credential_name: credential_name.into(),
105            ..Default::default()
106        };
107        Self { client, request }
108    }
109    /// Indicates whether the external location is read-only.
110    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    /// User-provided free-form text description.
115    pub fn with_comment(mut self, comment: impl Into<Option<String>>) -> Self {
116        self.request.comment = comment.into();
117        self
118    }
119    /// Skips validation of the storage credential associated with the external location.
120    pub fn with_skip_validation(mut self, skip_validation: impl Into<Option<bool>>) -> Self {
121        self.request.skip_validation = skip_validation.into();
122        self
123    }
124}
125impl IntoFuture for CreateExternalLocationBuilder {
126    type Output = Result<ExternalLocation>;
127    type IntoFuture = BoxFut<'static, Self::Output>;
128    fn into_future(self) -> Self::IntoFuture {
129        let client = self.client;
130        let request = self.request;
131        Box::pin(async move { client.create_external_location(&request).await })
132    }
133}
134/// Builder for getting a external location
135pub struct GetExternalLocationBuilder {
136    client: ExternalLocationServiceClient,
137    request: GetExternalLocationRequest,
138}
139impl GetExternalLocationBuilder {
140    /// Create a new builder instance.
141    /// Obtain via the corresponding method on `ExternalLocationServiceClient`.
142    pub(crate) fn new(client: ExternalLocationServiceClient, name: impl Into<String>) -> Self {
143        let request = GetExternalLocationRequest {
144            name: name.into(),
145            ..Default::default()
146        };
147        Self { client, request }
148    }
149}
150impl IntoFuture for GetExternalLocationBuilder {
151    type Output = Result<ExternalLocation>;
152    type IntoFuture = BoxFut<'static, Self::Output>;
153    fn into_future(self) -> Self::IntoFuture {
154        let client = self.client;
155        let request = self.request;
156        Box::pin(async move { client.get_external_location(&request).await })
157    }
158}
159/// Builder for updating a external location
160pub struct UpdateExternalLocationBuilder {
161    client: ExternalLocationServiceClient,
162    request: UpdateExternalLocationRequest,
163}
164impl UpdateExternalLocationBuilder {
165    /// Create a new builder instance.
166    /// Obtain via the corresponding method on `ExternalLocationServiceClient`.
167    pub(crate) fn new(client: ExternalLocationServiceClient, name: impl Into<String>) -> Self {
168        let request = UpdateExternalLocationRequest {
169            name: name.into(),
170            ..Default::default()
171        };
172        Self { client, request }
173    }
174    /// Path URL of the external location.
175    pub fn with_url(mut self, url: impl Into<Option<String>>) -> Self {
176        self.request.url = url.into();
177        self
178    }
179    /// Name of the storage credential used with this location.
180    pub fn with_credential_name(mut self, credential_name: impl Into<Option<String>>) -> Self {
181        self.request.credential_name = credential_name.into();
182        self
183    }
184    /// Indicates whether the external location is read-only.
185    pub fn with_read_only(mut self, read_only: impl Into<Option<bool>>) -> Self {
186        self.request.read_only = read_only.into();
187        self
188    }
189    /// owner of the external location.
190    pub fn with_owner(mut self, owner: impl Into<Option<String>>) -> Self {
191        self.request.owner = owner.into();
192        self
193    }
194    /// User-provided free-form text description.
195    pub fn with_comment(mut self, comment: impl Into<Option<String>>) -> Self {
196        self.request.comment = comment.into();
197        self
198    }
199    /// new name of the external location.
200    pub fn with_new_name(mut self, new_name: impl Into<Option<String>>) -> Self {
201        self.request.new_name = new_name.into();
202        self
203    }
204    /// force update of the external location.
205    pub fn with_force(mut self, force: impl Into<Option<bool>>) -> Self {
206        self.request.force = force.into();
207        self
208    }
209    /// Skips validation of the storage credential associated with the external location.
210    pub fn with_skip_validation(mut self, skip_validation: impl Into<Option<bool>>) -> Self {
211        self.request.skip_validation = skip_validation.into();
212        self
213    }
214}
215impl IntoFuture for UpdateExternalLocationBuilder {
216    type Output = Result<ExternalLocation>;
217    type IntoFuture = BoxFut<'static, Self::Output>;
218    fn into_future(self) -> Self::IntoFuture {
219        let client = self.client;
220        let request = self.request;
221        Box::pin(async move { client.update_external_location(&request).await })
222    }
223}
224/// Builder for deleting a external location
225pub struct DeleteExternalLocationBuilder {
226    client: ExternalLocationServiceClient,
227    request: DeleteExternalLocationRequest,
228}
229impl DeleteExternalLocationBuilder {
230    /// Create a new builder instance.
231    /// Obtain via the corresponding method on `ExternalLocationServiceClient`.
232    pub(crate) fn new(client: ExternalLocationServiceClient, name: impl Into<String>) -> Self {
233        let request = DeleteExternalLocationRequest {
234            name: name.into(),
235            ..Default::default()
236        };
237        Self { client, request }
238    }
239    /// Force deletion even if the external location is not empty.
240    pub fn with_force(mut self, force: impl Into<Option<bool>>) -> Self {
241        self.request.force = force.into();
242        self
243    }
244}
245impl IntoFuture for DeleteExternalLocationBuilder {
246    type Output = Result<()>;
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.delete_external_location(&request).await })
252    }
253}