reduct_base/msg/
server_api.rs

1// Copyright 2023 ReductSoftware UG
2// This Source Code Form is subject to the terms of the Mozilla Public
3//    License, v. 2.0. If a copy of the MPL was not distributed with this
4//    file, You can obtain one at https://mozilla.org/MPL/2.0/.
5
6use crate::msg::bucket_api::{BucketInfo, BucketSettings};
7use chrono::{DateTime, Utc};
8use serde::{Deserialize, Serialize};
9use std::fmt::{Display, Formatter};
10
11/// License information
12///
13#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
14pub struct License {
15    /// Licensee usually is the company name
16    pub licensee: String,
17    /// Invoice number
18    pub invoice: String,
19    /// Expiry date
20    pub expiry_date: DateTime<Utc>,
21    /// Plan name
22    pub plan: String,
23    /// Number of devices (0 for unlimited)
24    pub device_number: u32,
25    /// Disk quota in TB (0 for unlimited)
26    pub disk_quota: i32,
27    /// Fingerprint
28    #[serde(default)]
29    pub fingerprint: String,
30}
31
32impl Display for License {
33    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
34        write!(
35            f,
36            "\n\tLicensee: {}\n\tInvoice: {}\n\tExpiry Date: {}\n\tPlan: {}\n\tNumber of Devices: {}\n\tDisk Quota: {} TB,\n\tFingerprint: {}",
37            self.licensee, self.invoice, self.expiry_date, self.plan, self.device_number, self.disk_quota, self.fingerprint
38        )
39    }
40}
41
42/// Information about a ReductSoftware UG instance
43#[derive(Serialize, Deserialize, Default, Clone, Debug, PartialEq)]
44pub struct ServerInfo {
45    /// Version of ReductSoftware UG instance
46    pub version: String,
47    /// Number of buckets
48    pub bucket_count: u64,
49    /// Disk usage in bytes
50    pub usage: u64,
51    /// Uptime in seconds
52    pub uptime: u64,
53    /// Oldest record in instance
54    pub oldest_record: u64,
55    /// Latest record in instance
56    pub latest_record: u64,
57    /// Default settings
58    pub defaults: Defaults,
59    /// License information if it is None, then it is BUSL-1.1
60    pub license: Option<License>,
61}
62
63/// Default settings
64#[derive(Serialize, Deserialize, Default, Clone, Debug, PartialEq)]
65pub struct Defaults {
66    pub bucket: BucketSettings,
67}
68
69/// BucketLists
70#[derive(Serialize, Deserialize, Default, Clone, Debug, PartialEq)]
71pub struct BucketInfoList {
72    pub buckets: Vec<BucketInfo>,
73}