Package com.spotify.github.v3.clients
Class RepositoryClient
- java.lang.Object
-
- com.spotify.github.v3.clients.RepositoryClient
-
public class RepositoryClient extends Object
Repository API client
-
-
Field Summary
Fields Modifier and Type Field Description static String
STATUS_URI_TEMPLATE
-
Method Summary
-
-
-
Field Detail
-
STATUS_URI_TEMPLATE
public static final String STATUS_URI_TEMPLATE
- See Also:
- Constant Field Values
-
-
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
-
listAuthenticatedUserRepositories
public Iterator<AsyncPage<Repository>> listAuthenticatedUserRepositories(AuthenticatedUserRepositoriesFilter filter)
List repositories for the authenticated user.- Parameters:
filter
- filter parameters- Returns:
- list of repositories for the authenticated user
-
isCollaborator
public CompletableFuture<Boolean> isCollaborator(String user)
Check if a user is collaborator of the repo.- Parameters:
user
- the user to check- Returns:
- boolean indicating if user is collaborator
-
addCollaborator
public CompletableFuture<Optional<RepositoryInvitation>> addCollaborator(String user, String permission)
Add a collaborator to the repo.- Parameters:
user
- the GitHub username to addpermission
- the permission level for the user; one of RepositoryPermission, or a custom role- Returns:
-
removeCollaborator
public CompletableFuture<Void> removeCollaborator(String user)
-
removeInvite
public CompletableFuture<Void> removeInvite(String invitationId)
-
listInvitations
public CompletableFuture<List<RepositoryInvitation>> listInvitations()
-
downloadTarball
public CompletableFuture<Optional<InputStream>> downloadTarball()
Downloads a tar archive of the repository’s default branch (usually main).- Returns:
- a CompletableFuture that resolves to an Optional InputStream
-
downloadTarball
public CompletableFuture<Optional<InputStream>> downloadTarball(String ref)
Downloads a tar archive of the repository. Use :ref to specify a branch or tag to download.- Returns:
- a CompletableFuture that resolves to an Optional InputStream
-
downloadZipball
public CompletableFuture<Optional<InputStream>> downloadZipball()
Downloads a zip archive of the repository’s default branch (usually main).- Returns:
- a CompletableFuture that resolves to an Optional InputStream
-
downloadZipball
public CompletableFuture<Optional<InputStream>> downloadZipball(String ref)
Downloads a zip archive of the repository. Use :ref to specify a branch or tag to download.- Returns:
- a CompletableFuture that resolves to an Optional InputStream
-
createWebhook
public CompletableFuture<Void> createWebhook(WebhookCreate request, boolean ignoreExisting)
Create a webhook.- Parameters:
request
- create requestignoreExisting
- 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 forrequest
- 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 foritemsPerPage
- number of items per page- Returns:
- iterator of Status
-
listCommits
public CompletableFuture<List<CommitItem>> listCommits()
List repository commits.- Returns:
- commits
-
listPullRequestsForCommit
public CompletableFuture<List<PullRequestItem>> listPullRequestsForCommit(String sha)
List pull requests that contain the given commit.- Parameters:
sha
- commit sha- Returns:
- pull requests
-
getCommit
public CompletableFuture<Commit> getCommit(String sha)
Get a repository commit.- Parameters:
sha
- commit sha- Returns:
- commit
-
getTree
@Deprecated public CompletableFuture<Tree> getTree(String sha)
Deprecated.UseGitDataClient.getTree(String)
insteadGet a repository tree.- Parameters:
sha
- commit sha- Returns:
- tree
-
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 fileref
- name of the commit/branch/tag- Returns:
- content
-
getFolderContent
public CompletableFuture<List<FolderContent>> getFolderContent(String path)
Get repository contents of a folder.- Parameters:
path
- path to a folder- 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 onbody
- 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 folderref
- 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 commithead
- 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 editedbody
- comment content
-
getLanguages
public CompletableFuture<Languages> getLanguages()
Get repository language stats.- Returns:
Languages
-
merge
public CompletableFuture<Optional<CommitItem>> merge(String base, String head)
Perform a merge.- Parameters:
base
- branch name or shahead
- 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 intohead
- branch name or sha to mergecommitMessage
- 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"
-
-