Commit 0cb81715 authored by Nejc Habjan's avatar Nejc Habjan Committed by John Villalovos
Browse files

feat(cli): enable token rotation via CLI

parent bdc88520
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
@@ -663,6 +663,14 @@ class RotateMixin(_RestManagerBase):
    _path: Optional[str]
    gitlab: gitlab.Gitlab

    @cli.register_custom_action(
        cls_names=(
            "PersonalAccessTokenManager",
            "GroupAccessTokenManager",
            "ProjectAccessTokenManager",
        ),
        optional=("expires_at",),
    )
    @exc.on_http_error(exc.GitlabRotateError)
    def rotate(
        self, id: Union[str, int], expires_at: Optional[str] = None, **kwargs: Any
@@ -696,7 +704,12 @@ class ObjectRotateMixin(_RestObjectBase):
    _updated_attrs: Dict[str, Any]
    manager: base.RESTManager

    def rotate(self, **kwargs: Any) -> None:
    @cli.register_custom_action(
        cls_names=("PersonalAccessToken", "GroupAccessToken", "ProjectAccessToken"),
        optional=("expires_at",),
    )
    @exc.on_http_error(exc.GitlabRotateError)
    def rotate(self, **kwargs: Any) -> Dict[str, Any]:
        """Rotate the current access token object.

        Args:
@@ -711,6 +724,7 @@ class ObjectRotateMixin(_RestObjectBase):
            assert self.encoded_id is not None
        server_data = self.manager.rotate(self.encoded_id, **kwargs)
        self._update_attrs(server_data)
        return server_data


class SubscribableMixin(_RestObjectBase):