diff options
author | Gauvain Pocentek <gauvain@pocentek.net> | 2018-05-29 18:46:40 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-29 18:46:40 +0200 |
commit | 01a41efd271dd08d4b5744473fb71a67d9f5dea5 (patch) | |
tree | bc417407e9b6b056d14cb81cd953e572ce0b022b | |
parent | 40b9f4d62d5b9853bfd63317d8ad578b4525e665 (diff) | |
parent | e00cad4f73c43d28799ec6e79e32fd03e58e79b4 (diff) | |
download | gitlab-01a41efd271dd08d4b5744473fb71a67d9f5dea5.tar.gz |
Merge pull request #507 from Miouge1/badges
Add support for Project badges
-rw-r--r-- | gitlab/v4/objects.py | 13 | ||||
-rw-r--r-- | tools/python_test_v4.py | 6 |
2 files changed, 19 insertions, 0 deletions
diff --git a/gitlab/v4/objects.py b/gitlab/v4/objects.py index 55696a0..3223b63 100644 --- a/gitlab/v4/objects.py +++ b/gitlab/v4/objects.py @@ -1394,6 +1394,18 @@ class ProjectKeyManager(CRUDMixin, RESTManager): self.gitlab.http_post(path, **kwargs) +class ProjectBadge(SaveMixin, ObjectDeleteMixin, RESTObject): + pass + + +class ProjectBadgeManager(CRUDMixin, RESTManager): + _path = '/projects/%(project_id)s/badges' + _obj_cls = ProjectBadge + _from_parent_attrs = {'project_id': 'id'} + _create_attrs = (('link_url', 'image_url'), tuple()) + _update_attrs = (('link_url', 'image_url'), tuple()) + + class ProjectEvent(Event): pass @@ -2707,6 +2719,7 @@ class Project(SaveMixin, ObjectDeleteMixin, RESTObject): _short_print_attr = 'path' _managers = ( ('accessrequests', 'ProjectAccessRequestManager'), + ('badges', 'ProjectBadgeManager'), ('boards', 'ProjectBoardManager'), ('branches', 'ProjectBranchManager'), ('jobs', 'ProjectJobManager'), diff --git a/tools/python_test_v4.py b/tools/python_test_v4.py index 558d7ab..70f093d 100644 --- a/tools/python_test_v4.py +++ b/tools/python_test_v4.py @@ -653,6 +653,12 @@ assert(admin_project.star_count == 0) #lists = board.lists.list() #assert(len(lists) == begin_size - 1) +# project badges +badge_image = 'http://example.com' +badge_link = 'http://example/img.svg' +bp = admin_project.badges.create({'link_url': badge_link, 'image_url': badge_image}) +assert(len(admin_project.badges.list()) == 1) + # project wiki wiki_content = 'Wiki page content' wp = admin_project.wikis.create({'title': 'wikipage', 'content': wiki_content}) |