Interface

Amazon CloudWatch

class interface.cloudwatch_metrics.CWMetrics(config)
Parameters

config (config.Config) –

__init__(config)

Initialize self. See help(type(self)) for accurate signature.

Parameters

config (config.Config) –

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.

Parameters
  • app_id (str) –

  • private_key (str) –

__init__(app_id, private_key)

Init factory.

Parameters
  • app_id (str) – Github Apps ID

  • private_key (str) – Private key provided by Github Apps registration

create()

Create instance of pygithub interface with Github Apps API token.

Return type

github.MainClass.Github

class interface.github.GithubInterface(github_factory, org)

Utility class for interacting with Github API.

Parameters
__init__(github_factory, org)

Initialize bot by creating Github object and get organization.

Parameters
add_team_member(username, team_id)

Add user with given username to team with id team_id.

Parameters
  • username (str) –

  • team_id (str) –

get_team_member(username, team_id)

Return a team member with a username of username.

Parameters
  • username (str) –

  • team_id (str) –

Return type

github.NamedUser.NamedUser

has_team_member(username, team_id)

Check if team with team_id contains user with username.

Parameters
  • username (str) –

  • team_id (str) –

Return type

bool

list_team_members(team_id)

Return a list of users in the team of id team_id.

Parameters

team_id (str) –

Return type

typing.List[github.NamedUser.NamedUser]

org_add_admin(username)

Add member with given username as admin to organization.

Parameters

username (str) –

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.

Parameters

username (str) –

Return type

str

org_create_team(name)

Create team with given name and add to organization.

Parameters

name (str) – name of team

Return type

int

Returns

Github team ID

org_delete_team(id)

Get team with given ID and delete it from organization.

Parameters

id (int) –

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 (typing.Optional[str]) – new team description

org_get_team(id)

Given Github team ID, return team from organization.

Parameters

id (int) –

Return type

github.Team.Team

org_get_teams()

Return array of teams associated with organization.

Return type

typing.List[app.model.team.Team]

org_has_member(username)

Return true if user with username is member of organization.

Parameters

username (str) –

Return type

bool

org_remove_member(username)

Remove member with given username from organization.

Parameters

username (str) –

remove_team_member(username, team_id)

Remove user with given username from team with id team_id.

Parameters
  • username (str) –

  • team_id (str) –

interface.github.handle_github_error(func)

Github error handler that updates Github App API token if necessary.

Interface to Github App API.

class interface.github_app.DefaultGithubAppAuthFactory(app_id, private_key)

Factory for creating GithubAppAuth objects.

__init__(app_id, private_key)

Initialize a Github App API auth factory.

Parameters
  • app_id – Github Apps ID

  • private_key – Private key from application

create()

Create an instance of GithubAppAuth.

class interface.github_app.GithubAppInterface(app_auth_factory)

Interface class for interacting with Github App API.

class GithubAppAuth(app_id, private_key)

Class to encapsulate JWT encoding for Github App API.

__init__(app_id, private_key)

Initialize Github App authentication.

is_expired()

Check if Github App token is expired.

__init__(app_auth_factory)

Initialize GithubAppInterface.

Parameters

app_auth_factory – Factory for creating auth objects

create_api_token()

Create installation token to make Github API requests.

See https://developer.github.com/v3/apps/#find-installations and https://developer.github.com/v3/apps/#create-a-new-installation-token for details.

Returns

Authenticated API token

get_app_details()

Retrieve app details from Github Apps API.

See https://developer.github.com/v3/apps/#get-the-authenticated-github-app for details.

Returns

Decoded JSON object containing app details

Exceptions from interacting with Github API.

exception interface.exceptions.github.GithubAPIException(data)

Exception representing an error while calling Github API.

__init__(data)

Initialize a new GithubAPIException.

Parameters

data

Google

Slack

Utility classes for interacting with Slack API.

class interface.slack.Bot(sc, slack_channel='')

Utility class for calling Slack APIs.

Parameters
  • sc (slack.web.client.WebClient) –

  • slack_channel (str) –

__init__(sc, slack_channel='')

Initialize Bot by creating a WebClient Object.

Parameters
  • sc (slack.web.client.WebClient) –

  • slack_channel (str) –

create_channel(channel_name)

Create a channel with the given name.

:return name of newly created channel

get_channel_names()

Retrieve list of channel names.

Return type

typing.List[str]

get_channel_users(channel_id)

Retrieve list of user IDs from channel with channel_id.

Parameters

channel_id (str) –

Return type

typing.Dict[str, typing.Any]

get_channels()

Retrieve list of channel objects.

Return type

typing.List[typing.Any]

send_dm(message, slack_user_id)

Send direct message to user with id of slack_user_id.

Parameters
  • message (str) –

  • slack_user_id (str) –

send_event_notif(message)

Send a message to the slack bot channel, usually for webhook notifs.

:param message to send to configured bot channel

send_to_channel(message, channel_name, attachments=[])

Send message to channel with name channel_name.

Parameters
  • message (str) –

  • channel_name (str) –

  • attachments (typing.List[typing.Any]) –

exception interface.slack.SlackAPIError(error)

Exception representing an error while calling Slack API.

__init__(error)

Initialize a new SlackAPIError.

Parameters

error – Error string returned from Slack API.