OXYGENHUB
# 180dc43ad0e0 oxygenhub / crates / hub-api / src / lib.rs
39.6 KiB · Rust · last changed Placement ranks runners and says why a job ran where it did 24 days ago source blame history raw
1
//! Types of the OxygenHub JSON API (hub spec §12.1). Everything here is
2
//! `serde` data with no behaviour, so clients in other languages can be
3
//! generated from it and the server can never drift from them.
4
//!
5
//! Shapes reuse `oxy --json`'s where one exists (hashes as lowercase hex,
6
//! times as milliseconds since the epoch), so tools written against the
7
//! command line work against the hub.
8
9
use schemars::JsonSchema;
10
use serde::{Deserialize, Serialize};
11
12
/// A repository as the API lists it.
13
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
14
pub struct Repository {
15
    pub owner: String,
16
    pub name: String,
17
    pub description: String,
18
    pub default_bookmark: String,
19
    pub visibility: Visibility,
20
    /// Milliseconds since the epoch.
21
    pub created_ms: i64,
22
    pub updated_ms: i64,
23
    /// `https://…/{owner}/{name}`, what `oxy clone` takes.
24
    pub clone_url: String,
25
}
26
27
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
28
#[serde(rename_all = "lowercase")]
29
pub enum Visibility {
30
    Public,
31
    Internal,
32
    Private,
33
}
34
35
impl Visibility {
36
    pub fn as_str(self) -> &'static str {
37
        match self {
38
            Visibility::Public => "public",
39
            Visibility::Internal => "internal",
40
            Visibility::Private => "private",
41
        }
42
    }
43
44
    pub fn parse(s: &str) -> Option<Visibility> {
45
        Some(match s {
46
            "public" => Visibility::Public,
47
            "internal" => Visibility::Internal,
48
            "private" => Visibility::Private,
49
            _ => return None,
50
        })
51
    }
52
}
53
54
/// A bookmark: a name for a set of heads (spec §10.1).
55
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
56
pub struct Bookmark {
57
    pub name: String,
58
    pub heads: Vec<String>,
59
    /// Number of changes in the bookmark's state.
60
    pub changes: usize,
61
    pub default: bool,
62
}
63
64
/// A tag: a name for one state, with its attestation when signed.
65
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
66
pub struct Tag {
67
    pub name: String,
68
    pub heads: Vec<String>,
69
    pub message: String,
70
    pub signer: Option<String>,
71
}
72
73
/// One change in a history listing.
74
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
75
pub struct ChangeSummary {
76
    pub hash: String,
77
    pub message: String,
78
    pub author: Author,
79
    pub when_ms: u64,
80
    pub deps: Vec<String>,
81
    pub head: bool,
82
    pub signature: Signature,
83
    /// Signed for the author by a delegate (an agent), when it was.
84
    #[serde(default, skip_serializing_if = "Option::is_none")]
85
    pub via: Option<Via>,
86
}
87
88
/// A delegate that signed a change for its author (Oxygen spec §14.2).
89
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
90
pub struct Via {
91
    pub name: String,
92
    pub key: String,
93
    /// The delegation's scope, `changes` for an agent.
94
    pub scope: String,
95
    pub expires_ms: Option<u64>,
96
    /// The delegation has since been revoked or withdrawn.
97
    pub revoked: bool,
98
}
99
100
/// Who wrote a change: the linked account when the signing key is linked,
101
/// else the key alone.
102
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
103
pub struct Author {
104
    pub name: String,
105
    pub email: String,
106
    pub key: String,
107
    /// The hub account this key is linked to, when any.
108
    pub account: Option<String>,
109
    /// Set when the change is signed by a key no account has linked, and
110
    /// says how its owner links it.
111
    #[serde(default, skip_serializing_if = "Option::is_none")]
112
    pub note: Option<String>,
113
}
114
115
impl Author {
116
    /// What `note` says for a key that no account has linked.
117
    pub const UNLINKED: &'static str =
118
        "signed by a key not linked to any account; its owner links it under Settings → Keys (/settings/keys)";
119
120
    /// The note for an author with this key and account.
121
    pub fn note_for(key: &str, account: &Option<String>) -> Option<String> {
122
        (!key.is_empty() && account.is_none()).then(|| Self::UNLINKED.to_string())
123
    }
124
}
125
126
/// Signature status of a change as `oxy verify` reports it.
127
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
128
#[serde(tag = "status", rename_all = "lowercase")]
129
pub enum Signature {
130
    Unsigned,
131
    Valid { key: String, sealed: bool, revoked: bool },
132
    Invalid { reason: String },
133
}
134
135
/// An RFC 7807 problem response.
136
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
137
pub struct Problem {
138
    pub status: u16,
139
    pub title: String,
140
    pub detail: String,
141
}
142
143
#[cfg(test)]
144
mod tests {
145
    use super::*;
146
147
    #[test]
148
    fn visibility_round_trips() {
149
        for v in [Visibility::Public, Visibility::Internal, Visibility::Private] {
150
            assert_eq!(Visibility::parse(v.as_str()), Some(v));
151
        }
152
        assert_eq!(Visibility::parse("secret"), None);
153
    }
154
}
155
156
// ---------------------------------------------------------------- proposals
157
158
/// A proposal: a request to add changes to a target bookmark (hub spec §7).
159
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
160
pub struct Proposal {
161
    pub number: i64,
162
    pub title: String,
163
    pub body: String,
164
    pub author: String,
165
    pub state: ProposalState,
166
    pub target: String,
167
    pub source: ProposalSource,
168
    /// The changes the proposal adds, dependency order, newest last.
169
    pub changes: Vec<ChangeSummary>,
170
    /// Heads of the projected state (target plus the changes), when computed.
171
    pub projected_heads: Vec<String>,
172
    pub projected_state: Option<String>,
173
    pub conflicted: bool,
174
    pub approvals: Vec<Approval>,
175
    pub landable: bool,
176
    pub blockers: Vec<String>,
177
    pub created_ms: i64,
178
    pub updated_ms: i64,
179
    /// `https://hub/{owner}/{name}/proposal/{number}`.
180
    pub url: String,
181
    /// Where `oxy` fetches the changes from.
182
    pub repository_url: String,
183
    /// The fork's clone URL when the source is a fork.
184
    pub source_url: Option<String>,
185
    /// Who landed it, how and when, once landed.
186
    #[serde(default)]
187
    pub landed: Option<Landed>,
188
    /// Asked to review and not yet reviewing, in the order asked.
189
    #[serde(default)]
190
    pub requested_reviewers: Vec<String>,
191
    #[serde(default)]
192
    pub labels: Vec<Label>,
193
}
194
195
/// How a proposal was landed.
196
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
197
pub struct Landed {
198
    pub by: String,
199
    /// `web`, or `api (token NAME)`.
200
    pub via: String,
201
    pub when_ms: i64,
202
}
203
204
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
205
#[serde(rename_all = "lowercase")]
206
pub enum ProposalState {
207
    Draft,
208
    Open,
209
    Landed,
210
    Closed,
211
}
212
213
impl ProposalState {
214
    pub fn as_str(self) -> &'static str {
215
        match self {
216
            ProposalState::Draft => "draft",
217
            ProposalState::Open => "open",
218
            ProposalState::Landed => "landed",
219
            ProposalState::Closed => "closed",
220
        }
221
    }
222
223
    pub fn parse(s: &str) -> Option<ProposalState> {
224
        Some(match s {
225
            "draft" => ProposalState::Draft,
226
            "open" => ProposalState::Open,
227
            "landed" => ProposalState::Landed,
228
            "closed" => ProposalState::Closed,
229
            _ => return None,
230
        })
231
    }
232
}
233
234
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
235
#[serde(tag = "kind", rename_all = "lowercase")]
236
pub enum ProposalSource {
237
    /// A bookmark of the same repository.
238
    Bookmark { bookmark: String },
239
    /// A bookmark of a fork.
240
    Fork { owner: String, name: String, bookmark: String },
241
    /// An explicit list of change hashes.
242
    Changes { hashes: Vec<String> },
243
}
244
245
/// A reviewer's approval, counted only when backed by a seal over every
246
/// change of the proposal signed with a key linked to the reviewer.
247
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
248
pub struct Approval {
249
    pub account: String,
250
    pub sealed: bool,
251
    pub key: Option<String>,
252
}
253
254
// ------------------------------------------------------------------ issues
255
256
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
257
pub struct Issue {
258
    pub number: i64,
259
    pub title: String,
260
    pub body: String,
261
    pub author: String,
262
    pub state: String,
263
    pub reason: String,
264
    pub labels: Vec<Label>,
265
    pub assignees: Vec<String>,
266
    pub milestone: Option<String>,
267
    pub comments: i64,
268
    pub locked: bool,
269
    pub pinned: bool,
270
    pub created_ms: i64,
271
    pub updated_ms: i64,
272
    pub closed_ms: Option<i64>,
273
    pub url: String,
274
}
275
276
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
277
pub struct Label {
278
    pub name: String,
279
    pub colour: String,
280
    pub description: String,
281
}
282
283
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
284
pub struct Milestone {
285
    pub title: String,
286
    pub description: String,
287
    pub due_ms: Option<i64>,
288
    pub state: String,
289
    pub open: i64,
290
    pub closed: i64,
291
}
292
293
/// `POST /repos/{o}/{n}/milestones`: create a milestone, or change the
294
/// description and due date of the one with that title (triage).
295
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
296
pub struct NewMilestone {
297
    pub title: String,
298
    #[serde(default)]
299
    pub description: String,
300
    /// `YYYY-MM-DD`, UTC; absent for no due date.
301
    #[serde(default)]
302
    pub due: Option<String>,
303
}
304
305
/// `PATCH /repos/{o}/{n}/milestones/{title}`: only the fields given change
306
/// (triage).
307
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
308
pub struct MilestoneEdit {
309
    #[serde(default)]
310
    pub title: Option<String>,
311
    #[serde(default)]
312
    pub description: Option<String>,
313
    /// `YYYY-MM-DD`; the empty string clears the due date.
314
    #[serde(default)]
315
    pub due: Option<String>,
316
    /// `open` or `closed`.
317
    #[serde(default)]
318
    pub state: Option<String>,
319
}
320
321
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
322
pub struct Comment {
323
    pub id: i64,
324
    pub author: String,
325
    pub body: String,
326
    pub created_ms: i64,
327
    /// For proposal comments: the file and the atom the comment anchors to.
328
    pub path: Option<String>,
329
    pub anchor: Option<Atom>,
330
    pub resolved: bool,
331
}
332
333
/// One entry in the caller's inbox (hub spec §10).
334
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
335
pub struct Notification {
336
    pub id: i64,
337
    pub at_ms: i64,
338
    /// `issue.opened`, `proposal.comment`, `mention`, `review`, …
339
    pub kind: String,
340
    pub title: String,
341
    /// The page on the hub, absolute.
342
    pub url: String,
343
    pub actor: String,
344
    pub read: bool,
345
}
346
347
/// `GET /notifications`: the unread count and the newest entries, unread first.
348
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
349
pub struct Inbox {
350
    pub unread: i64,
351
    pub items: Vec<Notification>,
352
}
353
354
/// A file a proposal changes, between the target's state and the
355
/// projected state (hub spec §7.2). Fetch either side's bytes from
356
/// `/proposals/{number}/content/{base|head}/{path}`.
357
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
358
pub struct ProposalFile {
359
    pub path: String,
360
    /// For a rename, the path in the target's state.
361
    pub from: Option<String>,
362
    /// `added`, `removed`, `modified`, `renamed`, `mode` or `replaced`.
363
    pub kind: String,
364
    pub added: usize,
365
    pub removed: usize,
366
}
367
368
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
369
pub struct Atom {
370
    pub change: String,
371
    pub index: u32,
372
}
373
374
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
375
pub struct Review {
376
    pub id: i64,
377
    pub author: String,
378
    pub verdict: String,
379
    pub body: String,
380
    pub sealed: bool,
381
    pub created_ms: i64,
382
    /// The AI assistant that answered for `author`, empty for a person's
383
    /// own review (hub spec §13.4).
384
    #[serde(default, skip_serializing_if = "String::is_empty")]
385
    pub via: String,
386
}
387
388
// ------------------------------------------------------------- repository
389
390
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
391
pub struct TreeEntry {
392
    pub name: String,
393
    pub path: String,
394
    pub kind: String,
395
    pub exec: bool,
396
    pub size: Option<u64>,
397
    pub conflicted: bool,
398
}
399
400
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
401
pub struct BlameLine {
402
    pub line: usize,
403
    pub change: String,
404
    pub index: u32,
405
    pub author: String,
406
    pub when_ms: u64,
407
    pub text: String,
408
}
409
410
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
411
pub struct FileChange {
412
    pub path: String,
413
    pub kind: String,
414
    pub from: Option<String>,
415
    pub added: usize,
416
    pub removed: usize,
417
}
418
419
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
420
pub struct ChangeDetail {
421
    pub change: ChangeSummary,
422
    pub body: String,
423
    pub dependents: Vec<String>,
424
    pub in_bookmarks: Vec<String>,
425
    pub in_tags: Vec<String>,
426
    pub files: Vec<FileChange>,
427
}
428
429
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
430
pub struct History {
431
    pub reference: String,
432
    pub heads: Vec<String>,
433
    pub total: usize,
434
    pub offset: usize,
435
    pub changes: Vec<ChangeSummary>,
436
}
437
438
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
439
pub struct Conflict {
440
    pub bookmark: String,
441
    pub path: String,
442
    pub kind: String,
443
    pub contributors: Vec<String>,
444
}
445
446
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
447
pub struct Push {
448
    pub at_ms: i64,
449
    pub pusher: String,
450
    pub reference: String,
451
    pub ok: bool,
452
    pub reason: String,
453
    pub old_state: String,
454
    pub new_state: String,
455
    pub heads: i64,
456
    pub changes: i64,
457
}
458
459
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
460
pub struct Trust {
461
    pub policy: Option<Policy>,
462
    pub signed: usize,
463
    pub sealed: usize,
464
    pub unsigned: usize,
465
    pub invalid: Vec<String>,
466
    pub hub_key: String,
467
}
468
469
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
470
pub struct Policy {
471
    pub serial: u64,
472
    pub expires_ms: u64,
473
    pub roots: Vec<String>,
474
    pub root_threshold: u32,
475
    pub rules: Vec<Rule>,
476
}
477
478
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
479
pub struct Rule {
480
    pub pattern: String,
481
    pub keys: Vec<String>,
482
    pub threshold: u32,
483
    pub require: String,
484
    pub allow_conflicts: bool,
485
}
486
487
// ---------------------------------------------------------- hooks, checks
488
489
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
490
pub struct Hook {
491
    pub id: i64,
492
    pub url: String,
493
    pub events: String,
494
    pub active: bool,
495
    pub created_ms: i64,
496
}
497
498
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
499
pub struct NewHook {
500
    pub url: String,
501
    pub secret: String,
502
    #[serde(default = "star")]
503
    pub events: String,
504
}
505
506
fn star() -> String {
507
    "*".into()
508
}
509
510
/// An OxygenFlow run (hub spec §13.2).
511
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
512
pub struct FlowRun {
513
    /// The run's number within its repository.
514
    pub number: i64,
515
    pub bookmark: String,
516
    /// The state's hash, as checks are keyed.
517
    pub state: String,
518
    /// Its heads, full change hashes.
519
    pub heads: Vec<String>,
520
    /// `queued`, `running`, `passed`, `failed` or `error` (an invalid pipeline).
521
    pub status: String,
522
    /// `push`, `manual` or `rerun:N`.
523
    pub trigger: String,
524
    pub actor: String,
525
    pub pipeline_hash: String,
526
    /// An invalid pipeline's problems.
527
    pub error: String,
528
    pub created_ms: i64,
529
    pub finished_ms: Option<i64>,
530
    pub url: String,
531
    /// For a run waiting for a runner, its first queued job's 1-based
532
    /// place among all queued jobs.
533
    #[serde(default, skip_serializing_if = "Option::is_none")]
534
    pub queue_position: Option<i64>,
535
    /// Filled by the single-run endpoint.
536
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
537
    pub jobs: Vec<FlowJob>,
538
}
539
540
/// A job of a run.
541
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
542
pub struct FlowJob {
543
    pub name: String,
544
    /// `queued`, `running`, `passed`, `failed`, `skipped` or `error`.
545
    pub status: String,
546
    pub depends_on: Vec<String>,
547
    pub runner: String,
548
    pub exit_code: Option<i64>,
549
    pub error: String,
550
    pub started_ms: Option<i64>,
551
    pub finished_ms: Option<i64>,
552
    /// Log lines stored so far.
553
    pub log_lines: i64,
554
    /// Why a queued job no runner can take waits (OxygenFlow spec §11.4);
555
    /// empty when it only waits its turn.
556
    #[serde(default, skip_serializing_if = "String::is_empty")]
557
    pub waiting: String,
558
    /// Why it ran on its runner (oxygenflow#42): "holds the image, idle,
559
    /// speed 100 (class 3)".
560
    #[serde(default, skip_serializing_if = "String::is_empty")]
561
    pub placed: String,
562
}
563
564
/// A line of a job's log.
565
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
566
pub struct FlowLogLine {
567
    /// Increasing within the job; pass the last one as `after` for more.
568
    pub seq: i64,
569
    /// Milliseconds since the job started.
570
    pub t: i64,
571
    /// `stdout`, `stderr` or `flow` (the runner's own notes).
572
    pub stream: String,
573
    pub text: String,
574
}
575
576
/// A check on a state hash (hub spec §13.1).
577
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
578
pub struct Check {
579
    pub state: String,
580
    pub name: String,
581
    pub status: CheckStatus,
582
    pub summary: String,
583
    pub url: String,
584
    pub reporter: String,
585
    /// The seal attestation's reference when the checker sealed the changes.
586
    pub seal: Option<String>,
587
    pub started_ms: i64,
588
    pub finished_ms: Option<i64>,
589
}
590
591
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
592
#[serde(rename_all = "lowercase")]
593
pub enum CheckStatus {
594
    Queued,
595
    Running,
596
    Passed,
597
    Failed,
598
    Cancelled,
599
    Skipped,
600
}
601
602
impl CheckStatus {
603
    pub fn as_str(self) -> &'static str {
604
        match self {
605
            CheckStatus::Queued => "queued",
606
            CheckStatus::Running => "running",
607
            CheckStatus::Passed => "passed",
608
            CheckStatus::Failed => "failed",
609
            CheckStatus::Cancelled => "cancelled",
610
            CheckStatus::Skipped => "skipped",
611
        }
612
    }
613
614
    pub fn parse(s: &str) -> Option<CheckStatus> {
615
        Some(match s {
616
            "queued" => CheckStatus::Queued,
617
            "running" => CheckStatus::Running,
618
            "passed" => CheckStatus::Passed,
619
            "failed" => CheckStatus::Failed,
620
            "cancelled" => CheckStatus::Cancelled,
621
            "skipped" => CheckStatus::Skipped,
622
            _ => return None,
623
        })
624
    }
625
}
626
627
/// What a checker posts.
628
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
629
pub struct NewCheck {
630
    pub state: String,
631
    pub name: String,
632
    pub status: CheckStatus,
633
    #[serde(default)]
634
    pub summary: String,
635
    #[serde(default)]
636
    pub url: String,
637
    /// Hex of a seal attestation reference the checker pushed, if any.
638
    #[serde(default)]
639
    pub seal: Option<String>,
640
}
641
642
// ------------------------------------------------------------- accounts
643
644
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
645
pub struct User {
646
    pub username: String,
647
    pub display_name: String,
648
    pub is_admin: bool,
649
    pub keys: Vec<String>,
650
    pub created_ms: i64,
651
}
652
653
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
654
pub struct Organisation {
655
    pub name: String,
656
    pub display_name: String,
657
    pub description: String,
658
    pub members: Vec<String>,
659
}
660
661
/// Forms accepted by the write endpoints.
662
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
663
pub struct NewRepository {
664
    pub owner: String,
665
    pub name: String,
666
    #[serde(default)]
667
    pub description: String,
668
    #[serde(default = "public")]
669
    pub visibility: Visibility,
670
}
671
672
fn public() -> Visibility {
673
    Visibility::Public
674
}
675
676
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
677
pub struct NewIssue {
678
    pub title: String,
679
    #[serde(default)]
680
    pub body: String,
681
    /// Label names; each must exist. Needs triage.
682
    #[serde(default)]
683
    pub labels: Vec<String>,
684
    /// Usernames. Needs triage.
685
    #[serde(default)]
686
    pub assignees: Vec<String>,
687
    /// A milestone's title. Needs triage.
688
    #[serde(default)]
689
    pub milestone: Option<String>,
690
}
691
692
/// `PATCH /repos/{o}/{n}/issues/{number}`: only the fields given change.
693
/// Title and body: the author or triage. The rest: triage.
694
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
695
pub struct IssueEdit {
696
    #[serde(default)]
697
    pub title: Option<String>,
698
    #[serde(default)]
699
    pub body: Option<String>,
700
    /// The whole set of labels.
701
    #[serde(default)]
702
    pub labels: Option<Vec<String>>,
703
    /// The whole set of assignees.
704
    #[serde(default)]
705
    pub assignees: Option<Vec<String>>,
706
    /// A milestone's title; the empty string clears it.
707
    #[serde(default)]
708
    pub milestone: Option<String>,
709
}
710
711
/// The checks a proposal needs, passed, to land on the repository's
712
/// default bookmark (hub spec §13.1). `GET` and `PUT
713
/// /repos/{o}/{n}/checks/required`.
714
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
715
pub struct RequiredChecks {
716
    pub names: Vec<String>,
717
}
718
719
/// A project (hub spec §8.2).
720
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
721
pub struct Project {
722
    pub owner: String,
723
    pub number: i64,
724
    pub title: String,
725
    pub description: String,
726
    pub public: bool,
727
    pub closed: bool,
728
    pub updated_ms: i64,
729
    /// The board on the hub, absolute.
730
    pub url: String,
731
}
732
733
/// A card as the caller may see it.
734
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
735
pub struct ProjectCard {
736
    pub id: i64,
737
    /// `issue`, `proposal` or `note`.
738
    pub kind: String,
739
    /// `owner/name#N`; empty for a note.
740
    pub reference: String,
741
    /// The issue's or proposal's title, or the note.
742
    pub title: String,
743
    /// The issue's or proposal's state; empty for a note.
744
    pub state: String,
745
}
746
747
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
748
pub struct ProjectColumn {
749
    pub id: i64,
750
    pub name: String,
751
    pub cards: Vec<ProjectCard>,
752
}
753
754
/// `GET /projects/{owner}/{n}`.
755
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
756
pub struct Board {
757
    pub project: Project,
758
    pub columns: Vec<ProjectColumn>,
759
}
760
761
/// `POST /projects/{owner}`.
762
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
763
pub struct NewProject {
764
    pub title: String,
765
    #[serde(default)]
766
    pub description: String,
767
    #[serde(default)]
768
    pub private: bool,
769
}
770
771
/// `PATCH /projects/{owner}/{n}`: only the fields given change.
772
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
773
pub struct ProjectEdit {
774
    /// Transfer the board to this owner (#125): one the caller may make
775
    /// boards under. It takes the next number there.
776
    #[serde(default, skip_serializing_if = "Option::is_none")]
777
    pub owner: Option<String>,
778
    #[serde(default)]
779
    pub title: Option<String>,
780
    #[serde(default)]
781
    pub description: Option<String>,
782
    #[serde(default)]
783
    pub private: Option<bool>,
784
    #[serde(default)]
785
    pub closed: Option<bool>,
786
}
787
788
/// `POST /projects/{owner}/{n}/cards`: a reference (`repo#12`) or a note,
789
/// into the column named (by id or name; the first column when absent).
790
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
791
pub struct NewCard {
792
    #[serde(default)]
793
    pub column: Option<String>,
794
    #[serde(default)]
795
    pub reference: String,
796
    #[serde(default)]
797
    pub note: String,
798
}
799
800
/// `PATCH /projects/{owner}/{n}/cards/{id}`: move to a column (id or name).
801
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
802
pub struct CardMove {
803
    pub column: String,
804
}
805
806
/// `POST /repos/{o}/{n}/labels`: create a label, or change one of that name.
807
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
808
pub struct NewLabel {
809
    pub name: String,
810
    /// `#rrggbb`; a default when absent.
811
    #[serde(default)]
812
    pub colour: Option<String>,
813
    #[serde(default)]
814
    pub description: String,
815
}
816
817
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
818
pub struct NewComment {
819
    pub body: String,
820
    /// For a proposal: anchor the comment to this file's line (1-based) of
821
    /// the projected state; the hub records the line's atom.
822
    #[serde(default)]
823
    pub path: Option<String>,
824
    #[serde(default)]
825
    pub line: Option<usize>,
826
}
827
828
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
829
pub struct NewProposal {
830
    pub title: String,
831
    #[serde(default)]
832
    pub body: String,
833
    pub target: String,
834
    /// A bookmark here, or `owner/name:bookmark` of a fork.
835
    pub source: String,
836
    #[serde(default)]
837
    pub draft: bool,
838
}
839
840
/// `POST .../proposals/{number}/reviewers`: accounts to ask for a review.
841
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
842
pub struct ReviewRequest {
843
    pub reviewers: Vec<String>,
844
}
845
846
/// `POST .../proposals/{number}/review-requests`: ask an AI assistant the
847
/// repository may use (hub spec §13.4) to review; it answers as a `comment`
848
/// review via the assistant.
849
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
850
pub struct AssistantRequest {
851
    pub assistant: String,
852
}
853
854
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
855
pub struct NewReview {
856
    pub verdict: String,
857
    #[serde(default)]
858
    pub body: String,
859
}
860
861
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
862
pub struct IssueStateChange {
863
    /// `open` or `closed`.
864
    pub state: String,
865
    #[serde(default)]
866
    pub reason: String,
867
}
868
869
/// A webhook payload's envelope (hub spec §12.2).
870
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
871
pub struct WebhookEnvelope {
872
    pub event: String,
873
    pub delivery: String,
874
    pub repository: Option<Repository>,
875
    pub actor: String,
876
    pub at_ms: i64,
877
    pub data: serde_json::Value,
878
}
879
880
/// A server-sent event on a proposal's stream.
881
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
882
pub struct ProposalEvent {
883
    pub number: i64,
884
    pub kind: String,
885
    pub check: Option<Check>,
886
}
887
888
// --------------------------------------------------------------- releases
889
890
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
891
pub struct Release {
892
    pub tag: String,
893
    pub title: String,
894
    pub notes: String,
895
    pub prerelease: bool,
896
    pub latest: bool,
897
    pub author: String,
898
    pub heads: Vec<String>,
899
    pub signer: Option<String>,
900
    pub assets: Vec<ReleaseAsset>,
901
    pub archives: Vec<String>,
902
    pub created_ms: i64,
903
    pub url: String,
904
}
905
906
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
907
pub struct ReleaseAsset {
908
    pub name: String,
909
    pub size: i64,
910
    /// BLAKE3 of the content, hex.
911
    pub hash: String,
912
    pub content_type: String,
913
    pub downloads: i64,
914
    pub url: String,
915
    /// The OxygenFlow run and job whose artifact has this content, if any.
916
    #[serde(default, skip_serializing_if = "Option::is_none")]
917
    pub built_by: Option<AssetBuild>,
918
}
919
920
/// Where a release asset was built (hub spec §9): a job's artifact with the
921
/// same BLAKE3, and that job's signed receipt when one was kept.
922
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
923
pub struct AssetBuild {
924
    pub run: i64,
925
    pub job: String,
926
    pub artifact: String,
927
    pub run_url: String,
928
    /// The receipt attestation, hex; `None` when the receipt was not signed.
929
    pub receipt: Option<String>,
930
    pub receipt_url: Option<String>,
931
    pub signer: Option<String>,
932
}
933
934
/// `PATCH /repos/{o}/{n}/proposals/{number}`: what is given changes,
935
/// the rest stays (oxygenhub#76).
936
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
937
pub struct ProposalEdit {
938
    #[serde(default, skip_serializing_if = "Option::is_none")]
939
    pub title: Option<String>,
940
    #[serde(default, skip_serializing_if = "Option::is_none")]
941
    pub body: Option<String>,
942
    /// The whole set of labels, by name (triage); oxygenhub#80.
943
    #[serde(default, skip_serializing_if = "Option::is_none")]
944
    pub labels: Option<Vec<String>>,
945
}
946
947
/// `PATCH /repos/{owner}/{name}/releases/{tag}`: what to change; fields
948
/// left out stay as they are.
949
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
950
pub struct ReleaseEdit {
951
    #[serde(default, skip_serializing_if = "Option::is_none")]
952
    pub title: Option<String>,
953
    #[serde(default, skip_serializing_if = "Option::is_none")]
954
    pub notes: Option<String>,
955
    #[serde(default, skip_serializing_if = "Option::is_none")]
956
    pub prerelease: Option<bool>,
957
}
958
959
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
960
pub struct NewRelease {
961
    pub tag: String,
962
    pub title: String,
963
    #[serde(default)]
964
    pub notes: Option<String>,
965
    #[serde(default)]
966
    pub prerelease: bool,
967
}
968
969
/// Every type of the API, for schema generation.
970
pub fn schemas() -> Vec<(&'static str, schemars::Schema)> {
971
    vec![
972
        ("Repository", schemars::schema_for!(Repository)),
973
        ("Visibility", schemars::schema_for!(Visibility)),
974
        ("Bookmark", schemars::schema_for!(Bookmark)),
975
        ("Tag", schemars::schema_for!(Tag)),
976
        ("ChangeSummary", schemars::schema_for!(ChangeSummary)),
977
        ("Author", schemars::schema_for!(Author)),
978
        ("Signature", schemars::schema_for!(Signature)),
979
        ("Problem", schemars::schema_for!(Problem)),
980
        ("Proposal", schemars::schema_for!(Proposal)),
981
        ("ProposalState", schemars::schema_for!(ProposalState)),
982
        ("ProposalSource", schemars::schema_for!(ProposalSource)),
983
        ("Approval", schemars::schema_for!(Approval)),
984
        ("Issue", schemars::schema_for!(Issue)),
985
        ("Label", schemars::schema_for!(Label)),
986
        ("Milestone", schemars::schema_for!(Milestone)),
987
        ("NewMilestone", schemars::schema_for!(NewMilestone)),
988
        ("MilestoneEdit", schemars::schema_for!(MilestoneEdit)),
989
        ("Comment", schemars::schema_for!(Comment)),
990
        ("ProposalFile", schemars::schema_for!(ProposalFile)),
991
        ("Notification", schemars::schema_for!(Notification)),
992
        ("Inbox", schemars::schema_for!(Inbox)),
993
        ("Atom", schemars::schema_for!(Atom)),
994
        ("Review", schemars::schema_for!(Review)),
995
        ("TreeEntry", schemars::schema_for!(TreeEntry)),
996
        ("BlameLine", schemars::schema_for!(BlameLine)),
997
        ("FileChange", schemars::schema_for!(FileChange)),
998
        ("ChangeDetail", schemars::schema_for!(ChangeDetail)),
999
        ("History", schemars::schema_for!(History)),
1000
        ("Conflict", schemars::schema_for!(Conflict)),
1001
        ("Push", schemars::schema_for!(Push)),
1002
        ("Trust", schemars::schema_for!(Trust)),
1003
        ("Policy", schemars::schema_for!(Policy)),
1004
        ("Rule", schemars::schema_for!(Rule)),
1005
        ("Hook", schemars::schema_for!(Hook)),
1006
        ("NewHook", schemars::schema_for!(NewHook)),
1007
        ("Check", schemars::schema_for!(Check)),
1008
        ("CheckStatus", schemars::schema_for!(CheckStatus)),
1009
        ("NewCheck", schemars::schema_for!(NewCheck)),
1010
        ("User", schemars::schema_for!(User)),
1011
        ("Organisation", schemars::schema_for!(Organisation)),
1012
        ("NewRepository", schemars::schema_for!(NewRepository)),
1013
        ("NewIssue", schemars::schema_for!(NewIssue)),
1014
        ("IssueEdit", schemars::schema_for!(IssueEdit)),
1015
        ("ReleaseEdit", schemars::schema_for!(ReleaseEdit)),
1016
        ("ProposalEdit", schemars::schema_for!(ProposalEdit)),
1017
        ("NewLabel", schemars::schema_for!(NewLabel)),
1018
        ("RequiredChecks", schemars::schema_for!(RequiredChecks)),
1019
        ("Project", schemars::schema_for!(Project)),
1020
        ("ProjectCard", schemars::schema_for!(ProjectCard)),
1021
        ("ProjectColumn", schemars::schema_for!(ProjectColumn)),
1022
        ("Board", schemars::schema_for!(Board)),
1023
        ("NewProject", schemars::schema_for!(NewProject)),
1024
        ("ProjectEdit", schemars::schema_for!(ProjectEdit)),
1025
        ("NewCard", schemars::schema_for!(NewCard)),
1026
        ("CardMove", schemars::schema_for!(CardMove)),
1027
        ("NewComment", schemars::schema_for!(NewComment)),
1028
        ("NewProposal", schemars::schema_for!(NewProposal)),
1029
        ("NewReview", schemars::schema_for!(NewReview)),
1030
        ("IssueStateChange", schemars::schema_for!(IssueStateChange)),
1031
        ("WebhookEnvelope", schemars::schema_for!(WebhookEnvelope)),
1032
        ("ProposalEvent", schemars::schema_for!(ProposalEvent)),
1033
        ("Release", schemars::schema_for!(Release)),
1034
        ("FlowRun", schemars::schema_for!(FlowRun)),
1035
        ("FlowJob", schemars::schema_for!(FlowJob)),
1036
        ("FlowLogLine", schemars::schema_for!(FlowLogLine)),
1037
        ("AssetBuild", schemars::schema_for!(AssetBuild)),
1038
        ("ReleaseAsset", schemars::schema_for!(ReleaseAsset)),
1039
        ("NewRelease", schemars::schema_for!(NewRelease)),
1040
    ]
1041
}
1042
1043
/// An OxygenFlow runner (`GET /api/v1/runners`, site administrators).
1044
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
1045
pub struct Runner {
1046
    pub id: i64,
1047
    pub name: String,
1048
    /// `online`, `offline`, `draining` or `disabled`.
1049
    pub status: String,
1050
    /// What it serves: empty for the whole site, an owner, or `owner/name`.
1051
    pub serves: String,
1052
    pub arch: String,
1053
    pub os: String,
1054
    pub version: String,
1055
    pub labels: Vec<String>,
1056
    pub max_jobs: i64,
1057
    pub memory_mib: Option<i64>,
1058
    pub cpus: Option<i64>,
1059
    /// The key that signs its receipts (KeyId hex), empty until bound.
1060
    pub key: String,
1061
    /// `registered` or `config` (a hub.toml token).
1062
    pub source: String,
1063
    pub last_seen_ms: Option<i64>,
1064
    /// Jobs it is running now.
1065
    pub running: i64,
1066
    /// What it measured at its last claim (oxygenflow#40): free disk in
1067
    /// MiB, the 1-minute load ×100, its speed score (100 on the reference
1068
    /// machine) and class 1–5, its kernel.
1069
    #[serde(default, skip_serializing_if = "Option::is_none")]
1070
    pub free_disk_mib: Option<i64>,
1071
    #[serde(default, skip_serializing_if = "Option::is_none")]
1072
    pub load_x100: Option<i64>,
1073
    #[serde(default, skip_serializing_if = "Option::is_none")]
1074
    pub speed: Option<i64>,
1075
    #[serde(default, skip_serializing_if = "Option::is_none")]
1076
    pub speed_class: Option<i64>,
1077
    #[serde(default, skip_serializing_if = "String::is_empty")]
1078
    pub kernel: String,
1079
}
1080
1081
/// A job a runner ran or is running.
1082
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
1083
pub struct RunnerJob {
1084
    pub repo: String,
1085
    pub run: i64,
1086
    pub job: String,
1087
    pub status: String,
1088
    pub started_ms: Option<i64>,
1089
    pub finished_ms: Option<i64>,
1090
}
1091
1092
/// A job in the queue: running ones first, then queued ones in the order
1093
/// runners claim them.
1094
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
1095
pub struct QueueItem {
1096
    pub repo: String,
1097
    pub run: i64,
1098
    pub job: String,
1099
    /// `running` or `queued`.
1100
    pub status: String,
1101
    /// The runner holding it, when running.
1102
    pub runner: String,
1103
}
1104
1105
// ------------------------------------------------------------- assistants
1106
1107
/// An AI assistant at a level (hub spec §13.4). The token never leaves the
1108
/// hub: `has_token` says whether one is set.
1109
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
1110
pub struct Assistant {
1111
    pub name: String,
1112
    pub endpoint: String,
1113
    pub api: String,
1114
    pub model: String,
1115
    #[serde(default, skip_serializing_if = "String::is_empty")]
1116
    pub headers: String,
1117
    pub enabled: bool,
1118
    pub budget: i64,
1119
    pub has_token: bool,
1120
    /// Where it comes from: empty for the level's own, else `the site` or
1121
    /// `the NAME organisation`.
1122
    #[serde(default, skip_serializing_if = "String::is_empty")]
1123
    pub from: String,
1124
    /// Off because a level above turned a name like it off.
1125
    #[serde(default)]
1126
    pub off_above: bool,
1127
}
1128
1129
/// `POST …/assistants`: add one, or change the one of that name. A
1130
/// `preset` (`anthropic`, `openai`, `gemini`, `deepseek`, `mistral`,
1131
/// `perplexity`, `ollama`) fills what is left out; the model must be one
1132
/// the endpoint lists when it lists any; `token` is write-only.
1133
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
1134
pub struct NewAssistant {
1135
    #[serde(default)]
1136
    pub name: String,
1137
    #[serde(default)]
1138
    pub preset: String,
1139
    #[serde(default)]
1140
    pub endpoint: String,
1141
    #[serde(default)]
1142
    pub api: String,
1143
    pub model: String,
1144
    #[serde(default)]
1145
    pub token: String,
1146
    #[serde(default)]
1147
    pub headers: String,
1148
    #[serde(default = "yes")]
1149
    pub enabled: bool,
1150
    #[serde(default)]
1151
    pub budget: Option<i64>,
1152
}
1153
1154
fn yes() -> bool {
1155
    true
1156
}
1157
1158
/// A level's prompt and those it inherits, outermost first.
1159
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
1160
pub struct AssistantPrompt {
1161
    pub prompt: String,
1162
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
1163
    pub inherited: Vec<(String, String)>,
1164
}
1165
1166
/// `GET /repos/{o}/{n}/coverage`: a coverage report from a Flow job
1167
/// (oxygenhub#113); `percent` values are of lines, functions and branches,
1168
/// absent when nothing was counted.
1169
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema)]
1170
pub struct CoverageReport {
1171
    pub id: i64,
1172
    pub run: i64,
1173
    pub job: String,
1174
    pub bookmark: String,
1175
    /// The run's state, by hash.
1176
    pub state: String,
1177
    /// `lcov` or `cobertura`.
1178
    pub format: String,
1179
    pub lines_found: i64,
1180
    pub lines_hit: i64,
1181
    pub percent: Option<f64>,
1182
    pub functions_found: i64,
1183
    pub functions_hit: i64,
1184
    pub branches_found: i64,
1185
    pub branches_hit: i64,
1186
    pub files: i64,
1187
    /// Files the report named that are not in the run's state.
1188
    pub dropped: i64,
1189
    pub created_ms: i64,
1190
    /// The report on the hub's Coverage tab, absolute.
1191
    pub url: String,
1192
    /// Who uploaded it from a workstation (#136), when no Flow job made it;
1193
    /// `run` and `job` are then 0 and "upload".
1194
    #[serde(default, skip_serializing_if = "Option::is_none")]
1195
    pub uploaded_by: Option<String>,
1196
}
1197
1198
/// One file of a coverage report.
1199
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema)]
1200
pub struct CoverageFile {
1201
    pub path: String,
1202
    pub lines_found: i64,
1203
    pub lines_hit: i64,
1204
    pub percent: Option<f64>,
1205
    pub functions_found: i64,
1206
    pub functions_hit: i64,
1207
    pub branches_found: i64,
1208
    pub branches_hit: i64,
1209
}
1210
1211
/// `GET /repos/{o}/{n}/coverage/{id}`: a report with its files.
1212
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema)]
1213
pub struct CoverageDetail {
1214
    pub report: CoverageReport,
1215
    pub files: Vec<CoverageFile>,
1216
}
1217
1218
/// `GET /repos/{o}/{n}/tests`: a JUnit test report from a Flow job
1219
/// (oxygenhub#114).
1220
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
1221
pub struct TestReport {
1222
    pub id: i64,
1223
    pub run: i64,
1224
    pub job: String,
1225
    pub bookmark: String,
1226
    pub state: String,
1227
    pub tests: i64,
1228
    pub passed: i64,
1229
    pub failed: i64,
1230
    pub errors: i64,
1231
    pub skipped: i64,
1232
    /// The cases' times added up.
1233
    pub time_ms: i64,
1234
    pub created_ms: i64,
1235
    pub url: String,
1236
}
1237
1238
/// One test case of a report.
1239
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
1240
pub struct TestCase {
1241
    pub suite: String,
1242
    pub classname: String,
1243
    pub name: String,
1244
    /// `passed`, `failed`, `error` or `skipped`.
1245
    pub status: String,
1246
    pub time_ms: i64,
1247
    pub message: String,
1248
    /// A failure's text and output, cut to 16 KiB; empty for a pass.
1249
    pub output: String,
1250
}
1251
1252
/// `GET /repos/{o}/{n}/tests/{id}`: a report with its cases
1253
/// (`?status=failed` for the failed and errored ones).
1254
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
1255
pub struct TestReportDetail {
1256
    pub report: TestReport,
1257
    pub cases: Vec<TestCase>,
1258
}