monitor_client/api/write/
variable.rs

1use derive_empty_traits::EmptyTraits;
2use resolver_api::derive::Request;
3use serde::{Deserialize, Serialize};
4use typeshare::typeshare;
5
6use crate::entities::variable::Variable;
7
8use super::MonitorWriteRequest;
9
10/// **Admin only.** Create variable. Response: [Variable].
11#[typeshare]
12#[derive(
13  Debug, Clone, Serialize, Deserialize, Request, EmptyTraits,
14)]
15#[empty_traits(MonitorWriteRequest)]
16#[response(CreateVariableResponse)]
17pub struct CreateVariable {
18  /// The name of the variable to create.
19  pub name: String,
20  /// The initial value of the variable. defualt: "".
21  #[serde(default)]
22  pub value: String,
23  /// The initial value of the description. default: "".
24  #[serde(default)]
25  pub description: String,
26}
27
28#[typeshare]
29pub type CreateVariableResponse = Variable;
30
31//
32
33/// **Admin only.** Update variable. Response: [Variable].
34#[typeshare]
35#[derive(
36  Debug, Clone, Serialize, Deserialize, Request, EmptyTraits,
37)]
38#[empty_traits(MonitorWriteRequest)]
39#[response(UpdateVariableValueResponse)]
40pub struct UpdateVariableValue {
41  /// The name of the variable to update.
42  pub name: String,
43  /// The value to set.
44  pub value: String,
45}
46
47#[typeshare]
48pub type UpdateVariableValueResponse = Variable;
49
50//
51
52/// **Admin only.** Update variable. Response: [Variable].
53#[typeshare]
54#[derive(
55  Debug, Clone, Serialize, Deserialize, Request, EmptyTraits,
56)]
57#[empty_traits(MonitorWriteRequest)]
58#[response(UpdateVariableDescriptionResponse)]
59pub struct UpdateVariableDescription {
60  /// The name of the variable to update.
61  pub name: String,
62  /// The description to set.
63  pub description: String,
64}
65
66#[typeshare]
67pub type UpdateVariableDescriptionResponse = Variable;
68
69//
70
71/// **Admin only.** Delete a variable. Response: [Variable].
72#[typeshare]
73#[derive(
74  Debug, Clone, Serialize, Deserialize, Request, EmptyTraits,
75)]
76#[empty_traits(MonitorWriteRequest)]
77#[response(DeleteVariableResponse)]
78pub struct DeleteVariable {
79  pub name: String,
80}
81
82#[typeshare]
83pub type DeleteVariableResponse = Variable;