octocrate_types/
presets.rs

1use serde::{Deserialize, Serialize};
2
3#[derive(Serialize, Deserialize, Debug, Clone)]
4#[serde(untagged)]
5pub enum StringOrInteger {
6  String(String),
7  Number(i64),
8}
9
10#[derive(Serialize, Deserialize, Debug, Clone)]
11#[serde(untagged)]
12pub enum StringOrNumber {
13  String(String),
14  Number(f64),
15}
16
17#[derive(Serialize, Deserialize, Debug, Clone)]
18#[serde(untagged)]
19pub enum ObjectOrString<T> {
20  String(String),
21  Object(T),
22}
23
24#[derive(Serialize, Deserialize, Debug, Clone)]
25#[serde(untagged)]
26pub enum StringOrBool {
27  String(String),
28  Bool(bool),
29}
30
31#[derive(Serialize, Deserialize, Debug, Clone)]
32pub enum ReadWritePermission {
33  #[serde(rename = "read")]
34  Read,
35  #[serde(rename = "write")]
36  Write,
37}
38
39#[derive(Serialize, Deserialize, Debug, Clone)]
40pub enum Permissions {
41  #[serde(rename = "read")]
42  Read,
43  #[serde(rename = "write")]
44  Write,
45  #[serde(rename = "admin")]
46  Admin,
47  #[serde(rename = "none")]
48  None,
49}
50
51#[derive(Serialize, Deserialize, Debug, Clone)]
52pub enum ReadWriteAdminPermission {
53  #[serde(rename = "read")]
54  Read,
55  #[serde(rename = "write")]
56  Write,
57  #[serde(rename = "admin")]
58  Admin,
59}
60
61#[derive(Serialize, Deserialize, Debug, Clone)]
62pub enum ReadPermission {
63  #[serde(rename = "read")]
64  Read,
65}
66
67#[derive(Serialize, Deserialize, Debug, Clone)]
68pub enum WritePermission {
69  #[serde(rename = "write")]
70  Write,
71}
72
73/// The default value for a merge commit message.
74///
75/// - `PR_TITLE` - default to the pull request's title.
76/// - `PR_BODY` - default to the pull request's body.
77/// - `BLANK` - default to a blank commit message.
78#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Copy)]
79pub enum MergeCommitMessage {
80  #[serde(rename = "PR_BODY")]
81  PrBody,
82  #[serde(rename = "PR_TITLE")]
83  PrTitle,
84  #[serde(rename = "BLANK")]
85  Blank,
86}
87
88impl std::fmt::Display for MergeCommitMessage {
89  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
90    match self {
91      MergeCommitMessage::PrBody => write!(f, "PR_BODY"),
92      MergeCommitMessage::PrTitle => write!(f, "PR_TITLE"),
93      MergeCommitMessage::Blank => write!(f, "BLANK"),
94    }
95  }
96}
97
98/// The default value for a squash merge commit message:
99///
100/// - `PR_BODY` - default to the pull request's body.
101/// - `COMMIT_MESSAGES` - default to the branch's commit messages.
102/// - `BLANK` - default to a blank commit message.
103#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Copy)]
104pub enum SquashMergeCommitMessage {
105  #[serde(rename = "PR_BODY")]
106  PrBody,
107  #[serde(rename = "COMMIT_MESSAGES")]
108  CommitMessages,
109  #[serde(rename = "BLANK")]
110  Blank,
111}
112
113impl std::fmt::Display for SquashMergeCommitMessage {
114  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
115    match self {
116      SquashMergeCommitMessage::PrBody => write!(f, "PR_BODY"),
117      SquashMergeCommitMessage::CommitMessages => write!(f, "COMMIT_MESSAGES"),
118      SquashMergeCommitMessage::Blank => write!(f, "BLANK"),
119    }
120  }
121}
122
123/// The default value for a squash merge commit title:
124///
125/// - `PR_TITLE` - default to the pull request's title.
126/// - `COMMIT_OR_PR_TITLE` - default to the commit's title (if only one commit) or the pull request's title (when more than one commit).
127#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Copy)]
128pub enum SquashMergeCommitTitle {
129  #[serde(rename = "PR_TITLE")]
130  PrTitle,
131  #[serde(rename = "COMMIT_OR_PR_TITLE")]
132  CommitOrPrTitle,
133}
134
135impl std::fmt::Display for SquashMergeCommitTitle {
136  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
137    match self {
138      SquashMergeCommitTitle::PrTitle => write!(f, "PR_TITLE"),
139      SquashMergeCommitTitle::CommitOrPrTitle => write!(f, "COMMIT_OR_PR_TITLE"),
140    }
141  }
142}
143
144/// The default value for a merge commit title.
145///
146///   - `PR_TITLE` - default to the pull request's title.
147///   - `MERGE_MESSAGE` - default to the classic title for a merge message (e.g., Merge pull request #123 from branch-name).
148#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Copy)]
149pub enum MergeCommitTitle {
150  #[serde(rename = "PR_TITLE")]
151  PrTitle,
152  #[serde(rename = "MERGE_MESSAGE")]
153  MergeMessage,
154}
155
156impl std::fmt::Display for MergeCommitTitle {
157  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
158    match self {
159      MergeCommitTitle::PrTitle => write!(f, "PR_TITLE"),
160      MergeCommitTitle::MergeMessage => write!(f, "MERGE_MESSAGE"),
161    }
162  }
163}
164
165/// The severity of the vulnerability / alert / advisory.
166#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Copy)]
167pub enum Severity {
168  #[serde(rename = "low")]
169  Low,
170  #[serde(rename = "medium")]
171  Medium,
172  #[serde(rename = "high")]
173  High,
174  #[serde(rename = "critical")]
175  Critical,
176}
177
178impl std::fmt::Display for Severity {
179  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
180    match self {
181      Severity::Low => write!(f, "low"),
182      Severity::Medium => write!(f, "medium"),
183      Severity::High => write!(f, "high"),
184      Severity::Critical => write!(f, "critical"),
185    }
186  }
187}
188
189#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Copy)]
190pub enum Visibility {
191  #[serde(rename = "all")]
192  All,
193  #[serde(rename = "private")]
194  Private,
195  #[serde(rename = "selected")]
196  Selected,
197}
198
199impl std::fmt::Display for Visibility {
200  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
201    match self {
202      Visibility::All => write!(f, "all"),
203      Visibility::Private => write!(f, "private"),
204      Visibility::Selected => write!(f, "selected"),
205    }
206  }
207}
208
209/// The operator to use for matching.
210#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Copy)]
211pub enum Operator {
212  #[serde(rename = "starts_with")]
213  StartsWith,
214  #[serde(rename = "ends_with")]
215  EndsWith,
216  #[serde(rename = "contains")]
217  Contains,
218  #[serde(rename = "regex")]
219  Regex,
220}
221
222impl std::fmt::Display for Operator {
223  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
224    match self {
225      Operator::StartsWith => write!(f, "starts_with"),
226      Operator::EndsWith => write!(f, "ends_with"),
227      Operator::Contains => write!(f, "contains"),
228      Operator::Regex => write!(f, "regex"),
229    }
230  }
231}
232
233/// The type of identifier.
234#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Copy)]
235pub enum IdentifiersType {
236  #[serde(rename = "CVE")]
237  Cve,
238  #[serde(rename = "GHSA")]
239  Ghsa,
240}
241
242impl std::fmt::Display for IdentifiersType {
243  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
244    match self {
245      IdentifiersType::Cve => write!(f, "CVE"),
246      IdentifiersType::Ghsa => write!(f, "GHSA"),
247    }
248  }
249}
250
251#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Copy)]
252pub enum RepositorySelection {
253  #[serde(rename = "all")]
254  All,
255  #[serde(rename = "selected")]
256  Selected,
257}
258
259impl std::fmt::Display for RepositorySelection {
260  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
261    match self {
262      RepositorySelection::All => write!(f, "all"),
263      RepositorySelection::Selected => write!(f, "selected"),
264    }
265  }
266}
267
268/// The state of the Dependabot alert.
269#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Copy)]
270pub enum DependabotAlertState {
271  #[serde(rename = "auto_dismissed")]
272  AutoDismissed,
273  #[serde(rename = "dismissed")]
274  Dismissed,
275  #[serde(rename = "fixed")]
276  Fixed,
277  #[serde(rename = "open")]
278  Open,
279}
280
281impl std::fmt::Display for DependabotAlertState {
282  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
283    match self {
284      DependabotAlertState::AutoDismissed => write!(f, "auto_dismissed"),
285      DependabotAlertState::Dismissed => write!(f, "dismissed"),
286      DependabotAlertState::Fixed => write!(f, "fixed"),
287      DependabotAlertState::Open => write!(f, "open"),
288    }
289  }
290}
291
292/// The organization policy for allowing or disallowing organization members to use Copilot within their CLI / editor ..
293#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Copy)]
294pub enum CopilotOrganizationPolicy {
295  #[serde(rename = "enabled")]
296  Enabled,
297  #[serde(rename = "disabled")]
298  Disabled,
299  #[serde(rename = "unconfigured")]
300  Unconfigured,
301}
302
303impl std::fmt::Display for CopilotOrganizationPolicy {
304  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
305    match self {
306      CopilotOrganizationPolicy::Enabled => write!(f, "enabled"),
307      CopilotOrganizationPolicy::Disabled => write!(f, "disabled"),
308      CopilotOrganizationPolicy::Unconfigured => write!(f, "unconfigured"),
309    }
310  }
311}
312
313#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Copy)]
314pub enum PackageType {
315  #[serde(rename = "npm")]
316  Npm,
317  #[serde(rename = "maven")]
318  Maven,
319  #[serde(rename = "rubygems")]
320  Rubygems,
321  #[serde(rename = "docker")]
322  Docker,
323  #[serde(rename = "nuget")]
324  Nuget,
325  #[serde(rename = "container")]
326  Container,
327}
328
329impl std::fmt::Display for PackageType {
330  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
331    match self {
332      PackageType::Npm => write!(f, "npm"),
333      PackageType::Maven => write!(f, "maven"),
334      PackageType::Rubygems => write!(f, "rubygems"),
335      PackageType::Docker => write!(f, "docker"),
336      PackageType::Nuget => write!(f, "nuget"),
337      PackageType::Container => write!(f, "container"),
338    }
339  }
340}
341
342/// Type of repository selection requested.
343#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Copy)]
344pub enum RequestRepositorySelection {
345  #[serde(rename = "none")]
346  None,
347  #[serde(rename = "all")]
348  All,
349  #[serde(rename = "subset")]
350  Subset,
351}
352
353impl std::fmt::Display for RequestRepositorySelection {
354  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
355    match self {
356      RequestRepositorySelection::None => write!(f, "none"),
357      RequestRepositorySelection::All => write!(f, "all"),
358      RequestRepositorySelection::Subset => write!(f, "subset"),
359    }
360  }
361}
362
363/// The reason that the alert was dismissed.
364#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Copy)]
365pub enum DismissedReason {
366  #[serde(rename = "fix_started")]
367  FixStarted,
368  #[serde(rename = "inaccurate")]
369  Inaccurate,
370  #[serde(rename = "no_bandwidth")]
371  NoBandwidth,
372  #[serde(rename = "not_used")]
373  NotUsed,
374  #[serde(rename = "tolerable_risk")]
375  TolerableRisk,
376}
377
378impl std::fmt::Display for DismissedReason {
379  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
380    match self {
381      DismissedReason::FixStarted => write!(f, "fix_started"),
382      DismissedReason::Inaccurate => write!(f, "inaccurate"),
383      DismissedReason::NoBandwidth => write!(f, "no_bandwidth"),
384      DismissedReason::NotUsed => write!(f, "not_used"),
385      DismissedReason::TolerableRisk => write!(f, "tolerable_risk"),
386    }
387  }
388}
389
390impl std::fmt::Display for StringOrNumber {
391  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
392    match self {
393      StringOrNumber::String(x) => write!(f, "{}", x),
394      StringOrNumber::Number(x) => write!(f, "{}", x),
395    }
396  }
397}
398
399impl std::fmt::Display for StringOrInteger {
400  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
401    match self {
402      StringOrInteger::String(x) => write!(f, "{}", x),
403      StringOrInteger::Number(x) => write!(f, "{}", x),
404    }
405  }
406}
407
408impl std::fmt::Display for StringOrBool {
409  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
410    match self {
411      StringOrBool::String(x) => write!(f, "{}", x),
412      StringOrBool::Bool(x) => write!(f, "{}", x),
413    }
414  }
415}
416
417impl std::fmt::Display for ReadWritePermission {
418  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
419    match self {
420      ReadWritePermission::Read => write!(f, "read"),
421      ReadWritePermission::Write => write!(f, "write"),
422    }
423  }
424}
425
426impl std::fmt::Display for ReadPermission {
427  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
428    match self {
429      ReadPermission::Read => write!(f, "read"),
430    }
431  }
432}
433
434impl std::fmt::Display for WritePermission {
435  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
436    match self {
437      WritePermission::Write => write!(f, "write"),
438    }
439  }
440}
441
442impl std::fmt::Display for Permissions {
443  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
444    match self {
445      Permissions::Read => write!(f, "read"),
446      Permissions::Write => write!(f, "write"),
447      Permissions::Admin => write!(f, "admin"),
448      Permissions::None => write!(f, "none"),
449    }
450  }
451}
452
453impl std::fmt::Display for ReadWriteAdminPermission {
454  fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
455    match self {
456      ReadWriteAdminPermission::Read => write!(f, "read"),
457      ReadWriteAdminPermission::Write => write!(f, "write"),
458      ReadWriteAdminPermission::Admin => write!(f, "admin"),
459    }
460  }
461}