Skip to content

Commit fbd2010

Browse files
author
Gauvain Pocentek
committed
Add support for group boards
1 parent 8374bcc commit fbd2010

File tree

5 files changed

+120
-72
lines changed

5 files changed

+120
-72
lines changed

docs/api-objects.rst

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ API examples
2020
gl_objects/features
2121
gl_objects/groups
2222
gl_objects/issues
23+
gl_objects/boards
2324
gl_objects/labels
2425
gl_objects/notifications
2526
gl_objects/mrs

docs/gl_objects/boards.rst

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
############
2+
Issue boards
3+
############
4+
5+
Boards
6+
======
7+
8+
Boards are a visual representation of existing issues for a project or a group.
9+
Issues can be moved from one list to the other to track progress and help with
10+
priorities.
11+
12+
Reference
13+
---------
14+
15+
* v4 API:
16+
17+
+ :class:`gitlab.v4.objects.ProjectBoard`
18+
+ :class:`gitlab.v4.objects.ProjectBoardManager`
19+
+ :attr:`gitlab.v4.objects.Project.boards`
20+
+ :class:`gitlab.v4.objects.GroupBoard`
21+
+ :class:`gitlab.v4.objects.GroupBoardManager`
22+
+ :attr:`gitlab.v4.objects.Group.boards`
23+
24+
* GitLab API:
25+
26+
+ https://docs.gitlab.com/ce/api/boards.html
27+
+ https://docs.gitlab.com/ce/api/group_boards.html
28+
29+
Examples
30+
--------
31+
32+
Get the list of existing boards for a project or a group::
33+
34+
# item is a Project or a Group
35+
boards = item.boards.list()
36+
37+
Get a single board for a project or a group::
38+
39+
board = group.boards.get(board_id)
40+
41+
.. note::
42+
43+
Boards cannot be created using the API, they need to be created using the
44+
UI.
45+
46+
Board lists
47+
===========
48+
49+
Boards are made of lists of issues. Each list is associated to a label, and
50+
issues tagged with this label automatically belong to the list.
51+
52+
Reference
53+
---------
54+
55+
* v4 API:
56+
57+
+ :class:`gitlab.v4.objects.ProjectBoardList`
58+
+ :class:`gitlab.v4.objects.ProjectBoardListManager`
59+
+ :attr:`gitlab.v4.objects.ProjectBoard.lists`
60+
+ :class:`gitlab.v4.objects.GroupBoardList`
61+
+ :class:`gitlab.v4.objects.GroupBoardListManager`
62+
+ :attr:`gitlab.v4.objects.GroupBoard.lists`
63+
64+
* GitLab API:
65+
66+
+ https://docs.gitlab.com/ce/api/boards.html
67+
+ https://docs.gitlab.com/ce/api/group_boards.html
68+
69+
Examples
70+
--------
71+
72+
List the issue lists for a board::
73+
74+
b_lists = board.lists.list()
75+
76+
Get a single list::
77+
78+
b_list = board.lists.get(list_id)
79+
80+
Create a new list::
81+
82+
# First get a ProjectLabel
83+
label = get_or_create_label()
84+
# Then use its ID to create the new board list
85+
b_list = board.lists.create({'label_id': label.id})
86+
87+
Change a list position. The first list is at position 0. Moving a list will
88+
set it at the given position and move the following lists up a position::
89+
90+
b_list.position = 2
91+
b_list.save()
92+
93+
Delete a list::
94+
95+
b_list.delete()
File renamed without changes.

docs/gl_objects/projects.rst

-72
Original file line numberDiff line numberDiff line change
@@ -565,78 +565,6 @@ Disable a service::
565565

566566
service.delete()
567567

568-
Issue boards
569-
============
570-
571-
Boards are a visual representation of existing issues for a project. Issues can
572-
be moved from one list to the other to track progress and help with
573-
priorities.
574-
575-
Reference
576-
---------
577-
578-
* v4 API:
579-
580-
+ :class:`gitlab.v4.objects.ProjectBoard`
581-
+ :class:`gitlab.v4.objects.ProjectBoardManager`
582-
+ :attr:`gitlab.v4.objects.Project.boards`
583-
584-
* GitLab API: https://docs.gitlab.com/ce/api/boards.html
585-
586-
Examples
587-
--------
588-
589-
Get the list of existing boards for a project::
590-
591-
boards = project.boards.list()
592-
593-
Get a single board for a project::
594-
595-
board = project.boards.get(board_id)
596-
597-
Board lists
598-
===========
599-
600-
Reference
601-
---------
602-
603-
* v4 API:
604-
605-
+ :class:`gitlab.v4.objects.ProjectBoardList`
606-
+ :class:`gitlab.v4.objects.ProjectBoardListManager`
607-
+ :attr:`gitlab.v4.objects.Project.board_lists`
608-
609-
* GitLab API: https://docs.gitlab.com/ce/api/boards.html
610-
611-
Examples
612-
--------
613-
614-
List the issue lists for a board::
615-
616-
b_lists = board.lists.list()
617-
618-
Get a single list::
619-
620-
b_list = board.lists.get(list_id)
621-
622-
Create a new list::
623-
624-
# First get a ProjectLabel
625-
label = get_or_create_label()
626-
# Then use its ID to create the new board list
627-
b_list = board.lists.create({'label_id': label.id})
628-
629-
Change a list position. The first list is at position 0. Moving a list will
630-
set it at the given position and move the following lists up a position::
631-
632-
b_list.position = 2
633-
b_list.save()
634-
635-
Delete a list::
636-
637-
b_list.delete()
638-
639-
640568
File uploads
641569
============
642570

gitlab/v4/objects.py

+24
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,29 @@ class GroupAccessRequestManager(ListMixin, CreateMixin, DeleteMixin,
523523
_from_parent_attrs = {'group_id': 'id'}
524524

525525

526+
class GroupBoardList(SaveMixin, ObjectDeleteMixin, RESTObject):
527+
pass
528+
529+
530+
class GroupBoardListManager(CRUDMixin, RESTManager):
531+
_path = '/groups/%(group_id)s/boards/%(board_id)s/lists'
532+
_obj_cls = GroupBoardList
533+
_from_parent_attrs = {'group_id': 'group_id',
534+
'board_id': 'id'}
535+
_create_attrs = (('label_id', ), tuple())
536+
_update_attrs = (('position', ), tuple())
537+
538+
539+
class GroupBoard(RESTObject):
540+
_managers = (('lists', 'GroupBoardListManager'), )
541+
542+
543+
class GroupBoardManager(RetrieveMixin, RESTManager):
544+
_path = '/groups/%(group_id)s/boards'
545+
_obj_cls = GroupBoard
546+
_from_parent_attrs = {'group_id': 'id'}
547+
548+
526549
class GroupCustomAttribute(ObjectDeleteMixin, RESTObject):
527550
_id_attr = 'key'
528551

@@ -691,6 +714,7 @@ class Group(SaveMixin, ObjectDeleteMixin, RESTObject):
691714
_short_print_attr = 'name'
692715
_managers = (
693716
('accessrequests', 'GroupAccessRequestManager'),
717+
('boards', 'GroupBoardManager'),
694718
('customattributes', 'GroupCustomAttributeManager'),
695719
('issues', 'GroupIssueManager'),
696720
('members', 'GroupMemberManager'),

0 commit comments

Comments
 (0)