11from gitlab .base import RESTManager ,RESTObject
2- from gitlab .mixins import CreateMixin ,DeleteMixin ,ListMixin ,ObjectDeleteMixin
3- from gitlab .types import RequiredOptional
2+ from gitlab .mixins import (
3+ CreateMixin ,
4+ DeleteMixin ,
5+ ListMixin ,
6+ RotateMixin ,
7+ ObjectDeleteMixin ,
8+ ObjectRotateMixin ,
9+ )
10+ from gitlab .types import RequiredOptional ,ArrayAttribute
411
512__all__ = [
613"ServiceAccount" ,
714"ServiceAccountManager" ,
815"GroupServiceAccount" ,
916"GroupServiceAccountManager" ,
17+ "GroupServiceAccountAccessToken" ,
18+ "GroupServiceAccountAccessTokenManager" ,
1019]
1120
1221
@@ -33,3 +42,18 @@ class GroupServiceAccountManager(CreateMixin, DeleteMixin, ListMixin, RESTManage
3342_create_attrs = RequiredOptional (
3443optional = ("name" ,"username" ),
3544 )
45+
46+
47+ class GroupServiceAccountAccessToken (ObjectRotateMixin ,RESTObject ):
48+ pass
49+
50+
51+ class GroupServiceAccountAccessTokenManager (CreateMixin ,RotateMixin ,RESTManager ):
52+ _path = "/groups/{group_id}/service_accounts/{user_id}/personal_access_tokens"
53+ _obj_cls = GroupServiceAccountAccessToken
54+ _from_parent_attrs = {"group_id" :"id" ,"user_id" :"user_id" }
55+ _create_attrs = RequiredOptional (
56+ required = ("name" ,"scopes" ),
57+ optional = ("expires_at" ,),
58+ )
59+ _types = {"scopes" :ArrayAttribute }