Skip to content

Commit

Permalink
Move deploy key enable/disable to the object
Browse files Browse the repository at this point in the history
To keep things consistent with other objects, action methods are
available on the object itself, not the manager.
  • Loading branch information
Gauvain Pocentek committed Nov 5, 2016
1 parent 0c1817f commit c17ecc0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions docs/gl_objects/deploy_keys.py
Expand Up @@ -36,9 +36,9 @@
# end delete

# enable
key = project.keys.enable(key_id)
deploy_key.enable()
# end enable

# disable
key = project.keys.disable(key_id)
deploy_key.disable()
# end disable
18 changes: 9 additions & 9 deletions gitlab/objects.py
Expand Up @@ -1249,21 +1249,21 @@ class ProjectKey(GitlabObject):
requiredUrlAttrs = ['project_id']
requiredCreateAttrs = ['title', 'key']


class ProjectKeyManager(BaseManager):
obj_cls = ProjectKey

def enable(self, key_id):
def enable(self):
"""Enable a deploy key for a project."""
url = '/projects/%s/deploy_keys/%s/enable' % (self.parent.id, key_id)
url = '/projects/%s/deploy_keys/%s/enable' % (self.project_id, self.id)
r = self.gitlab._raw_post(url)
raise_error_from_response(r, GitlabProjectDeployKeyError, 201)

def disable(self, key_id):
def disable(self):
"""Disable a deploy key for a project."""
url = '/projects/%s/deploy_keys/%s/disable' % (self.parent.id, key_id)
url = '/projects/%s/deploy_keys/%s/disable' % (self.project_id, self.id)
r = self.gitlab._raw_delete(url)
raise_error_from_response(r, GitlabProjectDeployKeyError, 201)
raise_error_from_response(r, GitlabProjectDeployKeyError, 200)


class ProjectKeyManager(BaseManager):
obj_cls = ProjectKey


class ProjectEvent(GitlabObject):
Expand Down

0 comments on commit c17ecc0

Please sign in to comment.