unitycatalog_client/codegen/model_versions/
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::model_versions::v1::*;
18pub struct ListModelVersionsBuilder {
20 client: ModelVersionServiceClient,
21 request: ListModelVersionsRequest,
22}
23impl ListModelVersionsBuilder {
24 pub(crate) fn new(client: ModelVersionServiceClient, full_name: impl Into<String>) -> Self {
27 let request = ListModelVersionsRequest {
28 full_name: full_name.into(),
29 ..Default::default()
30 };
31 Self { client, request }
32 }
33 pub fn with_max_results(mut self, max_results: impl Into<Option<i32>>) -> Self {
35 self.request.max_results = max_results.into();
36 self
37 }
38 pub fn with_page_token(mut self, page_token: impl Into<Option<String>>) -> Self {
40 self.request.page_token = page_token.into();
41 self
42 }
43 pub fn with_include_browse(mut self, include_browse: impl Into<Option<bool>>) -> Self {
46 self.request.include_browse = include_browse.into();
47 self
48 }
49 pub fn into_stream(self) -> BoxStr<'static, Result<ModelVersion>> {
51 let remaining = self.request.max_results;
52 let stream = stream_paginated(
53 (self, remaining),
54 move |(mut builder, mut remaining), page_token| async move {
55 builder.request.page_token = page_token;
56 let res = builder.client.list_model_versions(&builder.request).await?;
57 if let Some(ref mut rem) = remaining {
58 *rem -= res.model_versions.len() as i32;
59 }
60 let next_page_token = if remaining.is_some_and(|r| r <= 0) {
61 None
62 } else {
63 res.next_page_token.clone()
64 };
65 Ok((res, (builder, remaining), next_page_token))
66 },
67 )
68 .map_ok(|resp| futures::stream::iter(resp.model_versions.into_iter().map(Ok)))
69 .try_flatten();
70 #[cfg(not(target_arch = "wasm32"))]
71 let stream = stream.boxed();
72 #[cfg(target_arch = "wasm32")]
73 let stream = stream.boxed_local();
74 stream
75 }
76}
77impl IntoFuture for ListModelVersionsBuilder {
78 type Output = Result<ListModelVersionsResponse>;
79 type IntoFuture = BoxFut<'static, Self::Output>;
80 fn into_future(self) -> Self::IntoFuture {
81 let client = self.client;
82 let request = self.request;
83 Box::pin(async move { client.list_model_versions(&request).await })
84 }
85}
86pub struct CreateModelVersionBuilder {
88 client: ModelVersionServiceClient,
89 request: CreateModelVersionRequest,
90}
91impl CreateModelVersionBuilder {
92 pub(crate) fn new(
95 client: ModelVersionServiceClient,
96 model_name: impl Into<String>,
97 catalog_name: impl Into<String>,
98 schema_name: impl Into<String>,
99 source: impl Into<String>,
100 ) -> Self {
101 let request = CreateModelVersionRequest {
102 model_name: model_name.into(),
103 catalog_name: catalog_name.into(),
104 schema_name: schema_name.into(),
105 source: source.into(),
106 ..Default::default()
107 };
108 Self { client, request }
109 }
110 pub fn with_run_id(mut self, run_id: impl Into<Option<String>>) -> Self {
112 self.request.run_id = run_id.into();
113 self
114 }
115 pub fn with_comment(mut self, comment: impl Into<Option<String>>) -> Self {
117 self.request.comment = comment.into();
118 self
119 }
120}
121impl IntoFuture for CreateModelVersionBuilder {
122 type Output = Result<ModelVersion>;
123 type IntoFuture = BoxFut<'static, Self::Output>;
124 fn into_future(self) -> Self::IntoFuture {
125 let client = self.client;
126 let request = self.request;
127 Box::pin(async move { client.create_model_version(&request).await })
128 }
129}
130pub struct GetModelVersionBuilder {
132 client: ModelVersionServiceClient,
133 request: GetModelVersionRequest,
134}
135impl GetModelVersionBuilder {
136 pub(crate) fn new(
139 client: ModelVersionServiceClient,
140 full_name: impl Into<String>,
141 version: i64,
142 ) -> Self {
143 let request = GetModelVersionRequest {
144 full_name: full_name.into(),
145 version,
146 ..Default::default()
147 };
148 Self { client, request }
149 }
150 pub fn with_include_browse(mut self, include_browse: impl Into<Option<bool>>) -> Self {
153 self.request.include_browse = include_browse.into();
154 self
155 }
156}
157impl IntoFuture for GetModelVersionBuilder {
158 type Output = Result<ModelVersion>;
159 type IntoFuture = BoxFut<'static, Self::Output>;
160 fn into_future(self) -> Self::IntoFuture {
161 let client = self.client;
162 let request = self.request;
163 Box::pin(async move { client.get_model_version(&request).await })
164 }
165}
166pub struct UpdateModelVersionBuilder {
168 client: ModelVersionServiceClient,
169 request: UpdateModelVersionRequest,
170}
171impl UpdateModelVersionBuilder {
172 pub(crate) fn new(
175 client: ModelVersionServiceClient,
176 full_name: impl Into<String>,
177 version: i64,
178 ) -> Self {
179 let request = UpdateModelVersionRequest {
180 full_name: full_name.into(),
181 version,
182 ..Default::default()
183 };
184 Self { client, request }
185 }
186 pub fn with_comment(mut self, comment: impl Into<Option<String>>) -> Self {
188 self.request.comment = comment.into();
189 self
190 }
191}
192impl IntoFuture for UpdateModelVersionBuilder {
193 type Output = Result<ModelVersion>;
194 type IntoFuture = BoxFut<'static, Self::Output>;
195 fn into_future(self) -> Self::IntoFuture {
196 let client = self.client;
197 let request = self.request;
198 Box::pin(async move { client.update_model_version(&request).await })
199 }
200}
201pub struct DeleteModelVersionBuilder {
203 client: ModelVersionServiceClient,
204 request: DeleteModelVersionRequest,
205}
206impl DeleteModelVersionBuilder {
207 pub(crate) fn new(
210 client: ModelVersionServiceClient,
211 full_name: impl Into<String>,
212 version: i64,
213 ) -> Self {
214 let request = DeleteModelVersionRequest {
215 full_name: full_name.into(),
216 version,
217 ..Default::default()
218 };
219 Self { client, request }
220 }
221}
222impl IntoFuture for DeleteModelVersionBuilder {
223 type Output = Result<()>;
224 type IntoFuture = BoxFut<'static, Self::Output>;
225 fn into_future(self) -> Self::IntoFuture {
226 let client = self.client;
227 let request = self.request;
228 Box::pin(async move { client.delete_model_version(&request).await })
229 }
230}
231pub struct FinalizeModelVersionBuilder {
233 client: ModelVersionServiceClient,
234 request: FinalizeModelVersionRequest,
235}
236impl FinalizeModelVersionBuilder {
237 pub(crate) fn new(
240 client: ModelVersionServiceClient,
241 full_name: impl Into<String>,
242 version: i64,
243 ) -> Self {
244 let request = FinalizeModelVersionRequest {
245 full_name: full_name.into(),
246 version,
247 ..Default::default()
248 };
249 Self { client, request }
250 }
251}
252impl IntoFuture for FinalizeModelVersionBuilder {
253 type Output = Result<ModelVersion>;
254 type IntoFuture = BoxFut<'static, Self::Output>;
255 fn into_future(self) -> Self::IntoFuture {
256 let client = self.client;
257 let request = self.request;
258 Box::pin(async move { client.finalize_model_version(&request).await })
259 }
260}