All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.gitlab4j.api.TodosApi Maven / Gradle / Ivy

Go to download

GitLab4J-API (gitlab4j-api) provides a full featured Java client library for working with GitLab repositories and servers via the GitLab REST API.

There is a newer version: 6.0.0-rc.6
Show newest version
package org.gitlab4j.api;

import java.util.List;
import java.util.stream.Stream;

import javax.ws.rs.core.Response;

import org.gitlab4j.api.models.Todo;

/**
 * This class implements the client side API for the GitLab Todos API.
 */
public class TodosApi extends AbstractApi {

    public TodosApi(GitLabApi gitLabApi) {
        super(gitLabApi);
    }

    /**
     * Get a List of pending todos for the current user.
     *
     * 
GitLab Endpoint: GET /todos
* * @return a List of pending Todos for the current user * @throws GitLabApiException if any exception occurs */ public List getPendingTodos() throws GitLabApiException { return (getTodos(null, null, null, null, TodoState.PENDING, null, getDefaultPerPage()).all()); } /** * Get a Pager of pending todos for the current user. * *
GitLab Endpoint: GET /todos
* * @param itemsPerPage the number of todo that will be fetched per page * @return a Pager containing the pending Todos for the current user * @throws GitLabApiException if any exception occurs */ public Pager getPendingTodos(int itemsPerPage) throws GitLabApiException { return (getTodos(null, null, null, null, TodoState.PENDING, null, itemsPerPage)); } /** * Get a Stream of pending todos for the current user. * *
GitLab Endpoint: GET /todos
* * @return a Stream containing the pending Todos for the user * @throws GitLabApiException if any exception occurs */ public Stream getPendingTodosStream() throws GitLabApiException { return (getTodos(null, null, null, null, TodoState.PENDING, null, getDefaultPerPage()).stream()); } /** * Get a List of done todos for the current user. * *
GitLab Endpoint: GET /todos
* * @return a List of done Todos for the current user * @throws GitLabApiException if any exception occurs */ public List getDoneTodos() throws GitLabApiException { return (getTodos(null, null, null, null, TodoState.DONE, null, getDefaultPerPage()).all()); } /** * Get a Pager of done todos for the current user. * *
GitLab Endpoint: GET /todos
* * @param itemsPerPage the number of todo that will be fetched per page * @return a Pager containing the done Todos for the current user * @throws GitLabApiException if any exception occurs */ public Pager getDoneTodos(int itemsPerPage) throws GitLabApiException { return (getTodos(null, null, null, null, TodoState.DONE, null, itemsPerPage)); } /** * Get a Stream of done todos for the current user. * *
GitLab Endpoint: GET /todos
* * @return a Stream containing the done Todos for the current user * @throws GitLabApiException if any exception occurs */ public Stream getDoneTodosStream() throws GitLabApiException { return (getTodos(null, null, null, null, TodoState.DONE, null, getDefaultPerPage()).stream()); } /** * Get a List of all todos that match the provided filter params. * *
GitLab Endpoint: GET /todos
* * @param action the action to be filtered. Can be assigned, mentioned, build_failed, marked, approval_required, unmergeable or directly_addressed. * @param authorId the ID of an author * @param projectId the ID of a project * @param groupId the ID of a group * @param state the state of the todo. Can be either pending or done * @param type the type of a todo. Can be either Issue or MergeRequest * @return Stream of Todo instances * @throws GitLabApiException if any exception occurs */ public List getTodos(TodoAction action, Long authorId, Long projectId, Long groupId, TodoState state, TodoType type) throws GitLabApiException { return (getTodos(action, authorId, projectId, groupId, state, type, getDefaultPerPage()).all()); } /** * Get a List of all todos that match the provided filter params. * *
GitLab Endpoint: GET /todos
* * @param action the action to be filtered. Can be assigned, mentioned, build_failed, marked, approval_required, unmergeable or directly_addressed. * @param authorId the ID of an author * @param projectId the ID of a project * @param groupId the ID of a group * @param state the state of the todo. Can be either pending or done * @param type the type of a todo. Can be either Issue or MergeRequest * @return Stream of Todo instances * @throws GitLabApiException if any exception occurs */ public Stream getTodosStream(TodoAction action, Long authorId, Long projectId, Long groupId, TodoState state, TodoType type) throws GitLabApiException { return (getTodos(action, authorId, projectId, groupId, state, type, getDefaultPerPage()).stream()); } /** * Returns a Pager of todos that match the provided filter params. When no filter params are provided, * will returns all pending todos for the current user. * *
GitLab Endpoint: GET /todos
* * @param action the action to be filtered. Can be assigned, mentioned, build_failed, marked, approval_required, * unmergeable or directly_addressed. * @param authorId the ID of an author * @param projectId the ID of a project * @param groupId the ID of a group * @param state the state of the todo. Can be either pending or done * @param type the type of a todo. Can be either Issue or MergeRequest * @param itemsPerPage the number of todo that will be fetched per page * @return a list of pages in todo for the specified range * @throws GitLabApiException if any exception occurs */ public Pager getTodos(TodoAction action, Long authorId, Long projectId, Long groupId, TodoState state, TodoType type, int itemsPerPage) throws GitLabApiException { GitLabApiForm formData = new GitLabApiForm() .withParam("action", action, false) .withParam("author_id", authorId, false) .withParam("project_id", projectId, false) .withParam("group_id", groupId, false) .withParam("state", state, false) .withParam("type", type, false); return (new Pager(this, Todo.class, itemsPerPage, formData.asMap(), "todos")); } /** * Marks a single pending todo given by its ID for the current user as done. * The todo marked as done is returned in the response. * *
GitLab Endpoint: POST /todos/:id/mark_as_done
* * @param todoId the ID of a todo * @return todo instance with info on the created page * @throws GitLabApiException if any exception occurs */ public Todo markAsDone(Long todoId) throws GitLabApiException { GitLabApiForm formData = new GitLabApiForm(); Response response = post(Response.Status.OK, formData, "todos", todoId, "mark_as_done"); return (response.readEntity(Todo.class)); } /** * Marks all pending todos for the current user as done. * *
GitLab Endpoint: POST /todos/mark_as_done
* * @throws GitLabApiException if any exception occurs */ public void markAllAsDone() throws GitLabApiException { GitLabApiForm formData = new GitLabApiForm(); post(Response.Status.NO_CONTENT, formData, "todos", "mark_as_done"); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy