From ad63e17ce7b6fd8c8eef993a44a1b18cc73fc4be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=20M=C3=A4enp=C3=A4=C3=A4?= Date: Thu, 9 Oct 2014 13:30:09 +0300 Subject: [PATCH] Classes for ProjectLabels and ProjectFiles --- gitlab.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/gitlab.py b/gitlab.py index 43ba54397..ed9243ee2 100644 --- a/gitlab.py +++ b/gitlab.py @@ -908,6 +908,29 @@ class ProjectMilestone(GitlabObject): shortPrintAttr = 'title' +class ProjectLabel(GitlabObject): + _url = '/projects/%(project_id)s/labels' + requiredUrlAttrs = ['project_id'] + requiredDeleteAttrs = ['name'] + requiredCreateAttrs = ['name', 'color'] + # FIXME: new_name is only valid with update + optionalCreateAttrs = ['new_name'] + shortPrintAttr = 'name' + + +class ProjectFile(GitlabObject): + _url = '/projects/%(project_id)s/repository/files' + canList = False + requiredUrlAttrs = ['project_id'] + requiredGetAttrs = ['file_path', 'ref'] + requiredCreateAttrs = ['file_path', 'branch_name', 'content', + 'commit_message'] + optionalCreateAttrs = ['encoding'] + requiredDeleteAttrs = ['branch_name', 'commit_message'] + getListWhenNoId = False + shortPrintAttr = 'name' + + class ProjectSnippetNote(GitlabObject): _url = '/projects/%(project_id)s/snippets/%(snippet_id)s/notes' _constructorTypes = {'author': 'User'} @@ -1025,6 +1048,16 @@ def Snippet(self, id=None, **kwargs): project_id=self.id, **kwargs) + def Label(self, id=None, **kwargs): + return self._getListOrObject(ProjectLabel, id, + project_id=self.id, + **kwargs) + + def File(self, id=None, **kwargs): + return self._getListOrObject(ProjectFile, id, + project_id=self.id, + **kwargs) + def Tag(self, id=None, **kwargs): return self._getListOrObject(ProjectTag, id, project_id=self.id,