forked from hub4j/github-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGHDeployment.java
More file actions
205 lines (184 loc) · 4.97 KB
/
GHDeployment.java
File metadata and controls
205 lines (184 loc) · 4.97 KB
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
package org.kohsuke.github;
import org.kohsuke.github.internal.Previews;
import java.io.IOException;
import java.net.URL;
import java.util.Collections;
import java.util.Map;
/**
* Represents a deployment
*
* @see <a href="https://developer.github.com/v3/repos/deployments/">documentation</a>
* @see GHRepository#listDeployments(String, String, String, String) GHRepository#listDeployments(String, String,
* String, String)
* @see GHRepository#getDeployment(long) GHRepository#getDeployment(long)
*/
public class GHDeployment extends GHObject {
private GHRepository owner;
protected String sha;
protected String ref;
protected String task;
protected Object payload;
protected String environment;
protected String description;
protected String statuses_url;
protected String repository_url;
protected GHUser creator;
protected String original_environment;
protected boolean transient_environment;
protected boolean production_environment;
GHDeployment wrap(GHRepository owner) {
this.owner = owner;
return this;
}
/**
* Gets statuses url.
*
* @return the statuses url
*/
public URL getStatusesUrl() {
return GitHubClient.parseURL(statuses_url);
}
/**
* Gets repository url.
*
* @return the repository url
*/
public URL getRepositoryUrl() {
return GitHubClient.parseURL(repository_url);
}
/**
* Gets task.
*
* @return the task
*/
public String getTask() {
return task;
}
/**
* Gets payload. <b>NOTE:</b> only use this method if you can guarantee the payload will be a simple string,
* otherwise use {@link #getPayloadObject()}.
*
* @return the payload
*/
public String getPayload() {
return (String) payload;
}
/**
* Gets payload. <b>NOTE:</b> only use this method if you can guarantee the payload will be a JSON object (Map),
* otherwise use {@link #getPayloadObject()}.
*
* @return the payload
*/
public Map<String, Object> getPayloadMap() {
return Collections.unmodifiableMap((Map<String, Object>) payload);
}
/**
* Gets payload without assuming its type. It could be a String or a Map.
*
* @return the payload
*/
public Object getPayloadObject() {
return payload;
}
/**
* The environment defined when the deployment was first created.
*
* @deprecated until preview feature has graduated to stable
*
* @return the original deployment environment
*/
@Preview(Previews.FLASH)
public String getOriginalEnvironment() {
return original_environment;
}
/**
* Gets environment.
*
* @return the environment
*/
public String getEnvironment() {
return environment;
}
/**
* Specifies if the given environment is specific to the deployment and will no longer exist at some point in the
* future.
*
* @deprecated until preview feature has graduated to stable
*
* @return the environment is transient
*/
@Preview(Previews.ANT_MAN)
public boolean isTransientEnvironment() {
return transient_environment;
}
/**
* Specifies if the given environment is one that end-users directly interact with.
*
* @deprecated until preview feature has graduated to stable
*
* @return the environment is used by end-users directly
*/
@Preview(Previews.ANT_MAN)
public boolean isProductionEnvironment() {
return production_environment;
}
/**
* Gets creator.
*
* @return the creator
* @throws IOException
* the io exception
*/
public GHUser getCreator() throws IOException {
return root().intern(creator);
}
/**
* Gets ref.
*
* @return the ref
*/
public String getRef() {
return ref;
}
/**
* Gets sha.
*
* @return the sha
*/
public String getSha() {
return sha;
}
/**
* @deprecated This object has no HTML URL.
*/
@Override
public URL getHtmlUrl() {
return null;
}
/**
* Create status gh deployment status builder.
*
* @param state
* the state
* @return the gh deployment status builder
*/
public GHDeploymentStatusBuilder createStatus(GHDeploymentState state) {
return new GHDeploymentStatusBuilder(owner, getId(), state);
}
/**
* List statuses paged iterable.
*
* @return the paged iterable
*/
public PagedIterable<GHDeploymentStatus> listStatuses() {
return root().createRequest()
.withUrlPath(statuses_url)
.withPreview(Previews.ANT_MAN)
.withPreview(Previews.FLASH)
.toIterable(GHDeploymentStatus[].class, item -> item.lateBind(owner));
}
// test only
GHRepository getOwner() {
return owner;
}
}