1use crate::CliOverridesPatch;
2use serde_json::Value;
3use std::process::ExitStatus;
4
5#[derive(Clone, Debug, Eq, PartialEq)]
7pub struct CloudOverviewRequest {
8 pub overrides: CliOverridesPatch,
9}
10
11impl CloudOverviewRequest {
12 pub fn new() -> Self {
13 Self {
14 overrides: CliOverridesPatch::default(),
15 }
16 }
17
18 pub fn with_overrides(mut self, overrides: CliOverridesPatch) -> Self {
19 self.overrides = overrides;
20 self
21 }
22}
23
24impl Default for CloudOverviewRequest {
25 fn default() -> Self {
26 Self::new()
27 }
28}
29
30#[derive(Clone, Debug, Eq, PartialEq)]
32pub struct CloudListRequest {
33 pub json: bool,
34 pub env_id: Option<String>,
35 pub limit: Option<u32>,
36 pub cursor: Option<String>,
37 pub overrides: CliOverridesPatch,
38}
39
40impl CloudListRequest {
41 pub fn new() -> Self {
42 Self {
43 json: false,
44 env_id: None,
45 limit: None,
46 cursor: None,
47 overrides: CliOverridesPatch::default(),
48 }
49 }
50
51 pub fn json(mut self, enable: bool) -> Self {
52 self.json = enable;
53 self
54 }
55
56 pub fn env_id(mut self, env_id: impl Into<String>) -> Self {
57 let env_id = env_id.into();
58 self.env_id = (!env_id.trim().is_empty()).then_some(env_id);
59 self
60 }
61
62 pub fn limit(mut self, limit: u32) -> Self {
63 self.limit = Some(limit);
64 self
65 }
66
67 pub fn cursor(mut self, cursor: impl Into<String>) -> Self {
68 let cursor = cursor.into();
69 self.cursor = (!cursor.trim().is_empty()).then_some(cursor);
70 self
71 }
72
73 pub fn with_overrides(mut self, overrides: CliOverridesPatch) -> Self {
74 self.overrides = overrides;
75 self
76 }
77}
78
79impl Default for CloudListRequest {
80 fn default() -> Self {
81 Self::new()
82 }
83}
84
85#[derive(Clone, Debug, PartialEq)]
87pub struct CloudListOutput {
88 pub status: ExitStatus,
89 pub stdout: String,
90 pub stderr: String,
91 pub json: Option<Value>,
93}
94
95#[derive(Clone, Debug, Eq, PartialEq)]
97pub struct CloudStatusRequest {
98 pub task_id: String,
99 pub overrides: CliOverridesPatch,
100}
101
102impl CloudStatusRequest {
103 pub fn new(task_id: impl Into<String>) -> Self {
104 Self {
105 task_id: task_id.into(),
106 overrides: CliOverridesPatch::default(),
107 }
108 }
109
110 pub fn with_overrides(mut self, overrides: CliOverridesPatch) -> Self {
111 self.overrides = overrides;
112 self
113 }
114}
115
116#[derive(Clone, Debug, Eq, PartialEq)]
118pub struct CloudExecRequest {
119 pub env_id: String,
120 pub query: Option<String>,
121 pub attempts: Option<u32>,
122 pub branch: Option<String>,
123 pub overrides: CliOverridesPatch,
124}
125
126impl CloudExecRequest {
127 pub fn new(env_id: impl Into<String>) -> Self {
128 Self {
129 env_id: env_id.into(),
130 query: None,
131 attempts: None,
132 branch: None,
133 overrides: CliOverridesPatch::default(),
134 }
135 }
136
137 pub fn query(mut self, query: impl Into<String>) -> Self {
138 let query = query.into();
139 self.query = (!query.trim().is_empty()).then_some(query);
140 self
141 }
142
143 pub fn attempts(mut self, attempts: u32) -> Self {
144 self.attempts = Some(attempts);
145 self
146 }
147
148 pub fn branch(mut self, branch: impl Into<String>) -> Self {
149 let branch = branch.into();
150 self.branch = (!branch.trim().is_empty()).then_some(branch);
151 self
152 }
153
154 pub fn with_overrides(mut self, overrides: CliOverridesPatch) -> Self {
155 self.overrides = overrides;
156 self
157 }
158}