|
| 1 | +# GitHub Module API Reference (`github`) |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +This document provides a detailed API reference for the `github` module in the Agentic DevOps framework. This module offers functionalities to interact with the GitHub API, allowing agents to manage repositories, issues, and pull requests. |
| 6 | + |
| 7 | +## Submodules |
| 8 | + |
| 9 | +### 1. GitHub Service Submodule (`github.github`) |
| 10 | + |
| 11 | +Provides classes and functions for interacting with GitHub API. |
| 12 | + |
| 13 | +#### Models |
| 14 | + |
| 15 | +- `GitHubRepoRequest(BaseModel)`: Model for requesting repository information. |
| 16 | + - `repo_path: str`: Repository path (e.g., `owner/repo-name`). |
| 17 | + - `owner: Optional[str]`: Repository owner (optional if `repo_path` is full path). |
| 18 | + |
| 19 | +- `GitHubIssueRequest(BaseModel)`: Model for requesting issue information. |
| 20 | + - `repo_path: str`: Repository path. |
| 21 | + - `owner: Optional[str]`: Repository owner. |
| 22 | + - `issue_number: int`: Issue number. |
| 23 | + |
| 24 | +- `GitHubCreateIssueRequest(BaseModel)`: Model for creating a new issue. |
| 25 | + - `title: str`: Issue title. |
| 26 | + - `body: Optional[str]`: Issue body/description. |
| 27 | + - `assignees: Optional[List[str]]`: List of usernames to assign. |
| 28 | + - `labels: Optional[List[str]]`: List of labels to apply. |
| 29 | + |
| 30 | +- `GitHubPRRequest(BaseModel)`: Model for requesting pull request information. |
| 31 | + - `repo_path: str`: Repository path. |
| 32 | + - `owner: Optional[str]`: Repository owner. |
| 33 | + - `pr_number: int`: Pull request number. |
| 34 | + |
| 35 | +- `GitHubRepository(BaseModel)`: Model representing a GitHub repository. |
| 36 | + - `name: str`: Repository name. |
| 37 | + - `full_name: str`: Full repository name (owner/repo-name). |
| 38 | + - `description: Optional[str]`: Repository description. |
| 39 | + - `default_branch: str`: Default branch name. |
| 40 | + - `clone_url: str`: Clone URL. |
| 41 | + - `html_url: str`: HTML URL. |
| 42 | + - `created_at: datetime`: Created at timestamp. |
| 43 | + - `updated_at: datetime`: Updated at timestamp. |
| 44 | + - `pushed_at: datetime`: Pushed at timestamp. |
| 45 | + - `stargazers_count: int`: Star count. |
| 46 | + - `forks_count: int`: Fork count. |
| 47 | + - `language: Optional[str]`: Primary language. |
| 48 | + |
| 49 | +- `GitHubIssue(BaseModel)`: Model representing a GitHub issue. |
| 50 | + - `number: int`: Issue number. |
| 51 | + - `title: str`: Issue title. |
| 52 | + - `body: Optional[str]`: Issue body. |
| 53 | + - `state: str`: Issue state (`open`, `closed`). |
| 54 | + - `html_url: str`: HTML URL. |
| 55 | + - `created_at: datetime`: Created at timestamp. |
| 56 | + - `updated_at: datetime`: Updated at timestamp. |
| 57 | + - `closed_at: Optional[datetime]`: Closed at timestamp. |
| 58 | + - `assignees: Optional[List[Dict[str, str]]]`: List of assignees. |
| 59 | + - `labels: Optional[List[Dict[str, str]]]`: List of labels. |
| 60 | + - `user: Optional[Dict[str, str]]`: User who created the issue. |
| 61 | + |
| 62 | +- `GitHubPullRequest(BaseModel)`: Model representing a GitHub pull request. |
| 63 | + - `number: int`: PR number. |
| 64 | + - `title: str`: PR title. |
| 65 | + - `body: Optional[str]`: PR body. |
| 66 | + - `state: str`: PR state (`open`, `closed`). |
| 67 | + - `html_url: str`: HTML URL. |
| 68 | + - `created_at: datetime`: Created at timestamp. |
| 69 | + - `updated_at: datetime`: Updated at timestamp. |
| 70 | + - `closed_at: Optional[datetime]`: Closed at timestamp. |
| 71 | + - `merged_at: Optional[datetime]`: Merged at timestamp. |
| 72 | + - `user: Optional[Dict[str, str]]`: User who created the PR. |
| 73 | + - `head: Dict[str, str]`: Head branch information. |
| 74 | + - `base: Dict[str, str]`: Base branch information. |
| 75 | + |
| 76 | +#### Functions |
| 77 | + |
| 78 | +- `get_repository(repo_path: str, owner: Optional[str] = None, context: Optional[DevOpsContext] = None) -> GitHubRepository`: |
| 79 | + - Gets a GitHub repository. |
| 80 | + - Parameters: |
| 81 | + - `repo_path (str)`: Repository path. |
| 82 | + - `owner (Optional[str])`: Repository owner (optional). |
| 83 | + - `context (Optional[DevOpsContext])`: DevOps context. |
| 84 | + - Returns: `GitHubRepository`: GitHubRepository object. |
| 85 | + |
| 86 | +- `list_repositories(org: Optional[str] = None, user: Optional[str] = None, context: Optional[DevOpsContext] = None) -> List[GitHubRepository]`: |
| 87 | + - Lists GitHub repositories for an organization or user. |
| 88 | + - Parameters: |
| 89 | + - `org (Optional[str])`: Organization name (optional). |
| 90 | + - `user (Optional[str])`: Username (optional). |
| 91 | + - `context (Optional[DevOpsContext])`: DevOps context. |
| 92 | + - Returns: `List[GitHubRepository]`: List of GitHubRepository objects. |
| 93 | + |
| 94 | +- `get_readme(repo_path: str, owner: Optional[str] = None, ref: Optional[str] = None, context: Optional[DevOpsContext] = None) -> Dict[str, Optional[str]]`: |
| 95 | + - Gets README file content from a GitHub repository. |
| 96 | + - Parameters: |
| 97 | + - `repo_path (str)`: Repository path. |
| 98 | + - `owner (Optional[str])`: Repository owner (optional). |
| 99 | + - `ref (Optional[str])`: Git reference (branch, tag, commit) (optional). |
| 100 | + - `context (Optional[DevOpsContext])`: DevOps context. |
| 101 | + - Returns: `Dict[str, Optional[str]]`: Dictionary with 'decoded_content' and 'encoding'. |
| 102 | + |
| 103 | +- `list_issues(repo_path: str, owner: Optional[str] = None, filters: Optional[Dict[str, str]] = None, context: Optional[DevOpsContext] = None) -> List[GitHubIssue]`: |
| 104 | + - Lists issues in a GitHub repository. |
| 105 | + - Parameters: |
| 106 | + - `repo_path (str)`: Repository path. |
| 107 | + - `owner (Optional[str])`: Repository owner (optional). |
| 108 | + - `filters (Optional[Dict[str, str]])`: Filters (e.g., `{'state': 'open'}`). |
| 109 | + - `context (Optional[DevOpsContext])`: DevOps context. |
| 110 | + - Returns: `List[GitHubIssue]`: List of GitHubIssue objects. |
| 111 | + |
| 112 | +- `create_issue(request: GitHubCreateIssueRequest, repo_path: str, owner: Optional[str] = None, context: Optional[DevOpsContext] = None) -> GitHubIssue`: |
| 113 | + - Creates a new issue in a GitHub repository. |
| 114 | + - Parameters: |
| 115 | + - `request (GitHubCreateIssueRequest)`: Issue creation request. |
| 116 | + - `repo_path (str)`: Repository path. |
| 117 | + - `owner (Optional[str])`: Repository owner (optional). |
| 118 | + - `context (Optional[DevOpsContext])`: DevOps context. |
| 119 | + - Returns: `GitHubIssue`: Created GitHubIssue object. |
| 120 | + |
| 121 | +- `list_pull_requests(repo_path: str, owner: Optional[str] = None, filters: Optional[Dict[str, str]] = None, context: Optional[DevOpsContext] = None) -> List[GitHubPullRequest]`: |
| 122 | + - Lists pull requests in a GitHub repository. |
| 123 | + - Parameters: |
| 124 | + - `repo_path (str)`: Repository path. |
| 125 | + - `owner (Optional[str])`: Repository owner (optional). |
| 126 | + - `filters (Optional[Dict[str, str]])`: Filters (e.g., `{'state': 'open'}`). |
| 127 | + - `context (Optional[DevOpsContext])`: DevOps context. |
| 128 | + - Returns: `List[GitHubPullRequest]`: List of GitHubPullRequest objects. |
| 129 | + |
| 130 | +### 2. Base Submodule (`github.github`) |
| 131 | + |
| 132 | +Provides base classes and exceptions for GitHub module. |
| 133 | + |
| 134 | +#### Classes |
| 135 | + |
| 136 | +- `GitHubError(Exception)`: Base class for GitHub exceptions. |
| 137 | +- `AuthenticationError(GitHubError)`: Authentication error exception. |
| 138 | +- `RepositoryNotFoundError(GitHubError)`: Repository not found exception. |
| 139 | +- `IssueNotFoundError(GitHubError)`: Issue not found exception. |
| 140 | +- `PullRequestNotFoundError(GitHubError)`: Pull request not found exception. |
| 141 | + |
| 142 | +This document provides a comprehensive API reference for the GitHub module, detailing its submodules, classes, models, and functions. |
0 commit comments