Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/gitlab/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class Client < API
include Environments
include Events
include Features
include GroupBoards
include GroupLabels
include GroupMilestones
include Groups
Expand Down
141 changes: 141 additions & 0 deletions lib/gitlab/client/group_boards.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
# frozen_string_literal: true

class Gitlab::Client
# Defines methods related to group issue boards.
# @see https://docs.gitlab.com/ee/api/group_boards.html
module GroupBoards
# Lists Issue Boards in the given group.
#
# @example
# Gitlab.group_boards(5)
#
# @param [Integer, String] group The ID or name of a group.
# @return [Array<Gitlab::ObjectifiedHash>] List of issue boards of the group
def group_boards(group)
get("/groups/#{url_encode group}/boards")
end

# Gets a single group issue board.
#
# @example
# Gitlab.group_board(5, 1)
#
# @param [Integer, String] group The ID or name of a group.
# @param [Integer] id The ID of the issue board.
# @return [Gitlab::ObjectifiedHash] Returns information about a group issue board
def group_board(group, id)
get("/groups/#{url_encode group}/boards/#{id}")
end

# Creates a new group issue board.
#
# @example
# Gitlab.create_group_board(5, 'Documentcloud')
#
# @param [Integer, String] group The ID or name of a group.
# @param [String] name The name of the new board.
# @return [Gitlab::ObjectifiedHash] Information about created group issue board.
def create_group_board(group, name)
body = { name: name }
post("/groups/#{url_encode group}/boards", body: body)
end

# Updates a group issue board.
#
# @example
# Gitlab.edit_group_board(5, 1, { name: 'DocumentCloud2' })
# Gitlab.edit_group_board(5, 1, { name: 'DocumentCloud2', assignee_id: 3 })
#
# @param [Integer, String] group The ID or name of a group.
# @param [Integer] id The ID of the issue 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 group issue board.
def edit_group_board(group, id, options = {})
put("/groups/#{url_encode group}/boards/#{id}", body: options)
end

# Deletes a group issue board.
#
# @example
# Gitlab.delete_group_board(5, 1)
#
# @param [Integer, String] group The ID or name of a group.
# @param [Integer] id The ID of the issue board.
# @return [void] This API call returns an empty response body.
def delete_group_board(group, id)
delete("/groups/#{url_encode group}/boards/#{id}")
end

# Get a list of the boards lists. Does not include open and closed lists
#
# @example
# Gitlab.group_board_lists(5, 1)
#
# @param [Integer, String] group The ID or name of a group.
# @param [Integer] board_id The ID of the group issue board.
# @return [Array<Gitlab::ObjectifiedHash>] List of boards lists of the group
def group_board_lists(group, board_id)
get("/groups/#{url_encode group}/boards/#{board_id}/lists")
end

# Get a single group issue board list.
#
# @example
# Gitlab.group_board_list(5, 1, 1)
#
# @param [Integer, String] group The ID or name of a group.
# @param [Integer] board_id The ID of the group issue board.
# @param [Integer] list_id The ID of a boards list.
# @return [Gitlab::ObjectifiedHash] Returns information about a single group issue board list
def group_board_list(group, board_id, id)
get("/groups/#{url_encode group}/boards/#{board_id}/lists/#{id}")
end

# Creates a new group issue board list.
#
# @example
# Gitlab.create_group_board_list(5, 1)
#
# @param [Integer, String] group The ID or name of a group.
# @param [Integer] board_id The ID of the group issue board.
# @param [Integer] label_id The ID of a label.
# @return [Gitlab::ObjectifiedHash] Information about created group issue board list.
def create_group_board_list(group, board_id, label_id)
body = { label_id: label_id }
post("/groups/#{url_encode group}/boards/#{board_id}/lists", body: body)
end

# Updates an existing group issue board list. This call is used to change list position.
#
# @example
# Gitlab.edit_group_board_list(5, 1, 1, { position: 1 })
#
# @param [Integer, String] group The ID or name of a group.
# @param [Integer] board_id The ID of the group issue board.
# @param [Integer] list_id The ID of a boards list.
# @param [Hash] options A customizable set of options.
# @option options [String] :position(required) The position of the list.
# @return [Gitlab::ObjectifiedHash] Information about updated group issue board list.
def edit_group_board_list(group, board_id, id, options = {})
put("/groups/#{url_encode group}/boards/#{board_id}/lists/#{id}", body: options)
end

# Deletes a group issue board list.
#
# @example
# Gitlab.delete_group_board_list(5, 1, 1)
#
# @param [Integer, String] group The ID or name of a group.
# @param [Integer] board_id The ID of the group issue board.
# @param [Integer] list_id The ID of a boards list.
# @return [void] This API call returns an empty response body.
def delete_group_board_list(group, board_id, id)
delete("/groups/#{url_encode group}/boards/#{board_id}/lists/#{id}")
end
end
end
67 changes: 67 additions & 0 deletions spec/fixtures/group_board.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"id": 1,
"name": "group issue board",
"group": {
"id": 5,
"name": "Documentcloud",
"path": "documentcloud",
"owner_id": null,
"created_at": "2018-05-07T06:52:45.788Z",
"updated_at": "2018-07-03T06:48:17.005Z",
"description": "Consequatur aut a aperiam ut.",
"avatar": {
"url": null
},
"membership_lock": false,
"share_with_group_lock": false,
"visibility_level": 20,
"request_access_enabled": false,
"ldap_sync_status": "ready",
"ldap_sync_error": null,
"ldap_sync_last_update_at": null,
"ldap_sync_last_successful_update_at": null,
"ldap_sync_last_sync_at": null,
"lfs_enabled": null,
"parent_id": null,
"shared_runners_minutes_limit": null,
"repository_size_limit": null,
"require_two_factor_authentication": false,
"two_factor_grace_period": 48,
"plan_id": null,
"project_creation_level": 2,
"runners_token": "rgeeL-nv4wa9YdRvuMid"
},
"milestone": {
"id": 12,
"title": "10.0"
},
"lists" : [
{
"id" : 1,
"label" : {
"name" : "Testing",
"color" : "#F0AD4E",
"description" : null
},
"position" : 1
},
{
"id" : 2,
"label" : {
"name" : "Ready",
"color" : "#FF0000",
"description" : null
},
"position" : 2
},
{
"id" : 3,
"label" : {
"name" : "Production",
"color" : "#FF5F00",
"description" : null
},
"position" : 3
}
]
}
9 changes: 9 additions & 0 deletions spec/fixtures/group_board_list.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"id" : 1,
"label" : {
"name" : "Testing",
"color" : "#F0AD4E",
"description" : null
},
"position" : 1
}
29 changes: 29 additions & 0 deletions spec/fixtures/group_board_lists.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[
{
"id" : 1,
"label" : {
"name" : "Testing",
"color" : "#F0AD4E",
"description" : null
},
"position" : 1
},
{
"id" : 2,
"label" : {
"name" : "Ready",
"color" : "#FF0000",
"description" : null
},
"position" : 2
},
{
"id" : 3,
"label" : {
"name" : "Production",
"color" : "#FF5F00",
"description" : null
},
"position" : 3
}
]
69 changes: 69 additions & 0 deletions spec/fixtures/group_boards.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
[
{
"id": 1,
"name": "group issue board",
"group": {
"id": 5,
"name": "Documentcloud",
"path": "documentcloud",
"owner_id": null,
"created_at": "2018-05-07T06:52:45.788Z",
"updated_at": "2018-07-03T06:48:17.005Z",
"description": "Consequatur aut a aperiam ut.",
"avatar": {
"url": null
},
"membership_lock": false,
"share_with_group_lock": false,
"visibility_level": 20,
"request_access_enabled": false,
"ldap_sync_status": "ready",
"ldap_sync_error": null,
"ldap_sync_last_update_at": null,
"ldap_sync_last_successful_update_at": null,
"ldap_sync_last_sync_at": null,
"lfs_enabled": null,
"parent_id": null,
"shared_runners_minutes_limit": null,
"repository_size_limit": null,
"require_two_factor_authentication": false,
"two_factor_grace_period": 48,
"plan_id": null,
"project_creation_level": 2,
"runners_token": "rgeeL-nv4wa9YdRvuMid"
},
"milestone": {
"id": 12,
"title": "10.0"
},
"lists" : [
{
"id" : 1,
"label" : {
"name" : "Testing",
"color" : "#F0AD4E",
"description" : null
},
"position" : 1
},
{
"id" : 2,
"label" : {
"name" : "Ready",
"color" : "#FF0000",
"description" : null
},
"position" : 2
},
{
"id" : 3,
"label" : {
"name" : "Production",
"color" : "#FF5F00",
"description" : null
},
"position" : 3
}
]
}
]
64 changes: 64 additions & 0 deletions spec/fixtures/updated_group_board.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"id": 1,
"project": null,
"lists": [],
"name": "new_name",
"group": {
"id": 5,
"name": "Documentcloud",
"path": "documentcloud",
"owner_id": null,
"created_at": "2018-05-07T06:52:45.788Z",
"updated_at": "2018-07-03T06:48:17.005Z",
"description": "Consequatur aut a aperiam ut.",
"avatar": {
"url": null
},
"membership_lock": false,
"share_with_group_lock": false,
"visibility_level": 20,
"request_access_enabled": false,
"ldap_sync_status": "ready",
"ldap_sync_error": null,
"ldap_sync_last_update_at": null,
"ldap_sync_last_successful_update_at": null,
"ldap_sync_last_sync_at": null,
"lfs_enabled": null,
"parent_id": null,
"shared_runners_minutes_limit": null,
"repository_size_limit": null,
"require_two_factor_authentication": false,
"two_factor_grace_period": 48,
"plan_id": null,
"project_creation_level": 2,
"runners_token": "rgeeL-nv3wa6YdRvuMid"
},
"milestone": {
"id": 44,
"iid": 1,
"group_id": 5,
"title": "Group Milestone",
"description": "Group Milestone Desc",
"state": "active",
"created_at": "2018-07-03T07:15:19.271Z",
"updated_at": "2018-07-03T07:15:19.271Z",
"due_date": null,
"start_date": null,
"web_url": "http://example.com/groups/documentcloud/-/milestones/1"
},
"assignee": {
"id": 1,
"name": "Administrator",
"username": "root",
"state": "active",
"avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
"web_url": "http://example.com/root"
},
"labels": [{
"id": 11,
"name": "GroupLabel",
"color": "#428BCA",
"description": ""
}],
"weight": 4
}
Loading