unitycatalog_client/codegen/external_locations/
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::external_locations::v1::*;
12pub struct ListExternalLocationsBuilder {
14 client: ExternalLocationServiceClient,
15 request: ListExternalLocationsRequest,
16}
17impl ListExternalLocationsBuilder {
18 pub(crate) fn new(client: ExternalLocationServiceClient) -> Self {
21 let request = ListExternalLocationsRequest {
22 ..Default::default()
23 };
24 Self { client, request }
25 }
26 pub fn with_max_results(mut self, max_results: impl Into<Option<i32>>) -> Self {
28 self.request.max_results = max_results.into();
29 self
30 }
31 pub fn with_page_token(mut self, page_token: impl Into<Option<String>>) -> Self {
33 self.request.page_token = page_token.into();
34 self
35 }
36 pub fn with_include_browse(mut self, include_browse: impl Into<Option<bool>>) -> Self {
38 self.request.include_browse = include_browse.into();
39 self
40 }
41 pub fn into_stream(self) -> BoxStr<'static, Result<ExternalLocation>> {
43 let remaining = self.request.max_results;
44 let stream = stream_paginated(
45 (self, remaining),
46 move |(mut builder, mut remaining), page_token| async move {
47 builder.request.page_token = page_token;
48 let res = builder
49 .client
50 .list_external_locations(&builder.request)
51 .await?;
52 if let Some(ref mut rem) = remaining {
53 *rem -= res.external_locations.len() as i32;
54 }
55 let next_page_token = if remaining.is_some_and(|r| r <= 0) {
56 None
57 } else {
58 res.next_page_token.clone()
59 };
60 Ok((res, (builder, remaining), next_page_token))
61 },
62 )
63 .map_ok(|resp| futures::stream::iter(resp.external_locations.into_iter().map(Ok)))
64 .try_flatten();
65 stream.boxed()
66 }
67}
68impl IntoFuture for ListExternalLocationsBuilder {
69 type Output = Result<ListExternalLocationsResponse>;
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_external_locations(&request).await })
75 }
76}
77pub struct CreateExternalLocationBuilder {
79 client: ExternalLocationServiceClient,
80 request: CreateExternalLocationRequest,
81}
82impl CreateExternalLocationBuilder {
83 pub(crate) fn new(
86 client: ExternalLocationServiceClient,
87 name: impl Into<String>,
88 url: impl Into<String>,
89 credential_name: impl Into<String>,
90 ) -> Self {
91 let request = CreateExternalLocationRequest {
92 name: name.into(),
93 url: url.into(),
94 credential_name: credential_name.into(),
95 ..Default::default()
96 };
97 Self { client, request }
98 }
99 pub fn with_read_only(mut self, read_only: impl Into<Option<bool>>) -> Self {
101 self.request.read_only = read_only.into();
102 self
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_skip_validation(mut self, skip_validation: impl Into<Option<bool>>) -> Self {
111 self.request.skip_validation = skip_validation.into();
112 self
113 }
114}
115impl IntoFuture for CreateExternalLocationBuilder {
116 type Output = Result<ExternalLocation>;
117 type IntoFuture = BoxFut<'static, Self::Output>;
118 fn into_future(self) -> Self::IntoFuture {
119 let client = self.client;
120 let request = self.request;
121 Box::pin(async move { client.create_external_location(&request).await })
122 }
123}
124pub struct GetExternalLocationBuilder {
126 client: ExternalLocationServiceClient,
127 request: GetExternalLocationRequest,
128}
129impl GetExternalLocationBuilder {
130 pub(crate) fn new(client: ExternalLocationServiceClient, name: impl Into<String>) -> Self {
133 let request = GetExternalLocationRequest {
134 name: name.into(),
135 ..Default::default()
136 };
137 Self { client, request }
138 }
139}
140impl IntoFuture for GetExternalLocationBuilder {
141 type Output = Result<ExternalLocation>;
142 type IntoFuture = BoxFut<'static, Self::Output>;
143 fn into_future(self) -> Self::IntoFuture {
144 let client = self.client;
145 let request = self.request;
146 Box::pin(async move { client.get_external_location(&request).await })
147 }
148}
149pub struct UpdateExternalLocationBuilder {
151 client: ExternalLocationServiceClient,
152 request: UpdateExternalLocationRequest,
153}
154impl UpdateExternalLocationBuilder {
155 pub(crate) fn new(client: ExternalLocationServiceClient, name: impl Into<String>) -> Self {
158 let request = UpdateExternalLocationRequest {
159 name: name.into(),
160 ..Default::default()
161 };
162 Self { client, request }
163 }
164 pub fn with_url(mut self, url: impl Into<Option<String>>) -> Self {
166 self.request.url = url.into();
167 self
168 }
169 pub fn with_credential_name(mut self, credential_name: impl Into<Option<String>>) -> Self {
171 self.request.credential_name = credential_name.into();
172 self
173 }
174 pub fn with_read_only(mut self, read_only: impl Into<Option<bool>>) -> Self {
176 self.request.read_only = read_only.into();
177 self
178 }
179 pub fn with_owner(mut self, owner: impl Into<Option<String>>) -> Self {
181 self.request.owner = owner.into();
182 self
183 }
184 pub fn with_comment(mut self, comment: impl Into<Option<String>>) -> Self {
186 self.request.comment = comment.into();
187 self
188 }
189 pub fn with_new_name(mut self, new_name: impl Into<Option<String>>) -> Self {
191 self.request.new_name = new_name.into();
192 self
193 }
194 pub fn with_force(mut self, force: impl Into<Option<bool>>) -> Self {
196 self.request.force = force.into();
197 self
198 }
199 pub fn with_skip_validation(mut self, skip_validation: impl Into<Option<bool>>) -> Self {
201 self.request.skip_validation = skip_validation.into();
202 self
203 }
204}
205impl IntoFuture for UpdateExternalLocationBuilder {
206 type Output = Result<ExternalLocation>;
207 type IntoFuture = BoxFut<'static, Self::Output>;
208 fn into_future(self) -> Self::IntoFuture {
209 let client = self.client;
210 let request = self.request;
211 Box::pin(async move { client.update_external_location(&request).await })
212 }
213}
214pub struct DeleteExternalLocationBuilder {
216 client: ExternalLocationServiceClient,
217 request: DeleteExternalLocationRequest,
218}
219impl DeleteExternalLocationBuilder {
220 pub(crate) fn new(client: ExternalLocationServiceClient, name: impl Into<String>) -> Self {
223 let request = DeleteExternalLocationRequest {
224 name: name.into(),
225 ..Default::default()
226 };
227 Self { client, request }
228 }
229 pub fn with_force(mut self, force: impl Into<Option<bool>>) -> Self {
231 self.request.force = force.into();
232 self
233 }
234}
235impl IntoFuture for DeleteExternalLocationBuilder {
236 type Output = Result<()>;
237 type IntoFuture = BoxFut<'static, Self::Output>;
238 fn into_future(self) -> Self::IntoFuture {
239 let client = self.client;
240 let request = self.request;
241 Box::pin(async move { client.delete_external_location(&request).await })
242 }
243}