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
//! # Onboarding
//!
//! Initial setup of InfluxDB instance

use serde::{Deserialize, Serialize};

/// Check if database has default user, org, bucket created, returns true if
/// not.
#[derive(Clone, Copy, Debug, PartialEq, Default, Serialize, Deserialize)]
pub struct IsOnboarding {
    /// True if onboarding has already been completed otherwise false
    #[serde(default)]
    pub allowed: bool,
}

impl IsOnboarding {
    /// Return instance of IsOnboarding
    pub fn new() -> Self {
        Self::default()
    }
}

/// Post onboarding request, to setup initial user, org and bucket.
#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct OnboardingRequest {
    /// Initial username
    pub username: String,
    /// Initial organization name
    pub org: String,
    /// Initial bucket name
    pub bucket: String,
    /// Initial password of user
    #[serde(skip_serializing_if = "Option::is_none")]
    pub password: Option<String>,
    /// Retention period in nanoseconds
    #[serde(skip_serializing_if = "Option::is_none")]
    pub retention_period_seconds: Option<i32>,
    /// Retention period *in nanoseconds* for the new bucket. This key's name
    /// has been misleading since OSS 2.0 GA, please transition to use
    /// `retentionPeriodSeconds`
    #[serde(skip_serializing_if = "Option::is_none")]
    pub retention_period_hrs: Option<i32>,
}

impl OnboardingRequest {
    /// Return instance of OnboardingRequest
    pub fn new(username: String, org: String, bucket: String) -> Self {
        Self {
            username,
            org,
            bucket,
            ..Default::default()
        }
    }
}

/// OnboardingResponse
#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
pub struct OnboardingResponse {
    /// User
    #[serde(skip_serializing_if = "Option::is_none")]
    pub user: Option<crate::models::User>,
    /// Organization
    #[serde(skip_serializing_if = "Option::is_none")]
    pub org: Option<crate::models::Organization>,
    /// Bucket
    #[serde(skip_serializing_if = "Option::is_none")]
    pub bucket: Option<crate::models::Bucket>,
    /// Auth token
    #[serde(skip_serializing_if = "Option::is_none")]
    pub auth: Option<crate::models::Authorization>,
}

impl OnboardingResponse {
    /// Return instance of OnboardingResponse
    pub fn new() -> Self {
        Self::default()
    }
}