Skip to content

Commit ad63e17

Browse files
committed
Classes for ProjectLabels and ProjectFiles
1 parent 221f418 commit ad63e17

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
@@ -908,6 +908,29 @@ class ProjectMilestone(GitlabObject):
908908
shortPrintAttr = 'title'
909909

910910

911+
class ProjectLabel(GitlabObject):
912+
_url = '/projects/%(project_id)s/labels'
913+
requiredUrlAttrs = ['project_id']
914+
requiredDeleteAttrs = ['name']
915+
requiredCreateAttrs = ['name', 'color']
916+
# FIXME: new_name is only valid with update
917+
optionalCreateAttrs = ['new_name']
918+
shortPrintAttr = 'name'
919+
920+
921+
class ProjectFile(GitlabObject):
922+
_url = '/projects/%(project_id)s/repository/files'
923+
canList = False
924+
requiredUrlAttrs = ['project_id']
925+
requiredGetAttrs = ['file_path', 'ref']
926+
requiredCreateAttrs = ['file_path', 'branch_name', 'content',
927+
'commit_message']
928+
optionalCreateAttrs = ['encoding']
929+
requiredDeleteAttrs = ['branch_name', 'commit_message']
930+
getListWhenNoId = False
931+
shortPrintAttr = 'name'
932+
933+
911934
class ProjectSnippetNote(GitlabObject):
912935
_url = '/projects/%(project_id)s/snippets/%(snippet_id)s/notes'
913936
_constructorTypes = {'author': 'User'}
@@ -1025,6 +1048,16 @@ def Snippet(self, id=None, **kwargs):
10251048
project_id=self.id,
10261049
**kwargs)
10271050

1051+
def Label(self, id=None, **kwargs):
1052+
return self._getListOrObject(ProjectLabel, id,
1053+
project_id=self.id,
1054+
**kwargs)
1055+
1056+
def File(self, id=None, **kwargs):
1057+
return self._getListOrObject(ProjectFile, id,
1058+
project_id=self.id,
1059+
**kwargs)
1060+
10281061
def Tag(self, id=None, **kwargs):
10291062
return self._getListOrObject(ProjectTag, id,
10301063
project_id=self.id,

0 commit comments

Comments
 (0)