-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlib.rs
More file actions
119 lines (106 loc) · 2.87 KB
/
lib.rs
File metadata and controls
119 lines (106 loc) · 2.87 KB
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
pub mod client;
pub use client::GodonClient;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BreederSummary {
pub id: String,
pub name: String,
pub status: String,
#[serde(rename = "createdAt")]
pub created_at: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Breeder {
pub id: String,
pub name: String,
pub status: String,
pub config: serde_json::Value,
#[serde(rename = "createdAt")]
pub created_at: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BreederCreateRequest {
pub name: String,
pub config: serde_json::Value,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BreederUpdateRequest {
pub uuid: String,
pub name: String,
pub description: String,
pub config: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Credential {
pub id: String,
pub name: String,
#[serde(rename = "credentialType")]
pub credential_type: String,
pub description: Option<String>,
#[serde(rename = "windmillVariable")]
pub windmill_variable: String,
#[serde(rename = "createdAt")]
pub created_at: Option<String>,
#[serde(rename = "lastUsedAt")]
pub last_used_at: Option<String>,
pub content: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Target {
pub id: String,
pub name: String,
#[serde(rename = "targetType")]
pub target_type: String,
pub address: String,
pub username: Option<String>,
#[serde(rename = "credentialId")]
pub credential_id: Option<String>,
#[serde(rename = "credentialName")]
pub credential_name: Option<String>,
pub description: Option<String>,
#[serde(rename = "allowsDowntime")]
pub allows_downtime: Option<bool>,
#[serde(rename = "createdAt")]
pub created_at: Option<String>,
#[serde(rename = "lastUsedAt")]
pub last_used_at: Option<String>,
}
#[derive(Debug, Clone)]
pub struct ApiConfig {
pub hostname: String,
pub port: u16,
pub api_version: String,
}
impl Default for ApiConfig {
fn default() -> Self {
Self {
hostname: "localhost".to_string(),
port: 8080,
api_version: "v0".to_string(),
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ApiResponse<T> {
pub success: bool,
#[serde(skip_serializing_if = "Option::is_none")]
pub data: Option<T>,
#[serde(skip_serializing_if = "Option::is_none")]
pub error: Option<String>,
}
impl<T> ApiResponse<T> {
pub fn success(data: T) -> Self {
Self {
success: true,
data: Some(data),
error: None,
}
}
pub fn error(msg: impl Into<String>) -> Self {
Self {
success: false,
data: None,
error: Some(msg.into()),
}
}
}