-
Notifications
You must be signed in to change notification settings - Fork 776
Expand file tree
/
Copy pathGHAsset.java
More file actions
175 lines (155 loc) · 3.51 KB
/
GHAsset.java
File metadata and controls
175 lines (155 loc) · 3.51 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
package org.kohsuke.github;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.IOException;
// TODO: Auto-generated Javadoc
/**
* Asset in a release.
*
* @see GHRelease#getAssets() GHRelease#getAssets()
*/
public class GHAsset extends GHObject {
/**
* Wrap gh asset [ ].
*
* @param assets
* the assets
* @param release
* the release
* @return the gh asset [ ]
*/
public static GHAsset[] wrap(GHAsset[] assets, GHRelease release) {
for (GHAsset aTo : assets) {
aTo.wrap(release);
}
return assets;
}
private String browser_download_url;
private String content_type;
private long download_count;
private String label;
private String name;
private long size;
private String state;
/** The owner. */
GHRepository owner;
/**
* Create default GHAsset instance
*/
public GHAsset() {
}
/**
* Delete.
*
* @throws IOException
* the io exception
*/
public void delete() throws IOException {
root().createRequest().method("DELETE").withUrlPath(getApiRoute()).send();
}
/**
* Gets browser download url.
*
* @return the browser download url
*/
public String getBrowserDownloadUrl() {
return browser_download_url;
}
/**
* Gets content type.
*
* @return the content type
*/
public String getContentType() {
return content_type;
}
/**
* Gets download count.
*
* @return the download count
*/
public long getDownloadCount() {
return download_count;
}
/**
* Gets label.
*
* @return the label
*/
public String getLabel() {
return label;
}
/**
* Gets name.
*
* @return the name
*/
public String getName() {
return name;
}
/**
* Gets owner.
*
* @return the owner
*/
@SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected behavior")
public GHRepository getOwner() {
return owner;
}
/**
* Gets size.
*
* @return the size
*/
public long getSize() {
return size;
}
/**
* Gets state.
*
* @return the state
*/
public String getState() {
return state;
}
/**
* Sets content type.
*
* @param contentType
* the content type
* @throws IOException
* the io exception
*/
public void setContentType(String contentType) throws IOException {
edit("content_type", contentType);
this.content_type = contentType;
}
/**
* Sets label.
*
* @param label
* the label
* @throws IOException
* the io exception
*/
public void setLabel(String label) throws IOException {
edit("label", label);
this.label = label;
}
private void edit(String key, Object value) throws IOException {
root().createRequest().with(key, value).method("PATCH").withUrlPath(getApiRoute()).send();
}
private String getApiRoute() {
return "/repos/" + owner.getOwnerName() + "/" + owner.getName() + "/releases/assets/" + getId();
}
/**
* Wrap.
*
* @param release
* the release
* @return the GH asset
*/
GHAsset wrap(GHRelease release) {
this.owner = release.getOwner();
return this;
}
}