summaryrefslogtreecommitdiffstats
path: root/crates/common/tedge_config/src/tedge_config_dto.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/common/tedge_config/src/tedge_config_dto.rs')
-rw-r--r--crates/common/tedge_config/src/tedge_config_dto.rs90
1 files changed, 90 insertions, 0 deletions
diff --git a/crates/common/tedge_config/src/tedge_config_dto.rs b/crates/common/tedge_config/src/tedge_config_dto.rs
new file mode 100644
index 00000000..92851962
--- /dev/null
+++ b/crates/common/tedge_config/src/tedge_config_dto.rs
@@ -0,0 +1,90 @@
+//! Crate-private plain-old data-type used for serialization.
+
+use crate::*;
+use serde::{Deserialize, Serialize};
+
+#[derive(Debug, Default, Deserialize, Serialize)]
+#[serde(deny_unknown_fields)]
+pub(crate) struct TEdgeConfigDto {
+ /// Captures the device specific configurations
+ #[serde(default)]
+ pub(crate) device: DeviceConfigDto,
+
+ /// Captures the configurations required to connect to Cumulocity
+ #[serde(default)]
+ pub(crate) c8y: CumulocityConfigDto,
+
+ #[serde(default, alias = "azure")] // for version 0.1.0 compatibility
+ pub(crate) az: AzureConfigDto,
+
+ #[serde(default)]
+ pub(crate) mqtt: MqttConfigDto,
+
+ #[serde(default)]
+ pub(crate) software: SoftwareConfigDto,
+}
+
+/// Represents the device specific configurations defined in the [device] section
+/// of the thin edge configuration TOML file
+#[derive(Debug, Default, Deserialize, Serialize)]
+#[serde(deny_unknown_fields)]
+pub(crate) struct DeviceConfigDto {
+ /// The unique id of the device (DEPRECATED)
+ /// This id is now derived from the device certificate
+ #[serde(rename(deserialize = "id"), skip_serializing)]
+ pub(crate) _id: Option<String>,
+
+ /// Path where the device's private key is stored.
+ /// Defaults to $HOME/.tedge/tedge-private.pem
+ pub(crate) key_path: Option<FilePath>,
+
+ /// Path where the device's certificate is stored.
+ /// Defaults to $HOME/.tedge/tedge-certificate.crt
+ pub(crate) cert_path: Option<FilePath>,
+}
+
+/// Represents the Cumulocity specific configurations defined in the
+/// [c8y] section of the thin edge configuration TOML file
+#[derive(Debug, Default, Deserialize, Serialize)]
+#[serde(deny_unknown_fields)]
+pub(crate) struct CumulocityConfigDto {
+ /// Preserves the current status of the connection
+ pub(crate) connect: Option<String>,
+
+ /// Endpoint URL of the Cumulocity tenant
+ pub(crate) url: Option<ConnectUrl>,
+
+ /// The path where Cumulocity root certificate(s) are stored.
+ /// The value can be a directory path as well as the path of the direct certificate file.
+ pub(crate) root_cert_path: Option<FilePath>,
+
+ /// Boolean whether Azure mapper adds timestamp or not.
+ pub(crate) mapper_timestamp: Option<bool>,
+}
+
+#[derive(Debug, Default, Deserialize, Serialize)]
+#[serde(deny_unknown_fields)]
+pub(crate) struct AzureConfigDto {
+ pub(crate) connect: Option<String>,
+ pub(crate) url: Option<ConnectUrl>,
+ pub(crate) root_cert_path: Option<FilePath>,
+ pub(crate) mapper_timestamp: Option<bool>,
+}
+
+#[derive(Debug, Default, Deserialize, Serialize)]
+#[serde(deny_unknown_fields)]
+pub(crate) struct MqttConfigDto {
+ pub(crate) port: Option<u16>,
+ pub(crate) external_port: Option<u16>,
+ pub(crate) external_bind_address: Option<String>,
+ pub(crate) external_bind_interface: Option<String>,
+ pub(crate) external_capath: Option<FilePath>,
+ pub(crate) external_certfile: Option<FilePath>,
+ pub(crate) external_keyfile: Option<FilePath>,
+}
+
+#[derive(Debug, Default, Deserialize, Serialize)]
+#[serde(deny_unknown_fields)]
+pub(crate) struct SoftwareConfigDto {
+ pub(crate) default_plugin_type: Option<String>,
+}