1
use serde::Deserialize;
2
use serde_json::{Map, Value};
3

            
4
390
#[derive(Deserialize)]
5
pub struct DeviceIdPath {
6
    pub device_id: String,
7
}
8

            
9
210
#[derive(Deserialize)]
10
pub struct PostDeviceBody {
11
    pub data: PostDeviceData,
12
}
13

            
14
441
#[derive(Deserialize)]
15
pub struct PostDeviceData {
16
    #[serde(rename = "unitId")]
17
    pub unit_id: String,
18
    #[serde(rename = "networkId")]
19
    pub network_id: String,
20
    #[serde(rename = "networkAddr")]
21
    pub network_addr: String,
22
    pub profile: Option<String>,
23
    pub name: Option<String>,
24
    pub info: Option<Map<String, Value>>,
25
}
26

            
27
204
#[derive(Deserialize)]
28
pub struct PostDeviceBulkBody {
29
    pub data: PostDeviceBulkData,
30
}
31

            
32
417
#[derive(Deserialize)]
33
pub struct PostDeviceBulkData {
34
    #[serde(rename = "unitId")]
35
    pub unit_id: String,
36
    #[serde(rename = "networkId")]
37
    pub network_id: String,
38
    #[serde(rename = "networkAddrs")]
39
    pub network_addrs: Vec<String>,
40
    pub profile: Option<String>,
41
}
42

            
43
264
#[derive(Deserialize)]
44
pub struct PostDeviceRangeBody {
45
    pub data: PostDeviceRangeData,
46
}
47

            
48
669
#[derive(Deserialize)]
49
pub struct PostDeviceRangeData {
50
    #[serde(rename = "unitId")]
51
    pub unit_id: String,
52
    #[serde(rename = "networkId")]
53
    pub network_id: String,
54
    #[serde(rename = "startAddr")]
55
    pub start_addr: String,
56
    #[serde(rename = "endAddr")]
57
    pub end_addr: String,
58
    pub profile: Option<String>,
59
}
60

            
61
261
#[derive(Deserialize)]
62
pub struct GetDeviceCountQuery {
63
    pub unit: Option<String>,
64
    pub network: Option<String>,
65
    pub addr: Option<String>,
66
    pub profile: Option<String>,
67
    pub contains: Option<String>,
68
}
69

            
70
555
#[derive(Clone, Deserialize)]
71
pub struct GetDeviceListQuery {
72
    pub unit: Option<String>,
73
    pub network: Option<String>,
74
    pub addr: Option<String>,
75
    pub profile: Option<String>,
76
    pub contains: Option<String>,
77
    pub offset: Option<u64>,
78
    pub limit: Option<u64>,
79
    pub sort: Option<String>,
80
    pub format: Option<ListFormat>,
81
}
82

            
83
186
#[derive(Deserialize)]
84
pub struct PatchDeviceBody {
85
    pub data: PatchDeviceData,
86
}
87

            
88
312
#[derive(Deserialize)]
89
pub struct PatchDeviceData {
90
    #[serde(rename = "networkId")]
91
    pub network_id: Option<String>,
92
    #[serde(rename = "networkAddr")]
93
    pub network_addr: Option<String>,
94
    pub profile: Option<String>,
95
    pub name: Option<String>,
96
    pub info: Option<Map<String, Value>>,
97
}
98

            
99
12
#[derive(Clone, Deserialize, PartialEq)]
100
pub enum ListFormat {
101
    #[serde(rename = "array")]
102
    Array,
103
    #[serde(rename = "data")]
104
    Data,
105
}