summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gitlab/__init__.py22
-rw-r--r--gitlab/objects.py10
2 files changed, 26 insertions, 6 deletions
diff --git a/gitlab/__init__.py b/gitlab/__init__.py
index d702f31..30aad85 100644
--- a/gitlab/__init__.py
+++ b/gitlab/__init__.py
@@ -81,8 +81,10 @@ class Gitlab(object):
builds
project_commits (ProjectCommitManager): Manager for GitLab projects
commits
- project_commitcomments (ProjectCommitCommentManager): Manager for
+ project_commit_comments (ProjectCommitCommentManager): Manager for
GitLab projects commits comments
+ project_commit_statuses (ProjectCommitStatusManager): Manager for
+ GitLab projects commits statuses
project_keys (ProjectKeyManager): Manager for GitLab projects keys
project_events (ProjectEventManager): Manager for GitLab projects
events
@@ -157,6 +159,7 @@ class Gitlab(object):
self.project_builds = ProjectBuildManager(self)
self.project_commits = ProjectCommitManager(self)
self.project_commit_comments = ProjectCommitCommentManager(self)
+ self.project_commit_statuses = ProjectCommitStatusManager(self)
self.project_keys = ProjectKeyManager(self)
self.project_events = ProjectEventManager(self)
self.project_forks = ProjectForkManager(self)
@@ -242,14 +245,24 @@ class Gitlab(object):
"""
self._url = '%s/api/v3' % url
- def _construct_url(self, id_, obj, parameters):
+ def _construct_url(self, id_, obj, parameters, action=None):
if 'next_url' in parameters:
return parameters['next_url']
args = _sanitize(parameters)
+
+ url_attr = '_url'
+ if action is not None:
+ attr = '_%s_url' % action
+ if hasattr(obj, attr):
+ url_attr = attr
+ obj_url = getattr(obj, url_attr)
+
+ # TODO(gpocentek): the following will need an update when we have
+ # object with both urlPlural and _ACTION_url attributes
if id_ is None and obj._urlPlural is not None:
url = obj._urlPlural % args
else:
- url = obj._url % args
+ url = obj_url % args
if id_ is not None:
url = '%s%s/%s' % (self._url, url, str(id_))
@@ -589,7 +602,8 @@ class Gitlab(object):
raise GitlabCreateError('Missing attribute(s): %s' %
", ".join(missing))
- url = self._construct_url(id_=None, obj=obj, parameters=params)
+ url = self._construct_url(id_=None, obj=obj, parameters=params,
+ action='create')
headers = self._create_headers(content_type="application/json")
# build data that can really be sent to server
diff --git a/gitlab/objects.py b/gitlab/objects.py
index 9bfb6ec..ea9f9ab 100644
--- a/gitlab/objects.py
+++ b/gitlab/objects.py
@@ -943,7 +943,8 @@ class ProjectBuildManager(BaseManager):
class ProjectCommitStatus(GitlabObject):
- _url = '/projects/%(project_id)s/statuses/%(commit_id)s'
+ _url = '/projects/%(project_id)s/repository/commits/%(commit_id)s/statuses'
+ _create_url = '/projects/%(project_id)s/statuses/%(commit_id)s'
canUpdate = False
canDelete = False
requiredUrlAttrs = ['project_id', 'commit_id']
@@ -979,6 +980,8 @@ class ProjectCommit(GitlabObject):
requiredUrlAttrs = ['project_id']
shortPrintAttr = 'title'
managers = [('comments', ProjectCommitCommentManager,
+ [('project_id', 'project_id'), ('commit_id', 'id')]),
+ ('statuses', ProjectCommitStatusManager,
[('project_id', 'project_id'), ('commit_id', 'id')])]
def diff(self, **kwargs):
@@ -1623,7 +1626,10 @@ class Project(GitlabObject):
('branches', ProjectBranchManager, [('project_id', 'id')]),
('builds', ProjectBuildManager, [('project_id', 'id')]),
('commits', ProjectCommitManager, [('project_id', 'id')]),
- ('commitstatuses', ProjectCommitStatusManager, [('project_id', 'id')]),
+ ('commit_comments', ProjectCommitCommentManager,
+ [('project_id', 'id')]),
+ ('commit_statuses', ProjectCommitStatusManager,
+ [('project_id', 'id')]),
('events', ProjectEventManager, [('project_id', 'id')]),
('files', ProjectFileManager, [('project_id', 'id')]),
('forks', ProjectForkManager, [('project_id', 'id')]),