Loading docs/gl_objects/deploy_keys.rst +5 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,11 @@ Reference Examples -------- List the deploy keys:: Add an instance-wide deploy key (requires admin access):: keys = gl.deploykeys.create({'title': 'instance key', 'key': INSTANCE_KEY}) List all deploy keys:: keys = gl.deploykeys.list() Loading gitlab/v4/objects/deploy_keys.py +15 −4 Original line number Diff line number Diff line Loading @@ -7,7 +7,13 @@ import requests from gitlab import cli from gitlab import exceptions as exc from gitlab.base import RESTObject from gitlab.mixins import CRUDMixin, ListMixin, ObjectDeleteMixin, SaveMixin from gitlab.mixins import ( CreateMixin, CRUDMixin, ListMixin, ObjectDeleteMixin, SaveMixin, ) from gitlab.types import RequiredOptional __all__ = ["DeployKey", "DeployKeyManager", "ProjectKey", "ProjectKeyManager"] Loading @@ -17,9 +23,12 @@ class DeployKey(RESTObject): pass class DeployKeyManager(ListMixin[DeployKey]): class DeployKeyManager(CreateMixin[DeployKey], ListMixin[DeployKey]): _path = "/deploy_keys" _obj_cls = DeployKey _create_attrs = RequiredOptional( required=("title", "key"), optional=("expires_at",) ) class ProjectKey(SaveMixin, ObjectDeleteMixin, RESTObject): Loading @@ -30,8 +39,10 @@ class ProjectKeyManager(CRUDMixin[ProjectKey]): _path = "/projects/{project_id}/deploy_keys" _obj_cls = ProjectKey _from_parent_attrs = {"project_id": "id"} _create_attrs = RequiredOptional(required=("title", "key"), optional=("can_push",)) _update_attrs = RequiredOptional(optional=("title", "can_push")) _create_attrs = RequiredOptional( required=("title", "key"), optional=("can_push", "expires_at") ) _update_attrs = RequiredOptional(optional=("title", "can_push", "expires_at")) @cli.register_custom_action( cls_names="ProjectKeyManager", Loading tests/functional/api/test_deploy_keys.py +10 −1 Original line number Diff line number Diff line def test_project_deploy_keys(gl, project, DEPLOY_KEY): from gitlab import Gitlab from gitlab.v4.objects import Project def test_deploy_keys(gl: Gitlab, DEPLOY_KEY: str) -> None: deploy_key = gl.deploykeys.create({"title": "foo@bar", "key": DEPLOY_KEY}) assert deploy_key in gl.deploykeys.list(get_all=False) def test_project_deploy_keys(gl: Gitlab, project: Project, DEPLOY_KEY: str) -> None: deploy_key = project.keys.create({"title": "foo@bar", "key": DEPLOY_KEY}) assert deploy_key in project.keys.list() Loading Loading
docs/gl_objects/deploy_keys.rst +5 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,11 @@ Reference Examples -------- List the deploy keys:: Add an instance-wide deploy key (requires admin access):: keys = gl.deploykeys.create({'title': 'instance key', 'key': INSTANCE_KEY}) List all deploy keys:: keys = gl.deploykeys.list() Loading
gitlab/v4/objects/deploy_keys.py +15 −4 Original line number Diff line number Diff line Loading @@ -7,7 +7,13 @@ import requests from gitlab import cli from gitlab import exceptions as exc from gitlab.base import RESTObject from gitlab.mixins import CRUDMixin, ListMixin, ObjectDeleteMixin, SaveMixin from gitlab.mixins import ( CreateMixin, CRUDMixin, ListMixin, ObjectDeleteMixin, SaveMixin, ) from gitlab.types import RequiredOptional __all__ = ["DeployKey", "DeployKeyManager", "ProjectKey", "ProjectKeyManager"] Loading @@ -17,9 +23,12 @@ class DeployKey(RESTObject): pass class DeployKeyManager(ListMixin[DeployKey]): class DeployKeyManager(CreateMixin[DeployKey], ListMixin[DeployKey]): _path = "/deploy_keys" _obj_cls = DeployKey _create_attrs = RequiredOptional( required=("title", "key"), optional=("expires_at",) ) class ProjectKey(SaveMixin, ObjectDeleteMixin, RESTObject): Loading @@ -30,8 +39,10 @@ class ProjectKeyManager(CRUDMixin[ProjectKey]): _path = "/projects/{project_id}/deploy_keys" _obj_cls = ProjectKey _from_parent_attrs = {"project_id": "id"} _create_attrs = RequiredOptional(required=("title", "key"), optional=("can_push",)) _update_attrs = RequiredOptional(optional=("title", "can_push")) _create_attrs = RequiredOptional( required=("title", "key"), optional=("can_push", "expires_at") ) _update_attrs = RequiredOptional(optional=("title", "can_push", "expires_at")) @cli.register_custom_action( cls_names="ProjectKeyManager", Loading
tests/functional/api/test_deploy_keys.py +10 −1 Original line number Diff line number Diff line def test_project_deploy_keys(gl, project, DEPLOY_KEY): from gitlab import Gitlab from gitlab.v4.objects import Project def test_deploy_keys(gl: Gitlab, DEPLOY_KEY: str) -> None: deploy_key = gl.deploykeys.create({"title": "foo@bar", "key": DEPLOY_KEY}) assert deploy_key in gl.deploykeys.list(get_all=False) def test_project_deploy_keys(gl: Gitlab, project: Project, DEPLOY_KEY: str) -> None: deploy_key = project.keys.create({"title": "foo@bar", "key": DEPLOY_KEY}) assert deploy_key in project.keys.list() Loading