vapi_client/models/assignment_mutation.rs
1/*
2 * Vapi API
3 *
4 * API for building voice assistants
5 *
6 * The version of the OpenAPI document: 1.0
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11use serde::{Deserialize, Serialize};
12
13use crate::models;
14
15#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
16pub struct AssignmentMutation {
17 /// This is an optional array of conditions that must be met for this mutation to be triggered.
18 #[serde(rename = "conditions", skip_serializing_if = "Option::is_none")]
19 pub conditions: Option<Vec<models::BlockStartMessageConditionsInner>>,
20 /// This mutation assigns a new value to an existing or new variable.
21 #[serde(rename = "type")]
22 pub r#type: Type,
23 /// This is the variable to assign a new value to. You can reference any variable in the context of the current block execution (step): - \"output.your-property-name\" for current step's output - \"your-step-name.output.your-property-name\" for another step's output (in the same workflow; read caveat #1) - \"your-block-name.output.your-property-name\" for another block's output (in the same workflow; read caveat #2) - \"global.your-property-name\" for the global context This needs to be the key path of the variable. If you use {{}}, it'll dereference that to the value of the variable before assignment. This can be useful if the path is dynamic. Example: - \"global.{{my-tool-call-step.output.my-key-name}}\" You can also string interpolate multiple variables to get the key name: - \"global.{{my-tool-call-step.output.my-key-name-suffix}}-{{my-tool-call-step.output.my-key-name}}\" The path to the new variable is created if it doesn't exist. Example: - \"global.this-does-not-exist.neither-does-this\" will create `this-does-not-exist` object with `neither-does-this` as a key Caveats: 1. a workflow can execute a step multiple times. example, if a loop is used in the graph. {{stepName.output.propertyName}} will reference the latest usage of the step. 2. a workflow can execute a block multiple times. example, if a step is called multiple times or if a block is used in multiple steps. {{blockName.output.propertyName}} will reference the latest usage of the block. this liquid variable is just provided for convenience when creating blocks outside of a workflow.
24 #[serde(rename = "variable")]
25 pub variable: String,
26 /// The value to assign to the variable. You can reference any variable in the context of the current block execution (step): - \"{{output.your-property-name}}\" for current step's output - \"{{your-step-name.output.your-property-name}}\" for another step's output (in the same workflow; read caveat #1) - \"{{your-block-name.output.your-property-name}}\" for another block's output (in the same workflow; read caveat #2) - \"{{global.your-property-name}}\" for the global context Or, you can use a constant: - \"1\" - \"text\" - \"true\" - \"false\" Or, you can mix and match with string interpolation: - \"{{your-property-name}}-{{input.your-property-name-2}}-1\" Caveats: 1. a workflow can execute a step multiple times. example, if a loop is used in the graph. {{stepName.output.propertyName}} will reference the latest usage of the step. 2. a workflow can execute a block multiple times. example, if a step is called multiple times or if a block is used in multiple steps. {{blockName.output.propertyName}} will reference the latest usage of the block. this liquid variable is just provided for convenience when creating blocks outside of a workflow.
27 #[serde(rename = "value")]
28 pub value: String,
29}
30
31impl AssignmentMutation {
32 pub fn new(r#type: Type, variable: String, value: String) -> AssignmentMutation {
33 AssignmentMutation {
34 conditions: None,
35 r#type,
36 variable,
37 value,
38 }
39 }
40}
41/// This mutation assigns a new value to an existing or new variable.
42#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
43pub enum Type {
44 #[serde(rename = "assignment")]
45 Assignment,
46}
47
48impl Default for Type {
49 fn default() -> Type {
50 Self::Assignment
51 }
52}