Skip to content

Commit

Permalink
initial poking around incomplete
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Brauer <[email protected]>
  • Loading branch information
danbrauer committed Nov 8, 2024
1 parent 5f4e459 commit 9ae8074
Showing 1 changed file with 122 additions and 0 deletions.
122 changes: 122 additions & 0 deletions cartography/models/github/users.py
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()

0 comments on commit 9ae8074

Please sign in to comment.