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 { name: name.into() };
134 Self { client, request }
135 }
136}
137impl IntoFuture for GetExternalLocationBuilder {
138 type Output = Result<ExternalLocation>;
139 type IntoFuture = BoxFut<'static, Self::Output>;
140 fn into_future(self) -> Self::IntoFuture {
141 let client = self.client;
142 let request = self.request;
143 Box::pin(async move { client.get_external_location(&request).await })
144 }
145}
146pub struct UpdateExternalLocationBuilder {
148 client: ExternalLocationServiceClient,
149 request: UpdateExternalLocationRequest,
150}
151impl UpdateExternalLocationBuilder {
152 pub(crate) fn new(client: ExternalLocationServiceClient, name: impl Into<String>) -> Self {
155 let request = UpdateExternalLocationRequest {
156 name: name.into(),
157 ..Default::default()
158 };
159 Self { client, request }
160 }
161 pub fn with_url(mut self, url: impl Into<Option<String>>) -> Self {
163 self.request.url = url.into();
164 self
165 }
166 pub fn with_credential_name(mut self, credential_name: impl Into<Option<String>>) -> Self {
168 self.request.credential_name = credential_name.into();
169 self
170 }
171 pub fn with_read_only(mut self, read_only: impl Into<Option<bool>>) -> Self {
173 self.request.read_only = read_only.into();
174 self
175 }
176 pub fn with_owner(mut self, owner: impl Into<Option<String>>) -> Self {
178 self.request.owner = owner.into();
179 self
180 }
181 pub fn with_comment(mut self, comment: impl Into<Option<String>>) -> Self {
183 self.request.comment = comment.into();
184 self
185 }
186 pub fn with_new_name(mut self, new_name: impl Into<Option<String>>) -> Self {
188 self.request.new_name = new_name.into();
189 self
190 }
191 pub fn with_force(mut self, force: impl Into<Option<bool>>) -> Self {
193 self.request.force = force.into();
194 self
195 }
196 pub fn with_skip_validation(mut self, skip_validation: impl Into<Option<bool>>) -> Self {
198 self.request.skip_validation = skip_validation.into();
199 self
200 }
201}
202impl IntoFuture for UpdateExternalLocationBuilder {
203 type Output = Result<ExternalLocation>;
204 type IntoFuture = BoxFut<'static, Self::Output>;
205 fn into_future(self) -> Self::IntoFuture {
206 let client = self.client;
207 let request = self.request;
208 Box::pin(async move { client.update_external_location(&request).await })
209 }
210}
211pub struct DeleteExternalLocationBuilder {
213 client: ExternalLocationServiceClient,
214 request: DeleteExternalLocationRequest,
215}
216impl DeleteExternalLocationBuilder {
217 pub(crate) fn new(client: ExternalLocationServiceClient, name: impl Into<String>) -> Self {
220 let request = DeleteExternalLocationRequest {
221 name: name.into(),
222 ..Default::default()
223 };
224 Self { client, request }
225 }
226 pub fn with_force(mut self, force: impl Into<Option<bool>>) -> Self {
228 self.request.force = force.into();
229 self
230 }
231}
232impl IntoFuture for DeleteExternalLocationBuilder {
233 type Output = Result<()>;
234 type IntoFuture = BoxFut<'static, Self::Output>;
235 fn into_future(self) -> Self::IntoFuture {
236 let client = self.client;
237 let request = self.request;
238 Box::pin(async move { client.delete_external_location(&request).await })
239 }
240}