asterisk_ari/apis/applications/params.rs
1use derive_new::new;
2use derive_setters::Setters;
3use serde::Serialize;
4
5#[derive(Clone, Debug, PartialEq, Serialize, new, Setters)]
6#[setters(prefix = "with_")]
7#[setters(into, strip_option)]
8#[serde(rename_all = "camelCase")]
9pub struct UnSubscribeRequest {
10 /// Application's name
11 #[setters(skip)]
12 #[serde(skip_serializing)]
13 pub(crate) name: String,
14
15 /// The application to subscribe to.
16 #[setters(skip)]
17 #[new(into_iter = "String")]
18 pub(crate) event_source: Vec<String>,
19}
20
21#[derive(Clone, Debug, PartialEq, Serialize, new, Setters)]
22#[setters(prefix = "with_")]
23#[setters(into, strip_option)]
24#[serde(rename_all = "camelCase")]
25pub struct SubscribeRequest {
26 /// Application's name
27 #[setters(skip)]
28 #[serde(skip_serializing)]
29 pub(crate) name: String,
30
31 /// URI for event source (channel:{channelId}, bridge:{bridgeId}, endpoint:{tech}[/{resource}], deviceState:{deviceName}
32 #[setters(skip)]
33 #[new(into_iter = "String")]
34 pub(crate) event_source: Vec<String>,
35}
36
37#[derive(Debug, Clone, PartialEq, Eq, Serialize, new, Setters)]
38#[setters(prefix = "with_")]
39#[setters(into, strip_option)]
40pub struct FilterEventsRequest {
41 /// Name of the application
42 #[serde(skip_serializing)]
43 #[setters(skip)]
44 #[new(into)]
45 pub(crate) name: String,
46
47 /// Specify which event types to allow/disallow
48 ///
49 /// The body (parameter) should specify a JSON key/value object that describes the type of event filtering needed.
50 /// One, or both of the following keys can be designated:
51 ///
52 /// \"allowed\" - Specifies an allowed list of event types
53 /// \"disallowed\" - Specifies a disallowed list of event types
54 ///
55 /// Further, each of those key's value should be a JSON array that holds zero, or more JSON key/value objects.
56 /// Each of these objects must contain the following key with an associated value:
57 /// \"type\" - The type name of the event to filter
58 ///
59 /// The value must be the string name (case sensitive) of the event type that needs filtering.
60 /// For example:
61 ///
62 /// `{ \"allowed\": [ { \"type\": \"StasisStart\" }, { \"type\": \"StasisEnd\" } ] }`
63 ///
64 /// As this specifies only an allowed list, then only those two event type messages are sent to the application.
65 /// No other event messages are sent.
66 ///
67 /// The following rules apply:
68 ///
69 /// * If the body is empty, both the allowed and disallowed filters are set empty.
70 /// * If both list types are given then both are set to their respective values (note, specifying an empty array for a given type sets that type to empty).
71 /// * If only one list type is given then only that type is set. The other type is not updated.
72 /// * An empty \"allowed\" list means all events are allowed.
73 /// * An empty \"disallowed\" list means no events are disallowed.
74 /// * Disallowed events take precedence over allowed events if the event type is specified in both lists.
75 #[serde(skip_serializing_if = "Option::is_none")]
76 #[new(default)]
77 pub(crate) filter: Option<Filter>,
78}
79
80#[derive(Debug, Clone, PartialEq, Eq, Serialize, new, Setters)]
81#[setters(prefix = "with_")]
82#[setters(into, strip_option)]
83pub struct Filter {
84 /// Specifies an allowed list of event types
85 #[serde(skip_serializing_if = "Option::is_none")]
86 #[new(default)]
87 allowed: Option<Vec<FilterType>>,
88 #[serde(skip_serializing_if = "Option::is_none")]
89 #[new(default)]
90 disallowed: Option<Vec<FilterType>>,
91}
92
93#[derive(Debug, Clone, PartialEq, Eq, Serialize, new)]
94pub struct FilterType {
95 #[serde(rename = "type")]
96 #[new(into)]
97 name: String,
98}