Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Meta endpoint #611

Merged
merged 7 commits into from
Nov 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions src/main/java/org/kohsuke/github/GHMeta.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package org.kohsuke.github;

import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
* Class that wraps the list of GitHub's IP addresses.
*
* @author Paulo Miguel Almeida
*
* @see GitHub#getMeta()
* @see <a href="https://developer.github.com/v3/meta/#meta">Get Meta</a>
*/

public class GHMeta {

@JsonProperty("verifiable_password_authentication")
private boolean verifiablePasswordAuthentication;
private List<String> hooks;
private List<String> git;
private List<String> web;
private List<String> api;
private List<String> pages;
private List<String> importer = new ArrayList<>();

public boolean isVerifiablePasswordAuthentication() {
return verifiablePasswordAuthentication;
}

public List<String> getHooks() {
return Collections.unmodifiableList(hooks);
}

public List<String> getGit() {
return Collections.unmodifiableList(git);
}

public List<String> getWeb() {
return Collections.unmodifiableList(web);
}

public List<String> getApi() {
return Collections.unmodifiableList(api);
}

public List<String> getPages() {
return Collections.unmodifiableList(pages);
}

public List<String> getImporter() {
return Collections.unmodifiableList(importer);
}
}
26 changes: 19 additions & 7 deletions src/main/java/org/kohsuke/github/GitHub.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,11 @@
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import com.fasterxml.jackson.databind.introspect.VisibilityChecker.Std;
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
import org.apache.commons.codec.Charsets;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;

import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
Expand Down Expand Up @@ -266,7 +264,7 @@ public static GitHub offline() {

/**
* Is this an anonymous connection
*
*
* @return {@code true} if operations that require authentication will fail.
*/
public boolean isAnonymous() {
Expand All @@ -275,7 +273,7 @@ public boolean isAnonymous() {

/**
* Is this an always offline "connection".
*
*
* @return {@code true} if this is an always offline "connection".
*/
public boolean isOffline() {
Expand Down Expand Up @@ -764,7 +762,7 @@ public GHAuthorization resetAuth(@Nonnull String clientId, @Nonnull String acces

/**
* Returns a list of all authorizations.
*
*
* @see <a href="https://developer.github.com/v3/oauth_authorizations/#list-your-authorizations">List your
* authorizations</a>
*/
Expand Down Expand Up @@ -802,6 +800,20 @@ public boolean isCredentialValid() {
}
}

/**
* Provides a list of GitHub's IP addresses.
*
* @see <a href="https://developer.github.com/v3/meta/#meta">Get Meta</a>
*
* @return an instance of {@link GHMeta}
* @throws IOException
* if the credentials supplied are invalid or if you're trying to access it as a GitHub App via the JWT
* authentication
*/
public GHMeta getMeta() throws IOException {
return retrieve().to("/meta", GHMeta.class);
}

GHUser intern(GHUser user) throws IOException {
if (user == null)
return user;
Expand Down Expand Up @@ -866,7 +878,7 @@ public void checkApiUrlValidity() throws IOException {
* Checks if a GitHub Enterprise server is configured in private mode.
*
* In private mode response looks like:
*
*
* <pre>
* $ curl -i https://github.mycompany.com/api/v3/
* HTTP/1.1 401 Unauthorized
Expand Down Expand Up @@ -955,7 +967,7 @@ public GHNotificationStream listNotifications() {

/**
* This provides a dump of every public repository, in the order that they were created.
*
*
* @see <a href="https://developer.github.com/v3/repos/#list-all-public-repositories">documentation</a>
*/
public PagedIterable<GHRepository> listAllPublicRepositories() {
Expand Down
Loading