forked from hub4j/github-api
/
GHWorkflowRunQueryBuilder.java
110 lines (99 loc) · 2.76 KB
/
GHWorkflowRunQueryBuilder.java
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
package org.kohsuke.github;
import org.kohsuke.github.GHWorkflowRun.Conclusion;
import org.kohsuke.github.GHWorkflowRun.Status;
/**
* Lists up workflow runs with some filtering and sorting.
*
* @author Guillaume Smet
* @see GHRepository#queryWorkflowRuns()
*/
public class GHWorkflowRunQueryBuilder extends GHQueryBuilder<GHWorkflowRun> {
private final GHRepository repo;
GHWorkflowRunQueryBuilder(GHRepository repo) {
super(repo.root());
this.repo = repo;
}
/**
* Actor workflow run query builder.
*
* @param actor
* the actor
* @return the gh workflow run query builder
*/
public GHWorkflowRunQueryBuilder actor(String actor) {
req.with("actor", actor);
return this;
}
/**
* Actor workflow run query builder.
*
* @param actor
* the actor
* @return the gh workflow run query builder
*/
public GHWorkflowRunQueryBuilder actor(GHUser actor) {
req.with("actor", actor.getLogin());
return this;
}
/**
* Branch workflow run query builder.
*
* @param branch
* the branch
* @return the gh workflow run query builder
*/
public GHWorkflowRunQueryBuilder branch(String branch) {
req.with("branch", branch);
return this;
}
/**
* Event workflow run query builder.
*
* @param event
* the event
* @return the gh workflow run query builder
*/
public GHWorkflowRunQueryBuilder event(GHEvent event) {
req.with("event", event.symbol());
return this;
}
/**
* Event workflow run query builder.
*
* @param event
* the event
* @return the gh workflow run query builder
*/
public GHWorkflowRunQueryBuilder event(String event) {
req.with("event", event);
return this;
}
/**
* Status workflow run query builder.
*
* @param status
* the status
* @return the gh workflow run query builder
*/
public GHWorkflowRunQueryBuilder status(Status status) {
req.with("status", status.toString());
return this;
}
/**
* Conclusion workflow run query builder.
* <p>
* The GitHub API is also using the status field to search by conclusion.
*
* @param conclusion
* the conclusion
* @return the gh workflow run query builder
*/
public GHWorkflowRunQueryBuilder conclusion(Conclusion conclusion) {
req.with("status", conclusion.toString());
return this;
}
@Override
public PagedIterable<GHWorkflowRun> list() {
return new GHWorkflowRunsIterable(repo, req.withUrlPath(repo.getApiTailUrl("actions/runs")));
}
}