vapi_client/models/
api_request_tool.rs

1/*
2 * Vapi API
3 *
4 * Voice AI for developers.
5 *
6 * The version of the OpenAPI document: 1.0
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11use crate::models;
12use serde::{Deserialize, Serialize};
13
14#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
15pub struct ApiRequestTool {
16    /// These are the messages that will be spoken to the user as the tool is running.  For some tools, this is auto-filled based on special fields like `tool.destinations`. For others like the function tool, these can be custom configured.
17    #[serde(rename = "messages", skip_serializing_if = "Option::is_none")]
18    pub messages: Option<Vec<models::CreateDtmfToolDtoMessagesInner>>,
19    /// The type of tool. \"apiRequest\" for API request tool.
20    #[serde(rename = "type")]
21    pub r#type: TypeTrue,
22    #[serde(rename = "method")]
23    pub method: MethodTrue,
24    /// This is the timeout in seconds for the request. Defaults to 20 seconds.  @default 20
25    #[serde(rename = "timeoutSeconds", skip_serializing_if = "Option::is_none")]
26    pub timeout_seconds: Option<f64>,
27    /// This is the unique identifier for the tool.
28    #[serde(rename = "id")]
29    pub id: String,
30    /// This is the unique identifier for the organization that this tool belongs to.
31    #[serde(rename = "orgId")]
32    pub org_id: String,
33    /// This is the ISO 8601 date-time string of when the tool was created.
34    #[serde(rename = "createdAt")]
35    pub created_at: String,
36    /// This is the ISO 8601 date-time string of when the tool was last updated.
37    #[serde(rename = "updatedAt")]
38    pub updated_at: String,
39    /// This is the function definition of the tool.  For `endCall`, `transferCall`, and `dtmf` tools, this is auto-filled based on tool-specific fields like `tool.destinations`. But, even in those cases, you can provide a custom function definition for advanced use cases.  An example of an advanced use case is if you want to customize the message that's spoken for `endCall` tool. You can specify a function where it returns an argument \"reason\". Then, in `messages` array, you can have many \"request-complete\" messages. One of these messages will be triggered if the `messages[].conditions` matches the \"reason\" argument.
40    #[serde(rename = "function", skip_serializing_if = "Option::is_none")]
41    pub function: Option<models::OpenAiFunction>,
42    /// This is the name of the tool. This will be passed to the model.  Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 40.
43    #[serde(rename = "name", skip_serializing_if = "Option::is_none")]
44    pub name: Option<String>,
45    /// This is the description of the tool. This will be passed to the model.
46    #[serde(rename = "description", skip_serializing_if = "Option::is_none")]
47    pub description: Option<String>,
48    /// This is where the request will be sent.
49    #[serde(rename = "url")]
50    pub url: String,
51    /// This is the body of the request.
52    #[serde(rename = "body", skip_serializing_if = "Option::is_none")]
53    pub body: Option<models::JsonSchema>,
54    /// These are the headers to send in the request.
55    #[serde(rename = "headers", skip_serializing_if = "Option::is_none")]
56    pub headers: Option<models::JsonSchema>,
57    /// This is the backoff plan if the request fails. Defaults to undefined (the request will not be retried).  @default undefined (the request will not be retried)
58    #[serde(rename = "backoffPlan", skip_serializing_if = "Option::is_none")]
59    pub backoff_plan: Option<models::BackoffPlan>,
60    /// This is the plan that controls the variable extraction from the tool's response.
61    #[serde(
62        rename = "variableExtractionPlan",
63        skip_serializing_if = "Option::is_none"
64    )]
65    pub variable_extraction_plan: Option<models::VariableExtractionPlan>,
66}
67
68impl ApiRequestTool {
69    pub fn new(
70        r#type: TypeTrue,
71        method: MethodTrue,
72        id: String,
73        org_id: String,
74        created_at: String,
75        updated_at: String,
76        url: String,
77    ) -> ApiRequestTool {
78        ApiRequestTool {
79            messages: None,
80            r#type,
81            method,
82            timeout_seconds: None,
83            id,
84            org_id,
85            created_at,
86            updated_at,
87            function: None,
88            name: None,
89            description: None,
90            url,
91            body: None,
92            headers: None,
93            backoff_plan: None,
94            variable_extraction_plan: None,
95        }
96    }
97}
98/// The type of tool. \"apiRequest\" for API request tool.
99#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
100pub enum TypeTrue {
101    #[serde(rename = "apiRequest")]
102    ApiRequest,
103}
104
105impl Default for TypeTrue {
106    fn default() -> TypeTrue {
107        Self::ApiRequest
108    }
109}
110///
111#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
112pub enum MethodTrue {
113    #[serde(rename = "POST")]
114    Post,
115    #[serde(rename = "GET")]
116    Get,
117}
118
119impl Default for MethodTrue {
120    fn default() -> MethodTrue {
121        Self::Post
122    }
123}