1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
5#[serde(rename_all = "lowercase")]
6pub enum ImportAction {
7 Create,
9 Update,
11 Skip,
13 Fail,
15}
16
17#[derive(Debug, Clone, Serialize, Deserialize)]
19pub struct ImportPlan {
20 pub action: ImportAction,
22 #[serde(skip_serializing_if = "Option::is_none")]
24 pub reason: Option<String>,
25 #[serde(rename = "dryRun")]
27 pub dry_run: bool,
28}
29
30impl ImportPlan {
31 pub fn create(dry_run: bool) -> Self {
33 Self {
34 action: ImportAction::Create,
35 reason: None,
36 dry_run,
37 }
38 }
39
40 pub fn update(dry_run: bool) -> Self {
42 Self {
43 action: ImportAction::Update,
44 reason: None,
45 dry_run,
46 }
47 }
48
49 pub fn skip(reason: String, dry_run: bool) -> Self {
51 Self {
52 action: ImportAction::Skip,
53 reason: Some(reason),
54 dry_run,
55 }
56 }
57
58 pub fn fail(reason: String, dry_run: bool) -> Self {
60 Self {
61 action: ImportAction::Fail,
62 reason: Some(reason),
63 dry_run,
64 }
65 }
66}
67
68#[derive(Debug, Clone, Serialize, Deserialize)]
70pub struct AuthStatus {
71 pub authenticated: bool,
72 #[serde(rename = "authMode", skip_serializing_if = "Option::is_none")]
73 pub auth_mode: Option<String>,
74 #[serde(skip_serializing_if = "Option::is_none")]
75 pub scopes: Option<Vec<String>>,
76 #[serde(rename = "nextSteps", skip_serializing_if = "Option::is_none")]
77 pub next_steps: Option<Vec<String>>,
78}
79
80impl AuthStatus {
81 pub fn unauthenticated(next_steps: Vec<String>) -> Self {
83 Self {
84 authenticated: false,
85 auth_mode: None,
86 scopes: None,
87 next_steps: Some(next_steps),
88 }
89 }
90
91 pub fn authenticated(auth_mode: String, scopes: Vec<String>) -> Self {
93 Self {
94 authenticated: true,
95 auth_mode: Some(auth_mode),
96 scopes: Some(scopes),
97 next_steps: None,
98 }
99 }
100}
101
102#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
104pub struct AuthToken {
105 #[serde(rename = "accessToken")]
106 pub access_token: String,
107 #[serde(rename = "tokenType")]
108 pub token_type: String,
109 #[serde(rename = "expiresAt", skip_serializing_if = "Option::is_none")]
110 pub expires_at: Option<i64>,
111 pub scopes: Vec<String>,
112}