Class GithubClient

java.lang.Object
org.sourcelab.github.client.GithubClient

public class GithubClient extends Object
API Client for Buildkite's REST Api. See API Documentation:
  • Constructor Details

    • GithubClient

      public GithubClient(Configuration configuration)
      Constructor.
      Parameters:
      configuration - The configuration for the org.sourcelab.github.client.
  • Method Details

    • octoCat

      public String octoCat() throws GithubException
      Make a 'test' or 'hello world' request to the Github API. Can be used to validate connectivity to the API.
      Returns:
      Response details from the ping request.
      Throws:
      GithubException - if API returns an error response.
    • getAuthenticatedUser

      public AuthenticatedUser getAuthenticatedUser() throws GithubException
      Get the currently authenticated user.
      Returns:
      Current authenticated user.
      Throws:
      GithubException - if API returns an error response.
    • userRepos

      public UserReposResponse userRepos(UserReposFilterCriteria options) throws GithubException
      Get current authenticated user's repositories.
      Parameters:
      options - Filter criteria.
      Returns:
      Response object.
      Throws:
      GithubException - if API returns an error response.
    • getWorkflowsForRepository

      public WorkflowsForRepositoryResponse getWorkflowsForRepository(WorkflowFilterCriteria options) throws GithubException
      Get workflows for a given repository.
      Parameters:
      options - Filter criteria.
      Returns:
      Response object.
      Throws:
      GithubException - if API returns an error response.
    • getRunsForWorkflow

      public WorkflowRunsResponse getRunsForWorkflow(WorkflowRunFilterCriteria options) throws GithubException
      Get runs for a given workflow..
      Parameters:
      options - Filter criteria.
      Returns:
      Response object.
      Throws:
      GithubException - if API returns an error response.
    • getWorkflowRunsForRepository

      public WorkflowRunsResponse getWorkflowRunsForRepository(WorkflowRunFilterCriteria options) throws GithubException
      Get runs for a given repository.
      Parameters:
      options - Filter criteria.
      Returns:
      Response object.
      Throws:
      GithubException - if API returns an error response.
    • rerunWorkflow

      public boolean rerunWorkflow(RerunWorkflowOptions options) throws GithubException
      Re-run a Workflow.
      Parameters:
      options - Defines which workflow to re-run.
      Returns:
      true on success, false on error.
      Throws:
      GithubException - if API returns an error response.
    • cancelWorkflow

      public boolean cancelWorkflow(CancelWorkflowOptions options) throws GithubException
      Cancel a Workflow.
      Parameters:
      options - Defines which workflow to cancel
      Returns:
      true on success, false on error.
      Throws:
      GithubException - if API returns an error response.
    • getJobsForWorkflowRun

      public WorkflowJobsResponse getJobsForWorkflowRun(WorkflowJobFilterCriteria options) throws GithubException
      Get runs for a given workflow..
      Parameters:
      options - Filter criteria.
      Returns:
      Response object.
      Throws:
      GithubException - if API returns an error response.
    • rerunJobFromWorkflow

      public boolean rerunJobFromWorkflow(RerunJobFromWorkflowOptions options) throws GithubException
      Request a re-run of a specific job Id for a given workflow.
      Parameters:
      options - Criteria of which job to re-run.
      Returns:
      true on success, false on error.
      Throws:
      GithubException - if API returns an error response.
    • rerunJobsFromWorkflow

      public RerunMultipleJobsResponse rerunJobsFromWorkflow(RerunJobsFromWorkflowOptions options) throws GithubException
      Request a re-run of a specific job Id for a given workflow.
      Parameters:
      options - Criteria of which job to re-run.
      Returns:
      true on success, false on error.
      Throws:
      GithubException - if API returns an error response.
    • nextPage

      public <T> T nextPage(PageableResponse<T> response) throws GithubException
      Retrieve the next page of results from the previously retrieved request.
      Type Parameters:
      T - The parsed return object representing the result.
      Parameters:
      response - Previously retrieved result/response to retrieve the next page of results for.
      Returns:
      The next page of results.
      Throws:
      InvalidPagingRequestException - if no next page exists to retrieve.
      GithubException - if API returns an error response.
    • executeRequest

      public <T> T executeRequest(Request<T> request) throws GithubException
      Execute the given request, returning the parsed response, or throwing the appropriate exception if an error was returned from the API. This method scoped public to allow for user defined requests to be executed by the library as an extension point.
      Type Parameters:
      T - The parsed response object.
      Parameters:
      request - The request to execute.
      Returns:
      The parsed response object.
      Throws:
      GithubException - if API returns an error response.