summaryrefslogtreecommitdiffstats
path: root/crates/common/tedge_config/src/settings.rs
blob: bca85b1a05735993068432a436f9a8483d2837ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
use crate::{config_setting::*, models::*};

///
/// Identifier of the device within the fleet. It must be globally
/// unique and the same one used in the device certificate.
/// NOTE: This setting is derived from the device certificate and therefore is read only.
///
/// Example: Raspberrypi-4d18303a-6d3a-11eb-b1a6-175f6bb72665")
///
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub struct DeviceIdSetting;

impl ConfigSetting for DeviceIdSetting {
    const KEY: &'static str = "device.id";

    const DESCRIPTION: &'static str = concat!(
        "Identifier of the device within the fleet. It must be ",
        "globally unique and is derived from the device certificate. ",
        "Example: Raspberrypi-4d18303a-6d3a-11eb-b1a6-175f6bb72665",
        "NOTE: This setting is derived from the device certificate and therefore is read only."
    );

    type Value = String;
}

#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub struct DeviceTypeSetting;

impl ConfigSetting for DeviceTypeSetting {
    const KEY: &'static str = "device.type";

    const DESCRIPTION: &'static str = "The default device type. Example: thin-edge.io";

    type Value = String;
}

///
/// Path to the private key file. Example: /home/user/.tedge/tedge-private-key.pem
///
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub struct DeviceKeyPathSetting;

impl ConfigSetting for DeviceKeyPathSetting {
    const KEY: &'static str = "device.key.path";

    const DESCRIPTION: &'static str =
        "Path to the private key file. Example: /home/user/.tedge/tedge-private-key.pem";

    type Value = FilePath;
}

///
/// Path to the certificate file.
///
/// Example: /home/user/.tedge/tedge-certificate.crt
///
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub struct DeviceCertPathSetting;

impl ConfigSetting for DeviceCertPathSetting {
    const KEY: &'static str = "device.cert.path";

    const DESCRIPTION: &'static str =
        "Path to the certificate file. Example: /home/user/.tedge/tedge-certificate.crt";

    type Value = FilePath;
}

///
/// Tenant endpoint URL of Cumulocity tenant.
///
/// Example: your-tenant.cumulocity.com
///
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub struct C8yUrlSetting;

impl ConfigSetting for C8yUrlSetting {
    const KEY: &'static str = "c8y.url";

    const DESCRIPTION: &'static str =
        "Tenant endpoint URL of Cumulocity tenant. Example: your-tenant.cumulocity.com";
    type Value = ConnectUrl;
}

///
/// Path where Cumulocity root certificate(s) are located.
///
/// Example: /home/user/.tedge/c8y-trusted-root-certificates.pem
///
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub struct C8yRootCertPathSetting;

impl ConfigSetting for C8yRootCertPathSetting {
    const KEY: &'static str = "c8y.root.cert.path";

    const DESCRIPTION: &'static str = concat!(
        "Path where Cumulocity root certificate(s) are located. ",
        "Example: /home/user/.tedge/c8y-trusted-root-certificates.pem"
    );

    type Value = FilePath;
}

///
/// Smartrest templates to subsribe to.
///
/// Example: template1,template2
///
#[derive(Debug)]
pub struct C8ySmartRestTemplates;

impl ConfigSetting for C8ySmartRestTemplates {
    const KEY: &'static str = "c8y.smartrest.templates";

    const DESCRIPTION: &'static str = concat!(
        "Set of SmartRest templates for the device ",
        "Example: template1,template2"
    );

    type Value = TemplatesSet;
}

///
/// Tenant endpoint URL of Azure IoT tenant.
///
/// Example: MyAzure.azure-devices.net
///
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub struct AzureUrlSetting;

impl ConfigSetting for AzureUrlSetting {
    const KEY: &'static str = "az.url";

    const DESCRIPTION: &'static str = concat!(
        "Tenant endpoint URL of Azure IoT tenant. ",
        "Example:  MyAzure.azure-devices.net"
    );

    type Value = ConnectUrl;
}

///
/// Path where Azure IoT root certificate(s) are located.
///
/// Example: /home/user/.tedge/azure-trusted-root-certificates.pem
///
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub struct AzureRootCertPathSetting;

impl ConfigSetting for AzureRootCertPathSetting {
    const KEY: &'static str = "az.root.cert.path";

    const DESCRIPTION: &'static str = concat!(
        "Path where Azure IoT root certificate(s) are located. ",
        "Example: /home/user/.tedge/azure-trusted-root-certificates.pem"
    );

    type Value = FilePath;
}

///
/// Boolean whether Azure mapper should add timestamp if timestamp is not added in the incoming payload.
///
/// Example: true
///
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub struct AzureMapperTimestamp;

impl ConfigSetting for AzureMapperTimestamp {
    const KEY: &'static str = "az.mapper.timestamp";

    const DESCRIPTION: &'static str = concat!(
        "Boolean whether Azure mapper should add timestamp or not. ",
        "Example: true"
    );

    type Value = Flag;
}

#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub struct MqttPortSetting;

impl ConfigSetting for MqttPortSetting {
    const KEY: &'static str = "mqtt.port";

    const DESCRIPTION: &'static str = concat!(
        "Mqtt broker port, which is used by the local mqtt clients to publish or subscribe. ",
        "Example: 1883"
    );

    type Value = Port;
}

pub struct MqttBindAddressSetting;

impl ConfigSetting for MqttBindAddressSetting {
    const KEY: &'static str = "mqtt.bind_address";

    const DESCRIPTION: &'static str = concat!(
        "Mqtt bind address, which is used by the mqtt clients to publish or subscribe. ",
        "Example: 127.0.0.1"
    );

    type Value = IpAddress;
}

#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub struct MqttExternalPortSetting;

impl ConfigSetting for MqttExternalPortSetting {
    const KEY: &'static str = "mqtt.external.port";

    const DESCRIPTION: &'static str = concat!(
        "Mqtt broker port, which is used by the external mqtt clients to publish or subscribe. ",
        "Example: 8883"
    );

    type Value = Port;
}

#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub struct MqttExternalBindAddressSetting;

impl ConfigSetting for MqttExternalBindAddressSetting {
    const KEY: &'static str = "mqtt.external.bind_address";

    const DESCRIPTION: &'static str = concat!(
        "IP address / hostname, which the mqtt broker limits incoming connections on. ",
        "Example: 0.0.0.0"
    );

    type Value = IpAddress;
}

#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub struct MqttExternalBindInterfaceSetting;

impl ConfigSetting for MqttExternalBindInterfaceSetting {
    const KEY: &'static str = "mqtt.external.bind_interface";

    const DESCRIPTION: &'static str = concat!(
        "Name of network interface, which the mqtt broker limits incoming connections on. ",
        "Example: wlan0"
    );

    type Value = String;
}

#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub struct MqttExternalCAPathSetting;

impl ConfigSetting for MqttExternalCAPathSetting {
    const KEY: &'static str = "mqtt.external.capath";

    const DESCRIPTION: &'static str = concat!(
        "Path to a file containing the PEM encoded CA certificates ",
        "that are trusted when checking incoming client certificates. ",
        "Example: /etc/ssl/certs",
        "Note: If the capath is not set, then no certificates are required for the external connections."
    );

    type Value = FilePath;
}

#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub struct MqttExternalCertfileSetting;

impl ConfigSetting for MqttExternalCertfileSetting {
    const KEY: &'static str = "mqtt.external.certfile";

    const DESCRIPTION: &'static str = concat!(
        "Path to the certificate file, which is used by external MQTT listener",
        "Example: /etc/tedge/device-certs/tedge-certificate.pem",
        "Note: This setting shall be used together with `mqtt.external.keyfile` for external connections."
    );

    type Value = FilePath;
}

#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub struct MqttExternalKeyfileSetting;

impl ConfigSetting for MqttExternalKeyfileSetting {
    const KEY: &'static str = "mqtt.external.keyfile";

    const DESCRIPTION: &'static str = concat!(
        "Path to the private key file, which is used by external MQTT listener",
        "Example: /etc/tedge/device-certs/tedge-private-key.pem",
        "Note: This setting shall be used together with `mqtt.external.certfile` for external connections."
    );

    type Value = FilePath;
}

#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub struct SoftwarePluginDefaultSetting;

impl ConfigSetting for SoftwarePluginDefaultSetting {
    const KEY: &'static str = "software.plugin.default";

    const DESCRIPTION: &'static str = concat!(
        "The default software plugin to be used for software management on the device",
        "Example: apt"
    );

    type Value = String;
}

#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub struct TmpPathSetting;

impl ConfigSetting for TmpPathSetting {
    const KEY: &'static str = "tmp.path";

    const DESCRIPTION: &'static str = concat!(
        "The temporary directory path to be used for downloads on the device",
        "Example: /tmp"
    );

    type Value = FilePath;
}

pub struct LogPathSetting;

impl ConfigSetting for LogPathSetting {
    const KEY: &'static str = "logs.path";

    const DESCRIPTION: &'static str = concat!(
        "The directory path to be used for logs",
        "Example: /var/log"
    );

    type Value = FilePath;
}

pub struct RunPathSetting;

impl ConfigSetting for RunPathSetting {
    const KEY: &'static str = "run.path";

    const DESCRIPTION: &'static str = concat!(
        "The directory path to be used for runtime information",
        "Example: /run"
    );

    type Value