forked from hub4j/github-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGHAsset.java
More file actions
176 lines (157 loc) · 3.43 KB
/
GHAsset.java
File metadata and controls
176 lines (157 loc) · 3.43 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
package org.kohsuke.github;
import java.io.IOException;
import java.net.URL;
/**
* Asset in a release.
*
* @see GHRelease#getAssets() GHRelease#getAssets()
*/
public class GHAsset extends GHObject {
GitHub root;
GHRepository owner;
private String name;
private String label;
private String state;
private String content_type;
private long size;
private long download_count;
private String browser_download_url;
/**
* Gets content type.
*
* @return the content type
*/
public String getContentType() {
return content_type;
}
/**
* 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;
}
/**
* Gets download count.
*
* @return the download count
*/
public long getDownloadCount() {
return download_count;
}
/**
* Gets label.
*
* @return the label
*/
public String getLabel() {
return label;
}
/**
* Sets label.
*
* @param label
* the label
* @throws IOException
* the io exception
*/
public void setLabel(String label) throws IOException {
edit("label", label);
this.label = label;
}
/**
* Gets name.
*
* @return the name
*/
public String getName() {
return name;
}
/**
* Gets owner.
*
* @return the owner
*/
public GHRepository getOwner() {
return owner;
}
/**
* Gets root.
*
* @return the root
*/
public GitHub getRoot() {
return root;
}
/**
* Gets size.
*
* @return the size
*/
public long getSize() {
return size;
}
/**
* Gets state.
*
* @return the state
*/
public String getState() {
return state;
}
/**
* @deprecated This object has no HTML URL.
*/
@Override
public URL getHtmlUrl() {
return null;
}
/**
* Gets browser download url.
*
* @return the browser download url
*/
public String getBrowserDownloadUrl() {
return browser_download_url;
}
private void edit(String key, Object value) throws IOException {
root.createRequest().with(key, value).method("PATCH").withUrlPath(getApiRoute()).send();
}
/**
* Delete.
*
* @throws IOException
* the io exception
*/
public void delete() throws IOException {
root.createRequest().method("DELETE").withUrlPath(getApiRoute()).send();
}
private String getApiRoute() {
return "/repos/" + owner.getOwnerName() + "/" + owner.getName() + "/releases/assets/" + getId();
}
GHAsset wrap(GHRelease release) {
this.owner = release.getOwner();
this.root = owner.root;
return this;
}
/**
* 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;
}
}