Class 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 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 URL
        token - authorization token
        Returns:
        github api client
      • 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 URL
        privateKey - the private key PEM file
        appId - 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 URL
        privateKey - the private key as byte array
        appId - 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 URL
        privateKey - the private key PEM file
        appId - the github app ID
        installationId - 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 URL
        privateKey - the private key as byte array
        appId - the github app ID
        installationId - 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 OkHttpClient
        baseUrl - base URL
        privateKey - the private key PEM file
        appId - 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 OkHttpClient
        baseUrl - base URL
        privateKey - the private key PEM file
        appId - 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 OkHttpClient
        baseUrl - base URL
        privateKey - the private key as byte array
        appId - 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 OkHttpClient
        baseUrl - base URL
        privateKey - the private key PEM file
        appId - 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 OkHttpClient
        baseUrl - base URL
        privateKey - the private key as byte array
        appId - 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 OkHttpClient
        baseUrl - base URL
        token - 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 key
        installationId - 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 a GitHubClient that has been scoped to the user's/organization's installation of the app, if any.
      • getPrivateKey

        public Optional<byte[]> getPrivateKey()
      • createRepositoryClient

        public RepositoryClient createRepositoryClient​(String owner,
                                                       String repo)
        Create a repository API client
        Parameters:
        owner - repository owner
        repo - repository name
        Returns:
        repository API client
      • createGitDataClient

        public GitDataClient createGitDataClient​(String owner,
                                                 String repo)
        Create a GitData API client
        Parameters:
        owner - repository owner
        repo - 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 owner
        repo - 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()