Skip to main content

ghl_sdk/services/
agent_studio.rs

1// @generated by xtask/generate_services.py — do not edit by hand.
2//! `agent-studio` — typed methods for all 11 API v2 operations
3//! in this module.
4//!
5//! Access via [`Ghl::agent_studio`](crate::Ghl::agent_studio).
6//!
7//! Request and response types come from [`ghl_models::v2::agent_studio`](https://docs.rs/ghl-models/latest/ghl_models/v2/agent_studio/); every endpoint is also documented in the
8//! [`agent-studio` API reference](https://github.com/Shahroz/ghl-rs/blob/main/docs/api/agent-studio.md).
9//!
10//! Enable with `features = ["agent-studio"]`.
11
12#![allow(clippy::too_many_arguments)]
13
14use crate::client::Ghl;
15use crate::error::Result;
16use ghl_models::v2::agent_studio as models;
17
18/// Typed access to the `agent-studio` API v2 surface (11 operations). Obtained via
19/// [`Ghl::agent_studio`](crate::Ghl::agent_studio).
20#[derive(Debug, Clone)]
21pub struct AgentStudioService {
22    pub(crate) client: Ghl,
23}
24
25impl AgentStudioService {
26    pub(crate) fn new(client: Ghl) -> Self {
27        Self { client }
28    }
29}
30
31/// Query parameters for [`AgentStudioService::list_agents`].
32#[derive(Debug, Clone, Default)]
33pub struct ListAgentsParams {
34    /// `locationId` query parameter.
35    /// Required by the API.
36    pub location_id: String,
37    /// Optional filter to return only agents with a published production version
38    pub is_published: Option<String>,
39    /// `limit` query parameter.
40    /// Required by the API.
41    pub limit: String,
42    /// `offset` query parameter.
43    /// Required by the API.
44    pub offset: String,
45    /// `source` query parameter.
46    pub source: Option<String>,
47}
48
49impl ListAgentsParams {
50    /// Start from the parameters the API requires.
51    pub fn new(
52        location_id: impl Into<String>,
53        limit: impl Into<String>,
54        offset: impl Into<String>,
55    ) -> Self {
56        Self {
57            location_id: location_id.into(),
58            limit: limit.into(),
59            offset: offset.into(),
60            ..Default::default()
61        }
62    }
63
64    /// Optional filter to return only agents with a published production version
65    pub fn is_published(mut self, v: impl Into<String>) -> Self {
66        self.is_published = Some(v.into());
67        self
68    }
69
70    /// Set the `source` query parameter.
71    pub fn source(mut self, v: impl Into<String>) -> Self {
72        self.source = Some(v.into());
73        self
74    }
75
76    fn to_query(&self) -> Vec<(String, String)> {
77        let mut q: Vec<(String, String)> = vec![
78            ("locationId".into(), self.location_id.clone()),
79            ("limit".into(), self.limit.clone()),
80            ("offset".into(), self.offset.clone()),
81        ];
82        if let Some(v) = &self.is_published {
83            q.push(("isPublished".into(), v.to_string()));
84        }
85        if let Some(v) = &self.source {
86            q.push(("source".into(), v.to_string()));
87        }
88        q
89    }
90}
91
92/// Query parameters for [`AgentStudioService::create_agent`].
93#[derive(Debug, Clone, Default)]
94pub struct CreateAgentParams {
95    /// `source` query parameter.
96    pub source: Option<String>,
97}
98
99impl CreateAgentParams {
100    /// Start from the parameters the API requires.
101    pub fn new() -> Self {
102        Self {
103            ..Default::default()
104        }
105    }
106
107    /// Set the `source` query parameter.
108    pub fn source(mut self, v: impl Into<String>) -> Self {
109        self.source = Some(v.into());
110        self
111    }
112
113    fn to_query(&self) -> Vec<(String, String)> {
114        let mut q: Vec<(String, String)> = Vec::new();
115        if let Some(v) = &self.source {
116            q.push(("source".into(), v.to_string()));
117        }
118        q
119    }
120}
121
122/// Query parameters for [`AgentStudioService::update_agent`].
123#[derive(Debug, Clone, Default)]
124pub struct UpdateAgentParams {
125    /// `source` query parameter.
126    pub source: Option<String>,
127}
128
129impl UpdateAgentParams {
130    /// Start from the parameters the API requires.
131    pub fn new() -> Self {
132        Self {
133            ..Default::default()
134        }
135    }
136
137    /// Set the `source` query parameter.
138    pub fn source(mut self, v: impl Into<String>) -> Self {
139        self.source = Some(v.into());
140        self
141    }
142
143    fn to_query(&self) -> Vec<(String, String)> {
144        let mut q: Vec<(String, String)> = Vec::new();
145        if let Some(v) = &self.source {
146            q.push(("source".into(), v.to_string()));
147        }
148        q
149    }
150}
151
152/// Query parameters for [`AgentStudioService::promote_to_production`].
153#[derive(Debug, Clone, Default)]
154pub struct PromoteToProductionParams {
155    /// `source` query parameter.
156    pub source: Option<String>,
157}
158
159impl PromoteToProductionParams {
160    /// Start from the parameters the API requires.
161    pub fn new() -> Self {
162        Self {
163            ..Default::default()
164        }
165    }
166
167    /// Set the `source` query parameter.
168    pub fn source(mut self, v: impl Into<String>) -> Self {
169        self.source = Some(v.into());
170        self
171    }
172
173    fn to_query(&self) -> Vec<(String, String)> {
174        let mut q: Vec<(String, String)> = Vec::new();
175        if let Some(v) = &self.source {
176            q.push(("source".into(), v.to_string()));
177        }
178        q
179    }
180}
181
182/// Query parameters for [`AgentStudioService::delete_agent`].
183#[derive(Debug, Clone, Default)]
184pub struct DeleteAgentParams {
185    /// `locationId` query parameter.
186    /// Required by the API.
187    pub location_id: String,
188    /// `source` query parameter.
189    pub source: Option<String>,
190}
191
192impl DeleteAgentParams {
193    /// Start from the parameters the API requires.
194    pub fn new(location_id: impl Into<String>) -> Self {
195        Self {
196            location_id: location_id.into(),
197            ..Default::default()
198        }
199    }
200
201    /// Set the `source` query parameter.
202    pub fn source(mut self, v: impl Into<String>) -> Self {
203        self.source = Some(v.into());
204        self
205    }
206
207    fn to_query(&self) -> Vec<(String, String)> {
208        let mut q: Vec<(String, String)> = vec![("locationId".into(), self.location_id.clone())];
209        if let Some(v) = &self.source {
210            q.push(("source".into(), v.to_string()));
211        }
212        q
213    }
214}
215
216/// Query parameters for [`AgentStudioService::get_agent`].
217#[derive(Debug, Clone, Default)]
218pub struct GetAgentParams {
219    /// `locationId` query parameter.
220    /// Required by the API.
221    pub location_id: String,
222    /// `source` query parameter.
223    pub source: Option<String>,
224}
225
226impl GetAgentParams {
227    /// Start from the parameters the API requires.
228    pub fn new(location_id: impl Into<String>) -> Self {
229        Self {
230            location_id: location_id.into(),
231            ..Default::default()
232        }
233    }
234
235    /// Set the `source` query parameter.
236    pub fn source(mut self, v: impl Into<String>) -> Self {
237        self.source = Some(v.into());
238        self
239    }
240
241    fn to_query(&self) -> Vec<(String, String)> {
242        let mut q: Vec<(String, String)> = vec![("locationId".into(), self.location_id.clone())];
243        if let Some(v) = &self.source {
244            q.push(("source".into(), v.to_string()));
245        }
246        q
247    }
248}
249
250/// Query parameters for [`AgentStudioService::update_agent_metadata`].
251#[derive(Debug, Clone, Default)]
252pub struct UpdateAgentMetadataParams {
253    /// `source` query parameter.
254    pub source: Option<String>,
255}
256
257impl UpdateAgentMetadataParams {
258    /// Start from the parameters the API requires.
259    pub fn new() -> Self {
260        Self {
261            ..Default::default()
262        }
263    }
264
265    /// Set the `source` query parameter.
266    pub fn source(mut self, v: impl Into<String>) -> Self {
267        self.source = Some(v.into());
268        self
269    }
270
271    fn to_query(&self) -> Vec<(String, String)> {
272        let mut q: Vec<(String, String)> = Vec::new();
273        if let Some(v) = &self.source {
274            q.push(("source".into(), v.to_string()));
275        }
276        q
277    }
278}
279
280/// Query parameters for [`AgentStudioService::execute_agent`].
281#[derive(Debug, Clone, Default)]
282pub struct ExecuteAgentParams {
283    /// `source` query parameter.
284    pub source: Option<String>,
285}
286
287impl ExecuteAgentParams {
288    /// Start from the parameters the API requires.
289    pub fn new() -> Self {
290        Self {
291            ..Default::default()
292        }
293    }
294
295    /// Set the `source` query parameter.
296    pub fn source(mut self, v: impl Into<String>) -> Self {
297        self.source = Some(v.into());
298        self
299    }
300
301    fn to_query(&self) -> Vec<(String, String)> {
302        let mut q: Vec<(String, String)> = Vec::new();
303        if let Some(v) = &self.source {
304            q.push(("source".into(), v.to_string()));
305        }
306        q
307    }
308}
309
310/// Query parameters for [`AgentStudioService::list_agents_deprecated`].
311#[derive(Debug, Clone, Default)]
312pub struct ListAgentsDeprecatedParams {
313    /// `locationId` query parameter.
314    /// Required by the API.
315    pub location_id: String,
316    /// `limit` query parameter.
317    /// Required by the API.
318    pub limit: String,
319    /// `offset` query parameter.
320    /// Required by the API.
321    pub offset: String,
322    /// `source` query parameter.
323    pub source: Option<String>,
324}
325
326impl ListAgentsDeprecatedParams {
327    /// Start from the parameters the API requires.
328    pub fn new(
329        location_id: impl Into<String>,
330        limit: impl Into<String>,
331        offset: impl Into<String>,
332    ) -> Self {
333        Self {
334            location_id: location_id.into(),
335            limit: limit.into(),
336            offset: offset.into(),
337            ..Default::default()
338        }
339    }
340
341    /// Set the `source` query parameter.
342    pub fn source(mut self, v: impl Into<String>) -> Self {
343        self.source = Some(v.into());
344        self
345    }
346
347    fn to_query(&self) -> Vec<(String, String)> {
348        let mut q: Vec<(String, String)> = vec![
349            ("locationId".into(), self.location_id.clone()),
350            ("limit".into(), self.limit.clone()),
351            ("offset".into(), self.offset.clone()),
352        ];
353        if let Some(v) = &self.source {
354            q.push(("source".into(), v.to_string()));
355        }
356        q
357    }
358}
359
360/// Query parameters for [`AgentStudioService::get_agent_deprecated`].
361#[derive(Debug, Clone, Default)]
362pub struct GetAgentDeprecatedParams {
363    /// `locationId` query parameter.
364    /// Required by the API.
365    pub location_id: String,
366    /// `source` query parameter.
367    pub source: Option<String>,
368}
369
370impl GetAgentDeprecatedParams {
371    /// Start from the parameters the API requires.
372    pub fn new(location_id: impl Into<String>) -> Self {
373        Self {
374            location_id: location_id.into(),
375            ..Default::default()
376        }
377    }
378
379    /// Set the `source` query parameter.
380    pub fn source(mut self, v: impl Into<String>) -> Self {
381        self.source = Some(v.into());
382        self
383    }
384
385    fn to_query(&self) -> Vec<(String, String)> {
386        let mut q: Vec<(String, String)> = vec![("locationId".into(), self.location_id.clone())];
387        if let Some(v) = &self.source {
388            q.push(("source".into(), v.to_string()));
389        }
390        q
391    }
392}
393
394/// Query parameters for [`AgentStudioService::execute_agent_deprecated`].
395#[derive(Debug, Clone, Default)]
396pub struct ExecuteAgentDeprecatedParams {
397    /// `source` query parameter.
398    pub source: Option<String>,
399}
400
401impl ExecuteAgentDeprecatedParams {
402    /// Start from the parameters the API requires.
403    pub fn new() -> Self {
404        Self {
405            ..Default::default()
406        }
407    }
408
409    /// Set the `source` query parameter.
410    pub fn source(mut self, v: impl Into<String>) -> Self {
411        self.source = Some(v.into());
412        self
413    }
414
415    fn to_query(&self) -> Vec<(String, String)> {
416        let mut q: Vec<(String, String)> = Vec::new();
417        if let Some(v) = &self.source {
418            q.push(("source".into(), v.to_string()));
419        }
420        q
421    }
422}
423
424impl AgentStudioService {
425    /// List Agents
426    ///
427    /// Lists all active agents for the specified location. locationId is required parameter
428    /// to ensure optimal performance. Supports pagination using limit and offset.
429    /// Optionally filter by isPublished=true to return only agents with a published
430    /// production version.
431    ///
432    /// `GET /agent-studio/agent`
433    ///
434    /// Requires scope: `agent-studio.readonly`.
435    pub async fn list_agents(
436        &self,
437        params: &ListAgentsParams,
438    ) -> Result<models::GetPublishedAgentsResponseDTO> {
439        let query = params.to_query();
440        self.client
441            .send_versioned(
442                reqwest::Method::GET,
443                "/agent-studio/agent",
444                &query,
445                None::<&()>,
446                Some("2021-04-15"),
447            )
448            .await
449    }
450
451    /// Create Agent
452    ///
453    /// Creates a new agent with staging version. The agent will be created with an initial
454    /// staging version that can later be promoted to production.
455    ///
456    /// `POST /agent-studio/agent`
457    ///
458    /// Requires scope: `agent-studio.write`.
459    pub async fn create_agent(
460        &self,
461        params: &CreateAgentParams,
462        body: &models::CreatePublicAgentDTO,
463    ) -> Result<models::CreatePublicAgentResponseDTO> {
464        let query = params.to_query();
465        self.client
466            .send_versioned(
467                reqwest::Method::POST,
468                "/agent-studio/agent",
469                &query,
470                Some(body),
471                Some("2021-04-15"),
472            )
473            .await
474    }
475
476    /// Update Agent
477    ///
478    /// Updates a specific agent version by versionId. Supports updating nodes, edges,
479    /// variables, and configuration.
480    ///
481    /// `PATCH /agent-studio/agent/versions/{versionId}`
482    ///
483    /// Requires scope: `agent-studio.write`.
484    pub async fn update_agent(
485        &self,
486        version_id: &str,
487        params: &UpdateAgentParams,
488        body: &models::UpdatePublicAgentVersionDTO,
489    ) -> Result<models::UpdatePublicAgentResponseDTO> {
490        let path = format!(
491            "/agent-studio/agent/versions/{}",
492            crate::services::encode(version_id)
493        );
494        let query = params.to_query();
495        self.client
496            .send_versioned(
497                reqwest::Method::PATCH,
498                &path,
499                &query,
500                Some(body),
501                Some("2021-04-15"),
502            )
503            .await
504    }
505
506    /// Promote to Production
507    ///
508    /// Promotes a draft version to production.
509    ///
510    /// `POST /agent-studio/agent/versions/{versionId}/publish`
511    ///
512    /// Requires scope: `agent-studio.write`.
513    pub async fn promote_to_production(
514        &self,
515        version_id: &str,
516        params: &PromoteToProductionParams,
517        body: &models::PromoteAndPublishDTO,
518    ) -> Result<models::PromoteAndPublishResponseDTO> {
519        let path = format!(
520            "/agent-studio/agent/versions/{}/publish",
521            crate::services::encode(version_id)
522        );
523        let query = params.to_query();
524        self.client
525            .send_versioned(
526                reqwest::Method::POST,
527                &path,
528                &query,
529                Some(body),
530                Some("2021-04-15"),
531            )
532            .await
533    }
534
535    /// Delete Agent
536    ///
537    /// Deletes an agent and all its versions.
538    ///
539    /// `DELETE /agent-studio/agent/{agentId}`
540    ///
541    /// Requires scope: `agent-studio.write`.
542    pub async fn delete_agent(
543        &self,
544        agent_id: &str,
545        params: &DeleteAgentParams,
546    ) -> Result<models::DeletePublicAgentResponseDTO> {
547        let path = format!("/agent-studio/agent/{}", crate::services::encode(agent_id));
548        let query = params.to_query();
549        self.client
550            .send_versioned(
551                reqwest::Method::DELETE,
552                &path,
553                &query,
554                None::<&()>,
555                Some("2021-04-15"),
556            )
557            .await
558    }
559
560    /// Get Agent
561    ///
562    /// Gets a specific agent by its ID for the specified location with all its versions.
563    /// Returns complete agent metadata and all non-deleted versions (draft, staging,
564    /// production). locationId is required parameter. The agent must have active status.
565    ///
566    /// `GET /agent-studio/agent/{agentId}`
567    ///
568    /// Requires scope: `agent-studio.readonly`.
569    pub async fn get_agent(
570        &self,
571        agent_id: &str,
572        params: &GetAgentParams,
573    ) -> Result<models::GetAgentByIdResponseDTO> {
574        let path = format!("/agent-studio/agent/{}", crate::services::encode(agent_id));
575        let query = params.to_query();
576        self.client
577            .send_versioned(
578                reqwest::Method::GET,
579                &path,
580                &query,
581                None::<&()>,
582                Some("2021-04-15"),
583            )
584            .await
585    }
586
587    /// Update Agent Metadata
588    ///
589    /// Updates agent metadata such as name, description, and status.
590    ///
591    /// `PATCH /agent-studio/agent/{agentId}`
592    ///
593    /// Requires scope: `agent-studio.write`.
594    pub async fn update_agent_metadata(
595        &self,
596        agent_id: &str,
597        params: &UpdateAgentMetadataParams,
598        body: &models::UpdatePublicAgentMetadataDTO,
599    ) -> Result<models::UpdatePublicAgentResponseDTO> {
600        let path = format!("/agent-studio/agent/{}", crate::services::encode(agent_id));
601        let query = params.to_query();
602        self.client
603            .send_versioned(
604                reqwest::Method::PATCH,
605                &path,
606                &query,
607                Some(body),
608                Some("2021-04-15"),
609            )
610            .await
611    }
612
613    /// Execute Agent
614    ///
615    /// Executes the specified agent and returns a non-streaming JSON response with the
616    /// complete agent output. The agent must be in active status and belong to the
617    /// specified location. locationId is required in the request body. **Session
618    /// Management:** - For the first message in a new session, do not include the
619    /// `executionId` in the request payload. - The API will return an `executionId` along
620    /// with the agent response, which uniquely identifies this conversation session. - To
621    /// continue the conversation within the same session, include the `executionId` from
622    /// the previous response in subsequent requests. T
623    ///
624    /// `POST /agent-studio/agent/{agentId}/execute`
625    ///
626    /// Requires scope: `agent-studio.write`.
627    pub async fn execute_agent(
628        &self,
629        agent_id: &str,
630        params: &ExecuteAgentParams,
631        body: &models::ExecutePublicAgentDTO,
632    ) -> Result<models::ExecutePublicAgentResponseDTO> {
633        let path = format!(
634            "/agent-studio/agent/{}/execute",
635            crate::services::encode(agent_id)
636        );
637        let query = params.to_query();
638        self.client
639            .send_versioned(
640                reqwest::Method::POST,
641                &path,
642                &query,
643                Some(body),
644                Some("2021-04-15"),
645            )
646            .await
647    }
648
649    /// List Agents (Deprecated)
650    ///
651    /// **Deprecated endpoint - use GET /agent instead.** Lists all active agents that have
652    /// a published production version for the specified location. locationId is required
653    /// parameter. Supports pagination using limit and offset.
654    ///
655    /// `GET /agent-studio/public-api/agents`
656    ///
657    /// Requires scope: `agent-studio.readonly`.
658    pub async fn list_agents_deprecated(
659        &self,
660        params: &ListAgentsDeprecatedParams,
661    ) -> Result<models::GetPublishedAgentsResponseDTO> {
662        let query = params.to_query();
663        self.client
664            .send_versioned(
665                reqwest::Method::GET,
666                "/agent-studio/public-api/agents",
667                &query,
668                None::<&()>,
669                Some("2021-04-15"),
670            )
671            .await
672    }
673
674    /// Get Agent (Deprecated)
675    ///
676    /// **Deprecated endpoint - use GET /agent/:agentId instead.** Gets a specific agent by
677    /// its ID for the specified location with all its versions. locationId is required
678    /// parameter. The agent must have active status.
679    ///
680    /// `GET /agent-studio/public-api/agents/{agentId}`
681    ///
682    /// Requires scope: `agent-studio.readonly`.
683    pub async fn get_agent_deprecated(
684        &self,
685        agent_id: &str,
686        params: &GetAgentDeprecatedParams,
687    ) -> Result<models::GetAgentByIdResponseDTO> {
688        let path = format!(
689            "/agent-studio/public-api/agents/{}",
690            crate::services::encode(agent_id)
691        );
692        let query = params.to_query();
693        self.client
694            .send_versioned(
695                reqwest::Method::GET,
696                &path,
697                &query,
698                None::<&()>,
699                Some("2021-04-15"),
700            )
701            .await
702    }
703
704    /// Execute Agent (Deprecated)
705    ///
706    /// **Deprecated endpoint - use POST /agent/:agentId/execute instead.** Executes the
707    /// specified agent and returns a non-streaming JSON response with the complete agent
708    /// output. The agent must be in active status and belong to the specified location.
709    /// locationId is required in the request body. **Session Management:** - For the first
710    /// message in a new session, do not include the `executionId` in the request payload. -
711    /// The API will return an `executionId` along with the agent response, which uniquely
712    /// identifies this conversation session. - To continue the conversation within the same
713    /// session, include th
714    ///
715    /// `POST /agent-studio/public-api/agents/{agentId}/execute`
716    ///
717    /// Requires scope: `agent-studio.write`.
718    pub async fn execute_agent_deprecated(
719        &self,
720        agent_id: &str,
721        params: &ExecuteAgentDeprecatedParams,
722        body: &models::ExecutePublicAgentDTO,
723    ) -> Result<models::ExecutePublicAgentResponseDTO> {
724        let path = format!(
725            "/agent-studio/public-api/agents/{}/execute",
726            crate::services::encode(agent_id)
727        );
728        let query = params.to_query();
729        self.client
730            .send_versioned(
731                reqwest::Method::POST,
732                &path,
733                &query,
734                Some(body),
735                Some("2021-04-15"),
736            )
737            .await
738    }
739}