1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
|
# frozen_string_literal: true
class Gitlab::Client
# Defines methods related to issue boards.
# @see https://docs.gitlab.com/ce/api/boards.html
module Boards
# Gets a list of project's boards.
#
# @example
# Gitlab.boards(5)
# Gitlab.boards({ per_page: 40 })
#
# @param [Integer, String] project The ID or name of a project.
# @param [Hash] options A customizable set of options.
# @option options [Integer] :page The page number.
# @option options [Integer] :per_page The number of results per page.
# @return [Array<Gitlab::ObjectifiedHash>]
def boards(project, options = {})
get("/projects/#{url_encode project}/boards", query: options)
end
# Get a single board.
#
# @example
# Gitlab.board(5, 1)
#
# @param [Integer, String] project The ID or name of a project.
# @param [Integer] id The ID of a board.
# @return [Gitlab::ObjectifiedHash] Returns information about the board
def board(project, id)
get("/projects/#{url_encode project}/boards/#{id}")
end
# Creates a new board.
#
# @example
# Gitlab.create_board(5, 'newboard')
#
# @param [Integer, String] project The ID or name of a project.
# @param [String] name The name of the new board.
# @return [Gitlab::ObjectifiedHash] Information about created board.
def create_board(project, name)
body = { name: name }
post("/projects/#{url_encode project}/boards", body: body)
end
# Updates a board.
#
# @example
# Gitlab.edit_board(5, 1, name: 'new_name')
# Gitlab.edit_board(5, 1, name: 'new_name', assignee_id: 1, milestone_id: 1)
#
# @param [Integer, String] project The ID or name of a project.
# @param [Integer] id The ID of a board.
# @param [Hash] options A customizable set of options.
# @option options [String] :name(optional) The new name of the board.
# @option options [Integer] :assignee_id(optional) The assignee the board should be scoped to.
# @option options [Integer] :milestone_id(optional) The milestone the board should be scoped to.
# @option options [String] :labels(optional) Comma-separated list of label names which the board should be scoped to.
# @option options [Integer] :weight(optional) The weight range from 0 to 9, to which the board should be scoped to.
# @return [Gitlab::ObjectifiedHash] Information about updated board.
def edit_board(project, id, options = {})
put("/projects/#{url_encode project}/boards/#{id}", body: options)
end
# Deletes a board.
#
# @example
# Gitlab.delete_board(5, 1)
#
# @param [Integer, String] project The ID or name of a project.
# @param [Integer] id The ID of a board.
# @return [void] This API call returns an empty response body.
def delete_board(project, id)
delete("/projects/#{url_encode project}/boards/#{id}")
end
# Gets a board lists
#
# @example
# Gitlab.board_lists(5, 42)
#
# @param [Integer, String] project The ID or name of a project.
# @param [Integer] id The ID of a board.
# @return [Gitlab::ObjectifiedHash]
def board_lists(project, id)
get("/projects/#{url_encode project}/boards/#{id}/lists")
end
#
# Gets a single board list
#
# @example
# Gitlab.board_list(5, 42, 25)
#
# @param [Integer, String] project The ID or name of a project.
# @param [Integer] board_id The ID of a board.
# @param [Integer] id The ID of a list.
# @return [Gitlab::ObjectifiedHash]
def board_list(project, board_id, id)
get("/projects/#{url_encode project}/boards/#{board_id}/lists/#{id}")
end
# Creates a new board list.
# Only for admins and project owners
#
# @example
# Gitlab.create_board_list(5, 42, 25)
#
# @param [Integer, String] project The ID or name of a project.
# @param [Integer] id The ID of a board.
# @param [Integer] label_id The ID of a label.
# @return [Gitlab::ObjectifiedHash] Information about created list.
def create_board_list(project, board_id, label_id)
post("/projects/#{url_encode project}/boards/#{board_id}/lists", body: { label_id: label_id })
end
# Updates a board list.
# Only for admins and project owners
#
# @example
# Gitlab.edit_board_list(6, 1, 12, 5)
#
# @param [Integer, String] project The ID or name of a project.
# @param [Integer] board_id The ID of a board.
# @param [Integer] id The ID of a list.
# @return [Gitlab::ObjectifiedHash] Information about updated board list.
def edit_board_list(project, board_id, id, position)
put("/projects/#{url_encode project}/boards/#{board_id}/lists/#{id}", body: { position: position })
end
# Deletes a board list.
# Only for admins and project owners
#
# @example
# Gitlab.delete_board_list(3, 42, 32)
#
# @param [Integer, String] project The ID or name of a project.
# @param [Integer] board_id The ID of a board.
# @param [Integer] id The ID of a list.
# @return [Gitlab::ObjectifiedHash] Information about deleted board list.
def delete_board_list(project, board_id, id)
delete("/projects/#{url_encode project}/boards/#{board_id}/lists/#{id}")
end
end
end
|