summaryrefslogtreecommitdiff
path: root/gitlab/v4/objects/deploy_tokens.py
diff options
context:
space:
mode:
authorNejc Habjan <nejc.habjan@siemens.com>2022-04-04 23:20:23 +0200
committerNejc Habjan <nejc.habjan@siemens.com>2022-04-04 23:20:23 +0200
commitfcd37feff132bd5b225cde9d5f9c88e62b3f1fd6 (patch)
treebd9b21c1f643c83de2a6ca2d3e160c6599cb0068 /gitlab/v4/objects/deploy_tokens.py
parent19ab07d425cbe9fd23e1e94e107b52f9d14eecf1 (diff)
downloadgitlab-fcd37feff132bd5b225cde9d5f9c88e62b3f1fd6.tar.gz
feat(objects): support getting project/group deploy tokens by id
Diffstat (limited to 'gitlab/v4/objects/deploy_tokens.py')
-rw-r--r--gitlab/v4/objects/deploy_tokens.py24
1 files changed, 21 insertions, 3 deletions
diff --git a/gitlab/v4/objects/deploy_tokens.py b/gitlab/v4/objects/deploy_tokens.py
index 563c1d6..9fcfc23 100644
--- a/gitlab/v4/objects/deploy_tokens.py
+++ b/gitlab/v4/objects/deploy_tokens.py
@@ -1,6 +1,14 @@
+from typing import Any, cast, Union
+
from gitlab import types
from gitlab.base import RequiredOptional, RESTManager, RESTObject
-from gitlab.mixins import CreateMixin, DeleteMixin, ListMixin, ObjectDeleteMixin
+from gitlab.mixins import (
+ CreateMixin,
+ DeleteMixin,
+ ListMixin,
+ ObjectDeleteMixin,
+ RetrieveMixin,
+)
__all__ = [
"DeployToken",
@@ -25,7 +33,7 @@ class GroupDeployToken(ObjectDeleteMixin, RESTObject):
pass
-class GroupDeployTokenManager(ListMixin, CreateMixin, DeleteMixin, RESTManager):
+class GroupDeployTokenManager(RetrieveMixin, CreateMixin, DeleteMixin, RESTManager):
_path = "/groups/{group_id}/deploy_tokens"
_from_parent_attrs = {"group_id": "id"}
_obj_cls = GroupDeployToken
@@ -41,12 +49,17 @@ class GroupDeployTokenManager(ListMixin, CreateMixin, DeleteMixin, RESTManager):
)
_types = {"scopes": types.CommaSeparatedListAttribute}
+ def get(
+ self, id: Union[str, int], lazy: bool = False, **kwargs: Any
+ ) -> GroupDeployToken:
+ return cast(GroupDeployToken, super().get(id=id, lazy=lazy, **kwargs))
+
class ProjectDeployToken(ObjectDeleteMixin, RESTObject):
pass
-class ProjectDeployTokenManager(ListMixin, CreateMixin, DeleteMixin, RESTManager):
+class ProjectDeployTokenManager(RetrieveMixin, CreateMixin, DeleteMixin, RESTManager):
_path = "/projects/{project_id}/deploy_tokens"
_from_parent_attrs = {"project_id": "id"}
_obj_cls = ProjectDeployToken
@@ -61,3 +74,8 @@ class ProjectDeployTokenManager(ListMixin, CreateMixin, DeleteMixin, RESTManager
),
)
_types = {"scopes": types.CommaSeparatedListAttribute}
+
+ def get(
+ self, id: Union[str, int], lazy: bool = False, **kwargs: Any
+ ) -> ProjectDeployToken:
+ return cast(ProjectDeployToken, super().get(id=id, lazy=lazy, **kwargs))