2
2
3
3
from gitlab .base import RESTManager , RESTObject
4
4
from gitlab .mixins import (
5
+ CreateMixin ,
6
+ DeleteMixin ,
5
7
GetWithoutIdMixin ,
8
+ ListMixin ,
9
+ ObjectDeleteMixin ,
6
10
RefreshMixin ,
7
11
SaveMixin ,
8
12
UpdateMethod ,
9
13
UpdateMixin ,
10
14
)
15
+ from gitlab .types import RequiredOptional
16
+
11
17
12
18
__all__ = [
13
19
"ProjectJobTokenScope" ,
18
24
class ProjectJobTokenScope (RefreshMixin , SaveMixin , RESTObject ):
19
25
_id_attr = None
20
26
27
+ allowlist : "AllowlistedProjectManager"
28
+
21
29
22
30
class ProjectJobTokenScopeManager (GetWithoutIdMixin , UpdateMixin , RESTManager ):
23
31
_path = "/projects/{project_id}/job_token_scope"
@@ -27,3 +35,23 @@ class ProjectJobTokenScopeManager(GetWithoutIdMixin, UpdateMixin, RESTManager):
27
35
28
36
def get (self , ** kwargs : Any ) -> ProjectJobTokenScope :
29
37
return cast (ProjectJobTokenScope , super ().get (** kwargs ))
38
+
39
+
40
+ class AllowlistedProject (ObjectDeleteMixin , RESTObject ):
41
+ _id_attr = "target_project_id" # note: only true for create endpoint
42
+
43
+ def get_id (self ) -> int :
44
+ """Returns the id of the resource. This override deals with
45
+ the fact that either an `id` or a `target_project_id` attribute
46
+ is returned by the server depending on the endpoint called."""
47
+ try :
48
+ return cast (int , getattr (self , self ._id_attr ))
49
+ except AttributeError :
50
+ return cast (int , getattr (self , "id" ))
51
+
52
+
53
+ class AllowlistedProjectManager (ListMixin , CreateMixin , DeleteMixin , RESTManager ):
54
+ _path = "/projects/{project_id}/job_token_scope/allowlist"
55
+ _obj_cls = AllowlistedProject
56
+ _from_parent_attrs = {"project_id" : "project_id" }
57
+ _create_attrs = RequiredOptional (required = ("target_project_id" ,))
0 commit comments