Skip to main content

unitycatalog_client/codegen/agent_skills/
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::agent_skills::v0alpha1::*;
18/// Builder for listing agent skills
19pub struct ListAgentSkillsBuilder {
20    client: AgentSkillServiceClient,
21    request: ListAgentSkillsRequest,
22}
23impl ListAgentSkillsBuilder {
24    /// Create a new builder instance.
25    /// Obtain via the corresponding method on `AgentSkillServiceClient`.
26    pub(crate) fn new(
27        client: AgentSkillServiceClient,
28        catalog_name: impl Into<String>,
29        schema_name: impl Into<String>,
30    ) -> Self {
31        let request = ListAgentSkillsRequest {
32            catalog_name: catalog_name.into(),
33            schema_name: schema_name.into(),
34            ..Default::default()
35        };
36        Self { client, request }
37    }
38    /// The maximum number of results per page that should be returned.
39    pub fn with_max_results(mut self, max_results: impl Into<Option<i32>>) -> Self {
40        self.request.max_results = max_results.into();
41        self
42    }
43    /// Opaque pagination token to go to next page based on previous query.
44    pub fn with_page_token(mut self, page_token: impl Into<Option<String>>) -> Self {
45        self.request.page_token = page_token.into();
46        self
47    }
48    /** Whether to include agent skills in the response for which the principal can
49    only access selective metadata for.*/
50    pub fn with_include_browse(mut self, include_browse: impl Into<Option<bool>>) -> Self {
51        self.request.include_browse = include_browse.into();
52        self
53    }
54    /// Convert paginated request into stream of results
55    pub fn into_stream(self) -> BoxStr<'static, Result<AgentSkill>> {
56        let remaining = self.request.max_results;
57        let stream = stream_paginated(
58            (self, remaining),
59            move |(mut builder, mut remaining), page_token| async move {
60                builder.request.page_token = page_token;
61                let res = builder.client.list_agent_skills(&builder.request).await?;
62                if let Some(ref mut rem) = remaining {
63                    *rem -= res.agent_skills.len() as i32;
64                }
65                let next_page_token = if remaining.is_some_and(|r| r <= 0) {
66                    None
67                } else {
68                    res.next_page_token.clone()
69                };
70                Ok((res, (builder, remaining), next_page_token))
71            },
72        )
73        .map_ok(|resp| futures::stream::iter(resp.agent_skills.into_iter().map(Ok)))
74        .try_flatten();
75        #[cfg(not(target_arch = "wasm32"))]
76        let stream = stream.boxed();
77        #[cfg(target_arch = "wasm32")]
78        let stream = stream.boxed_local();
79        stream
80    }
81}
82impl IntoFuture for ListAgentSkillsBuilder {
83    type Output = Result<ListAgentSkillsResponse>;
84    type IntoFuture = BoxFut<'static, Self::Output>;
85    fn into_future(self) -> Self::IntoFuture {
86        let client = self.client;
87        let request = self.request;
88        Box::pin(async move { client.list_agent_skills(&request).await })
89    }
90}
91/// Builder for creating a agent skill
92pub struct CreateAgentSkillBuilder {
93    client: AgentSkillServiceClient,
94    request: CreateAgentSkillRequest,
95}
96impl CreateAgentSkillBuilder {
97    /// Create a new builder instance.
98    /// Obtain via the corresponding method on `AgentSkillServiceClient`.
99    pub(crate) fn new(
100        client: AgentSkillServiceClient,
101        catalog_name: impl Into<String>,
102        schema_name: impl Into<String>,
103        name: impl Into<String>,
104        agent_skill_type: AgentSkillType,
105    ) -> Self {
106        let request = CreateAgentSkillRequest {
107            catalog_name: catalog_name.into(),
108            schema_name: schema_name.into(),
109            name: name.into(),
110            agent_skill_type: buffa::EnumValue::Known(agent_skill_type),
111            ..Default::default()
112        };
113        Self { client, request }
114    }
115    /** The storage location of the skill directory on the cloud.
116
117    Required for EXTERNAL skills; ignored (server-derived) for MANAGED skills.*/
118    pub fn with_storage_location(mut self, storage_location: impl Into<Option<String>>) -> Self {
119        self.request.storage_location = storage_location.into();
120        self
121    }
122    /// A human-readable description of what the skill does and when to use it.
123    pub fn with_description(mut self, description: impl Into<Option<String>>) -> Self {
124        self.request.description = description.into();
125        self
126    }
127    /// SPDX license identifier or free-form license text for the skill.
128    pub fn with_license(mut self, license: impl Into<Option<String>>) -> Self {
129        self.request.license = license.into();
130        self
131    }
132    /// The tools the skill is permitted to use.
133    pub fn with_allowed_tools<I>(mut self, allowed_tools: I) -> Self
134    where
135        I: IntoIterator<Item = String>,
136    {
137        self.request.allowed_tools = allowed_tools.into_iter().collect();
138        self
139    }
140    /// Arbitrary additional metadata declared by the skill.
141    pub fn with_metadata<I, K, V>(mut self, metadata: I) -> Self
142    where
143        I: IntoIterator<Item = (K, V)>,
144        K: Into<String>,
145        V: Into<String>,
146    {
147        self.request.metadata = metadata
148            .into_iter()
149            .map(|(k, v)| (k.into(), v.into()))
150            .collect();
151        self
152    }
153    /// User-provided free-form text description.
154    pub fn with_comment(mut self, comment: impl Into<Option<String>>) -> Self {
155        self.request.comment = comment.into();
156        self
157    }
158}
159impl IntoFuture for CreateAgentSkillBuilder {
160    type Output = Result<AgentSkill>;
161    type IntoFuture = BoxFut<'static, Self::Output>;
162    fn into_future(self) -> Self::IntoFuture {
163        let client = self.client;
164        let request = self.request;
165        Box::pin(async move { client.create_agent_skill(&request).await })
166    }
167}
168/// Builder for getting a agent skill
169pub struct GetAgentSkillBuilder {
170    client: AgentSkillServiceClient,
171    request: GetAgentSkillRequest,
172}
173impl GetAgentSkillBuilder {
174    /// Create a new builder instance.
175    /// Obtain via the corresponding method on `AgentSkillServiceClient`.
176    pub(crate) fn new(client: AgentSkillServiceClient, name: impl Into<String>) -> Self {
177        let request = GetAgentSkillRequest {
178            name: name.into(),
179            ..Default::default()
180        };
181        Self { client, request }
182    }
183    /** Whether to include agent skills in the response for which the principal can
184    only access selective metadata for.*/
185    pub fn with_include_browse(mut self, include_browse: impl Into<Option<bool>>) -> Self {
186        self.request.include_browse = include_browse.into();
187        self
188    }
189}
190impl IntoFuture for GetAgentSkillBuilder {
191    type Output = Result<AgentSkill>;
192    type IntoFuture = BoxFut<'static, Self::Output>;
193    fn into_future(self) -> Self::IntoFuture {
194        let client = self.client;
195        let request = self.request;
196        Box::pin(async move { client.get_agent_skill(&request).await })
197    }
198}
199/// Builder for updating a agent skill
200pub struct UpdateAgentSkillBuilder {
201    client: AgentSkillServiceClient,
202    request: UpdateAgentSkillRequest,
203}
204impl UpdateAgentSkillBuilder {
205    /// Create a new builder instance.
206    /// Obtain via the corresponding method on `AgentSkillServiceClient`.
207    pub(crate) fn new(client: AgentSkillServiceClient, name: impl Into<String>) -> Self {
208        let request = UpdateAgentSkillRequest {
209            name: name.into(),
210            ..Default::default()
211        };
212        Self { client, request }
213    }
214    /// New name for the agent skill.
215    pub fn with_new_name(mut self, new_name: impl Into<Option<String>>) -> Self {
216        self.request.new_name = new_name.into();
217        self
218    }
219    /// Updated description of what the skill does and when to use it.
220    pub fn with_description(mut self, description: impl Into<Option<String>>) -> Self {
221        self.request.description = description.into();
222        self
223    }
224    /// Updated tools the skill is permitted to use.
225    pub fn with_allowed_tools<I>(mut self, allowed_tools: I) -> Self
226    where
227        I: IntoIterator<Item = String>,
228    {
229        self.request.allowed_tools = allowed_tools.into_iter().collect();
230        self
231    }
232    /// The comment attached to the agent skill.
233    pub fn with_comment(mut self, comment: impl Into<Option<String>>) -> Self {
234        self.request.comment = comment.into();
235        self
236    }
237    /// The identifier of the user who owns the agent skill.
238    pub fn with_owner(mut self, owner: impl Into<Option<String>>) -> Self {
239        self.request.owner = owner.into();
240        self
241    }
242}
243impl IntoFuture for UpdateAgentSkillBuilder {
244    type Output = Result<AgentSkill>;
245    type IntoFuture = BoxFut<'static, Self::Output>;
246    fn into_future(self) -> Self::IntoFuture {
247        let client = self.client;
248        let request = self.request;
249        Box::pin(async move { client.update_agent_skill(&request).await })
250    }
251}
252/// Builder for deleting a agent skill
253pub struct DeleteAgentSkillBuilder {
254    client: AgentSkillServiceClient,
255    request: DeleteAgentSkillRequest,
256}
257impl DeleteAgentSkillBuilder {
258    /// Create a new builder instance.
259    /// Obtain via the corresponding method on `AgentSkillServiceClient`.
260    pub(crate) fn new(client: AgentSkillServiceClient, name: impl Into<String>) -> Self {
261        let request = DeleteAgentSkillRequest {
262            name: name.into(),
263            ..Default::default()
264        };
265        Self { client, request }
266    }
267}
268impl IntoFuture for DeleteAgentSkillBuilder {
269    type Output = Result<()>;
270    type IntoFuture = BoxFut<'static, Self::Output>;
271    fn into_future(self) -> Self::IntoFuture {
272        let client = self.client;
273        let request = self.request;
274        Box::pin(async move { client.delete_agent_skill(&request).await })
275    }
276}