Skip to main content

reduct_base/msg/
server_api.rs

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