Skip to content

Commit e00cad4

Browse files
committed
Add support for Project badges
1 parent 97c8619 commit e00cad4

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

gitlab/v4/objects.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,6 +1250,18 @@ def enable(self, key_id, **kwargs):
12501250
self.gitlab.http_post(path, **kwargs)
12511251

12521252

1253+
class ProjectBadge(SaveMixin, ObjectDeleteMixin, RESTObject):
1254+
pass
1255+
1256+
1257+
class ProjectBadgeManager(CRUDMixin, RESTManager):
1258+
_path = '/projects/%(project_id)s/badges'
1259+
_obj_cls = ProjectBadge
1260+
_from_parent_attrs = {'project_id': 'id'}
1261+
_create_attrs = (('link_url', 'image_url'), tuple())
1262+
_update_attrs = (('link_url', 'image_url'), tuple())
1263+
1264+
12531265
class ProjectEvent(Event):
12541266
pass
12551267

@@ -2472,6 +2484,7 @@ class Project(SaveMixin, ObjectDeleteMixin, RESTObject):
24722484
_short_print_attr = 'path'
24732485
_managers = (
24742486
('accessrequests', 'ProjectAccessRequestManager'),
2487+
('badges', 'ProjectBadgeManager'),
24752488
('boards', 'ProjectBoardManager'),
24762489
('branches', 'ProjectBranchManager'),
24772490
('jobs', 'ProjectJobManager'),

tools/python_test_v4.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,12 @@
583583
#lists = board.lists.list()
584584
#assert(len(lists) == begin_size - 1)
585585

586+
# project badges
587+
badge_image = 'http://example.com'
588+
badge_link = 'http://example/img.svg'
589+
bp = admin_project.badges.create({'link_url': badge_link, 'image_url': badge_image})
590+
assert(len(admin_project.badges.list()) == 1)
591+
586592
# project wiki
587593
wiki_content = 'Wiki page content'
588594
wp = admin_project.wikis.create({'title': 'wikipage', 'content': wiki_content})

0 commit comments

Comments
 (0)