diff options
author | Lukasz Woznicki <75632179+makr11st@users.noreply.github.com> | 2021-11-24 20:54:56 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-24 20:54:56 +0000 |
commit | a4ffeccf60090e4456755bc53a6e3b8c8038e855 (patch) | |
tree | 9583f187114913a92866571920dd3bb205bd50a3 /crates/common/tedge_config/src/tedge_config_dto.rs | |
parent | 8217e80670e76dbf9168780f5e0545355a39f8f3 (diff) |
Restructure directories of the workspace (#559)
* Restructure directories of the workspace
* Rename c8y_translator_lib to c8y_translator
* Update comment on how to get dummy plugin path
Signed-off-by: Lukasz Woznicki <lukasz.woznicki@softwareag.com>
Diffstat (limited to 'crates/common/tedge_config/src/tedge_config_dto.rs')
-rw-r--r-- | crates/common/tedge_config/src/tedge_config_dto.rs | 90 |
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>, +} |