Files
github-api/src/main/java/org/kohsuke/github/GHDeployKey.java
2019-12-17 12:41:23 -08:00

91 lines
1.6 KiB
Java

package org.kohsuke.github;
import org.apache.commons.lang3.builder.ToStringBuilder;
import java.io.IOException;
/**
* The type GHDeployKey.
*/
public class GHDeployKey {
protected String url, key, title;
protected boolean verified;
protected long id;
private GHRepository owner;
/**
* 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;
}
/**
* Wrap gh deploy key.
*
* @param repo
* the repo
* @return the gh deploy key
*/
public GHDeployKey wrap(GHRepository repo) {
this.owner = repo;
return this;
}
public String toString() {
return new ToStringBuilder(this).append("title", title).append("id", id).append("key", key).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();
}
}