public class RepositoryFileApi extends AbstractApi
Constants.ActionType, Constants.ArchiveFormat, Constants.CommitBuildState, Constants.EpicOrderBy, Constants.GroupOrderBy, Constants.ImpersonationState, Constants.IssueOrderBy, Constants.IssueScope, Constants.IssueState, Constants.JobScope, Constants.LineType, Constants.MergeRequestOrderBy, Constants.MergeRequestScope, Constants.MergeRequestState, Constants.MilestoneState, Constants.PipelineOrderBy, Constants.PipelineScope, Constants.ProjectOrderBy, Constants.SortOrder, Constants.StateEvent, Constants.TargetType, Constants.TokenType
NEXT_PAGE_HEADER, PAGE_HEADER, PAGE_PARAM, PER_PAGE, PER_PAGE_PARAM, PREV_PAGE_HEADER, TOTAL_HEADER, TOTAL_PAGES_HEADER
Constructor and Description |
---|
RepositoryFileApi(GitLabApi gitLabApi) |
Modifier and Type | Method and Description |
---|---|
RepositoryFile |
createFile(Object projectIdOrPath,
RepositoryFile file,
String branchName,
String commitMessage)
Create new file in repository
|
RepositoryFile |
createFile(RepositoryFile file,
Integer projectId,
String branchName,
String commitMessage)
Deprecated.
Will be removed in version 5.0, replaced by
createFile(Object, RepositoryFile, String, String) |
protected javax.ws.rs.core.Form |
createForm(RepositoryFile file,
String branchName,
String commitMessage)
Gets the query params based on the API version.
|
void |
deleteFile(Object projectIdOrPath,
String filePath,
String branchName,
String commitMessage)
Delete existing file in repository
|
void |
deleteFile(String filePath,
Integer projectId,
String branchName,
String commitMessage)
Deprecated.
Will be removed in version 5.0, replaced by
deleteFile(Object, String, String, String) |
RepositoryFile |
getFile(Object projectIdOrPath,
String filePath,
String ref)
Get file from repository.
|
RepositoryFile |
getFile(Object projectIdOrPath,
String filePath,
String ref,
boolean includeContent)
Get file from repository.
|
RepositoryFile |
getFile(String filePath,
Integer projectId,
String ref)
Deprecated.
Will be removed in version 5.0, replaced by
getFile(Object, String, String) |
RepositoryFile |
getFileInfo(Object projectIdOrPath,
String filePath,
String ref)
Get information on a file in the repository.
|
protected RepositoryFile |
getFileV3(String filePath,
Integer projectId,
String ref)
Deprecated.
Will be removed in version 5.0
|
Optional<RepositoryFile> |
getOptionalFile(Object projectIdOrPath,
String filePath,
String ref)
Get an Optional instance with the value holding information and content for a file in the repository.
|
Optional<RepositoryFile> |
getOptionalFileInfo(Object projectIdOrPath,
String filePath,
String ref)
Get an Optional instance with the value holding information on a file in the repository.
|
InputStream |
getRawFile(Object projectIdOrPath,
String commitOrBranchName,
String filepath)
Get the raw file contents for a file by commit sha and path.
|
File |
getRawFile(Object projectIdOrPath,
String commitOrBranchName,
String filepath,
File directory)
Get the raw file for the file by commit sha and path.
|
RepositoryFile |
updateFile(Object projectIdOrPath,
RepositoryFile file,
String branchName,
String commitMessage)
Update existing file in repository
|
RepositoryFile |
updateFile(RepositoryFile file,
Integer projectId,
String branchName,
String commitMessage)
Deprecated.
Will be removed in version 5.0, replaced by
updateFile(Object, RepositoryFile, String, String) |
addFormParam, addFormParam, delete, delete, get, get, getApiClient, getApiVersion, getDefaultPerPage, getDefaultPerPageParam, getDefaultPerPageParam, getGroupIdOrPath, getPageQueryParams, getPageQueryParams, getPerPageQueryParam, getProjectIdOrPath, getUserIdOrUsername, getWithAccepts, handle, head, isApiVersion, post, post, post, post, post, put, put, putUpload, putUpload, putWithFormData, upload, upload, upload, urlEncode, validate
public RepositoryFileApi(GitLabApi gitLabApi)
public Optional<RepositoryFile> getOptionalFileInfo(Object projectIdOrPath, String filePath, String ref)
GitLab Endpoint: HEAD /projects/:id/repository/files
projectIdOrPath
- the id, path of the project, or a Project instance holding the project ID or pathfilePath
- (required) - Full path to the file. Ex. lib/class.rbref
- (required) - The name of branch, tag or commitpublic RepositoryFile getFileInfo(Object projectIdOrPath, String filePath, String ref) throws GitLabApiException
GitLab Endpoint: HEAD /projects/:id/repository/files
projectIdOrPath
- the id, path of the project, or a Project instance holding the project ID or pathfilePath
- (required) - Full path to the file. Ex. lib/class.rbref
- (required) - The name of branch, tag or commitGitLabApiException
- if any exception occurspublic Optional<RepositoryFile> getOptionalFile(Object projectIdOrPath, String filePath, String ref)
GitLab Endpoint: HEAD /projects/:id/repository/files
projectIdOrPath
- the id, path of the project, or a Project instance holding the project ID or pathfilePath
- (required) - Full path to the file. Ex. lib/class.rbref
- (required) - The name of branch, tag or commitpublic RepositoryFile getFile(Object projectIdOrPath, String filePath, String ref) throws GitLabApiException
GitLab Endpoint: GET /projects/:id/repository/files
projectIdOrPath
- the id, path of the project, or a Project instance holding the project ID or pathfilePath
- (required) - Full path to the file. Ex. lib/class.rbref
- (required) - The name of branch, tag or commitGitLabApiException
- if any exception occurs@Deprecated public RepositoryFile getFile(String filePath, Integer projectId, String ref) throws GitLabApiException
getFile(Object, String, String)
GitLab Endpoint: GET /projects/:id/repository/files
filePath
- (required) - Full path to the file. Ex. lib/class.rbprojectId
- (required) - the project IDref
- (required) - The name of branch, tag or commitGitLabApiException
- if any exception occurspublic RepositoryFile getFile(Object projectIdOrPath, String filePath, String ref, boolean includeContent) throws GitLabApiException
GitLab Endpoint: GET /projects/:id/repository/files
projectIdOrPath
- the id, path of the project, or a Project instance holding the project ID or pathfilePath
- (required) - Full path to the file. Ex. lib/class.rbref
- (required) - The name of branch, tag or commitincludeContent
- if true will also fetch file contentGitLabApiException
- if any exception occurs@Deprecated protected RepositoryFile getFileV3(String filePath, Integer projectId, String ref) throws GitLabApiException
GitLab Endpoint: GET /projects/:id/repository/files
filePath
- (required) - Full path to new file. Ex. lib/class.rbprojectId
- (required) - the project IDref
- (required) - The name of branch, tag or commitGitLabApiException
- if any exception occurspublic RepositoryFile createFile(Object projectIdOrPath, RepositoryFile file, String branchName, String commitMessage) throws GitLabApiException
GitLab Endpoint: POST /projects/:id/repository/files
file_path (required) - Full path to new file. Ex. lib/class.rb
branch_name (required) - The name of branch
encoding (optional) - 'text' or 'base64'. Text is default.
content (required) - File content
commit_message (required) - Commit messageprojectIdOrPath
- the id, path of the project, or a Project instance holding the project ID or pathfile
- a ReposityoryFile instance with info for the file to createbranchName
- the name of branchcommitMessage
- the commit messageGitLabApiException
- if any exception occurs@Deprecated public RepositoryFile createFile(RepositoryFile file, Integer projectId, String branchName, String commitMessage) throws GitLabApiException
createFile(Object, RepositoryFile, String, String)
GitLab Endpoint: POST /projects/:id/repository/files
file_path (required) - Full path to new file. Ex. lib/class.rb
branch_name (required) - The name of branch
encoding (optional) - 'text' or 'base64'. Text is default.
content (required) - File content
commit_message (required) - Commit messagefile
- a ReposityoryFile instance with info for the file to createprojectId
- the project IDbranchName
- the name of branchcommitMessage
- the commit messageGitLabApiException
- if any exception occurspublic RepositoryFile updateFile(Object projectIdOrPath, RepositoryFile file, String branchName, String commitMessage) throws GitLabApiException
GitLab Endpoint: PUT /projects/:id/repository/files
file_path (required) - Full path to new file. Ex. lib/class.rb
branch_name (required) - The name of branch
encoding (optional) - 'text' or 'base64'. Text is default.
content (required) - File content
commit_message (required) - Commit messageprojectIdOrPath
- the id, path of the project, or a Project instance holding the project ID or pathfile
- a ReposityoryFile instance with info for the file to updatebranchName
- the name of branchcommitMessage
- the commit messageGitLabApiException
- if any exception occurs@Deprecated public RepositoryFile updateFile(RepositoryFile file, Integer projectId, String branchName, String commitMessage) throws GitLabApiException
updateFile(Object, RepositoryFile, String, String)
GitLab Endpoint: PUT /projects/:id/repository/files
file_path (required) - Full path to new file. Ex. lib/class.rb
branch_name (required) - The name of branch
encoding (optional) - 'text' or 'base64'. Text is default.
content (required) - File content
commit_message (required) - Commit messagefile
- a ReposityoryFile instance with info for the file to updateprojectId
- the project IDbranchName
- the name of branchcommitMessage
- the commit messageGitLabApiException
- if any exception occurspublic void deleteFile(Object projectIdOrPath, String filePath, String branchName, String commitMessage) throws GitLabApiException
GitLab Endpoint: DELETE /projects/:id/repository/files
file_path (required) - Full path to file. Ex. lib/class.rb
branch_name (required) - The name of branch
commit_message (required) - Commit messageprojectIdOrPath
- the id, path of the project, or a Project instance holding the project ID or pathfilePath
- full path to new file. Ex. lib/class.rbbranchName
- the name of branchcommitMessage
- the commit messageGitLabApiException
- if any exception occurs@Deprecated public void deleteFile(String filePath, Integer projectId, String branchName, String commitMessage) throws GitLabApiException
deleteFile(Object, String, String, String)
GitLab Endpoint: DELETE /projects/:id/repository/files
file_path (required) - Full path to file. Ex. lib/class.rb
branch_name (required) - The name of branch
commit_message (required) - Commit messagefilePath
- full path to new file. Ex. lib/class.rbprojectId
- the project IDbranchName
- the name of branchcommitMessage
- the commit messageGitLabApiException
- if any exception occurspublic File getRawFile(Object projectIdOrPath, String commitOrBranchName, String filepath, File directory) throws GitLabApiException
GitLab Endpoint: GET /projects/:id/repository/blobs/:sha
V4:
GitLab Endpoint: GET /projects/:id/repository/files/:filepath
projectIdOrPath
- the project in the form of an Integer(ID), String(path), or Project instancecommitOrBranchName
- the commit or branch name to get the file forfilepath
- the path of the file to getdirectory
- the File instance of the directory to save the file to, if null will use "java.io.tmpdir"GitLabApiException
- if any exception occurspublic InputStream getRawFile(Object projectIdOrPath, String commitOrBranchName, String filepath) throws GitLabApiException
GitLab Endpoint: GET /projects/:id/repository/blobs/:sha
V4:
GitLab Endpoint: GET /projects/:id/repository/files/:filepath
projectIdOrPath
- the project in the form of an Integer(ID), String(path), or Project instancecommitOrBranchName
- the commit or branch name to get the file contents forfilepath
- the path of the file to getGitLabApiException
- if any exception occursprotected javax.ws.rs.core.Form createForm(RepositoryFile file, String branchName, String commitMessage)
file
- the RepositoryFile instance with the info for the query paramsbranchName
- the branch namecommitMessage
- the commit messageCopyright © 2019. All rights reserved.