public class RepositoryApi extends AbstractApi
This class provides an entry point to all the GitLab API repository calls. For more information on the repository APIs see:
Repositories API Branches APIConstants.ActionType, Constants.ApplicationScope, Constants.ArchiveFormat, Constants.AutoDevopsDeployStrategy, Constants.BuildGitStrategy, Constants.CommitBuildState, Constants.ContributorOrderBy, Constants.DeploymentOrderBy, Constants.DeploymentStatus, Constants.DeployTokenScope, Constants.Encoding, Constants.EpicOrderBy, Constants.EventScope, Constants.GroupOrderBy, Constants.GroupSearchScope, Constants.ImpersonationState, Constants.IssueOrderBy, Constants.IssueScope, Constants.IssueState, Constants.JobScope, Constants.LineType, Constants.MergeRequestOrderBy, Constants.MergeRequestScope, Constants.MergeRequestSearchIn, Constants.MergeRequestState, Constants.MilestoneState, Constants.PackageOrderBy, Constants.PackageStatus, Constants.PipelineOrderBy, Constants.PipelineScope, Constants.ProjectOrderBy, Constants.ProjectSearchScope, Constants.SearchScope, Constants.SortOrder, Constants.SquashOption, Constants.StateEvent, Constants.TagOrderBy, Constants.TargetType, Constants.TodoAction, Constants.TodoState, Constants.TodoType, Constants.TokenType
gitLabApi
NEXT_PAGE_HEADER, PAGE_HEADER, PAGE_PARAM, PER_PAGE, PER_PAGE_PARAM, PREV_PAGE_HEADER, TOTAL_HEADER, TOTAL_PAGES_HEADER
Constructor and Description |
---|
RepositoryApi(GitLabApi gitLabApi) |
Modifier and Type | Method and Description |
---|---|
CompareResults |
compare(Object projectIdOrPath,
String from,
String to)
Compare branches, tags or commits.
|
CompareResults |
compare(Object projectIdOrPath,
String from,
String to,
boolean straight)
Compare branches, tags or commits.
|
Branch |
createBranch(Object projectIdOrPath,
String branchName,
String ref)
Creates a branch for the project.
|
void |
deleteBranch(Object projectIdOrPath,
String branchName)
Delete a single project repository branch.
|
void |
deleteMergedBranches(Object projectIdOrPath)
Delete all branches that are merged into the project’s default branch.
|
void |
generateChangelog(Object projectIdOrPath,
ChangelogPayload payload)
Generate changelog data based on commits in a repository.
|
void |
generateChangelog(Object projectIdOrPath,
String version)
Generate changelog data based on commits in a repository.
|
Branch |
getBranch(Object projectIdOrPath,
String branchName)
Get a single project repository branch.
|
List<Branch> |
getBranches(Object projectIdOrPath)
Get a list of repository branches from a project, sorted by name alphabetically.
|
Pager<Branch> |
getBranches(Object projectIdOrPath,
int itemsPerPage)
Get a Pager of repository branches from a project, sorted by name alphabetically.
|
List<Branch> |
getBranches(Object projectIdOrPath,
int page,
int perPage)
Get a list of repository branches from a project, sorted by name alphabetically.
|
List<Branch> |
getBranches(Object projectIdOrPath,
String search)
Get a List of repository branches from a project, sorted by name alphabetically, filter by the search term.
|
Pager<Branch> |
getBranches(Object projectIdOrPath,
String search,
int itemsPerPage)
Get a Pager of repository branches from a project, sorted by name alphabetically, filter by the search term.
|
Stream<Branch> |
getBranchesStream(Object projectIdOrPath)
Get a Stream of repository branches from a project, sorted by name alphabetically.
|
Stream<Branch> |
getBranchesStream(Object projectIdOrPath,
String search)
Get a Stream of repository branches from a project, sorted by name alphabetically, filter by the search term.
|
List<Contributor> |
getContributors(Object projectIdOrPath)
Get a list of contributors from a project.
|
Pager<Contributor> |
getContributors(Object projectIdOrPath,
int itemsPerPage)
Get a Pager of contributors from a project.
|
List<Contributor> |
getContributors(Object projectIdOrPath,
int page,
int perPage)
Get a list of contributors from a project and in the specified page range.
|
List<Contributor> |
getContributors(Object projectIdOrPath,
int page,
int perPage,
Constants.ContributorOrderBy orderBy,
Constants.SortOrder sortOrder)
Get a list of contributors from a project and in the specified page range, sorted by specified param.
|
Stream<Contributor> |
getContributorsStream(Object projectIdOrPath)
Get a list of contributors from a project.
|
Commit |
getMergeBase(Object projectIdOrPath,
List<String> refs)
Get the common ancestor for 2 or more refs (commit SHAs, branch names or tags).
|
Optional<Branch> |
getOptionalBranch(Object projectIdOrPath,
String branchName)
Get an Optional instance with the value for the specific repository branch.
|
Optional<Commit> |
getOptionalMergeBase(Object projectIdOrPath,
List<String> refs)
Get an Optional instance with the value of the common ancestor
for 2 or more refs (commit SHAs, branch names or tags).
|
InputStream |
getRawBlobContent(Object projectIdOrPath,
String sha)
Get the raw file contents for a blob by blob SHA.
|
InputStream |
getRepositoryArchive(Object projectIdOrPath,
String sha)
Get an archive of the complete repository by SHA (optional).
|
InputStream |
getRepositoryArchive(Object projectIdOrPath,
String sha,
Constants.ArchiveFormat format)
Get an archive of the complete repository by SHA (optional).
|
File |
getRepositoryArchive(Object projectIdOrPath,
String sha,
File directory)
Get an archive of the complete repository by SHA (optional) and saves to the specified directory.
|
File |
getRepositoryArchive(Object projectIdOrPath,
String sha,
File directory,
Constants.ArchiveFormat format)
Get an archive of the complete repository by SHA (optional) and saves to the specified directory.
|
File |
getRepositoryArchive(Object projectIdOrPath,
String sha,
File directory,
String format)
Get an archive of the complete repository by SHA (optional) and saves to the specified directory.
|
InputStream |
getRepositoryArchive(Object projectIdOrPath,
String sha,
String format)
Get an archive of the complete repository by SHA (optional).
|
List<TreeItem> |
getTree(Object projectIdOrPath)
Get a list of repository files and directories in a project.
|
Pager<TreeItem> |
getTree(Object projectIdOrPath,
int itemsPerPage)
Get a Pager of repository files and directories in a project.
|
List<TreeItem> |
getTree(Object projectIdOrPath,
String filePath,
String refName)
Get a list of repository files and directories in a project.
|
List<TreeItem> |
getTree(Object projectIdOrPath,
String filePath,
String refName,
Boolean recursive)
Get a list of repository files and directories in a project.
|
Pager<TreeItem> |
getTree(Object projectIdOrPath,
String filePath,
String refName,
Boolean recursive,
int itemsPerPage)
Get a Pager of repository files and directories in a project.
|
Pager<TreeItem> |
getTree(Object projectIdOrPath,
String filePath,
String refName,
int itemsPerPage)
Get a Pager of repository files and directories in a project.
|
Stream<TreeItem> |
getTreeStream(Object projectIdOrPath)
Get a Stream of repository files and directories in a project.
|
Stream<TreeItem> |
getTreeStream(Object projectIdOrPath,
String filePath,
String refName)
Get a Stream of repository files and directories in a project.
|
Stream<TreeItem> |
getTreeStream(Object projectIdOrPath,
String filePath,
String refName,
Boolean recursive)
Get a Stream of repository files and directories in a project.
|
Branch |
protectBranch(Object projectIdOrPath,
String branchName)
Protects a single project repository branch.
|
Branch |
unprotectBranch(Object projectIdOrPath,
String branchName)
Unprotects a single project repository branch.
|
addFormParam, addFormParam, delete, delete, get, get, getApiClient, getApiVersion, getDefaultPerPage, getDefaultPerPageParam, getDefaultPerPageParam, getGroupIdOrPath, getLabelIdOrName, getPageQueryParams, getPageQueryParams, getPerPageQueryParam, getProjectIdOrPath, getUserIdOrUsername, getWithAccepts, handle, head, isApiVersion, post, post, post, post, post, put, put, put, putUpload, putUpload, putWithFormData, upload, upload, upload, upload, urlEncode, validate
public RepositoryApi(GitLabApi gitLabApi)
public List<Branch> getBranches(Object projectIdOrPath) throws GitLabApiException
GitLab Endpoint: GET /projects/:id/repository/branches
projectIdOrPath
- the project in the form of an Long(ID), String(path), or Project instanceGitLabApiException
- if any exception occurspublic List<Branch> getBranches(Object projectIdOrPath, int page, int perPage) throws GitLabApiException
GitLab Endpoint: GET /projects/:id/repository/branches
projectIdOrPath
- the project in the form of an Long(ID), String(path), or Project instancepage
- the page to getperPage
- the number of Branch instances per pageGitLabApiException
- if any exception occurspublic Pager<Branch> getBranches(Object projectIdOrPath, int itemsPerPage) throws GitLabApiException
GitLab Endpoint: GET /projects/:id/repository/branches
projectIdOrPath
- the project in the form of an Long(ID), String(path), or Project instanceitemsPerPage
- the number of Project instances that will be fetched per pageGitLabApiException
- if any exception occurspublic Stream<Branch> getBranchesStream(Object projectIdOrPath) throws GitLabApiException
GitLab Endpoint: GET /projects/:id/repository/branches
projectIdOrPath
- the project in the form of an Long(ID), String(path), or Project instanceGitLabApiException
- if any exception occurspublic Branch getBranch(Object projectIdOrPath, String branchName) throws GitLabApiException
GitLab Endpoint: GET /projects/:id/repository/branches/:branch
projectIdOrPath
- the project in the form of an Long(ID), String(path), or Project instancebranchName
- the name of the branch to getGitLabApiException
- if any exception occurspublic List<Branch> getBranches(Object projectIdOrPath, String search) throws GitLabApiException
GitLab Endpoint: GET /projects/:id/repository/branches?search=:search
projectIdOrPath
- the project in the form of an Long(ID), String(path), or Project instancesearch
- the branch name search termGitLabApiException
- if any exception occurspublic Pager<Branch> getBranches(Object projectIdOrPath, String search, int itemsPerPage) throws GitLabApiException
GitLab Endpoint: GET /projects/:id/repository/branches?search=:search
projectIdOrPath
- the project in the form of an Long(ID), String(path), or Project instancesearch
- the branch name search termitemsPerPage
- the number of Project instances that will be fetched per pageGitLabApiException
- if any exception occurspublic Stream<Branch> getBranchesStream(Object projectIdOrPath, String search) throws GitLabApiException
GitLab Endpoint: GET /projects/:id/repository/branches?search=:search
projectIdOrPath
- the project in the form of an Long(ID), String(path), or Project instancesearch
- the branch name search termGitLabApiException
- if any exception occurspublic Optional<Branch> getOptionalBranch(Object projectIdOrPath, String branchName) throws GitLabApiException
GitLab Endpoint: GET /projects/:id/repository/branches/:branch
projectIdOrPath
- the project in the form of an Long(ID), String(path), or Project instancebranchName
- the name of the branch to getGitLabApiException
- if any exception occurspublic Branch createBranch(Object projectIdOrPath, String branchName, String ref) throws GitLabApiException
GitLab Endpoint: POST /projects/:id/repository/branches
projectIdOrPath
- the project in the form of an Long(ID), String(path), or Project instancebranchName
- the name of the branch to createref
- Source to create the branch from, can be an existing branch, tag or commit SHAGitLabApiException
- if any exception occurspublic void deleteBranch(Object projectIdOrPath, String branchName) throws GitLabApiException
GitLab Endpoint: DELETE /projects/:id/repository/branches/:branch
projectIdOrPath
- the project in the form of an Long(ID), String(path), or Project instancebranchName
- the name of the branch to deleteGitLabApiException
- if any exception occurspublic Branch protectBranch(Object projectIdOrPath, String branchName) throws GitLabApiException
GitLab Endpoint: PUT /projects/:id/repository/branches/:branch/protect
projectIdOrPath
- the project in the form of an Long(ID), String(path), or Project instancebranchName
- the name of the branch to protectGitLabApiException
- if any exception occurspublic Branch unprotectBranch(Object projectIdOrPath, String branchName) throws GitLabApiException
GitLab Endpoint: PUT /projects/:id/repository/branches/:branch/unprotect
projectIdOrPath
- the project in the form of an Long(ID), String(path), or Project instancebranchName
- the name of the branch to un-protectGitLabApiException
- if any exception occurspublic List<TreeItem> getTree(Object projectIdOrPath) throws GitLabApiException
GitLab Endpoint: GET /projects/:id/repository/tree
projectIdOrPath
- the project in the form of an Long(ID), String(path), or Project instanceGitLabApiException
- if any exception occurspublic Pager<TreeItem> getTree(Object projectIdOrPath, int itemsPerPage) throws GitLabApiException
GitLab Endpoint: GET /projects/:id/repository/tree
projectIdOrPath
- the project in the form of an Long(ID), String(path), or Project instanceitemsPerPage
- the number of Project instances that will be fetched per pageGitLabApiException
- if any exception occurspublic Stream<TreeItem> getTreeStream(Object projectIdOrPath) throws GitLabApiException
GitLab Endpoint: GET /projects/:id/repository/tree
projectIdOrPath
- the project in the form of an Long(ID), String(path), or Project instanceGitLabApiException
- if any exception occurspublic List<TreeItem> getTree(Object projectIdOrPath, String filePath, String refName) throws GitLabApiException
GitLab Endpoint: GET /projects/:id/repository/tree
id (required) - The ID of a project
path (optional) - The path inside repository. Used to get content of subdirectories
ref_name (optional) - The name of a repository branch or tag or if not given the default branchprojectIdOrPath
- the project in the form of an Long(ID), String(path), or Project instancefilePath
- the path inside repository, used to get content of subdirectoriesrefName
- the name of a repository branch or tag or if not given the default branchGitLabApiException
- if any exception occurspublic Pager<TreeItem> getTree(Object projectIdOrPath, String filePath, String refName, int itemsPerPage) throws GitLabApiException
GitLab Endpoint: GET /projects/:id/repository/tree
id (required) - The ID of a project
path (optional) - The path inside repository. Used to get content of subdirectories
ref_name (optional) - The name of a repository branch or tag or if not given the default branchprojectIdOrPath
- the project in the form of an Long(ID), String(path), or Project instancefilePath
- the path inside repository, used to get content of subdirectoriesrefName
- the name of a repository branch or tag or if not given the default branchitemsPerPage
- the number of Project instances that will be fetched per pageGitLabApiException
- if any exception occurspublic Stream<TreeItem> getTreeStream(Object projectIdOrPath, String filePath, String refName) throws GitLabApiException
GitLab Endpoint: GET /projects/:id/repository/tree
id (required) - The ID of a project
path (optional) - The path inside repository. Used to get content of subdirectories
ref_name (optional) - The name of a repository branch or tag or if not given the default branchprojectIdOrPath
- the project in the form of an Long(ID), String(path), or Project instancefilePath
- the path inside repository, used to get content of subdirectoriesrefName
- the name of a repository branch or tag or if not given the default branchGitLabApiException
- if any exception occurspublic List<TreeItem> getTree(Object projectIdOrPath, String filePath, String refName, Boolean recursive) throws GitLabApiException
GitLab Endpoint: GET /projects/:id/repository/tree
id (required) - The ID of a project
path (optional) - The path inside repository. Used to get contend of subdirectories
ref_name (optional) - The name of a repository branch or tag or if not given the default branch
recursive (optional) - Boolean value used to get a recursive tree (false by default)projectIdOrPath
- the project in the form of an Long(ID), String(path), or Project instancefilePath
- the path inside repository, used to get content of subdirectoriesrefName
- the name of a repository branch or tag or if not given the default branchrecursive
- flag to get a recursive tree or notGitLabApiException
- if any exception occurspublic Pager<TreeItem> getTree(Object projectIdOrPath, String filePath, String refName, Boolean recursive, int itemsPerPage) throws GitLabApiException
GitLab Endpoint: GET /projects/:id/repository/tree
id (required) - The ID of a project
path (optional) - The path inside repository. Used to get contend of subdirectories
ref_name (optional) - The name of a repository branch or tag or if not given the default branch
recursive (optional) - Boolean value used to get a recursive tree (false by default)projectIdOrPath
- the project in the form of an Long(ID), String(path), or Project instancefilePath
- the path inside repository, used to get content of subdirectoriesrefName
- the name of a repository branch or tag or if not given the default branchrecursive
- flag to get a recursive tree or notitemsPerPage
- the number of Project instances that will be fetched per pageGitLabApiException
- if any exception occurspublic Stream<TreeItem> getTreeStream(Object projectIdOrPath, String filePath, String refName, Boolean recursive) throws GitLabApiException
GitLab Endpoint: GET /projects/:id/repository/tree
id (required) - The ID of a project
path (optional) - The path inside repository. Used to get contend of subdirectories
ref_name (optional) - The name of a repository branch or tag or if not given the default branch
recursive (optional) - Boolean value used to get a recursive tree (false by default)projectIdOrPath
- the project in the form of an Long(ID), String(path), or Project instancefilePath
- the path inside repository, used to get content of subdirectoriesrefName
- the name of a repository branch or tag or if not given the default branchrecursive
- flag to get a recursive tree or notGitLabApiException
- if any exception occurspublic InputStream getRawBlobContent(Object projectIdOrPath, String sha) throws GitLabApiException
GitLab Endpoint: GET /projects/:id/repository/raw_blobs/:sha
projectIdOrPath
- the project in the form of an Long(ID), String(path), or Project instancesha
- the SHA of the file to get the contents forGitLabApiException
- if any exception occurspublic InputStream getRepositoryArchive(Object projectIdOrPath, String sha) throws GitLabApiException
GitLab Endpoint: GET /projects/:id/repository/archive
projectIdOrPath
- the project in the form of an Long(ID), String(path), or Project instancesha
- the SHA of the archive to getGitLabApiException
- if any exception occurspublic InputStream getRepositoryArchive(Object projectIdOrPath, String sha, String format) throws GitLabApiException
GitLab Endpoint: GET /projects/:id/repository/archive
projectIdOrPath
- the project in the form of an Long(ID), String(path), or Project instancesha
- the SHA of the archive to getformat
- The archive format, defaults to "tar.gz" if nullGitLabApiException
- if format is not a valid archive format or any exception occurspublic InputStream getRepositoryArchive(Object projectIdOrPath, String sha, Constants.ArchiveFormat format) throws GitLabApiException
GitLab Endpoint: GET /projects/:id/repository/archive
projectIdOrPath
- the project in the form of an Long(ID), String(path), or Project instancesha
- the SHA of the archive to getformat
- The archive format, defaults to TAR_GZ if nullGitLabApiException
- if any exception occurspublic File getRepositoryArchive(Object projectIdOrPath, String sha, File directory) throws GitLabApiException
GitLab Endpoint: GET /projects/:id/repository/archive
projectIdOrPath
- the project in the form of an Long(ID), String(path), or Project instancesha
- the SHA of the archive to getdirectory
- the File instance of the directory to save the archive to, if null will use "java.io.tmpdir"GitLabApiException
- if any exception occurspublic File getRepositoryArchive(Object projectIdOrPath, String sha, File directory, String format) throws GitLabApiException
GitLab Endpoint: GET /projects/:id/repository/archive
projectIdOrPath
- the project in the form of an Long(ID), String(path), or Project instancesha
- the SHA of the archive to getdirectory
- the File instance of the directory to save the archive to, if null will use "java.io.tmpdir"format
- The archive format, defaults to "tar.gz" if nullGitLabApiException
- if format is not a valid archive format or any exception occurspublic File getRepositoryArchive(Object projectIdOrPath, String sha, File directory, Constants.ArchiveFormat format) throws GitLabApiException
GitLab Endpoint: GET /projects/:id/repository/archive
projectIdOrPath
- the project in the form of an Long(ID), String(path), or Project instancesha
- the SHA of the archive to getdirectory
- the File instance of the directory to save the archive to, if null will use "java.io.tmpdir"format
- The archive format, defaults to TAR_GZ if nullGitLabApiException
- if any exception occurspublic CompareResults compare(Object projectIdOrPath, String from, String to, boolean straight) throws GitLabApiException
projectIdOrPath
- the project in the form of an Long(ID), String(path), or Project instancefrom
- the commit SHA or branch nameto
- the commit SHA or branch namestraight
- specifies the comparison method, true for direct comparison between from and to (from..to),
false to compare using merge base (from…to)’.GitLabApiException
- if any exception occurspublic CompareResults compare(Object projectIdOrPath, String from, String to) throws GitLabApiException
projectIdOrPath
- the project in the form of an Long(ID), String(path), or Project instancefrom
- the commit SHA or branch nameto
- the commit SHA or branch nameGitLabApiException
- if any exception occurspublic List<Contributor> getContributors(Object projectIdOrPath) throws GitLabApiException
GitLab Endpoint: GET /projects/:id/repository/contributors
projectIdOrPath
- the project in the form of an Long(ID), String(path), or Project instanceGitLabApiException
- if any exception occurspublic List<Contributor> getContributors(Object projectIdOrPath, int page, int perPage) throws GitLabApiException
GitLab Endpoint: GET /projects/:id/repository/contributors
projectIdOrPath
- the project in the form of an Long(ID), String(path), or Project instancepage
- the page to getperPage
- the number of projects per pageGitLabApiException
- if any exception occurspublic List<Contributor> getContributors(Object projectIdOrPath, int page, int perPage, Constants.ContributorOrderBy orderBy, Constants.SortOrder sortOrder) throws GitLabApiException
GitLab Endpoint: GET /projects/:id/repository/contributors
projectIdOrPath
- the project in the form of an Long(ID), String(path), or Project instancepage
- the page to getperPage
- the number of projects per pageorderBy
- (optional param) returns contributors ordered by NAME, EMAIL, or COMMITS. Default is COMMITSsortOrder
- (optional param) returns contributors sorted in ASC or DESC order. Default is ASCGitLabApiException
- if any exception occurspublic Pager<Contributor> getContributors(Object projectIdOrPath, int itemsPerPage) throws GitLabApiException
GitLab Endpoint: GET /projects/:id/repository/contributors
projectIdOrPath
- the project in the form of an Long(ID), String(path), or Project instanceitemsPerPage
- the number of Project instances that will be fetched per pageGitLabApiException
- if any exception occurspublic Stream<Contributor> getContributorsStream(Object projectIdOrPath) throws GitLabApiException
GitLab Endpoint: GET /projects/:id/repository/contributors
projectIdOrPath
- the project in the form of an Long(ID), String(path), or Project instanceGitLabApiException
- if any exception occurspublic Commit getMergeBase(Object projectIdOrPath, List<String> refs) throws GitLabApiException
GitLab Endpoint: GET /projects/:id/repository/merge_base
projectIdOrPath
- the project in the form of an Long(ID), String(path), or Project instancerefs
- a List of 2 or more refs (commit SHAs, branch names or tags)GitLabApiException
- if any exception occurspublic Optional<Commit> getOptionalMergeBase(Object projectIdOrPath, List<String> refs) throws GitLabApiException
GitLab Endpoint: GET /projects/:id/repository/merge_base
projectIdOrPath
- the project in the form of an Long(ID), String(path), or Project instancerefs
- a List of 2 or more refs (commit SHAs, branch names or tags)GitLabApiException
- if any exception occurspublic void deleteMergedBranches(Object projectIdOrPath) throws GitLabApiException
Delete all branches that are merged into the project’s default branch.
NOTE: Protected branches will not be deleted as part of this operation.GitLab Endpoint: /projects/:id/repository/merged_branches
projectIdOrPath
- the project in the form of an Long(ID), String(path), or Project instanceGitLabApiException
- if any exception occurspublic void generateChangelog(Object projectIdOrPath, String version) throws GitLabApiException
GitLab Endpoint: POST /projects/:id/repository/changelog
projectIdOrPath
- the project in the form of an Long(ID), String(path), or Project instanceversion
- the version to generate the changelog forGitLabApiException
- if any exception occurspublic void generateChangelog(Object projectIdOrPath, ChangelogPayload payload) throws GitLabApiException
GitLab Endpoint: POST /projects/:id/repository/changelog
projectIdOrPath
- the project in the form of an Long(ID), String(path), or Project instancepayload
- the payload to generate the changelog forGitLabApiException
- if any exception occursCopyright © 2022. All rights reserved.