unitycatalog_client/codegen/agent_skills/
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::agent_skills::v0alpha1::*;
12pub struct ListAgentSkillsBuilder {
14 client: AgentSkillServiceClient,
15 request: ListAgentSkillsRequest,
16}
17impl ListAgentSkillsBuilder {
18 pub(crate) fn new(
21 client: AgentSkillServiceClient,
22 catalog_name: impl Into<String>,
23 schema_name: impl Into<String>,
24 ) -> Self {
25 let request = ListAgentSkillsRequest {
26 catalog_name: catalog_name.into(),
27 schema_name: schema_name.into(),
28 ..Default::default()
29 };
30 Self { client, request }
31 }
32 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 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 pub fn with_include_browse(mut self, include_browse: impl Into<Option<bool>>) -> Self {
45 self.request.include_browse = include_browse.into();
46 self
47 }
48 pub fn into_stream(self) -> BoxStr<'static, Result<AgentSkill>> {
50 let remaining = self.request.max_results;
51 let stream = stream_paginated(
52 (self, remaining),
53 move |(mut builder, mut remaining), page_token| async move {
54 builder.request.page_token = page_token;
55 let res = builder.client.list_agent_skills(&builder.request).await?;
56 if let Some(ref mut rem) = remaining {
57 *rem -= res.agent_skills.len() as i32;
58 }
59 let next_page_token = if remaining.is_some_and(|r| r <= 0) {
60 None
61 } else {
62 res.next_page_token.clone()
63 };
64 Ok((res, (builder, remaining), next_page_token))
65 },
66 )
67 .map_ok(|resp| futures::stream::iter(resp.agent_skills.into_iter().map(Ok)))
68 .try_flatten();
69 stream.boxed()
70 }
71}
72impl IntoFuture for ListAgentSkillsBuilder {
73 type Output = Result<ListAgentSkillsResponse>;
74 type IntoFuture = BoxFut<'static, Self::Output>;
75 fn into_future(self) -> Self::IntoFuture {
76 let client = self.client;
77 let request = self.request;
78 Box::pin(async move { client.list_agent_skills(&request).await })
79 }
80}
81pub struct CreateAgentSkillBuilder {
83 client: AgentSkillServiceClient,
84 request: CreateAgentSkillRequest,
85}
86impl CreateAgentSkillBuilder {
87 pub(crate) fn new(
90 client: AgentSkillServiceClient,
91 catalog_name: impl Into<String>,
92 schema_name: impl Into<String>,
93 name: impl Into<String>,
94 agent_skill_type: AgentSkillType,
95 ) -> Self {
96 let request = CreateAgentSkillRequest {
97 catalog_name: catalog_name.into(),
98 schema_name: schema_name.into(),
99 name: name.into(),
100 agent_skill_type: buffa::EnumValue::Known(agent_skill_type),
101 ..Default::default()
102 };
103 Self { client, request }
104 }
105 pub fn with_storage_location(mut self, storage_location: impl Into<Option<String>>) -> Self {
109 self.request.storage_location = storage_location.into();
110 self
111 }
112 pub fn with_description(mut self, description: impl Into<Option<String>>) -> Self {
114 self.request.description = description.into();
115 self
116 }
117 pub fn with_license(mut self, license: impl Into<Option<String>>) -> Self {
119 self.request.license = license.into();
120 self
121 }
122 pub fn with_allowed_tools<I>(mut self, allowed_tools: I) -> Self
124 where
125 I: IntoIterator<Item = String>,
126 {
127 self.request.allowed_tools = allowed_tools.into_iter().collect();
128 self
129 }
130 pub fn with_metadata<I, K, V>(mut self, metadata: I) -> Self
132 where
133 I: IntoIterator<Item = (K, V)>,
134 K: Into<String>,
135 V: Into<String>,
136 {
137 self.request.metadata = metadata
138 .into_iter()
139 .map(|(k, v)| (k.into(), v.into()))
140 .collect();
141 self
142 }
143 pub fn with_comment(mut self, comment: impl Into<Option<String>>) -> Self {
145 self.request.comment = comment.into();
146 self
147 }
148}
149impl IntoFuture for CreateAgentSkillBuilder {
150 type Output = Result<AgentSkill>;
151 type IntoFuture = BoxFut<'static, Self::Output>;
152 fn into_future(self) -> Self::IntoFuture {
153 let client = self.client;
154 let request = self.request;
155 Box::pin(async move { client.create_agent_skill(&request).await })
156 }
157}
158pub struct GetAgentSkillBuilder {
160 client: AgentSkillServiceClient,
161 request: GetAgentSkillRequest,
162}
163impl GetAgentSkillBuilder {
164 pub(crate) fn new(client: AgentSkillServiceClient, name: impl Into<String>) -> Self {
167 let request = GetAgentSkillRequest {
168 name: name.into(),
169 ..Default::default()
170 };
171 Self { client, request }
172 }
173 pub fn with_include_browse(mut self, include_browse: impl Into<Option<bool>>) -> Self {
176 self.request.include_browse = include_browse.into();
177 self
178 }
179}
180impl IntoFuture for GetAgentSkillBuilder {
181 type Output = Result<AgentSkill>;
182 type IntoFuture = BoxFut<'static, Self::Output>;
183 fn into_future(self) -> Self::IntoFuture {
184 let client = self.client;
185 let request = self.request;
186 Box::pin(async move { client.get_agent_skill(&request).await })
187 }
188}
189pub struct UpdateAgentSkillBuilder {
191 client: AgentSkillServiceClient,
192 request: UpdateAgentSkillRequest,
193}
194impl UpdateAgentSkillBuilder {
195 pub(crate) fn new(client: AgentSkillServiceClient, name: impl Into<String>) -> Self {
198 let request = UpdateAgentSkillRequest {
199 name: name.into(),
200 ..Default::default()
201 };
202 Self { client, request }
203 }
204 pub fn with_new_name(mut self, new_name: impl Into<Option<String>>) -> Self {
206 self.request.new_name = new_name.into();
207 self
208 }
209 pub fn with_description(mut self, description: impl Into<Option<String>>) -> Self {
211 self.request.description = description.into();
212 self
213 }
214 pub fn with_allowed_tools<I>(mut self, allowed_tools: I) -> Self
216 where
217 I: IntoIterator<Item = String>,
218 {
219 self.request.allowed_tools = allowed_tools.into_iter().collect();
220 self
221 }
222 pub fn with_comment(mut self, comment: impl Into<Option<String>>) -> Self {
224 self.request.comment = comment.into();
225 self
226 }
227 pub fn with_owner(mut self, owner: impl Into<Option<String>>) -> Self {
229 self.request.owner = owner.into();
230 self
231 }
232}
233impl IntoFuture for UpdateAgentSkillBuilder {
234 type Output = Result<AgentSkill>;
235 type IntoFuture = BoxFut<'static, Self::Output>;
236 fn into_future(self) -> Self::IntoFuture {
237 let client = self.client;
238 let request = self.request;
239 Box::pin(async move { client.update_agent_skill(&request).await })
240 }
241}
242pub struct DeleteAgentSkillBuilder {
244 client: AgentSkillServiceClient,
245 request: DeleteAgentSkillRequest,
246}
247impl DeleteAgentSkillBuilder {
248 pub(crate) fn new(client: AgentSkillServiceClient, name: impl Into<String>) -> Self {
251 let request = DeleteAgentSkillRequest {
252 name: name.into(),
253 ..Default::default()
254 };
255 Self { client, request }
256 }
257}
258impl IntoFuture for DeleteAgentSkillBuilder {
259 type Output = Result<()>;
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.delete_agent_skill(&request).await })
265 }
266}