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)]
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::*;
12/// Builder for listing agent skills
13pub struct ListAgentSkillsBuilder {
14    client: AgentSkillServiceClient,
15    request: ListAgentSkillsRequest,
16}
17impl ListAgentSkillsBuilder {
18    /// Create a new builder instance.
19    /// Obtain via the corresponding method on `AgentSkillServiceClient`.
20    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    /// The maximum number of results per page that should be returned.
33    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    /// Opaque pagination token to go to next page based on previous query.
38    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    /** Whether to include agent skills in the response for which the principal can
43    only access selective metadata for.*/
44    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    /// Convert paginated request into stream of results
49    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}
81/// Builder for creating a agent skill
82pub struct CreateAgentSkillBuilder {
83    client: AgentSkillServiceClient,
84    request: CreateAgentSkillRequest,
85}
86impl CreateAgentSkillBuilder {
87    /// Create a new builder instance.
88    /// Obtain via the corresponding method on `AgentSkillServiceClient`.
89    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    /** The storage location of the skill directory on the cloud.
106
107    Required for EXTERNAL skills; ignored (server-derived) for MANAGED skills.*/
108    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    /// A human-readable description of what the skill does and when to use it.
113    pub fn with_description(mut self, description: impl Into<Option<String>>) -> Self {
114        self.request.description = description.into();
115        self
116    }
117    /// SPDX license identifier or free-form license text for the skill.
118    pub fn with_license(mut self, license: impl Into<Option<String>>) -> Self {
119        self.request.license = license.into();
120        self
121    }
122    /// The tools the skill is permitted to use.
123    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    /// Arbitrary additional metadata declared by the skill.
131    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    /// User-provided free-form text description.
144    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}
158/// Builder for getting a agent skill
159pub struct GetAgentSkillBuilder {
160    client: AgentSkillServiceClient,
161    request: GetAgentSkillRequest,
162}
163impl GetAgentSkillBuilder {
164    /// Create a new builder instance.
165    /// Obtain via the corresponding method on `AgentSkillServiceClient`.
166    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    /** Whether to include agent skills in the response for which the principal can
174    only access selective metadata for.*/
175    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}
189/// Builder for updating a agent skill
190pub struct UpdateAgentSkillBuilder {
191    client: AgentSkillServiceClient,
192    request: UpdateAgentSkillRequest,
193}
194impl UpdateAgentSkillBuilder {
195    /// Create a new builder instance.
196    /// Obtain via the corresponding method on `AgentSkillServiceClient`.
197    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    /// New name for the agent skill.
205    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    /// Updated description of what the skill does and when to use it.
210    pub fn with_description(mut self, description: impl Into<Option<String>>) -> Self {
211        self.request.description = description.into();
212        self
213    }
214    /// Updated tools the skill is permitted to use.
215    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    /// The comment attached to the agent skill.
223    pub fn with_comment(mut self, comment: impl Into<Option<String>>) -> Self {
224        self.request.comment = comment.into();
225        self
226    }
227    /// The identifier of the user who owns the agent skill.
228    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}
242/// Builder for deleting a agent skill
243pub struct DeleteAgentSkillBuilder {
244    client: AgentSkillServiceClient,
245    request: DeleteAgentSkillRequest,
246}
247impl DeleteAgentSkillBuilder {
248    /// Create a new builder instance.
249    /// Obtain via the corresponding method on `AgentSkillServiceClient`.
250    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}