Skip to content

Commit 928b9f0

Browse files
author
Gauvain Pocentek
committed
Merge pull request #45 from mjmaenpaa/labels_files
Classes for ProjectLabels and ProjectFiles
2 parents afe0ab4 + ad63e17 commit 928b9f0

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

gitlab.py

+33
Original file line numberDiff line numberDiff line change
@@ -965,6 +965,29 @@ class ProjectMilestone(GitlabObject):
965965
shortPrintAttr = 'title'
966966

967967

968+
class ProjectLabel(GitlabObject):
969+
_url = '/projects/%(project_id)s/labels'
970+
requiredUrlAttrs = ['project_id']
971+
requiredDeleteAttrs = ['name']
972+
requiredCreateAttrs = ['name', 'color']
973+
# FIXME: new_name is only valid with update
974+
optionalCreateAttrs = ['new_name']
975+
shortPrintAttr = 'name'
976+
977+
978+
class ProjectFile(GitlabObject):
979+
_url = '/projects/%(project_id)s/repository/files'
980+
canList = False
981+
requiredUrlAttrs = ['project_id']
982+
requiredGetAttrs = ['file_path', 'ref']
983+
requiredCreateAttrs = ['file_path', 'branch_name', 'content',
984+
'commit_message']
985+
optionalCreateAttrs = ['encoding']
986+
requiredDeleteAttrs = ['branch_name', 'commit_message']
987+
getListWhenNoId = False
988+
shortPrintAttr = 'name'
989+
990+
968991
class ProjectSnippetNote(GitlabObject):
969992
_url = '/projects/%(project_id)s/snippets/%(snippet_id)s/notes'
970993
_constructorTypes = {'author': 'User'}
@@ -1081,6 +1104,16 @@ def Snippet(self, id=None, **kwargs):
10811104
project_id=self.id,
10821105
**kwargs)
10831106

1107+
def Label(self, id=None, **kwargs):
1108+
return self._getListOrObject(ProjectLabel, id,
1109+
project_id=self.id,
1110+
**kwargs)
1111+
1112+
def File(self, id=None, **kwargs):
1113+
return self._getListOrObject(ProjectFile, id,
1114+
project_id=self.id,
1115+
**kwargs)
1116+
10841117
def Tag(self, id=None, **kwargs):
10851118
return self._getListOrObject(ProjectTag, id,
10861119
project_id=self.id,

0 commit comments

Comments
 (0)