reactive_graph/client/instances/flows/args/
add_entity_instance.rs

1use crate::client::instances::properties::args::parse_property;
2use clap::Args;
3use reactive_graph_graph::PropertyInstances;
4use serde_json::Value;
5use uuid::Uuid;
6
7#[derive(Args, Debug, Clone)]
8pub(crate) struct AddEntityInstanceArgs {
9    /// The entity type namespace.
10    pub entity_type_namespace: String,
11
12    /// The entity type name.
13    pub entity_type_name: String,
14
15    /// The entity instance id.
16    #[clap(short, long)]
17    pub id: Option<Uuid>,
18
19    /// The entity instance description.
20    #[clap(short, long)]
21    pub description: Option<String>,
22
23    /// The entity instance properties.
24    #[clap(short, long, value_parser = parse_property)]
25    pub properties: Option<Vec<(String, Value)>>,
26    // TODO: The entity instance extensions.
27    // #[clap(short, long, value_parser = parse_extension)]
28    // pub extensions: Option<Vec<(String, Value)>>,
29}
30
31impl AddEntityInstanceArgs {
32    pub fn properties(&self) -> PropertyInstances {
33        match &self.properties {
34            None => PropertyInstances::new(),
35            Some(properties) => properties.iter().map(|(name, value)| (name.clone(), value.clone())).collect(),
36        }
37    }
38}