GitHub

This part of the documentation covers all the github APIs.

GitHub

class ghastoolkit.GitHub

The GitHub Class.

This API is used to configure the state for all Octokit apis. Its a standard interface across all projects.

api_graphql: str = 'https://api.github.com/graphql'

GraphQL API URL

api_rest: str = 'https://api.github.com'

REST API URL

static display() str

Display the GitHub Settings.

enterprise: str | None = None

Enterprise Name

static getMetaInformation() Dict

Get the GitHub Meta Information.

static getOrganization() str

Get the Organization.

static getToken(masked: bool = True) str | None

Get the GitHub token.

Masking the token will only show the first 5 and all the other characters as #.

Parameters:

masked (bool) – Mask the token. Defaults to True.

Returns:

The GitHub token.

Return type:

str

property github_app: bool

Check if the token is a GitHub App token.

static init(repository: str | None = None, owner: str | None = None, repo: str | None = None, reference: str | None = None, branch: str | None = None, token: str | None = None, instance: str | None = None, enterprise: str | None = None, retrieve_metadata: bool = True) None

Initialise a GitHub class using a number of properties.

instance: str = 'https://github.com'

Instance

static isEnterpriseServer() bool

Is the GitHub instance an Enterprise Server.

static loadToken()

Load the GitHub token from the environment variable.

owner: str | None = None

Owner / Organisation

static parseInstance(instance: str) Tuple[str, str]

Parse GitHub Instance.

repository: Repository = GeekMasher/ghastoolkit

Repository

server_version: Version | None = None

GitHub Enterprise Server Version

token: str | None = None

GitHub Access Token This is used to authenticate with the GitHub API.

This can be set using the GITHUB_TOKEN environment variable or passed in as a parameter.

token_type: str | None = None

GitHub Token Type

static validateTokenType(token: str | None) str | None

Check what type of token is being used.

Returns:

The type of token being used.
  • ”PAT” for Personal Access Token

  • ”OAUTH” for GitHub App token / OAuth token

  • ”ACTIONS” for GitHub Actions token

  • ”SERVICES” for Server-to-Server token

  • ”UNKNOWN” for unknown token type

Return type:

str

https://github.blog/engineering/behind-githubs-new-authentication-token-formats/