vendor_connectors.github
Github Connector using jbcom ecosystem packages.
Submodules
Section titled “Submodules”Package Contents
Section titled “Package Contents”Classes
Section titled “Classes”GithubConnector | Github connector for repository operations. |
|---|
Functions
Section titled “Functions”get_github_api_error | Extract error message from Github exception. |
|---|---|
build_github_actions_workflow | Generate a GitHub Actions workflow YAML string. |
FilePath | |
|---|---|
DEFAULT_PER_PAGE |
vendor_connectors.github.FilePath
Section titled “vendor_connectors.github.FilePath”None
vendor_connectors.github.get_github_api_error(exc: github.GithubException.GithubException) → str | None
Section titled “vendor_connectors.github.get_github_api_error(exc: github.GithubException.GithubException) → str | None”Extract error message from Github exception.
vendor_connectors.github.DEFAULT_PER_PAGE
Section titled “vendor_connectors.github.DEFAULT_PER_PAGE”100
class vendor_connectors.github.GithubConnector(github_owner: str, github_repo: str | None = None, github_branch: str | None = None, github_token: str | None = None, per_page: int = DEFAULT_PER_PAGE, logger: lifecyclelogging.Logging | None = None, **kwargs)
Section titled “class vendor_connectors.github.GithubConnector(github_owner: str, github_repo: str | None = None, github_branch: str | None = None, github_token: str | None = None, per_page: int = DEFAULT_PER_PAGE, logger: lifecyclelogging.Logging | None = None, **kwargs)”Bases: vendor_connectors.base.VendorConnectorBase
Github connector for repository operations.
Initialization
Section titled “Initialization”Initialize the connector.
Args: api_key: API key (overrides environment variable) base_url: Base URL (overrides class default) timeout: HTTP timeout in seconds logger: Logger instance **kwargs: Passed to DirectedInputsClass
get_repository_branch(branch_name: str)
Section titled “get_repository_branch(branch_name: str)”Get a repository branch by name.
create_repository_branch(branch_name: str, parent_branch: str | None = None)
Section titled “create_repository_branch(branch_name: str, parent_branch: str | None = None)”Create a new repository branch.
get_repository_file(file_path: vendor_connectors.github.FilePath, decode: bool | None = True, return_sha: bool | None = False, return_path: bool | None = False, charset: str | None = ‘utf-8’, errors: str | None = ‘strict’, raise_on_not_found: bool = False)
Section titled “get_repository_file(file_path: vendor_connectors.github.FilePath, decode: bool | None = True, return_sha: bool | None = False, return_path: bool | None = False, charset: str | None = ‘utf-8’, errors: str | None = ‘strict’, raise_on_not_found: bool = False)”Get a file from the repository.
update_repository_file(file_path: vendor_connectors.github.FilePath, file_data: Any, file_sha: str | None = None, msg: str | None = None, allow_encoding: bool | str | None = None, allow_empty: bool = False, **format_opts: Any)
Section titled “update_repository_file(file_path: vendor_connectors.github.FilePath, file_data: Any, file_sha: str | None = None, msg: str | None = None, allow_encoding: bool | str | None = None, allow_empty: bool = False, **format_opts: Any)”Update a file in the repository.
delete_repository_file(file_path: vendor_connectors.github.FilePath, msg: str | None = None)
Section titled “delete_repository_file(file_path: vendor_connectors.github.FilePath, msg: str | None = None)”Delete a file from the repository.
list_org_members(role: str | None = None, include_pending: bool = False) → dict[str, dict[str, Any]]
Section titled “list_org_members(role: str | None = None, include_pending: bool = False) → dict[str, dict[str, Any]]”List organization members.
Args: role: Filter by role (‘admin’, ‘member’). None returns all. include_pending: Include pending invitations. Defaults to False.
Returns: Dictionary mapping usernames to member data.
get_org_member(username: str) → dict[str, Any] | None
Section titled “get_org_member(username: str) → dict[str, Any] | None”Get a specific organization member.
Args: username: GitHub username.
Returns: Member data or None if not found.
list_repositories(type_filter: str = ‘all’, include_branches: bool = False) → dict[str, dict[str, Any]]
Section titled “list_repositories(type_filter: str = ‘all’, include_branches: bool = False) → dict[str, dict[str, Any]]”List organization repositories.
Args: type_filter: Filter type (‘all’, ‘public’, ‘private’, ‘forks’, ‘sources’, ‘member’). include_branches: Include branch information. Defaults to False.
Returns: Dictionary mapping repo names to repository data.
get_repository(repo_name: str) → dict[str, Any] | None
Section titled “get_repository(repo_name: str) → dict[str, Any] | None”Get a specific repository.
Args: repo_name: Repository name.
Returns: Repository data or None if not found.
list_teams(include_members: bool = False, include_repos: bool = False) → dict[str, dict[str, Any]]
Section titled “list_teams(include_members: bool = False, include_repos: bool = False) → dict[str, dict[str, Any]]”List organization teams.
Args: include_members: Include team members. Defaults to False. include_repos: Include team repositories. Defaults to False.
Returns: Dictionary mapping team slugs to team data.
get_team(team_slug: str) → dict[str, Any] | None
Section titled “get_team(team_slug: str) → dict[str, Any] | None”Get a specific team.
Args: team_slug: Team slug.
Returns: Team data or None if not found.
add_team_member(team_slug: str, username: str, role: str = ‘member’) → bool
Section titled “add_team_member(team_slug: str, username: str, role: str = ‘member’) → bool”Add a member to a team.
Args: team_slug: Team slug. username: GitHub username. role: Role (‘member’ or ‘maintainer’). Defaults to ‘member’.
Returns: True if successful.
remove_team_member(team_slug: str, username: str) → bool
Section titled “remove_team_member(team_slug: str, username: str) → bool”Remove a member from a team.
Args: team_slug: Team slug. username: GitHub username.
Returns: True if successful.
execute_graphql(query: str, variables: dict[str, Any] | None = None) → dict[str, Any]
Section titled “execute_graphql(query: str, variables: dict[str, Any] | None = None) → dict[str, Any]”Execute a GraphQL query against the GitHub API.
Args: query: GraphQL query string. variables: Optional query variables.
Returns: Query response data.
get_users_with_verified_emails(members: dict[str, dict[str, Any]] | None = None, domain_filter: str | None = None) → dict[str, dict[str, Any]]
Section titled “get_users_with_verified_emails(members: dict[str, dict[str, Any]] | None = None, domain_filter: str | None = None) → dict[str, dict[str, Any]]”Get organization members with their verified emails.
Uses GraphQL to get verified email addresses for org members.
Args: members: Pre-fetched members dict. Fetched if not provided. domain_filter: Filter by email domain (e.g., ‘company.com’).
Returns: Dictionary mapping usernames to member data with verified emails.
build_workflow(name: str, on: dict[str, Any], jobs: dict[str, dict[str, Any]], env: dict[str, str] | None = None, permissions: dict[str, str] | None = None, concurrency: dict[str, Any] | None = None, defaults: dict[str, Any] | None = None) → dict[str, Any]
Section titled “build_workflow(name: str, on: dict[str, Any], jobs: dict[str, dict[str, Any]], env: dict[str, str] | None = None, permissions: dict[str, str] | None = None, concurrency: dict[str, Any] | None = None, defaults: dict[str, Any] | None = None) → dict[str, Any]”Build a GitHub Actions workflow structure.
Args: name: Workflow name. on: Trigger configuration. jobs: Jobs configuration. env: Global environment variables. permissions: Workflow permissions. concurrency: Concurrency settings. defaults: Default settings for jobs.
Returns: Workflow configuration dict suitable for YAML export.
build_workflow_job(runs_on: str = ‘ubuntu-latest’, steps: list[dict[str, Any]] | None = None, needs: list[str] | None = None, if_condition: str | None = None, env: dict[str, str] | None = None, strategy: dict[str, Any] | None = None, timeout_minutes: int | None = None, services: dict[str, Any] | None = None, outputs: dict[str, str] | None = None) → dict[str, Any]
Section titled “build_workflow_job(runs_on: str = ‘ubuntu-latest’, steps: list[dict[str, Any]] | None = None, needs: list[str] | None = None, if_condition: str | None = None, env: dict[str, str] | None = None, strategy: dict[str, Any] | None = None, timeout_minutes: int | None = None, services: dict[str, Any] | None = None, outputs: dict[str, str] | None = None) → dict[str, Any]”Build a GitHub Actions workflow job.
Args: runs_on: Runner label(s). steps: Job steps. needs: Dependencies on other jobs. if_condition: Conditional expression. env: Job environment variables. strategy: Matrix strategy. timeout_minutes: Job timeout. services: Service containers. outputs: Job outputs.
Returns: Job configuration dict.
build_workflow_step(name: str, uses: str | None = None, run: str | None = None, with_params: dict[str, Any] | None = None, env: dict[str, str] | None = None, if_condition: str | None = None, working_directory: str | None = None, shell: str | None = None, id: str | None = None) → dict[str, Any]
Section titled “build_workflow_step(name: str, uses: str | None = None, run: str | None = None, with_params: dict[str, Any] | None = None, env: dict[str, str] | None = None, if_condition: str | None = None, working_directory: str | None = None, shell: str | None = None, id: str | None = None) → dict[str, Any]”Build a GitHub Actions workflow step.
Args: name: Step name. uses: Action to use (e.g., ‘actions/checkout@v4’). run: Shell command(s) to run. with_params: Input parameters for the action. env: Step environment variables. if_condition: Conditional expression. working_directory: Working directory for run commands. shell: Shell to use for run commands. id: Step ID for outputs.
Returns: Step configuration dict.
create_python_ci_workflow(python_versions: list[str] | None = None, test_command: str = ‘pytest’, lint_command: str = ‘ruff check’, format_command: str | None = ‘ruff format —check’, install_command: str = ‘uv sync —all-packages’, working_directory: str = ’.’) → dict[str, Any]
Section titled “create_python_ci_workflow(python_versions: list[str] | None = None, test_command: str = ‘pytest’, lint_command: str = ‘ruff check’, format_command: str | None = ‘ruff format —check’, install_command: str = ‘uv sync —all-packages’, working_directory: str = ’.’) → dict[str, Any]”Create a standard Python CI workflow.
Args: python_versions: Python versions to test. Defaults to [‘3.12’]. test_command: Test command. Defaults to ‘pytest’. lint_command: Lint command. Defaults to ‘ruff check’. format_command: Format check command. None to skip. install_command: Dependency install command. working_directory: Working directory for commands.
Returns: Complete workflow configuration.
vendor_connectors.github.build_github_actions_workflow(workflow_name: str, jobs: dict[str, Any], concurrency_group: str | None = None, environment_variables: dict[str, str] | None = None, secrets: dict[str, str] | None = None, use_oidc_auth: bool = True, events: dict[str, Any] | None = None, triggers: dict[str, Any] | None = None, inputs: dict[str, Any] | None = None, pull_requests: dict[str, Any] | None = None) → str
Section titled “vendor_connectors.github.build_github_actions_workflow(workflow_name: str, jobs: dict[str, Any], concurrency_group: str | None = None, environment_variables: dict[str, str] | None = None, secrets: dict[str, str] | None = None, use_oidc_auth: bool = True, events: dict[str, Any] | None = None, triggers: dict[str, Any] | None = None, inputs: dict[str, Any] | None = None, pull_requests: dict[str, Any] | None = None) → str”Generate a GitHub Actions workflow YAML string.