Skip to content

Commit c17ecc0

Browse files
author
Gauvain Pocentek
committed
Move deploy key enable/disable to the object
To keep things consistent with other objects, action methods are available on the object itself, not the manager.
1 parent 0c1817f commit c17ecc0

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

docs/gl_objects/deploy_keys.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@
3636
# end delete
3737

3838
# enable
39-
key = project.keys.enable(key_id)
39+
deploy_key.enable()
4040
# end enable
4141

4242
# disable
43-
key = project.keys.disable(key_id)
43+
deploy_key.disable()
4444
# end disable

gitlab/objects.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -1249,21 +1249,21 @@ class ProjectKey(GitlabObject):
12491249
requiredUrlAttrs = ['project_id']
12501250
requiredCreateAttrs = ['title', 'key']
12511251

1252-
1253-
class ProjectKeyManager(BaseManager):
1254-
obj_cls = ProjectKey
1255-
1256-
def enable(self, key_id):
1252+
def enable(self):
12571253
"""Enable a deploy key for a project."""
1258-
url = '/projects/%s/deploy_keys/%s/enable' % (self.parent.id, key_id)
1254+
url = '/projects/%s/deploy_keys/%s/enable' % (self.project_id, self.id)
12591255
r = self.gitlab._raw_post(url)
12601256
raise_error_from_response(r, GitlabProjectDeployKeyError, 201)
12611257

1262-
def disable(self, key_id):
1258+
def disable(self):
12631259
"""Disable a deploy key for a project."""
1264-
url = '/projects/%s/deploy_keys/%s/disable' % (self.parent.id, key_id)
1260+
url = '/projects/%s/deploy_keys/%s/disable' % (self.project_id, self.id)
12651261
r = self.gitlab._raw_delete(url)
1266-
raise_error_from_response(r, GitlabProjectDeployKeyError, 201)
1262+
raise_error_from_response(r, GitlabProjectDeployKeyError, 200)
1263+
1264+
1265+
class ProjectKeyManager(BaseManager):
1266+
obj_cls = ProjectKey
12671267

12681268

12691269
class ProjectEvent(GitlabObject):

0 commit comments

Comments
 (0)