forked from cartography-cncf/cartography
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Daniel Brauer <[email protected]>
- Loading branch information
Showing
1 changed file
with
122 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
from dataclasses import dataclass | ||
from typing import Optional | ||
|
||
from cartography.models.core.common import PropertyRef | ||
from cartography.models.core.nodes import CartographyNodeProperties | ||
from cartography.models.core.nodes import CartographyNodeSchema | ||
from cartography.models.core.relationships import CartographyRelProperties | ||
from cartography.models.core.relationships import CartographyRelSchema | ||
from cartography.models.core.relationships import LinkDirection | ||
from cartography.models.core.relationships import make_target_node_matcher | ||
from cartography.models.core.relationships import OtherRelationships | ||
from cartography.models.core.relationships import TargetNodeMatcher | ||
|
||
|
||
@dataclass(frozen=True) | ||
class GitHubUserNodeProperties(CartographyNodeProperties): | ||
id: PropertyRef = PropertyRef('url') | ||
lastupdated: PropertyRef = PropertyRef('lastupdated', set_in_kwargs=True) | ||
fullname: PropertyRef = PropertyRef('name') | ||
username: PropertyRef = PropertyRef('login', extra_index=True) | ||
# optional because some enterprise owners do not have this property specified | ||
has_2fa_enabled: Optional[PropertyRef] = PropertyRef('hasTwoFactorEnabled') | ||
role: PropertyRef = PropertyRef('role') | ||
is_site_admin: PropertyRef = PropertyRef('isSiteAdmin') | ||
is_enterprise_owner: PropertyRef = PropertyRef('isEnterpriseOwner') | ||
email: PropertyRef = PropertyRef('email') | ||
company: PropertyRef = PropertyRef('company') | ||
|
||
|
||
|
||
|
||
|
||
# @dataclass(frozen=True) | ||
# class GitHubTeamToRepoRelProperties(CartographyRelProperties): | ||
# lastupdated: PropertyRef = PropertyRef('lastupdated', set_in_kwargs=True) | ||
# | ||
# | ||
# @dataclass(frozen=True) | ||
# class GitHubTeamAdminRepoRel(CartographyRelSchema): | ||
# target_node_label: str = 'GitHubRepository' | ||
# target_node_matcher: TargetNodeMatcher = make_target_node_matcher( | ||
# {'id': PropertyRef('ADMIN')}, | ||
# ) | ||
# direction: LinkDirection = LinkDirection.OUTWARD | ||
# rel_label: str = "ADMIN" | ||
# properties: GitHubTeamToRepoRelProperties = GitHubTeamToRepoRelProperties() | ||
# | ||
# | ||
# @dataclass(frozen=True) | ||
# class GitHubTeamMaintainRepoRel(CartographyRelSchema): | ||
# target_node_label: str = 'GitHubRepository' | ||
# target_node_matcher: TargetNodeMatcher = make_target_node_matcher( | ||
# {'id': PropertyRef('MAINTAIN')}, | ||
# ) | ||
# direction: LinkDirection = LinkDirection.OUTWARD | ||
# rel_label: str = "MAINTAIN" | ||
# properties: GitHubTeamToRepoRelProperties = GitHubTeamToRepoRelProperties() | ||
# | ||
# | ||
# @dataclass(frozen=True) | ||
# class GitHubTeamReadRepoRel(CartographyRelSchema): | ||
# target_node_label: str = 'GitHubRepository' | ||
# target_node_matcher: TargetNodeMatcher = make_target_node_matcher( | ||
# {'id': PropertyRef('READ')}, | ||
# ) | ||
# direction: LinkDirection = LinkDirection.OUTWARD | ||
# rel_label: str = "READ" | ||
# properties: GitHubTeamToRepoRelProperties = GitHubTeamToRepoRelProperties() | ||
# | ||
# | ||
# @dataclass(frozen=True) | ||
# class GitHubTeamTriageRepoRel(CartographyRelSchema): | ||
# target_node_label: str = 'GitHubRepository' | ||
# target_node_matcher: TargetNodeMatcher = make_target_node_matcher( | ||
# {'id': PropertyRef('TRIAGE')}, | ||
# ) | ||
# direction: LinkDirection = LinkDirection.OUTWARD | ||
# rel_label: str = "TRIAGE" | ||
# properties: GitHubTeamToRepoRelProperties = GitHubTeamToRepoRelProperties() | ||
# | ||
# | ||
# @dataclass(frozen=True) | ||
# class GitHubTeamWriteRepoRel(CartographyRelSchema): | ||
# target_node_label: str = 'GitHubRepository' | ||
# target_node_matcher: TargetNodeMatcher = make_target_node_matcher( | ||
# {'id': PropertyRef('WRITE')}, | ||
# ) | ||
# direction: LinkDirection = LinkDirection.OUTWARD | ||
# rel_label: str = "WRITE" | ||
# properties: GitHubTeamToRepoRelProperties = GitHubTeamToRepoRelProperties() | ||
# | ||
# | ||
# @dataclass(frozen=True) | ||
# class GitHubTeamToOrganizationRelProperties(CartographyRelProperties): | ||
# lastupdated: PropertyRef = PropertyRef('lastupdated', set_in_kwargs=True) | ||
# | ||
# | ||
# @dataclass(frozen=True) | ||
# class GitHubTeamToOrganizationRel(CartographyRelSchema): | ||
# target_node_label: str = 'GitHubOrganization' | ||
# target_node_matcher: TargetNodeMatcher = make_target_node_matcher( | ||
# {'id': PropertyRef('org_url', set_in_kwargs=True)}, | ||
# ) | ||
# direction: LinkDirection = LinkDirection.INWARD | ||
# rel_label: str = "RESOURCE" | ||
# properties: GitHubTeamToOrganizationRelProperties = GitHubTeamToOrganizationRelProperties() | ||
# | ||
# | ||
# @dataclass(frozen=True) | ||
# class GitHubTeamSchema(CartographyNodeSchema): | ||
# label: str = 'GitHubTeam' | ||
# properties: GitHubTeamNodeProperties = GitHubTeamNodeProperties() | ||
# other_relationships: OtherRelationships = OtherRelationships( | ||
# [ | ||
# GitHubTeamAdminRepoRel(), | ||
# GitHubTeamMaintainRepoRel(), | ||
# GitHubTeamReadRepoRel(), | ||
# GitHubTeamTriageRepoRel(), | ||
# GitHubTeamWriteRepoRel(), | ||
# ], | ||
# ) | ||
# sub_resource_relationship: GitHubTeamToOrganizationRel = GitHubTeamToOrganizationRel() |