22
33from gitlab .base import RESTManager , RESTObject
44from gitlab .mixins import (
5+ CreateMixin ,
6+ DeleteMixin ,
57 GetWithoutIdMixin ,
8+ ListMixin ,
9+ ObjectDeleteMixin ,
610 RefreshMixin ,
711 SaveMixin ,
812 UpdateMethod ,
913 UpdateMixin ,
1014)
15+ from gitlab .types import RequiredOptional
16+
1117
1218__all__ = [
1319 "ProjectJobTokenScope" ,
1824class ProjectJobTokenScope (RefreshMixin , SaveMixin , RESTObject ):
1925 _id_attr = None
2026
27+ allowlist : "AllowlistedProjectManager"
28+
2129
2230class ProjectJobTokenScopeManager (GetWithoutIdMixin , UpdateMixin , RESTManager ):
2331 _path = "/projects/{project_id}/job_token_scope"
@@ -27,3 +35,23 @@ class ProjectJobTokenScopeManager(GetWithoutIdMixin, UpdateMixin, RESTManager):
2735
2836 def get (self , ** kwargs : Any ) -> ProjectJobTokenScope :
2937 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