10000 feat(cli): enable token rotation via CLI · ibrahim60-git/python-gitlab@0cb8171 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0cb8171

Browse files
nejchJohnVillalovos
authored andcommitted
feat(cli): enable token rotation via CLI
1 parent bdc8852 commit 0cb8171

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

gitlab/mixins.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,14 @@ class RotateMixin(_RestManagerBase):
663663
_path: Optional[str]
664664
gitlab: gitlab.Gitlab
665665

666+
@cli.register_custom_action(
667+
cls_names=(
668+
"PersonalAccessTokenManager",
669+
"GroupAccessTokenManager",
670+
"ProjectAccessTokenManager",
671+
),
672+
optional=("expires_at",),
673+
)
666674
@exc.on_http_error(exc.GitlabRotateError)
667675
def rotate(
668676
self, id: Union[str, int], expires_at: Optional[str] = None, **kwargs: Any
@@ -696,7 +704,12 @@ class ObjectRotateMixin(_RestObjectBase):
696704
_updated_attrs: Dict[str, Any]
697705
manager: base.RESTManager
698706

699-
def rotate(self, **kwargs: Any) -> None:
707+
@cli.register_custom_action(
708+
cls_names=("PersonalAccessToken", "GroupAccessToken", "ProjectAccessToken"),
709+
optional=("expires_at",),
710+
)
711+
@exc.on_http_error(exc.GitlabRotateError)
712+
def rotate(self, **kwargs: Any) -> Dict[str, Any]:
700713
"""Rotate the current access token object.
701714
702715
Args:
@@ -711,6 +724,7 @@ def rotate(self, **kwargs: Any) -> None:
711724
assert self.encoded_id is not None
712725
server_data = self.manager.rotate(self.encoded_id, **kwargs)
713726
self._update_attrs(server_data)
727+
return server_data
714728

715729

716730
class SubscribableMixin(_RestObjectBase):

0 commit comments

Comments
 (0)
0