forked from hub4j/github-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGHDeployKey.java
More file actions
170 lines (147 loc) · 3.31 KB
/
Copy pathGHDeployKey.java
File metadata and controls
170 lines (147 loc) · 3.31 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
package org.kohsuke.github;
import org.apache.commons.lang3.builder.ToStringBuilder;
import java.io.IOException;
import java.util.Date;
// TODO: Auto-generated Javadoc
/**
* The type GHDeployKey.
*/
public class GHDeployKey {
/** The title. */
protected String url, key, title;
/** The verified. */
protected boolean verified;
/** The id. */
protected long id;
private GHRepository owner;
/** Creation date of the deploy key */
private String created_at;
/** Last used date of the deploy key */
private String last_used;
/** Name of user that added the deploy key */
private String added_by;
/** Whether the deploykey has readonly permission or full access */
private boolean read_only;
/**
* Gets id.
*
* @return the id
*/
public long getId() {
return id;
}
/**
* Gets key.
*
* @return the key
*/
public String getKey() {
return key;
}
/**
* Gets title.
*
* @return the title
*/
public String getTitle() {
return title;
}
/**
* Gets url.
*
* @return the url
*/
public String getUrl() {
return url;
}
/**
* Is verified boolean.
*
* @return the boolean
*/
public boolean isVerified() {
return verified;
}
/**
* Gets created_at.
*
* @return the created_at
*/
public Date getCreatedAt() {
return GitHubClient.parseDate(created_at);
}
/**
* Gets last_used.
*
* @return the last_used
*/
public Date getLastUsedAt() {
return GitHubClient.parseDate(last_used);
}
/**
* Gets added_by
*
* @return the added_by
*/
public String getAdded_by() {
return added_by;
}
/**
* Is read_only
*
* @return true if the key can only read. False if the key has write permission as well.
*/
public boolean isRead_only() {
return read_only;
}
/**
* Wrap gh deploy key.
*
* @param repo
* the repo
* @return the gh deploy key
*/
@Deprecated
public GHDeployKey wrap(GHRepository repo) {
throw new RuntimeException("Do not use this method.");
}
/**
* Wrap gh deploy key.
*
* @param repo
* the repo
* @return the gh deploy key
*/
GHDeployKey lateBind(GHRepository repo) {
this.owner = repo;
return this;
}
/**
* To string.
*
* @return the string
*/
public String toString() {
return new ToStringBuilder(this).append("title", title)
.append("id", id)
.append("key", key)
.append("created_at", created_at)
.append("last_used", last_used)
.append("added_by", added_by)
.append("read_only", read_only)
.toString();
}
/**
* Delete.
*
* @throws IOException
* the io exception
*/
public void delete() throws IOException {
owner.root()
.createRequest()
.method("DELETE")
.withUrlPath(String.format("/repos/%s/%s/keys/%d", owner.getOwnerName(), owner.getName(), id))
.send();
}
}