1
use std::collections::HashMap;
2

            
3
use serde::{Deserialize, Serialize};
4
use serde_json::{Map, Value};
5

            
6
16
#[derive(Deserialize)]
7
pub struct GetTokenInfo {
8
    pub data: TokenInfo,
9
}
10

            
11
56
#[derive(Deserialize)]
12
pub struct TokenInfo {
13
    #[serde(rename = "userId")]
14
    pub _user_id: String,
15
    #[serde(rename = "account")]
16
    pub _account: String,
17
    #[serde(rename = "name")]
18
    pub _name: String,
19
    pub roles: HashMap<String, bool>,
20
    #[serde(rename = "clientId")]
21
    pub _client_id: String,
22
    #[serde(rename = "scopes")]
23
    pub _scopes: Vec<String>,
24
}
25

            
26
136
#[derive(Deserialize)]
27
pub struct GetCount {
28
    pub data: GetCountData,
29
}
30

            
31
136
#[derive(Deserialize)]
32
pub struct GetCountData {
33
    pub count: u64,
34
}
35

            
36
136
#[derive(Deserialize)]
37
pub struct GetUnit {
38
    pub data: Unit,
39
}
40

            
41
/// The unit response that is from broker GET API and **ONLY be serialized for CSV**.
42
2432
#[derive(Deserialize, Serialize)]
43
pub struct Unit {
44
    #[serde(rename = "unitId")]
45
    pub unit_id: String,
46
    pub code: String,
47
    #[serde(rename = "createdAt")]
48
    pub created_at: String,
49
    #[serde(rename = "modifiedAt")]
50
    pub modified_at: String,
51
    #[serde(rename = "ownerId")]
52
    pub owner_id: String,
53
    #[serde(rename(deserialize = "memberIds"), skip_serializing)]
54
    pub member_ids: Vec<String>,
55
    #[serde(rename(serialize = "memberIds"))]
56
    pub member_ids_str: Option<String>,
57
    pub name: String,
58
    #[serde(skip_serializing)]
59
    pub info: Map<String, Value>,
60
    #[serde(rename(serialize = "info"))]
61
    pub info_str: Option<String>,
62
}
63

            
64
52
#[derive(Deserialize, Serialize)]
65
pub struct PostApplication {
66
    pub data: PostApplicationData,
67
}
68

            
69
52
#[derive(Deserialize, Serialize)]
70
pub struct PostApplicationData {
71
    #[serde(rename = "applicationId")]
72
    pub application_id: String,
73
    pub password: Option<String>,
74
}
75

            
76
166
#[derive(Deserialize, Serialize)]
77
pub struct GetApplication {
78
    pub data: GetApplicationData,
79
}
80

            
81
830
#[derive(Deserialize, Serialize)]
82
pub struct GetApplicationData {
83
    #[serde(rename = "applicationId")]
84
    pub application_id: String,
85
    pub code: String,
86
    #[serde(rename = "unitId")]
87
    pub unit_id: String,
88
    #[serde(rename = "unitCode")]
89
    pub unit_code: String,
90
    #[serde(rename = "createdAt")]
91
    pub created_at: String,
92
    #[serde(rename = "modifiedAt")]
93
    pub modified_at: String,
94
    #[serde(rename = "hostUri")]
95
    pub host_uri: String,
96
    pub name: String,
97
    pub info: Map<String, Value>,
98
    #[serde(skip_serializing_if = "Option::is_none")]
99
    pub ttl: Option<usize>,
100
    #[serde(skip_serializing_if = "Option::is_none")]
101
    pub length: Option<usize>,
102
}
103

            
104
#[derive(Serialize)]
105
pub struct GetApplicationStats {
106
    pub data: GetApplicationStatsData,
107
}
108

            
109
#[derive(Serialize)]
110
pub struct GetApplicationStatsData {
111
    pub uldata: Stats,
112
    #[serde(rename = "dldataResp")]
113
    pub dldata_resp: Stats,
114
    #[serde(rename = "dldataResult")]
115
    pub dldata_result: Stats,
116
}
117

            
118
60
#[derive(Deserialize, Serialize)]
119
pub struct PostNetwork {
120
    pub data: PostNetworkData,
121
}
122

            
123
60
#[derive(Deserialize, Serialize)]
124
pub struct PostNetworkData {
125
    #[serde(rename = "networkId")]
126
    pub network_id: String,
127
    pub password: Option<String>,
128
}
129

            
130
234
#[derive(Deserialize, Serialize)]
131
pub struct GetNetwork {
132
    pub data: GetNetworkData,
133
}
134

            
135
1170
#[derive(Deserialize, Serialize)]
136
pub struct GetNetworkData {
137
    #[serde(rename = "networkId")]
138
    pub network_id: String,
139
    pub code: String,
140
    #[serde(rename = "unitId")]
141
    pub unit_id: Option<String>,
142
    #[serde(rename = "unitCode")]
143
    pub unit_code: Option<String>,
144
    #[serde(rename = "createdAt")]
145
    pub created_at: String,
146
    #[serde(rename = "modifiedAt")]
147
    pub modified_at: String,
148
    #[serde(rename = "hostUri")]
149
    pub host_uri: String,
150
    pub name: String,
151
    pub info: Map<String, Value>,
152
    #[serde(skip_serializing_if = "Option::is_none")]
153
    pub ttl: Option<usize>,
154
    #[serde(skip_serializing_if = "Option::is_none")]
155
    pub length: Option<usize>,
156
}
157

            
158
#[derive(Serialize)]
159
pub struct GetNetworkStats {
160
    pub data: GetNetworkStatsData,
161
}
162

            
163
#[derive(Serialize)]
164
pub struct GetNetworkStatsData {
165
    pub dldata: Stats,
166
    pub ctrl: Stats,
167
}
168

            
169
#[derive(Default, Serialize)]
170
pub struct Stats {
171
    pub consumers: usize,
172
    pub messages: usize,
173
    #[serde(rename = "publishRate")]
174
    pub publish_rate: f64,
175
    #[serde(rename = "deliverRate")]
176
    pub deliver_rate: f64,
177
}
178

            
179
16
#[derive(Deserialize)]
180
pub struct GetDevice {
181
    pub data: Device,
182
}
183

            
184
96
#[derive(Deserialize)]
185
pub struct Device {
186
    #[serde(rename = "deviceId")]
187
    pub _device_id: String,
188
    #[serde(rename = "unitId")]
189
    pub _unit_id: String,
190
    #[serde(rename = "unitCode")]
191
    pub _unit_code: Option<String>,
192
    #[serde(rename = "networkId")]
193
    pub _network_id: String,
194
    #[serde(rename = "networkCode")]
195
    pub _network_code: String,
196
    #[serde(rename = "networkAddr")]
197
    pub network_addr: String,
198
    #[serde(rename = "createdAt")]
199
    pub _created_at: String,
200
    #[serde(rename = "modifiedAt")]
201
    pub _modified_at: String,
202
    #[serde(rename = "name")]
203
    pub _name: String,
204
    #[serde(rename = "info")]
205
    pub _info: Map<String, Value>,
206
}