Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit22be96c

Browse files
nejchJohnVillalovos
authored andcommitted
feat(api): add support for adding instance deploy keys
1 parent193c5de commit22be96c

File tree

3 files changed

+30
-6
lines changed

3 files changed

+30
-6
lines changed

‎docs/gl_objects/deploy_keys.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ Reference
1919
Examples
2020
--------
2121

22-
List the deploy keys::
22+
Add an instance-wide deploy key (requires admin access)::
23+
24+
keys = gl.deploykeys.create({'title': 'instance key', 'key': INSTANCE_KEY})
25+
26+
List all deploy keys::
2327

2428
keys = gl.deploykeys.list()
2529

‎gitlab/v4/objects/deploy_keys.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@
77
fromgitlabimportcli
88
fromgitlabimportexceptionsasexc
99
fromgitlab.baseimportRESTObject
10-
fromgitlab.mixinsimportCRUDMixin,ListMixin,ObjectDeleteMixin,SaveMixin
10+
fromgitlab.mixinsimport (
11+
CreateMixin,
12+
CRUDMixin,
13+
ListMixin,
14+
ObjectDeleteMixin,
15+
SaveMixin,
16+
)
1117
fromgitlab.typesimportRequiredOptional
1218

1319
__all__= ["DeployKey","DeployKeyManager","ProjectKey","ProjectKeyManager"]
@@ -17,9 +23,12 @@ class DeployKey(RESTObject):
1723
pass
1824

1925

20-
classDeployKeyManager(ListMixin[DeployKey]):
26+
classDeployKeyManager(CreateMixin[DeployKey],ListMixin[DeployKey]):
2127
_path="/deploy_keys"
2228
_obj_cls=DeployKey
29+
_create_attrs=RequiredOptional(
30+
required=("title","key"),optional=("expires_at",)
31+
)
2332

2433

2534
classProjectKey(SaveMixin,ObjectDeleteMixin,RESTObject):
@@ -30,8 +39,10 @@ class ProjectKeyManager(CRUDMixin[ProjectKey]):
3039
_path="/projects/{project_id}/deploy_keys"
3140
_obj_cls=ProjectKey
3241
_from_parent_attrs= {"project_id":"id"}
33-
_create_attrs=RequiredOptional(required=("title","key"),optional=("can_push",))
34-
_update_attrs=RequiredOptional(optional=("title","can_push"))
42+
_create_attrs=RequiredOptional(
43+
required=("title","key"),optional=("can_push","expires_at")
44+
)
45+
_update_attrs=RequiredOptional(optional=("title","can_push","expires_at"))
3546

3647
@cli.register_custom_action(
3748
cls_names="ProjectKeyManager",

‎tests/functional/api/test_deploy_keys.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
deftest_project_deploy_keys(gl,project,DEPLOY_KEY):
1+
fromgitlabimportGitlab
2+
fromgitlab.v4.objectsimportProject
3+
4+
5+
deftest_deploy_keys(gl:Gitlab,DEPLOY_KEY:str)->None:
6+
deploy_key=gl.deploykeys.create({"title":"foo@bar","key":DEPLOY_KEY})
7+
assertdeploy_keyingl.deploykeys.list(get_all=False)
8+
9+
10+
deftest_project_deploy_keys(gl:Gitlab,project:Project,DEPLOY_KEY:str)->None:
211
deploy_key=project.keys.create({"title":"foo@bar","key":DEPLOY_KEY})
312
assertdeploy_keyinproject.keys.list()
413

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp