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
use super::{Client, Error, Future, Owner, State};
use futures::{Future as StdFuture, IntoFuture};
use futures::future;
use hyper::client::Connect;
#[derive(Debug, Deserialize)]
struct JobsWrapper {
jobs: Vec<Job>,
}
#[derive(Debug, Deserialize, Clone)]
pub struct Job {
pub id: usize,
pub number: Option<String>,
pub state: Option<State>,
pub started_at: Option<String>,
pub finished_at: Option<String>,
pub queue: Option<String>,
pub owner: Option<Owner>,
}
pub struct Jobs<'a, C>
where
C: Clone + Connect,
{
pub(crate) travis: &'a Client<C>,
pub(crate) build_id: usize,
}
impl<'a, C> Jobs<'a, C>
where
C: Clone + Connect,
{
pub fn list(&self) -> Future<Vec<Job>> {
Box::new(
self.travis
.get(
format!(
"{host}/build/{build_id}/jobs",
host = self.travis.host,
build_id = self.build_id
).parse()
.map_err(Error::from)
.into_future(),
)
.and_then(|wrapper: JobsWrapper| future::ok(wrapper.jobs)),
)
}
}