-
Notifications
You must be signed in to change notification settings - Fork 776
Expand file tree
/
Copy pathGHAutolink.java
More file actions
100 lines (88 loc) · 2.29 KB
/
GHAutolink.java
File metadata and controls
100 lines (88 loc) · 2.29 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
package org.kohsuke.github;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.IOException;
/**
* Represents a GitHub repository autolink reference.
*
* @author Alaurant
* @see GHAutolinkBuilder
* @see GHRepository#listAutolinks() GHRepository#listAutolinks()
* @see <a href="https://docs.github.com/en/rest/repos/autolinks">Repository autolinks API</a>
*/
public class GHAutolink {
private int id;
private boolean is_alphanumeric;
private String key_prefix;
private GHRepository owner;
private String url_template;
/**
* Instantiates a new Gh autolink.
*/
public GHAutolink() {
}
/**
* Deletes this autolink
*
* @throws IOException
* if the deletion fails
*/
public void delete() throws IOException {
owner.root()
.createRequest()
.method("DELETE")
.withUrlPath(String.format("/repos/%s/%s/autolinks/%d", owner.getOwnerName(), owner.getName(), getId()))
.send();
}
/**
* Gets the autolink ID
*
* @return the id
*/
public int getId() {
return id;
}
/**
* Gets the key prefix used to identify issues/PR references
*
* @return the key prefix string
*/
public String getKeyPrefix() {
return key_prefix;
}
/**
* Gets the repository that owns this autolink
*
* @return the repository instance
*/
@SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected behavior")
public GHRepository getOwner() {
return owner;
}
/**
* Gets the URL template that will be used for matching
*
* @return the URL template string
*/
public String getUrlTemplate() {
return url_template;
}
/**
* Checks if the autolink uses alphanumeric values
*
* @return true if alphanumeric, false otherwise
*/
public boolean isAlphanumeric() {
return is_alphanumeric;
}
/**
* Wraps this autolink with its owner repository.
*
* @param owner
* the repository that owns this autolink
* @return this instance
*/
GHAutolink lateBind(GHRepository owner) {
this.owner = owner;
return this;
}
}