Class RepositoryClient


  • public class RepositoryClient
    extends Object
    Repository API client
    • Method Detail

      • createIssueClient

        public IssueClient createIssueClient()
        Create an issue API client.
        Returns:
        issue API client
      • createPullRequestClient

        public PullRequestClient createPullRequestClient()
        Create a pull request API client.
        Returns:
        pull request API client
      • createGithubAppClient

        public GithubAppClient createGithubAppClient()
        Create Github App API client
        Returns:
        Github App API client
      • createChecksApiClient

        public ChecksClient createChecksApiClient()
        Create a checks API client
        Returns:
        repository API client
      • getRepository

        public CompletableFuture<Repository> getRepository()
        Get information about this repository.
        Returns:
        repository information
      • listOrganizationRepositories

        public CompletableFuture<List<Repository>> listOrganizationRepositories()
        List all repositories in this organization.
        Returns:
        list of all repositories under organization
      • createWebhook

        public CompletableFuture<Void> createWebhook​(WebhookCreate request,
                                                     boolean ignoreExisting)
        Create a webhook.
        Parameters:
        request - create request
        ignoreExisting - if true hook exists errors will be ignored
      • setCommitStatus

        public CompletableFuture<Void> setCommitStatus​(String sha,
                                                       RepositoryCreateStatus request)
        Set status for a given commit.
        Parameters:
        sha - the commit sha to set the status for
        request - The body of the request to sent to github to create a commit status
      • getCommitStatus

        public CompletableFuture<CommitStatus> getCommitStatus​(String ref)
        Get status for a given commit.
        Parameters:
        ref - ref can be a sha, branch or tag name
      • listCommitStatuses

        public CompletableFuture<List<Status>> listCommitStatuses​(String sha)
        List statuses for a specific ref. Statuses are returned in reverse chronological order. The first status in the list will be the latest one.
        Parameters:
        sha - the commit sha to list the statuses for
      • listCommitStatuses

        public Iterator<AsyncPage<Status>> listCommitStatuses​(String sha,
                                                              int itemsPerPage)
        List statuses for a specific ref. Statuses are returned in reverse chronological order. The first status in the list will be the latest one.
        Parameters:
        sha - the commit sha to list the statuses for
        itemsPerPage - number of items per page
        Returns:
        iterator of Status
      • getFileContent

        public CompletableFuture<Content> getFileContent​(String path)
        Get repository contents of a file.
        Parameters:
        path - path to a file
        Returns:
        content
      • getFileContent

        public CompletableFuture<Content> getFileContent​(String path,
                                                         String ref)
        Get repository contents of a file.
        Parameters:
        path - path to a file
        ref - name of the commit/branch/tag
        Returns:
        content
      • createComment

        public CompletableFuture<Comment> createComment​(String sha,
                                                        String body)
        Create a comment for a given issue number.
        Parameters:
        sha - the commit sha to create the comment on
        body - comment content
        Returns:
        the Comment that was just created
      • getComment

        public CompletableFuture<Comment> getComment​(int id)
        Get a specific comment.
        Parameters:
        id - comment id
        Returns:
        a comment
      • getFolderContent

        public CompletableFuture<List<FolderContent>> getFolderContent​(String path,
                                                                       String ref)
        Get repository contents of a folder.
        Parameters:
        path - path to a folder
        ref - name of the commit/branch/tag
        Returns:
        content
      • compareCommits

        public CompletableFuture<CommitComparison> compareCommits​(String base,
                                                                  String head)
        Compare two commits content.
        Parameters:
        base - the base commit
        head - the head commit
        Returns:
        a CommitComparison object
      • getBranch

        public CompletableFuture<Branch> getBranch​(String branch)
        Get a specific branch.
        Parameters:
        branch - the branch name
        Returns:
        a Branch
      • listBranches

        public CompletableFuture<List<Branch>> listBranches()
        Get a specific branch.
        Returns:
        list of all branches in repository
      • deleteComment

        public CompletableFuture<Void> deleteComment​(int id)
        Delete a comment for a given id.
        Parameters:
        id - the commit id to be deleted
      • editComment

        public CompletableFuture<Void> editComment​(int id,
                                                   String body)
        Edit a comment for a given id.
        Parameters:
        id - the commit id to be edited
        body - comment content
      • merge

        public CompletableFuture<Optional<CommitItem>> merge​(String base,
                                                             String head)
        Perform a merge.
        Parameters:
        base - branch name or sha
        head - branch name or sha
        Returns:
        resulting merge commit, or empty if base already contains the head (nothing to merge)
        See Also:
        "https://developer.github.com/enterprise/2.18/v3/repos/merging/"
      • merge

        public CompletableFuture<Optional<CommitItem>> merge​(String base,
                                                             String head,
                                                             String commitMessage)
        Perform a merge.
        Parameters:
        base - branch name that the head will be merged into
        head - branch name or sha to merge
        commitMessage - commit message to use for the merge commit
        Returns:
        resulting merge commit, or empty if base already contains the head (nothing to merge)
        See Also:
        "https://developer.github.com/enterprise/2.18/v3/repos/merging/"
      • createFork

        public CompletableFuture<Repository> createFork​(String organization)
        Create a fork.
        Parameters:
        organization - the organization where the fork will be created
        Returns:
        resulting repository
        See Also:
        "https://developer.github.com/v3/repos/forks/#create-a-fork"