@@ -47,7 +47,7 @@ class Organization(BaseModel):
4747@dataclass
4848class GHOrgRoleProperties (GHNodeProperties ):
4949 """Org role properties and accordion panel queries.
50-
50+
5151 Attributes:
5252 short_name: The short display name of the role (e.g., `Owners`, `Members`, or the custom role name).
5353 type: `default` for built-in roles (Owner, Member) or `custom` for custom organization roles.
@@ -92,10 +92,31 @@ class GHOrgRoleProperties(GHNodeProperties):
9292 EdgeDef (
9393 start = nk .ORG_ROLE ,
9494 end = nk .ORGANIZATION ,
95- kind = ek .CREATE_REPOSITORY ,
95+ kind = ek .CAN_CREATE_REPOSITORIES ,
9696 description = "Role can create repositories in the organization" ,
9797 traversable = False ,
9898 ),
99+ EdgeDef (
100+ start = nk .ORG_ROLE ,
101+ end = nk .ORGANIZATION ,
102+ kind = ek .CAN_CREATE_PUBLIC_REPOSITORIES ,
103+ description = "Role can create public repositories in the organization" ,
104+ traversable = False ,
105+ ),
106+ EdgeDef (
107+ start = nk .ORG_ROLE ,
108+ end = nk .ORGANIZATION ,
109+ kind = ek .CAN_CREATE_INTERNAL_REPOSITORIES ,
110+ description = "Role can create internal repositories in the organization" ,
111+ traversable = False ,
112+ ),
113+ EdgeDef (
114+ start = nk .ORG_ROLE ,
115+ end = nk .ORGANIZATION ,
116+ kind = ek .CAN_CREATE_PRIVATE_REPOSITORIES ,
117+ description = "Role can create private repositories in the organization" ,
118+ traversable = False ,
119+ ),
99120 EdgeDef (
100121 start = nk .ORG_ROLE ,
101122 end = nk .ORGANIZATION ,
@@ -174,7 +195,7 @@ def as_node(self) -> GHNode:
174195 displayname = f"{ self .org_login } /{ self .name } " ,
175196 node_id = self .node_id ,
176197 short_name = self .name ,
177- type = "custom" ,
198+ type = self . type ,
178199 environment_name = self .org_login ,
179200 environmentid = self .org_node_id ,
180201 query_explicit_members = f"MATCH p=(:GH_User)-[:GH_HasRole]->(:GH_OrgRole {{node_id:'{ self .node_id } '}}) RETURN p" ,
@@ -184,6 +205,48 @@ def as_node(self) -> GHNode:
184205 ),
185206 )
186207
208+ @property
209+ def _can_create_repos_edge (self ):
210+ if self .type == "default" and (self .name == "owners" or self .name == "members" ):
211+ (
212+ members_can_create_repositories ,
213+ members_can_create_public_repositories ,
214+ members_can_create_internal_repositories ,
215+ members_can_create_private_repositories ,
216+ ) = self ._lookup .members_can_create_repository (self .org_login )
217+
218+ if members_can_create_private_repositories :
219+ yield Edge (
220+ kind = ek .CAN_CREATE_PRIVATE_REPOSITORIES ,
221+ start = EdgePath (value = self .node_id , match_by = "id" ),
222+ end = EdgePath (value = self .org_node_id , match_by = "id" ),
223+ properties = EdgeProperties (traversable = False ),
224+ )
225+
226+ if members_can_create_public_repositories :
227+ yield Edge (
228+ kind = ek .CAN_CREATE_PUBLIC_REPOSITORIES ,
229+ start = EdgePath (value = self .node_id , match_by = "id" ),
230+ end = EdgePath (value = self .org_node_id , match_by = "id" ),
231+ properties = EdgeProperties (traversable = False ),
232+ )
233+
234+ if members_can_create_internal_repositories :
235+ yield Edge (
236+ kind = ek .CAN_CREATE_INTERNAL_REPOSITORIES ,
237+ start = EdgePath (value = self .node_id , match_by = "id" ),
238+ end = EdgePath (value = self .org_node_id , match_by = "id" ),
239+ properties = EdgeProperties (traversable = False ),
240+ )
241+
242+ if members_can_create_repositories :
243+ yield Edge (
244+ kind = ek .CAN_CREATE_REPOSITORIES ,
245+ start = EdgePath (value = self .node_id , match_by = "id" ),
246+ end = EdgePath (value = self .org_node_id , match_by = "id" ),
247+ properties = EdgeProperties (traversable = False ),
248+ )
249+
187250 @property
188251 def _owners_edge (self ):
189252 if self .type == "default" and self .name == "owners" :
@@ -194,13 +257,6 @@ def _owners_edge(self):
194257 properties = EdgeProperties (traversable = True ),
195258 )
196259
197- yield Edge (
198- kind = ek .CREATE_REPOSITORY ,
199- start = EdgePath (value = self .node_id , match_by = "id" ),
200- end = EdgePath (value = self .org_node_id , match_by = "id" ),
201- properties = EdgeProperties (traversable = False ),
202- )
203-
204260 yield Edge (
205261 kind = ek .INVITE_MEMBER ,
206262 start = EdgePath (value = self .node_id , match_by = "id" ),
@@ -235,12 +291,6 @@ def _owners_edge(self):
235291 @property
236292 def _members_edge (self ):
237293 if self .type == "default" and self .name == "members" :
238- yield Edge (
239- kind = ek .CREATE_REPOSITORY ,
240- start = EdgePath (value = self .node_id , match_by = "id" ),
241- end = EdgePath (value = self .org_node_id , match_by = "id" ),
242- properties = EdgeProperties (traversable = False ),
243- )
244294 yield Edge (
245295 kind = ek .CREATE_TEAM ,
246296 start = EdgePath (value = self .node_id , match_by = "id" ),
@@ -260,7 +310,6 @@ def _members_edge(self):
260310
261311 @property
262312 def _custom_edges (self ):
263-
264313 if self .type == "custom" :
265314 if self .base_role and self .base_role in _ALL_REPO_PERMISSIONS :
266315 yield Edge (
@@ -283,14 +332,18 @@ def _custom_edges(self):
283332 )
284333
285334 @property
286- def edges (self ):
335+ def _contains_edge (self ):
287336 yield Edge (
288337 kind = ek .CONTAINS ,
289338 start = EdgePath (value = self .org_node_id , match_by = "id" ),
290339 end = EdgePath (value = self .node_id , match_by = "id" ),
291340 properties = EdgeProperties (traversable = False ),
292341 )
293342
343+ @property
344+ def edges (self ):
345+ yield from self ._contains_edge
294346 yield from self ._owners_edge
295347 yield from self ._members_edge
348+ yield from self ._can_create_repos_edge
296349 yield from self ._custom_edges
0 commit comments