public class GitlabAPI extends Object
Modifier and Type | Field and Description |
---|---|
static com.fasterxml.jackson.databind.ObjectMapper |
MAPPER |
public static GitlabSession connect(String hostUrl, String username, String password) throws IOException
IOException
public GitlabAPI ignoreCertificateErrors(boolean ignoreCertificateErrors)
public GitlabHTTPRequestor retrieve()
public GitlabHTTPRequestor dispatch()
public boolean isIgnoreCertificateErrors()
public URL getAPIUrl(String tailAPIUrl) throws IOException
IOException
public URL getUrl(String tailAPIUrl) throws IOException
IOException
public List<GitlabUser> getUsers() throws IOException
IOException
public List<GitlabUser> findUsers(String emailOrUsername) throws IOException
IOException
public GitlabUser getUser(Integer userId) throws IOException
IOException
public GitlabUser getUserViaSudo(String username) throws IOException
IOException
public GitlabUser createUser(String email, String password, String username, String fullName, String skypeId, String linkedIn, String twitter, String website_url, Integer projects_limit, String extern_uid, String extern_provider_name, String bio, Boolean isAdmin, Boolean can_create_group, Boolean skip_confirmation) throws IOException
email
- User emailpassword
- Passwordusername
- User namefullName
- Full nameskypeId
- Skype IdlinkedIn
- LinkedIntwitter
- Twitterwebsite_url
- Website URLprojects_limit
- Projects limitextern_uid
- External User IDextern_provider_name
- External Provider Namebio
- BioisAdmin
- Is Admincan_create_group
- Can Create Groupskip_confirmation
- Skip ConfirmationIOException
- on gitlab api call errorpublic GitlabUser updateUser(Integer targetUserId, String email, String password, String username, String fullName, String skypeId, String linkedIn, String twitter, String website_url, Integer projects_limit, String extern_uid, String extern_provider_name, String bio, Boolean isAdmin, Boolean can_create_group) throws IOException
targetUserId
- User IDemail
- User emailpassword
- Passwordusername
- User namefullName
- Full nameskypeId
- Skype IdlinkedIn
- LinkedIntwitter
- Twitterwebsite_url
- Website URLprojects_limit
- Projects limitextern_uid
- External User IDextern_provider_name
- External Provider Namebio
- BioisAdmin
- Is Admincan_create_group
- Can Create GroupIOException
- on gitlab api call errorpublic void blockUser(Integer targetUserId) throws IOException
targetUserId
- The id of the Gitlab userIOException
- on gitlab api call errorpublic void unblockUser(Integer targetUserId) throws IOException
targetUserId
- The id of the Gitlab userIOException
- on gitlab api call errorpublic GitlabSSHKey createSSHKey(Integer targetUserId, String title, String key) throws IOException
targetUserId
- The id of the Gitlab usertitle
- The title of the ssh keykey
- The public keyIOException
- on gitlab api call errorpublic void deleteSSHKey(Integer targetUserId, Integer targetKeyId) throws IOException
targetUserId
- The id of the Gitlab usertargetKeyId
- The id of the Gitlab ssh keyIOException
- on gitlab api call errorpublic List<GitlabSSHKey> getSSHKeys(Integer targetUserId) throws IOException
targetUserId
- The id of the GitLab UserIOException
- on gitlab api call errorpublic GitlabSSHKey getSSHKey(Integer keyId) throws IOException
keyId
- The ID of an SSH keyIOException
- on gitlab api call errorpublic void deleteUser(Integer targetUserId) throws IOException
targetUserId
- The target User IDIOException
- on gitlab api call errorpublic GitlabGroup getGroup(Integer groupId) throws IOException
IOException
public List<GitlabGroup> getGroups() throws IOException
IOException
public List<GitlabGroupMember> getGroupMembers(GitlabGroup group) throws IOException
group
- The GitLab GroupIOException
- on gitlab api call errorpublic List<GitlabGroupMember> getGroupMembers(Integer groupId) throws IOException
groupId
- The id of the GitLab GroupIOException
- on gitlab api call errorpublic GitlabGroup createGroup(String name) throws IOException
name
- The name of the group. The
name will also be used as the path
of the group.IOException
- on gitlab api call errorpublic GitlabGroup createGroup(String name, String path) throws IOException
name
- The name of the grouppath
- The path for the groupIOException
- on gitlab api call errorpublic GitlabGroup createGroup(String name, String path, String ldapCn, GitlabAccessLevel ldapAccess) throws IOException
name
- The name of the grouppath
- The path for the groupldapCn
- LDAP Group Name to sync with, null otherwiseldapAccess
- Access level for LDAP group members, null otherwiseIOException
- on gitlab api call errorpublic GitlabGroupMember addGroupMember(GitlabGroup group, GitlabUser user, GitlabAccessLevel accessLevel) throws IOException
group
- the GitlabGroupuser
- the GitlabUseraccessLevel
- the GitlabAccessLevelIOException
- on gitlab api call errorpublic GitlabGroupMember addGroupMember(Integer groupId, Integer userId, GitlabAccessLevel accessLevel) throws IOException
groupId
- the group iduserId
- the user idaccessLevel
- the GitlabAccessLevelIOException
- on gitlab api call errorpublic void deleteGroupMember(GitlabGroup group, GitlabUser user) throws IOException
group
- the GitlabGroupuser
- the GitlabUserIOException
- on gitlab api call errorpublic void deleteGroupMember(Integer groupId, Integer userId) throws IOException
groupId
- the group iduserId
- the user idIOException
- on gitlab api call errorpublic void deleteGroup(Integer groupId) throws IOException
groupId
- the group idIOException
- on gitlab api call errorpublic GitlabProject getProject(Serializable projectId) throws IOException
IOException
public List<GitlabProject> getProjects() throws IOException
IOException
public List<GitlabProject> getAllProjects() throws IOException
IOException
public GitlabProject createProject(String name) throws IOException
name
- The name of the projectIOException
- on gitlab api call errorpublic GitlabProject createProject(String name, Integer namespaceId, String description, Boolean issuesEnabled, Boolean wallEnabled, Boolean mergeRequestsEnabled, Boolean wikiEnabled, Boolean snippetsEnabled, Boolean publik, Integer visibilityLevel, String importUrl) throws IOException
name
- The name of the projectnamespaceId
- The Namespace for the new project, otherwise null indicates to use the GitLab default (user)description
- A description for the project, null otherwiseissuesEnabled
- Whether Issues should be enabled, otherwise null indicates to use GitLab defaultwallEnabled
- Whether The Wall should be enabled, otherwise null indicates to use GitLab defaultmergeRequestsEnabled
- Whether Merge Requests should be enabled, otherwise null indicates to use GitLab defaultwikiEnabled
- Whether a Wiki should be enabled, otherwise null indicates to use GitLab defaultsnippetsEnabled
- Whether Snippets should be enabled, otherwise null indicates to use GitLab defaultpublik
- Whether the project is public or private, if true same as setting visibilityLevel = 20, otherwise null indicates to use GitLab defaultvisibilityLevel
- The visibility level of the project, otherwise null indicates to use GitLab defaultimportUrl
- The Import URL for the project, otherwise nullIOException
- on gitlab api call errorpublic GitlabProject createUserProject(Integer userId, String name) throws IOException
userId
- The id of the user to create the project forname
- The name of the projectIOException
- on gitlab api call errorpublic GitlabProject createUserProject(Integer userId, String name, String description, String defaultBranch, Boolean issuesEnabled, Boolean wallEnabled, Boolean mergeRequestsEnabled, Boolean wikiEnabled, Boolean snippetsEnabled, Boolean publik, Integer visibilityLevel) throws IOException
userId
- The id of the user to create the project forname
- The name of the projectdescription
- A description for the project, null otherwisedefaultBranch
- The default branch for the project, otherwise null indicates to use GitLab default (master)issuesEnabled
- Whether Issues should be enabled, otherwise null indicates to use GitLab defaultwallEnabled
- Whether The Wall should be enabled, otherwise null indicates to use GitLab defaultmergeRequestsEnabled
- Whether Merge Requests should be enabled, otherwise null indicates to use GitLab defaultwikiEnabled
- Whether a Wiki should be enabled, otherwise null indicates to use GitLab defaultsnippetsEnabled
- Whether Snippets should be enabled, otherwise null indicates to use GitLab defaultpublik
- Whether the project is public or private, if true same as setting visibilityLevel = 20, otherwise null indicates to use GitLab defaultvisibilityLevel
- The visibility level of the project, otherwise null indicates to use GitLab defaultIOException
- on gitlab api call errorpublic GitlabProject updateProject(Integer projectId, String name, String description, Boolean issuesEnabled, Boolean wallEnabled, Boolean mergeRequestsEnabled, Boolean wikiEnabled, Boolean snippetsEnabled, Boolean publik, Integer visibilityLevel) throws IOException
projectId
- The id of the project to updatename
- The name of the projectdescription
- A description for the project, null otherwiseissuesEnabled
- Whether Issues should be enabled, otherwise null indicates to use GitLab defaultwallEnabled
- Whether The Wall should be enabled, otherwise null indicates to use GitLab defaultmergeRequestsEnabled
- Whether Merge Requests should be enabled, otherwise null indicates to use GitLab defaultwikiEnabled
- Whether a Wiki should be enabled, otherwise null indicates to use GitLab defaultsnippetsEnabled
- Whether Snippets should be enabled, otherwise null indicates to use GitLab defaultpublik
- Whether the project is public or private, if true same as setting visibilityLevel = 20, otherwise null indicates to use GitLab defaultvisibilityLevel
- The visibility level of the project, otherwise null indicates to use GitLab defaultIOException
- on gitlab api call errorpublic void deleteProject(Serializable projectId) throws IOException
projectId
- The id of the project to deleteIOException
- on gitlab api call errorpublic List<GitlabMergeRequest> getOpenMergeRequests(Serializable projectId) throws IOException
IOException
public List<GitlabMergeRequest> getOpenMergeRequests(GitlabProject project) throws IOException
IOException
public List<GitlabMergeRequest> getMergeRequests(Serializable projectId) throws IOException
IOException
public List<GitlabMergeRequest> getMergeRequests(GitlabProject project) throws IOException
IOException
public List<GitlabMergeRequest> getAllMergeRequests(GitlabProject project) throws IOException
IOException
public GitlabMergeRequest getMergeRequest(GitlabProject project, Integer mergeRequestId) throws IOException
IOException
public GitlabMergeRequest acceptMergeRequest(GitlabProject project, Integer mergeRequestId, String mergeCommitMessage) throws IOException
project
- The ProjectmergeRequestId
- Merge Request IDmergeCommitMessage
- optional merge commit message. Null if not setIOException
- on gitlab api call errorpublic List<GitlabNote> getNotes(GitlabMergeRequest mergeRequest) throws IOException
IOException
public List<GitlabNote> getAllNotes(GitlabMergeRequest mergeRequest) throws IOException
IOException
public GitlabCommit getCommit(Serializable projectId, String commitHash) throws IOException
IOException
public List<GitlabCommit> getCommits(GitlabMergeRequest mergeRequest) throws IOException
IOException
public List<GitlabCommit> getAllCommits(Serializable projectId) throws IOException
IOException
public List<GitlabCommitDiff> getCommitDiffs(Serializable projectId, String commitHash) throws IOException
IOException
public byte[] getRawFileContent(GitlabProject project, String sha, String filepath) throws IOException
project
- The Projectsha
- The commit or branch namefilepath
- The path of the fileIOException
- on gitlab api call errorpublic byte[] getRawBlobContent(GitlabProject project, String sha) throws IOException
project
- The Projectsha
- The commit or branch nameIOException
- on gitlab api call errorpublic byte[] getFileArchive(GitlabProject project) throws IOException
project
- The ProjectIOException
- on gitlab api call errorpublic List<GitlabRepositoryTree> getRepositoryTree(GitlabProject project, String path, String ref_name) throws IOException
project
- The Projectpath
- The path inside the repository. Used to get content of subdirectories (optional)ref_name
- The name of a repository branch or tag or if not given the default branch (optional)IOException
- on gitlab api call errorpublic GitlabNote createNote(GitlabMergeRequest mergeRequest, String body) throws IOException
IOException
public List<GitlabBranch> getBranches(Serializable projectId) throws IOException
IOException
public List<GitlabBranch> getBranches(GitlabProject project) throws IOException
IOException
public GitlabBranch getBranch(GitlabProject project, String branchName) throws IOException
IOException
public void protectBranch(GitlabProject project, String branchName) throws IOException
IOException
public void unprotectBranch(GitlabProject project, String branchName) throws IOException
IOException
public List<GitlabProjectHook> getProjectHooks(Serializable projectId) throws IOException
IOException
public List<GitlabProjectHook> getProjectHooks(GitlabProject project) throws IOException
IOException
public GitlabProjectHook getProjectHook(GitlabProject project, String hookId) throws IOException
IOException
public GitlabProjectHook addProjectHook(GitlabProject project, String url) throws IOException
IOException
public GitlabProjectHook addProjectHook(Serializable projectId, String url, boolean pushEvents, boolean issuesEvents, boolean mergeRequestEvents) throws IOException
IOException
public GitlabProjectHook editProjectHook(GitlabProject project, String hookId, String url) throws IOException
IOException
public void deleteProjectHook(GitlabProjectHook hook) throws IOException
IOException
public void deleteProjectHook(GitlabProject project, String hookId) throws IOException
IOException
public List<GitlabIssue> getIssues(GitlabProject project) throws IOException
IOException
public GitlabIssue getIssue(Serializable projectId, Integer issueId) throws IOException
IOException
public GitlabIssue createIssue(int projectId, int assigneeId, int milestoneId, String labels, String description, String title) throws IOException
IOException
public GitlabIssue editIssue(int projectId, int issueId, int assigneeId, int milestoneId, String labels, String description, String title, GitlabIssue.Action action) throws IOException
IOException
public List<GitlabNote> getNotes(GitlabIssue issue) throws IOException
IOException
public GitlabNote createNote(Serializable projectId, Integer issueId, String message) throws IOException
IOException
public GitlabNote createNote(GitlabIssue issue, String message) throws IOException
IOException
public List<GitlabMilestone> getMilestones(GitlabProject project) throws IOException
IOException
public List<GitlabMilestone> getMilestones(Serializable projectId) throws IOException
IOException
public GitlabProjectMember addProjectMember(GitlabProject project, GitlabUser user, GitlabAccessLevel accessLevel) throws IOException
project
- the GitlabProjectuser
- the GitlabUseraccessLevel
- the GitlabAccessLevelIOException
- on gitlab api call errorpublic GitlabProjectMember addProjectMember(Integer projectId, Integer userId, GitlabAccessLevel accessLevel) throws IOException
projectId
- the project iduserId
- the user idaccessLevel
- the GitlabAccessLevelIOException
- on gitlab api call errorpublic void deleteProjectMember(GitlabProject project, GitlabUser user) throws IOException
project
- the GitlabProjectuser
- the GitlabUserIOException
- on gitlab api call errorpublic void deleteProjectMember(Integer projectId, Integer userId) throws IOException
projectId
- the project iduserId
- the user idIOException
- on gitlab api call errorpublic List<GitlabProjectMember> getProjectMembers(GitlabProject project) throws IOException
IOException
public List<GitlabProjectMember> getProjectMembers(Serializable projectId) throws IOException
IOException
public List<GitlabProjectMember> getNamespaceMembers(GitlabNamespace namespace) throws IOException
namespace
- The namespaceIOException
- on gitlab api call errorpublic List<GitlabProjectMember> getNamespaceMembers(Integer namespaceId) throws IOException
namespaceId
- Namespace IDIOException
- on gitlab api call errorpublic void transfer(Integer namespaceId, Integer projectId) throws IOException
namespaceId
- Namespace IDprojectId
- Project IDIOException
- on gitlab api call errorpublic GitlabSSHKey createDeployKey(Integer targetProjectId, String title, String key) throws IOException
targetProjectId
- The id of the Gitlab projecttitle
- The title of the ssh keykey
- The public keyIOException
- on gitlab api call errorpublic void deleteDeployKey(Integer targetProjectId, Integer targetKeyId) throws IOException
targetProjectId
- The id of the Gitlab projecttargetKeyId
- The id of the Gitlab ssh keyIOException
- on gitlab api call errorpublic List<GitlabSSHKey> getDeployKeys(Integer targetProjectId) throws IOException
targetProjectId
- The id of the Gitlab projectIOException
- on gitlab api call errorpublic GitlabSession getCurrentSession() throws IOException
IOException
public List<GitlabSystemHook> getSystemHooks() throws IOException
IOException
- on gitlab api call errorpublic GitlabSystemHook addSystemHook(String url) throws IOException
url
- System hook urlIOException
- on gitlab api call errorpublic void testSystemHook(Integer hookId) throws IOException
IOException
- on gitlab api call errorpublic GitlabSystemHook deleteSystemHook(Integer hookId) throws IOException
IOException
- on gitlab api call errorCopyright © 2015. All Rights Reserved.