Skip to content

Commit

Permalink
Classes for ProjectLabels and ProjectFiles
Browse files Browse the repository at this point in the history
  • Loading branch information
mjmaenpaa committed Oct 16, 2014
1 parent 221f418 commit ad63e17
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions gitlab.py
Expand Up @@ -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'}
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit ad63e17

Please sign in to comment.