File tree Expand file tree Collapse file tree 3 files changed +26
-11
lines changed
Expand file tree Collapse file tree 3 files changed +26
-11
lines changed Original file line number Diff line number Diff line change 3636# end delete
3737
3838# enable
39- deploy_key . enable ()
39+ project . keys . enable (key_id )
4040# end enable
4141
4242# disable
43- deploy_key . disable ()
43+ project . keys . disable (key_id )
4444# end disable
Original file line number Diff line number Diff line change @@ -1366,24 +1366,23 @@ class ProjectKey(GitlabObject):
13661366 requiredUrlAttrs = ['project_id' ]
13671367 requiredCreateAttrs = ['title' , 'key' ]
13681368
1369- def enable (self ):
1369+
1370+ class ProjectKeyManager (BaseManager ):
1371+ obj_cls = ProjectKey
1372+
1373+ def enable (self , key_id ):
13701374 """Enable a deploy key for a project."""
1371- url = '/projects/%s/deploy_keys/%s/enable' % (self .project_id , self .id )
1375+ url = '/projects/%s/deploy_keys/%s/enable' % (self .parent .id , key_id )
13721376 r = self .gitlab ._raw_post (url )
13731377 raise_error_from_response (r , GitlabProjectDeployKeyError , 201 )
13741378
1375- def disable (self ):
1379+ def disable (self , key_id ):
13761380 """Disable a deploy key for a project."""
1377- url = '/projects/%s/deploy_keys/%s/disable' % (self .project_id ,
1378- self .id )
1381+ url = '/projects/%s/deploy_keys/%s/disable' % (self .parent .id , key_id )
13791382 r = self .gitlab ._raw_delete (url )
13801383 raise_error_from_response (r , GitlabProjectDeployKeyError , 200 )
13811384
13821385
1383- class ProjectKeyManager (BaseManager ):
1384- obj_cls = ProjectKey
1385-
1386-
13871386class ProjectEvent (GitlabObject ):
13881387 _url = '/projects/%(project_id)s/events'
13891388 canGet = 'from_list'
Original file line number Diff line number Diff line change 1212 "a6WP5lTi/HJIjAl6Hu+zHgdj1XVExeH+S52EwpZf/ylTJub0Bl5gHwf/siVE48mLMI"
1313 "sqrukXTZ6Zg+8EHAIvIQwJ1dKcXe8P5IoLT7VKrbkgAnolS0I8J+uH7KtErZJb5oZh"
1414 "S4OEwsNpaXMAr+6/wWSpircV2/e7sFLlhlKBC4Iq1MpqlZ7G3p foo@bar" )
15+ DEPLOY_KEY = ("ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDFdRyjJQh+1niBpXqE2I8dzjG"
16+ "MXFHlRjX9yk/UfOn075IdaockdU58sw2Ai1XIWFpZpfJkW7z+P47ZNSqm1gzeXI"
17+ "rtKa9ZUp8A7SZe8vH4XVn7kh7bwWCUirqtn8El9XdqfkzOs/+FuViriUWoJVpA6"
18+ "WZsDNaqINFKIA5fj/q8XQw+BcS92L09QJg9oVUuH0VVwNYbU2M2IRmSpybgC/gu"
19+ "uWTrnCDMmLItksATifLvRZwgdI8dr+q6tbxbZknNcgEPrI2jT0hYN9ZcjNeWuyv"
20+ "rke9IepE7SPBT41C+YtUX4dfDZDmczM1cE0YL/krdUCfuZHMa4ZS2YyNd6slufc"
21+ "vn bar@foo" )
1522
1623# login/password authentication
1724gl = gitlab .Gitlab ('http://localhost:8080' , email = LOGIN , password = PASSWORD )
183190archive2 = admin_project .repository_archive ('master' )
184191assert (archive1 == archive2 )
185192
193+ # deploy keys
194+ deploy_key = admin_project .keys .create ({'title' : 'foo@bar' , 'key' : DEPLOY_KEY })
195+ project_keys = admin_project .keys .list ()
196+ assert (len (project_keys ) == 1 )
197+ sudo_project .keys .enable (deploy_key .id )
198+ assert (len (sudo_project .keys .list ()) == 1 )
199+ sudo_project .keys .disable (deploy_key .id )
200+ assert (len (sudo_project .keys .list ()) == 0 )
201+
186202# labels
187203label1 = admin_project .labels .create ({'name' : 'label1' , 'color' : '#778899' })
188204label1 = admin_project .labels .get ('label1' )
You can’t perform that action at this time.
0 commit comments