code
stringlengths
73
34.1k
label
stringclasses
1 value
public List<Project> getForks(Object projectIdOrPath) throws GitLabApiException { return (getForks(projectIdOrPath, getDefaultPerPage()).all()); }
java
public List<Project> getForks(Object projectIdOrPath, int page, int perPage) throws GitLabApiException { Response response = get(Response.Status.OK, getPageQueryParams(page, perPage),"projects", getProjectIdOrPath(projectIdOrPath), "forks"); return (response.readEntity(new GenericType<List<Project>>() { })); }
java
public Pager<Project> getForks(Object projectIdOrPath, int itemsPerPage) throws GitLabApiException { return new Pager<Project>(this, Project.class, itemsPerPage, null, "projects", getProjectIdOrPath(projectIdOrPath), "forks"); }
java
public Stream<Project> getForksStream(Object projectIdOrPath) throws GitLabApiException { return (getForks(projectIdOrPath, getDefaultPerPage()).stream()); }
java
public Project starProject(Object projectIdOrPath) throws GitLabApiException { Response.Status expectedStatus = (isApiVersion(ApiVersion.V3) ? Response.Status.OK : Response.Status.CREATED); Response response = post(expectedStatus, (Form) null, "projects", getProjectIdOrPath(projectIdOrPath), "star"); return (response.readEntity(Project.class)); }
java
public Map<String, Float> getProjectLanguages(Object projectIdOrPath) throws GitLabApiException { Response response = get(Response.Status.OK, null, "projects", getProjectIdOrPath(projectIdOrPath), "languages"); return (response.readEntity(new GenericType<Map<String, Float>>() {})); }
java
public Project transferProject(Object projectIdOrPath, String namespace) throws GitLabApiException { GitLabApiForm formData = new GitLabApiForm().withParam("namespace", namespace, true); Response response = put(Response.Status.OK, formData.asMap(), "projects", getProjectIdOrPath(projectIdOrPath), "transfer"); return (response.readEntity(Project.class)); }
java
public Project setProjectAvatar(Object projectIdOrPath, File avatarFile) throws GitLabApiException { Response response = putUpload(Response.Status.OK, "avatar", avatarFile, "projects", getProjectIdOrPath(projectIdOrPath)); return (response.readEntity(Project.class)); }
java
public List<Variable> getVariables(Object projectIdOrPath) throws GitLabApiException { return (getVariables(projectIdOrPath, getDefaultPerPage()).all()); }
java
public List<Variable> getVariables(Object projectIdOrPath, int page, int perPage) throws GitLabApiException { Response response = get(Response.Status.OK, getPageQueryParams(page, perPage), "projects", getProjectIdOrPath(projectIdOrPath), "variables"); return (response.readEntity(new GenericType<List<Variable>>() {})); }
java
public Pager<Variable> getVariables(Object projectIdOrPath, int itemsPerPage) throws GitLabApiException { return (new Pager<Variable>(this, Variable.class, itemsPerPage, null, "projects", getProjectIdOrPath(projectIdOrPath), "variables")); }
java
public Stream<Variable> getVariablesStream(Object projectIdOrPath) throws GitLabApiException { return (getVariables(projectIdOrPath, getDefaultPerPage()).stream()); }
java
public Variable getVariable(Object projectIdOrPath, String key) throws GitLabApiException { Response response = get(Response.Status.OK, null, "projects", getProjectIdOrPath(projectIdOrPath), "variables", key); return (response.readEntity(Variable.class)); }
java
public Variable updateVariable(Object projectIdOrPath, String key, String value, Boolean isProtected, String environmentScope) throws GitLabApiException { GitLabApiForm formData = new GitLabApiForm() .withParam("value", value, true) .withParam("protected", isProtected) .withParam("environment_scope", environmentScope); Response response = putWithFormData(Response.Status.OK, formData, "projects", getProjectIdOrPath(projectIdOrPath), "variables", key); return (response.readEntity(Variable.class)); }
java
public void deleteVariable(Object projectIdOrPath, String key) throws GitLabApiException { delete(Response.Status.NO_CONTENT, null, "projects", getProjectIdOrPath(projectIdOrPath), "variables", key); }
java
public static String getShortRequestDump(String fromMethod, HttpServletRequest request) { return (getShortRequestDump(fromMethod, false, request)); }
java
public static String getShortRequestDump(String fromMethod, boolean includeHeaders, HttpServletRequest request) { StringBuilder dump = new StringBuilder(); dump.append("Timestamp : ").append(ISO8601.getTimestamp()).append("\n"); dump.append("fromMethod : ").append(fromMethod).append("\n"); dump.append("Method : ").append(request.getMethod()).append('\n'); dump.append("Scheme : ").append(request.getScheme()).append('\n'); dump.append("URI : ").append(request.getRequestURI()).append('\n'); dump.append("Query-String : ").append(request.getQueryString()).append('\n'); dump.append("Auth-Type : ").append(request.getAuthType()).append('\n'); dump.append("Remote-Addr : ").append(request.getRemoteAddr()).append('\n'); dump.append("Scheme : ").append(request.getScheme()).append('\n'); dump.append("Content-Type : ").append(request.getContentType()).append('\n'); dump.append("Content-Length: ").append(request.getContentLength()).append('\n'); if (includeHeaders) { dump.append("Headers :\n"); Enumeration<String> headers = request.getHeaderNames(); while (headers.hasMoreElements()) { String header = headers.nextElement(); dump.append("\t").append(header).append(": ").append(request.getHeader(header)).append('\n'); } } return (dump.toString()); }
java
public static String getRequestDump(String fromMethod, HttpServletRequest request, boolean includePostData) { String shortDump = getShortRequestDump(fromMethod, request); StringBuilder buf = new StringBuilder(shortDump); try { buf.append("\nAttributes:\n"); Enumeration<String> attrs = request.getAttributeNames(); while (attrs.hasMoreElements()) { String attr = attrs.nextElement(); buf.append("\t").append(attr).append(": ").append(request.getAttribute(attr)).append('\n'); } buf.append("\nHeaders:\n"); Enumeration<String> headers = request.getHeaderNames(); while (headers.hasMoreElements()) { String header = headers.nextElement(); buf.append("\t").append(header).append(": ").append(request.getHeader(header)).append('\n'); } buf.append("\nParameters:\n"); Enumeration<String> params = request.getParameterNames(); while (params.hasMoreElements()) { String param = params.nextElement(); buf.append("\t").append(param).append(": ").append(request.getParameter(param)).append('\n'); } buf.append("\nCookies:\n"); Cookie[] cookies = request.getCookies(); if (cookies != null) { for (Cookie cookie : cookies) { String cstr = "\t" + cookie.getDomain() + "." + cookie.getPath() + "." + cookie.getName() + ": " + cookie.getValue() + "\n"; buf.append(cstr); } } if (includePostData) { buf.append(getPostDataAsString(request)).append("\n"); } return (buf.toString()); } catch (IOException e) { return e.getMessage(); } }
java
public static String getPostDataAsString(HttpServletRequest request) throws IOException { try (InputStreamReader reader = new InputStreamReader(request.getInputStream(), "UTF-8")) { return (getReaderContentAsString(reader)); } }
java
public static String getReaderContentAsString(Reader reader) throws IOException { int count; final char[] buffer = new char[2048]; final StringBuilder out = new StringBuilder(); while ((count = reader.read(buffer, 0, buffer.length)) >= 0) { out.append(buffer, 0, count); } return (out.toString()); }
java
@JsonIgnore public void encodeAndSetContent(String content) { encodeAndSetContent(content != null ? content.getBytes() : null); }
java
@JsonIgnore public void encodeAndSetContent(byte[] byteContent) { if (byteContent == null) { this.content = null; return; } this.content = Base64.getEncoder().encodeToString(byteContent); encoding = "base64"; }
java
public List<WikiPage> getPages(Object projectIdOrPath, int page, int perPage) throws GitLabApiException { Response response = get(Response.Status.OK, getPageQueryParams(page, perPage), "projects", getProjectIdOrPath(projectIdOrPath), "wikis"); return response.readEntity(new GenericType<List<WikiPage>>() {}); }
java
public WikiPage getPage(Object projectIdOrPath, String slug) throws GitLabApiException { Response response = get(Response.Status.OK, null, "projects", getProjectIdOrPath(projectIdOrPath), "wikis", slug); return (response.readEntity(WikiPage.class)); }
java
public Optional<WikiPage> getOptionalPage(Object projectIdOrPath, String slug) { try { return (Optional.ofNullable(getPage(projectIdOrPath, slug))); } catch (GitLabApiException glae) { return (GitLabApi.createOptionalFromException(glae)); } }
java
public WikiPage createPage(Object projectIdOrPath, String title, String content) throws GitLabApiException { // one of title or content is required GitLabApiForm formData = new GitLabApiForm() .withParam("title", title) .withParam("content", content); Response response = post(Response.Status.CREATED, formData, "projects", getProjectIdOrPath(projectIdOrPath), "wikis"); return (response.readEntity(WikiPage.class)); }
java
public WikiPage updatePage(Object projectIdOrPath, String slug, String title, String content) throws GitLabApiException { GitLabApiForm formData = new GitLabApiForm() .withParam("title", title) .withParam("slug", slug, true) .withParam("content", content); Response response = put(Response.Status.OK, formData.asMap(), "projects", getProjectIdOrPath(projectIdOrPath), "wikis", slug); return (response.readEntity(WikiPage.class)); }
java
public void deletePage(Object projectIdOrPath, String slug) throws GitLabApiException { delete(Response.Status.NO_CONTENT, null, "projects", getProjectIdOrPath(projectIdOrPath), "wikis", slug); }
java
public List<ProtectedBranch> getProtectedBranches(Object projectIdOrPath) throws GitLabApiException { return (getProtectedBranches(projectIdOrPath, this.getDefaultPerPage()).all()); }
java
public Pager<ProtectedBranch> getProtectedBranches(Object projectIdOrPath, int itemsPerPage) throws GitLabApiException { return (new Pager<ProtectedBranch>(this, ProtectedBranch.class, itemsPerPage, null, "projects", getProjectIdOrPath(projectIdOrPath), "protected_branches")); }
java
public Stream<ProtectedBranch> getProtectedBranchesStream(Object projectIdOrPath) throws GitLabApiException { return (getProtectedBranches(projectIdOrPath, this.getDefaultPerPage()).stream()); }
java
public void unprotectBranch(Integer projectIdOrPath, String branchName) throws GitLabApiException { delete(Response.Status.NO_CONTENT, null, "projects", getProjectIdOrPath(projectIdOrPath), "protected_branches", urlEncode(branchName)); }
java
public List<Commit> getCommits(Object projectIdOrPath, String ref, String path) throws GitLabApiException { return (getCommits(projectIdOrPath, ref, null, null, path, getDefaultPerPage()).all()); }
java
public Pager<Commit> getCommits(Object projectIdOrPath, String ref, Date since, Date until, String path, int itemsPerPage) throws GitLabApiException { Form formData = new GitLabApiForm() .withParam("ref_name", ref) .withParam("since", ISO8601.toString(since, false)) .withParam("until", ISO8601.toString(until, false)) .withParam("path", (path == null ? null : urlEncode(path))); return (new Pager<Commit>(this, Commit.class, itemsPerPage, formData.asMap(), "projects", getProjectIdOrPath(projectIdOrPath), "repository", "commits")); }
java
public Commit getCommit(Object projectIdOrPath, String sha) throws GitLabApiException { Response response = get(Response.Status.OK, getDefaultPerPageParam(), "projects", getProjectIdOrPath(projectIdOrPath), "repository", "commits", urlEncode(sha)); return (response.readEntity(Commit.class)); }
java
public Pager<CommitStatus> getCommitStatuses(Object projectIdOrPath, String sha, CommitStatusFilter filter, int itemsPerPage) throws GitLabApiException { if (projectIdOrPath == null) { throw new RuntimeException("projectIdOrPath cannot be null"); } if (sha == null || sha.trim().isEmpty()) { throw new RuntimeException("sha cannot be null"); } MultivaluedMap<String, String> queryParams = (filter != null ? filter.getQueryParams().asMap() : null); return (new Pager<CommitStatus>(this, CommitStatus.class, itemsPerPage, queryParams, "projects", this.getProjectIdOrPath(projectIdOrPath), "repository", "commits", sha, "statuses")); }
java
public Stream<CommitStatus> getCommitStatusesStream(Object projectIdOrPath, String sha, CommitStatusFilter filter) throws GitLabApiException { return (getCommitStatuses(projectIdOrPath, sha, filter, getDefaultPerPage()).stream()); }
java
public List<Diff> getDiff(Object projectIdOrPath, String sha) throws GitLabApiException { Response response = get(Response.Status.OK, null, "projects", getProjectIdOrPath(projectIdOrPath), "repository", "commits", sha, "diff"); return (response.readEntity(new GenericType<List<Diff>>() {})); }
java
public List<Comment> getComments(Object projectIdOrPath, String sha) throws GitLabApiException { return (getComments(projectIdOrPath, sha, getDefaultPerPage()).all()); }
java
public Pager<Comment> getComments(Object projectIdOrPath, String sha, int itemsPerPage) throws GitLabApiException { return new Pager<Comment>(this, Comment.class, itemsPerPage, null, "projects", getProjectIdOrPath(projectIdOrPath), "repository", "commits", sha, "comments"); }
java
public Stream<Comment> getCommentsStream(Object projectIdOrPath, String sha) throws GitLabApiException { return (getComments(projectIdOrPath, sha, getDefaultPerPage()).stream()); }
java
public Comment addComment(Object projectIdOrPath, String sha, String note, String path, Integer line, LineType lineType) throws GitLabApiException { GitLabApiForm formData = new GitLabApiForm() .withParam("note", note, true) .withParam("path", path) .withParam("line", line) .withParam("line_type", lineType); Response response = post(Response.Status.CREATED, formData, "projects", getProjectIdOrPath(projectIdOrPath), "repository", "commits", sha, "comments"); return (response.readEntity(Comment.class)); }
java
public Comment addComment(Object projectIdOrPath, String sha, String note) throws GitLabApiException { return (addComment(projectIdOrPath, sha, note, null, null, null)); }
java
public Commit createCommit(Object projectIdOrPath, String branch, String commitMessage, String startBranch, String authorEmail, String authorName, List<CommitAction> actions) throws GitLabApiException { CommitPayload payload = new CommitPayload(); payload.setBranch(branch); payload.setCommitMessage(commitMessage); payload.setStartBranch(startBranch); payload.setAuthorEmail(authorEmail); payload.setAuthorName(authorName); payload.setActions(actions); Response response = post(Response.Status.CREATED, payload, "projects", getProjectIdOrPath(projectIdOrPath), "repository", "commits"); return (response.readEntity(Commit.class)); }
java
public NotificationSettings getGlobalNotificationSettings() throws GitLabApiException { Response response = get(Response.Status.OK, null, "notification_settings"); return (response.readEntity(NotificationSettings.class)); }
java
public NotificationSettings updateGlobalNotificationSettings(NotificationSettings settings) throws GitLabApiException { GitLabApiForm formData = new GitLabApiForm() .withParam("level", settings.getLevel()) .withParam("email", settings.getEmail()); Events events = settings.getEvents(); if (events != null) { formData.withParam("new_note", events.getNewNote()) .withParam("new_issuee", events.getNewIssue()) .withParam("reopen_issuee", events.getReopenIssue()) .withParam("close_issuee", events.getCloseIssue()) .withParam("reassign_issuee", events.getReassignIssue()) .withParam("new_merge_requeste", events.getNewMergeRequest()) .withParam("reopen_merge_requeste", events.getReopenMergeRequest()) .withParam("close_merge_requeste", events.getCloseMergeRequest()) .withParam("reassign_merge_requeste", events.getReassignMergeRequest()) .withParam("merge_merge_requeste", events.getMergeMergeRequest()) .withParam("failed_pipelinee", events.getFailedPipeline()) .withParam("success_pipelinee", events.getSuccessPipeline()); } Response response = put(Response.Status.OK, formData.asMap(), "notification_settings"); return (response.readEntity(NotificationSettings.class)); }
java
public NotificationSettings getGroupNotificationSettings(int groupId) throws GitLabApiException { Response response = get(Response.Status.OK, null, "groups", groupId, "notification_settings"); return (response.readEntity(NotificationSettings.class)); }
java
public NotificationSettings getProjectNotificationSettings(int projectId) throws GitLabApiException { Response response = get(Response.Status.OK, null, "projects", projectId, "notification_settings"); return (response.readEntity(NotificationSettings.class)); }
java
public void addEnum(E e, String name) { valuesMap.put(name, e); namesMap.put(e, name); }
java
public Session login(String username, String email, String password) throws GitLabApiException { if ((username == null || username.trim().length() == 0) && (email == null || email.trim().length() == 0)) { throw new IllegalArgumentException("both username and email cannot be empty or null"); } Form formData = new Form(); addFormParam(formData, "email", email, false); addFormParam(formData, "password", password, true); addFormParam(formData, "login", username, false); Response response = post(Response.Status.CREATED, formData, "session"); return (response.readEntity(Session.class)); }
java
public Markdown getMarkdown(String text) throws GitLabApiException { if (!isApiVersion(ApiVersion.V4)) { throw new GitLabApiException("Api version must be v4"); } Form formData = new GitLabApiForm().withParam("text", text, true); Response response = post(Response.Status.OK, formData.asMap(), "markdown"); return (response.readEntity(Markdown.class)); }
java
public static String getFilenameFromContentDisposition(Response response) { String disposition = response.getHeaderString("Content-Disposition"); if (disposition == null || disposition.trim().length() == 0) return (null); return (disposition.replaceFirst("(?i)^.*filename=\"([^\"]+)\".*$", "$1")); }
java
public static String readFileContents(File file) throws IOException { try (Scanner in = new Scanner(file)) { in.useDelimiter("\\Z"); return (in.next()); } }
java
public Stream<Group> getGroupsStream(String search) throws GitLabApiException { return (getGroups(search, getDefaultPerPage()).stream()); }
java
public List<Group> getGroups(GroupFilter filter) throws GitLabApiException { return (getGroups(filter, getDefaultPerPage()).all()); }
java
public Pager<Group> getGroups(GroupFilter filter, int itemsPerPage) throws GitLabApiException { GitLabApiForm formData = filter.getQueryParams(); return (new Pager<Group>(this, Group.class, itemsPerPage, formData.asMap(), "groups")); }
java
public Stream<Group> getGroupsStream(GroupFilter filter) throws GitLabApiException { return (getGroups(filter, getDefaultPerPage()).stream()); }
java
public Stream<Group> getSubGroupsStream(Object groupIdOrPath) throws GitLabApiException { return (getSubGroups(groupIdOrPath, getDefaultPerPage()).stream()); }
java
public Pager<Project> getProjects(Object groupIdOrPath, GroupProjectsFilter filter, int itemsPerPage) throws GitLabApiException { GitLabApiForm formData = filter.getQueryParams(); return (new Pager<Project>(this, Project.class, itemsPerPage, formData.asMap(), "groups", getGroupIdOrPath(groupIdOrPath), "projects")); }
java
public Stream<Project> getProjectsStream(Object groupIdOrPath, GroupProjectsFilter filter) throws GitLabApiException { return (getProjects(groupIdOrPath, filter, getDefaultPerPage()).stream()); }
java
public List<Project> getProjects(Object groupIdOrPath) throws GitLabApiException { return (getProjects(groupIdOrPath, getDefaultPerPage()).all()); }
java
public List<Project> getProjects(Object groupIdOrPath, int page, int perPage) throws GitLabApiException { Response response = get(Response.Status.OK, getPageQueryParams(page, perPage), "groups", getGroupIdOrPath(groupIdOrPath), "projects"); return (response.readEntity(new GenericType<List<Project>>() {})); }
java
public Pager<Project> getProjects(Object groupIdOrPath, int itemsPerPage) throws GitLabApiException { return (new Pager<Project>(this, Project.class, itemsPerPage, null, "groups", getGroupIdOrPath(groupIdOrPath), "projects")); }
java
public Group getGroup(Object groupIdOrPath) throws GitLabApiException { Response response = get(Response.Status.OK, null, "groups", getGroupIdOrPath(groupIdOrPath)); return (response.readEntity(Group.class)); }
java
public Optional<Group> getOptionalGroup(Object groupIdOrPath) { try { return (Optional.ofNullable(getGroup(groupIdOrPath))); } catch (GitLabApiException glae) { return (GitLabApi.createOptionalFromException(glae)); } }
java
public void deleteGroup(Object groupIdOrPath) throws GitLabApiException { Response.Status expectedStatus = (isApiVersion(ApiVersion.V3) ? Response.Status.OK : Response.Status.NO_CONTENT); delete(expectedStatus, null, "groups", getGroupIdOrPath(groupIdOrPath)); }
java
public List<Member> getMembers(Object groupIdOrPath) throws GitLabApiException { return (getMembers(groupIdOrPath, getDefaultPerPage()).all()); }
java
public List<Member> getMembers(Object groupIdOrPath, int page, int perPage) throws GitLabApiException { Response response = get(Response.Status.OK, getPageQueryParams(page, perPage), "groups", getGroupIdOrPath(groupIdOrPath), "members"); return (response.readEntity(new GenericType<List<Member>>() {})); }
java
public Pager<Member> getMembers(Object groupIdOrPath, int itemsPerPage) throws GitLabApiException { return (new Pager<Member>(this, Member.class, itemsPerPage, null, "groups", getGroupIdOrPath(groupIdOrPath), "members")); }
java
public Stream<Member> getMembersStream(Object groupIdOrPath) throws GitLabApiException { return (getMembers(groupIdOrPath, getDefaultPerPage()).stream()); }
java
public Member getMember(Object groupIdOrPath, int userId) throws GitLabApiException { Response response = get(Response.Status.OK, getDefaultPerPageParam(), "groups", getGroupIdOrPath(groupIdOrPath), "members", userId); return (response.readEntity(new GenericType<Member>() {})); }
java
public Optional<Member> getOptionalMember(Object groupIdOrPath, int userId) { try { return (Optional.ofNullable(getMember(groupIdOrPath, userId))); } catch (GitLabApiException glae) { return (GitLabApi.createOptionalFromException(glae)); } }
java
public void removeMember(Object groupIdOrPath, Integer userId) throws GitLabApiException { Response.Status expectedStatus = (isApiVersion(ApiVersion.V3) ? Response.Status.OK : Response.Status.NO_CONTENT); delete(expectedStatus, null, "groups", getGroupIdOrPath(groupIdOrPath), "members", userId); }
java
public void ldapSync(Object groupIdOrPath) throws GitLabApiException { post(Response.Status.NO_CONTENT, (Form)null, "groups", getGroupIdOrPath(groupIdOrPath), "ldap_sync"); }
java
public void deleteLdapGroupLink(Object groupIdOrPath, String cn) throws GitLabApiException { if (cn == null || cn.trim().isEmpty()) { throw new RuntimeException("cn cannot be null or empty"); } delete(Response.Status.OK, null, "groups", getGroupIdOrPath(groupIdOrPath), "ldap_group_links", cn); }
java
public void deleteLdapGroupLink(Object groupIdOrPath, String cn, String provider) throws GitLabApiException { if (cn == null || cn.trim().isEmpty()) { throw new RuntimeException("cn cannot be null or empty"); } if (provider == null || provider.trim().isEmpty()) { throw new RuntimeException("LDAP provider cannot be null or empty"); } delete(Response.Status.OK, null, "groups", getGroupIdOrPath(groupIdOrPath), "ldap_group_links", provider, cn); }
java
public List<Variable> getVariables(Object groupIdOrPath, int page, int perPage) throws GitLabApiException { Response response = get(Response.Status.OK, getPageQueryParams(page, perPage), "groups", getGroupIdOrPath(groupIdOrPath), "variables"); return (response.readEntity(new GenericType<List<Variable>>() {})); }
java
public Pager<Variable> getVariables(Object groupIdOrPath, int itemsPerPage) throws GitLabApiException { return (new Pager<Variable>(this, Variable.class, itemsPerPage, null, "groups", getGroupIdOrPath(groupIdOrPath), "variables")); }
java
public Stream<Variable> getVariablesStream(Object groupIdOrPath) throws GitLabApiException { return (getVariables(groupIdOrPath, getDefaultPerPage()).stream()); }
java
public Variable getVariable(Object groupIdOrPath, String key) throws GitLabApiException { Response response = get(Response.Status.OK, null, "groups", getGroupIdOrPath(groupIdOrPath), "variables", key); return (response.readEntity(Variable.class)); }
java
public Optional<Variable> getOptionalVariable(Object groupIdOrPath, String key) { try { return (Optional.ofNullable(getVariable(groupIdOrPath, key))); } catch (GitLabApiException glae) { return (GitLabApi.createOptionalFromException(glae)); } }
java
public Variable createVariable(Object groupIdOrPath, String key, String value, Boolean isProtected) throws GitLabApiException { GitLabApiForm formData = new GitLabApiForm() .withParam("key", key, true) .withParam("value", value, true) .withParam("protected", isProtected); Response response = post(Response.Status.CREATED, formData, "groups", getGroupIdOrPath(groupIdOrPath), "variables"); return (response.readEntity(Variable.class)); }
java
public void deleteVariable(Object groupIdOrPath, String key) throws GitLabApiException { delete(Response.Status.NO_CONTENT, null, "groups", getGroupIdOrPath(groupIdOrPath), "variables", key); }
java
public List<Snippet> getSnippets(boolean downloadContent) throws GitLabApiException { Response response = get(Response.Status.OK, getDefaultPerPageParam(), "snippets"); List<Snippet> snippets = (response.readEntity(new GenericType<List<Snippet>>(){})); if (downloadContent) { for (Snippet snippet : snippets) { snippet.setContent(getSnippetContent(snippet.getId())); } } return snippets; }
java
public Pager<Snippet> getSnippets(int itemsPerPage) throws GitLabApiException { return (new Pager<Snippet>(this, Snippet.class, itemsPerPage, null, "snippets")); }
java
public String getSnippetContent(Integer snippetId) throws GitLabApiException { Response response = get(Response.Status.OK, null, "snippets", snippetId, "raw"); return (response.readEntity(String.class)); }
java
public Snippet getSnippet(Integer snippetId, boolean downloadContent) throws GitLabApiException { if (snippetId == null) { throw new RuntimeException("snippetId can't be null"); } Response response = get(Response.Status.OK, null, "snippets", snippetId); Snippet snippet = response.readEntity(Snippet.class); if (downloadContent) { snippet.setContent(getSnippetContent(snippet.getId())); } return snippet; }
java
public Optional<Snippet> getOptionalSnippet(Integer snippetId, boolean downloadContent) { try { return (Optional.ofNullable(getSnippet(snippetId, downloadContent))); } catch (GitLabApiException glae) { return (GitLabApi.createOptionalFromException(glae)); } }
java
public Snippet createSnippet(String title, String fileName, String content) throws GitLabApiException { GitLabApiForm formData = new GitLabApiForm() .withParam("title", title, true) .withParam("file_name", fileName, true) .withParam("content", content, true); Response response = post(Response.Status.CREATED, formData, "snippets"); return (response.readEntity(Snippet.class)); }
java
public void deleteSnippet(Integer snippetId) throws GitLabApiException { if (snippetId == null) { throw new RuntimeException("snippetId can't be null"); } delete(Response.Status.NO_CONTENT, null, "snippets", snippetId); }
java
public List<DeployKey> getDeployKeys(int page, int perPage) throws GitLabApiException { Response response = get(Response.Status.OK, getPageQueryParams(page, perPage), "deploy_keys"); return (response.readEntity(new GenericType<List<DeployKey>>() {})); }
java
public Pager<DeployKey> getDeployKeys(int itemsPerPage) throws GitLabApiException { return (new Pager<DeployKey>(this, DeployKey.class, itemsPerPage, null, "deploy_keys")); }
java
public List<DeployKey> getProjectDeployKeys(Object projectIdOrPath, int page, int perPage) throws GitLabApiException { Response response = get(Response.Status.OK, getPageQueryParams(page, perPage), "projects", getProjectIdOrPath(projectIdOrPath), "deploy_keys"); return (response.readEntity(new GenericType<List<DeployKey>>() {})); }
java
public Pager<DeployKey> getProjectDeployKeys(Object projectIdOrPath, int itemsPerPage) throws GitLabApiException { return (new Pager<DeployKey>(this, DeployKey.class, itemsPerPage, null, "projects", getProjectIdOrPath(projectIdOrPath), "deploy_keys")); }
java
public DeployKey getDeployKey(Object projectIdOrPath, Integer keyId) throws GitLabApiException { if (keyId == null) { throw new RuntimeException("keyId cannot be null"); } Response response = get(Response.Status.OK, null, "projects", getProjectIdOrPath(projectIdOrPath), "deploy_keys", keyId); return (response.readEntity(DeployKey.class)); }
java
public Optional<DeployKey> getOptionalDeployKey(Object projectIdOrPath, Integer keyId) { try { return (Optional.ofNullable(getDeployKey(projectIdOrPath, keyId))); } catch (GitLabApiException glae) { return (GitLabApi.createOptionalFromException(glae)); } }
java
public DeployKey addDeployKey(Object projectIdOrPath, String title, String key, Boolean canPush) throws GitLabApiException { GitLabApiForm formData = new GitLabApiForm() .withParam("title", title, true) .withParam("key", key, true) .withParam("can_push", canPush); Response response = post(Response.Status.CREATED, formData, "projects", getProjectIdOrPath(projectIdOrPath), "deploy_keys"); return (response.readEntity(DeployKey.class)); }
java
public void deleteDeployKey(Object projectIdOrPath, Integer keyId) throws GitLabApiException { if (keyId == null) { throw new RuntimeException("keyId cannot be null"); } delete(Response.Status.OK, null, "projects", getProjectIdOrPath(projectIdOrPath), "deploy_keys", keyId); }
java
public DeployKey enableDeployKey(Object projectIdOrPath, Integer keyId) throws GitLabApiException { if (keyId == null) { throw new RuntimeException("keyId cannot be null"); } Response response = post(Response.Status.CREATED, (Form)null, "projects", getProjectIdOrPath(projectIdOrPath), "deploy_keys", keyId, "enable"); return (response.readEntity(DeployKey.class)); }
java
public Stream<MergeRequest> getMergeRequestsStream(MergeRequestFilter filter) throws GitLabApiException { return (getMergeRequests(filter, getDefaultPerPage()).stream()); }
java