Interface¶
Github¶
Utility classes for interacting with Github API via PyGithub.
-
class
interface.github.
DefaultGithubFactory
(app_id, private_key)¶ Default factory for creating interface to Github API.
-
__init__
(app_id, private_key)¶ Init factory.
Parameters: - app_id (
str
) – Github Apps ID - private_key (
str
) – Private key provided by Github Apps registration
- app_id (
-
create
()¶ Create instance of pygithub interface with Github Apps API token.
Return type: Github
-
-
class
interface.github.
GithubInterface
(github_factory, org)¶ Utility class for interacting with Github API.
-
__init__
(github_factory, org)¶ Initialize bot by creating Github object and get organization.
-
add_team_member
(username, team_id)¶ Add user with given username to team with id team_id.
-
get_team_member
(username, team_id)¶ Return a team member with a username of username.
Return type: NamedUser
-
has_team_member
(username, team_id)¶ Check if team with team_id contains user with username.
Return type: bool
-
list_team_members
(team_id)¶ Return a list of users in the team of id team_id.
Return type: List
[NamedUser
]
-
org_add_admin
(username)¶ Add member with given username as admin to organization.
-
org_add_member
(username)¶ Add/update to member with given username to organization.
If the user is already in the organization, don’t do anything.
Return type: str
-
org_create_team
(name)¶ Create team with given name and add to organization.
Parameters: name ( str
) – name of teamReturn type: int
Returns: Github team ID
-
org_delete_team
(id)¶ Get team with given ID and delete it from organization.
-
org_edit_team
(key, name, description=None)¶ Get team with given ID and edit name and description.
Parameters: - key (
int
) – team’s Github ID - name (
str
) – new team name - description (
Optional
[str
]) – new team description
- key (
-
org_get_team
(id)¶ Given Github team ID, return team from organization.
Return type: Team
-
org_has_member
(username)¶ Return true if user with username is member of organization.
Return type: bool
-
org_remove_member
(username)¶ Remove member with given username from organization.
-
remove_team_member
(username, team_id)¶ Remove user with given username from team with id team_id.
-
-
interface.github.
handle_github_error
(func)¶ Github error handler that updates Github App API token if necessary.