Package com.spotify.github.v3.clients
Class GitHubClient
- java.lang.Object
-
- com.spotify.github.v3.clients.GitHubClient
-
public class GitHubClient extends Object
GitHub client is a main communication entry point. Provides lower level communication functionality as well as acts as a factory for the higher level API clients.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description CompletionStage<Optional<GitHubClient>>asAppScopedClient(String owner)This is for clients authenticated as a GitHub App: when performing operations, the "installation" of the App must be specified.static GitHubClientcreate(URI baseUrl, byte[] privateKey, Integer appId)Create a github api client with a given base URL and a path to a key.static GitHubClientcreate(URI baseUrl, byte[] privateKey, Integer appId, Integer installationId)Create a github api client with a given base URL and a path to a key.static GitHubClientcreate(URI baseUrl, File privateKey, Integer appId)Create a github api client with a given base URL and a path to a key.static GitHubClientcreate(URI baseUrl, File privateKey, Integer appId, Integer installationId)Create a github api client with a given base URL and a path to a key.static GitHubClientcreate(URI baseUrl, String token)Create a github api client with a given base URL and authorization token.static GitHubClientcreate(URI baseUrl, URI graphqlUri, String token)static GitHubClientcreate(okhttp3.OkHttpClient httpClient, URI baseUrl, byte[] privateKey, Integer appId)Create a github api client with a given base URL and a path to a key.static GitHubClientcreate(okhttp3.OkHttpClient httpClient, URI baseUrl, byte[] privateKey, Integer appId, Integer installationId)Create a github api client with a given base URL and a path to a key.static GitHubClientcreate(okhttp3.OkHttpClient httpClient, URI baseUrl, File privateKey, Integer appId)Create a github api client with a given base URL and a path to a key.static GitHubClientcreate(okhttp3.OkHttpClient httpClient, URI baseUrl, File privateKey, Integer appId, Integer installationId)Create a github api client with a given base URL and a path to a key.static GitHubClientcreate(okhttp3.OkHttpClient httpClient, URI baseUrl, String token)Create a github api client with a given base URL and authorization token.static GitHubClientcreate(okhttp3.OkHttpClient httpClient, URI baseUrl, URI graphqlUrl, File privateKey, Integer appId)Create a github api client with a given base URL and a path to a key.static GitHubClientcreate(okhttp3.OkHttpClient httpClient, URI baseUrl, URI graphqlUrl, String token)ChecksClientcreateChecksClient(String owner, String repo)Create a checks API clientGitDataClientcreateGitDataClient(String owner, String repo)Create a GitData API clientOrganisationClientcreateOrganisationClient(String org)Create organisation API clientRepositoryClientcreateRepositoryClient(String owner, String repo)Create a repository API clientSearchClientcreateSearchClient()Create search API clientUserClientcreateUserClient(String owner)Create user API clientOptional<String>getAccessToken()Optional<byte[]>getPrivateKey()booleanisGraphqlEnabled()CompletableFuture<okhttp3.Response>postGraphql(String data)Make a POST request to the graphql endpoint of Githubstatic GitHubClientscopeForInstallationId(GitHubClient client, int installationId)Receives a github client and scopes it to a certain installation ID.GitHubClientwithScopeForInstallationId(int installationId)GitHubClientwithTracer(Tracer tracer)
-
-
-
Method Detail
-
create
public static GitHubClient create(URI baseUrl, String token)
Create a github api client with a given base URL and authorization token.- Parameters:
baseUrl- base URLtoken- authorization token- Returns:
- github api client
-
create
public static GitHubClient create(URI baseUrl, URI graphqlUri, String token)
-
create
public static GitHubClient create(URI baseUrl, File privateKey, Integer appId)
Create a github api client with a given base URL and a path to a key.- Parameters:
baseUrl- base URLprivateKey- the private key PEM fileappId- the github app ID- Returns:
- github api client
-
create
public static GitHubClient create(URI baseUrl, byte[] privateKey, Integer appId)
Create a github api client with a given base URL and a path to a key.- Parameters:
baseUrl- base URLprivateKey- the private key as byte arrayappId- the github app ID- Returns:
- github api client
-
create
public static GitHubClient create(URI baseUrl, File privateKey, Integer appId, Integer installationId)
Create a github api client with a given base URL and a path to a key.- Parameters:
baseUrl- base URLprivateKey- the private key PEM fileappId- the github app IDinstallationId- the installationID to be authenticated as- Returns:
- github api client
-
create
public static GitHubClient create(URI baseUrl, byte[] privateKey, Integer appId, Integer installationId)
Create a github api client with a given base URL and a path to a key.- Parameters:
baseUrl- base URLprivateKey- the private key as byte arrayappId- the github app IDinstallationId- the installationID to be authenticated as- Returns:
- github api client
-
create
public static GitHubClient create(okhttp3.OkHttpClient httpClient, URI baseUrl, File privateKey, Integer appId)
Create a github api client with a given base URL and a path to a key.- Parameters:
httpClient- an instance of OkHttpClientbaseUrl- base URLprivateKey- the private key PEM fileappId- the github app ID- Returns:
- github api client
-
create
public static GitHubClient create(okhttp3.OkHttpClient httpClient, URI baseUrl, URI graphqlUrl, File privateKey, Integer appId)
Create a github api client with a given base URL and a path to a key.- Parameters:
httpClient- an instance of OkHttpClientbaseUrl- base URLprivateKey- the private key PEM fileappId- the github app ID- Returns:
- github api client
-
create
public static GitHubClient create(okhttp3.OkHttpClient httpClient, URI baseUrl, byte[] privateKey, Integer appId)
Create a github api client with a given base URL and a path to a key.- Parameters:
httpClient- an instance of OkHttpClientbaseUrl- base URLprivateKey- the private key as byte arrayappId- the github app ID- Returns:
- github api client
-
create
public static GitHubClient create(okhttp3.OkHttpClient httpClient, URI baseUrl, File privateKey, Integer appId, Integer installationId)
Create a github api client with a given base URL and a path to a key.- Parameters:
httpClient- an instance of OkHttpClientbaseUrl- base URLprivateKey- the private key PEM fileappId- the github app ID- Returns:
- github api client
-
create
public static GitHubClient create(okhttp3.OkHttpClient httpClient, URI baseUrl, byte[] privateKey, Integer appId, Integer installationId)
Create a github api client with a given base URL and a path to a key.- Parameters:
httpClient- an instance of OkHttpClientbaseUrl- base URLprivateKey- the private key as byte arrayappId- the github app ID- Returns:
- github api client
-
create
public static GitHubClient create(okhttp3.OkHttpClient httpClient, URI baseUrl, String token)
Create a github api client with a given base URL and authorization token.- Parameters:
httpClient- an instance of OkHttpClientbaseUrl- base URLtoken- authorization token- Returns:
- github api client
-
create
public static GitHubClient create(okhttp3.OkHttpClient httpClient, URI baseUrl, URI graphqlUrl, String token)
-
scopeForInstallationId
public static GitHubClient scopeForInstallationId(GitHubClient client, int installationId)
Receives a github client and scopes it to a certain installation ID.- Parameters:
client- the github client with a valid private keyinstallationId- the installation ID to be scoped- Returns:
- github api client
-
withScopeForInstallationId
public GitHubClient withScopeForInstallationId(int installationId)
-
asAppScopedClient
public CompletionStage<Optional<GitHubClient>> asAppScopedClient(String owner)
This is for clients authenticated as a GitHub App: when performing operations, the "installation" of the App must be specified. This returns aGitHubClientthat has been scoped to the user's/organization's installation of the app, if any.
-
withTracer
public GitHubClient withTracer(Tracer tracer)
-
getPrivateKey
public Optional<byte[]> getPrivateKey()
-
createRepositoryClient
public RepositoryClient createRepositoryClient(String owner, String repo)
Create a repository API client- Parameters:
owner- repository ownerrepo- repository name- Returns:
- repository API client
-
createGitDataClient
public GitDataClient createGitDataClient(String owner, String repo)
Create a GitData API client- Parameters:
owner- repository ownerrepo- repository name- Returns:
- GitData API client
-
createSearchClient
public SearchClient createSearchClient()
Create search API client- Returns:
- search API client
-
createChecksClient
public ChecksClient createChecksClient(String owner, String repo)
Create a checks API client- Parameters:
owner- repository ownerrepo- repository name- Returns:
- checks API client
-
createOrganisationClient
public OrganisationClient createOrganisationClient(String org)
Create organisation API client- Returns:
- organisation API client
-
createUserClient
public UserClient createUserClient(String owner)
Create user API client- Returns:
- user API client
-
postGraphql
public CompletableFuture<okhttp3.Response> postGraphql(String data)
Make a POST request to the graphql endpoint of Github- Parameters:
data- request body as stringified JSON- Returns:
- response
-
isGraphqlEnabled
public boolean isGraphqlEnabled()
-
-