pub struct InstallationClient { /* private fields */ }Expand description
Installation-scoped GitHub API client.
Holds a reference to the parent GitHubClient for shared HTTP client,
auth provider, and rate limiter. All operations use installation tokens.
Implementations§
Source§impl InstallationClient
impl InstallationClient
Sourcepub async fn get_commit(
&self,
owner: &str,
repo: &str,
ref_name: &str,
) -> Result<FullCommit, ApiError>
pub async fn get_commit( &self, owner: &str, repo: &str, ref_name: &str, ) -> Result<FullCommit, ApiError>
Get a single commit by SHA, branch name, or tag name.
Retrieves complete commit details including the author, committer, commit message, parent references, and GPG verification status.
§Arguments
owner- Repository owner loginrepo- Repository nameref_name- Commit SHA (full or abbreviated), branch name, or tag name
§Returns
Returns a FullCommit with complete metadata.
§Errors
ApiError::NotFound- Commit or ref doesn’t exist, or repository not foundApiError::InvalidRequest- Invalid ref syntax or empty repository (GitHub returns 422)ApiError::AuthorizationFailed- Missingcontents:readpermissionApiError::AuthenticationFailed- Token expired or invalidApiError::HttpError- Unexpected API response
§Examples
// Get by SHA
let commit = client.get_commit("owner", "repo", "abc123def456").await?;
println!("Message: {}", commit.commit.message);
// Get by branch name
let head = client.get_commit("owner", "repo", "main").await?;
println!("HEAD: {}", head.sha);
// Get by tag
let release = client.get_commit("owner", "repo", "v1.0.0").await?;
println!("Release commit: {}", release.sha);§GitHub API
GET /repos/{owner}/{repo}/commits/{ref}
See https://docs.github.com/en/rest/commits/commits#get-a-commit
Sourcepub async fn list_commits(
&self,
owner: &str,
repo: &str,
sha: Option<&str>,
path: Option<&str>,
author: Option<&str>,
since: Option<DateTime<Utc>>,
until: Option<DateTime<Utc>>,
per_page: Option<u32>,
page: Option<u32>,
) -> Result<Vec<FullCommit>, ApiError>
pub async fn list_commits( &self, owner: &str, repo: &str, sha: Option<&str>, path: Option<&str>, author: Option<&str>, since: Option<DateTime<Utc>>, until: Option<DateTime<Utc>>, per_page: Option<u32>, page: Option<u32>, ) -> Result<Vec<FullCommit>, ApiError>
List commits in a repository with optional filtering.
Returns commits in reverse chronological order (newest first). All filter arguments are combined with AND logic.
§Arguments
owner- Repository owner loginrepo- Repository namesha- SHA or branch name to start listing from (default: repository default branch)path- Only return commits that modified this file path or directoryauthor- Filter by GitHub username or commit author email addresssince- Only include commits after this timestamp (inclusive)until- Only include commits before this timestamp (inclusive)per_page- Number of results per page; clamped to the range 1..=100page- Page number for pagination (1-based, default: 1)
§Returns
Returns a Vec<FullCommit> in reverse chronological order.
§Errors
ApiError::NotFound- Repository not foundApiError::InvalidRequest- Repository is empty (GitHub returns 422)ApiError::AuthorizationFailed- Missingcontents:readpermissionApiError::AuthenticationFailed- Token expired or invalidApiError::HttpError- Unexpected API response
§Examples
// List recent commits on the default branch
let commits = client.list_commits(
"owner", "repo",
None, None, None, None, None, None, None
).await?;
// List commits on a feature branch
let feature_commits = client.list_commits(
"owner", "repo",
Some("feature-branch"), None, None, None, None, None, None
).await?;
// List commits affecting a specific file
let readme_commits = client.list_commits(
"owner", "repo",
None, Some("README.md"), None, None, None, Some(50), None
).await?;
// List commits by author in a date range
let since = "2026-01-01T00:00:00Z".parse::<DateTime<Utc>>()?;
let until = "2026-01-31T23:59:59Z".parse::<DateTime<Utc>>()?;
let author_commits = client.list_commits(
"owner", "repo",
None, None, Some("alice"), Some(since), Some(until), None, None
).await?;§Notes
per_pageis silently clamped to the range 1..=100 (GitHub API maximum is 100; 0 is raised to 1).- Empty repositories cause GitHub to return 422, mapped to
ApiError::InvalidRequest.
§GitHub API
GET /repos/{owner}/{repo}/commits
See https://docs.github.com/en/rest/commits/commits#list-commits
Sourcepub async fn compare_commits(
&self,
owner: &str,
repo: &str,
base: &str,
head: &str,
) -> Result<Comparison, ApiError>
pub async fn compare_commits( &self, owner: &str, repo: &str, base: &str, head: &str, ) -> Result<Comparison, ApiError>
Compare two commits, branches, or tags.
Returns a complete comparison including the list of commits between the two refs and every file that changed, with per-file statistics. Useful for changelog generation and release notes automation.
§Arguments
owner- Repository owner loginrepo- Repository namebase- Base ref (SHA, branch, or tag) — the starting pointhead- Head ref (SHA, branch, or tag) — the ending point
§Returns
Returns a Comparison with commits, file changes, and statistics.
§Errors
ApiError::NotFound- Base or head ref not found, or repository not foundApiError::AuthorizationFailed- Missingcontents:readpermissionApiError::AuthenticationFailed- Token expired or invalidApiError::HttpError- Unexpected API response
§Examples
// Compare two tags for release notes
let cmp = client.compare_commits("owner", "repo", "v1.0.0", "v1.1.0").await?;
println!("Status: {}", cmp.status);
println!("Commits: {}", cmp.total_commits);
println!("Files changed: {}", cmp.files.len());
for commit in &cmp.commits {
let subject = commit.commit.message.lines().next().unwrap_or("");
println!("- {}", subject);
}
// Compare a feature branch to main
let branch_diff = client.compare_commits("owner", "repo", "main", "feature-x").await?;
match branch_diff.status.as_str() {
"ahead" => println!("Feature is {} commits ahead", branch_diff.ahead_by),
"behind" => println!("Feature is {} commits behind", branch_diff.behind_by),
"identical" => println!("Branches are identical"),
"diverged" => println!("Branches have diverged"),
_ => {}
}§Comparison Status Values
| Status | Meaning |
|---|---|
"ahead" | Head has commits not in base |
"behind" | Base has commits not in head |
"identical" | Both refs point to the same commit |
"diverged" | Refs have different histories |
§Notes
- Commits are returned in chronological order (oldest to newest).
- GitHub limits comparisons to 250 commits.
- File patches may be absent for binary files or very large diffs.
§GitHub API
GET /repos/{owner}/{repo}/compare/{base}...{head}
See https://docs.github.com/en/rest/commits/commits#compare-two-commits
Source§impl InstallationClient
impl InstallationClient
Sourcepub fn new(client: Arc<GitHubClient>, installation_id: InstallationId) -> Self
pub fn new(client: Arc<GitHubClient>, installation_id: InstallationId) -> Self
Create a new installation client.
§Arguments
client- Parent GitHubClientinstallation_id- Installation ID to bind to
Sourcepub fn installation_id(&self) -> InstallationId
pub fn installation_id(&self) -> InstallationId
Get the installation ID this client is bound to.
Sourcepub async fn get(&self, path: &str) -> Result<Response, ApiError>
pub async fn get(&self, path: &str) -> Result<Response, ApiError>
Make an authenticated GET request to the GitHub API.
Uses installation token for authentication and includes automatic retry logic for transient errors (5xx, 429, network failures).
§Arguments
path- API path (e.g., “/repos/owner/repo” or “repos/owner/repo”)
§Returns
Returns the raw reqwest::Response for flexible handling.
§Errors
Returns ApiError for HTTP errors, authentication failures, or network issues.
Sourcepub async fn put<T: Serialize>(
&self,
path: &str,
body: &T,
) -> Result<Response, ApiError>
pub async fn put<T: Serialize>( &self, path: &str, body: &T, ) -> Result<Response, ApiError>
Make an authenticated PUT request to the GitHub API.
Includes automatic retry logic for transient errors.
Sourcepub async fn delete(&self, path: &str) -> Result<Response, ApiError>
pub async fn delete(&self, path: &str) -> Result<Response, ApiError>
Make an authenticated DELETE request to the GitHub API.
Includes automatic retry logic for transient errors.
Sourcepub async fn post_graphql<V: Serialize>(
&self,
query: &str,
variables: V,
) -> Result<Value, ApiError>
pub async fn post_graphql<V: Serialize>( &self, query: &str, variables: V, ) -> Result<Value, ApiError>
Make an authenticated POST request to the GitHub GraphQL API.
GitHub’s GraphQL endpoint always returns HTTP 200 even for errors.
Application-level errors are detected by checking the .errors
array in the response body; the first error message is surfaced as
ApiError::GraphQlError. On success, the .data value is returned.
Retry logic (backoff, 5xx, rate-limit handling) is identical to the REST helpers because the transport layer is the same.
§Arguments
query- GraphQL query or mutation stringvariables- Variables object (serialised to JSON)
§Returns
Returns the data field from the GraphQL response as a serde_json::Value.
§Errors
ApiError::GraphQlError— GitHub returned.errorsin the bodyApiError::GraphQlError— response body contains neither.errorsnor a non-null.datafield (malformed or unexpected response shape)ApiError::AuthenticationFailed— HTTP 401ApiError::JsonError— response body could not be parsed- Any other
ApiErrorvariant for HTTP-level failures
Source§impl InstallationClient
impl InstallationClient
Sourcepub async fn list_issues(
&self,
owner: &str,
repo: &str,
state: Option<&str>,
page: Option<u32>,
) -> Result<PagedResponse<Issue>, ApiError>
pub async fn list_issues( &self, owner: &str, repo: &str, state: Option<&str>, page: Option<u32>, ) -> Result<PagedResponse<Issue>, ApiError>
List issues in a repository.
Returns a paginated response with issues and pagination metadata. Use the pagination information to fetch subsequent pages if needed.
§Arguments
owner- Repository ownerrepo- Repository namestate- Filter by state ("open","closed", or"all")page- Page number (1-indexed, omit for first page)
§Examples
// Get first page
let response = client.list_issues("owner", "repo", None, None).await?;
println!("Got {} issues", response.items.len());
// Check if more pages exist
if response.has_next() {
if let Some(next_page) = response.next_page_number() {
let next_response = client.list_issues("owner", "repo", None, Some(next_page)).await?;
println!("Got {} more issues", next_response.items.len());
}
}Sourcepub async fn get_issue(
&self,
owner: &str,
repo: &str,
issue_number: u64,
) -> Result<Issue, ApiError>
pub async fn get_issue( &self, owner: &str, repo: &str, issue_number: u64, ) -> Result<Issue, ApiError>
Get a specific issue by number.
Sourcepub async fn create_issue(
&self,
owner: &str,
repo: &str,
request: CreateIssueRequest,
) -> Result<Issue, ApiError>
pub async fn create_issue( &self, owner: &str, repo: &str, request: CreateIssueRequest, ) -> Result<Issue, ApiError>
Create a new issue.
Sourcepub async fn update_issue(
&self,
owner: &str,
repo: &str,
issue_number: u64,
request: UpdateIssueRequest,
) -> Result<Issue, ApiError>
pub async fn update_issue( &self, owner: &str, repo: &str, issue_number: u64, request: UpdateIssueRequest, ) -> Result<Issue, ApiError>
Update an existing issue.
Sourcepub async fn set_issue_milestone(
&self,
owner: &str,
repo: &str,
issue_number: u64,
milestone_number: Option<u64>,
) -> Result<Issue, ApiError>
pub async fn set_issue_milestone( &self, owner: &str, repo: &str, issue_number: u64, milestone_number: Option<u64>, ) -> Result<Issue, ApiError>
Set the milestone on an issue.
Sourcepub async fn list_labels(
&self,
owner: &str,
repo: &str,
) -> Result<Vec<Label>, ApiError>
pub async fn list_labels( &self, owner: &str, repo: &str, ) -> Result<Vec<Label>, ApiError>
List all labels in a repository.
See docs/spec/interfaces/issue-operations.md
Sourcepub async fn get_label(
&self,
owner: &str,
repo: &str,
name: &str,
) -> Result<Label, ApiError>
pub async fn get_label( &self, owner: &str, repo: &str, name: &str, ) -> Result<Label, ApiError>
Get a specific label by name.
See docs/spec/interfaces/issue-operations.md
Sourcepub async fn create_label(
&self,
owner: &str,
repo: &str,
request: CreateLabelRequest,
) -> Result<Label, ApiError>
pub async fn create_label( &self, owner: &str, repo: &str, request: CreateLabelRequest, ) -> Result<Label, ApiError>
Create a new label.
See docs/spec/interfaces/issue-operations.md
Sourcepub async fn update_label(
&self,
owner: &str,
repo: &str,
name: &str,
request: UpdateLabelRequest,
) -> Result<Label, ApiError>
pub async fn update_label( &self, owner: &str, repo: &str, name: &str, request: UpdateLabelRequest, ) -> Result<Label, ApiError>
Update an existing label.
See docs/spec/interfaces/issue-operations.md
Sourcepub async fn delete_label(
&self,
owner: &str,
repo: &str,
name: &str,
) -> Result<(), ApiError>
pub async fn delete_label( &self, owner: &str, repo: &str, name: &str, ) -> Result<(), ApiError>
Delete a label.
See docs/spec/interfaces/issue-operations.md
Sourcepub async fn add_labels_to_issue(
&self,
owner: &str,
repo: &str,
issue_number: u64,
labels: Vec<String>,
) -> Result<Vec<Label>, ApiError>
pub async fn add_labels_to_issue( &self, owner: &str, repo: &str, issue_number: u64, labels: Vec<String>, ) -> Result<Vec<Label>, ApiError>
Add labels to an issue.
See docs/spec/interfaces/issue-operations.md
Sourcepub async fn remove_label_from_issue(
&self,
owner: &str,
repo: &str,
issue_number: u64,
name: &str,
) -> Result<Vec<Label>, ApiError>
pub async fn remove_label_from_issue( &self, owner: &str, repo: &str, issue_number: u64, name: &str, ) -> Result<Vec<Label>, ApiError>
Remove a label from an issue.
See docs/spec/interfaces/issue-operations.md
Sourcepub async fn list_issue_comments(
&self,
owner: &str,
repo: &str,
issue_number: u64,
) -> Result<Vec<Comment>, ApiError>
pub async fn list_issue_comments( &self, owner: &str, repo: &str, issue_number: u64, ) -> Result<Vec<Comment>, ApiError>
List comments on an issue.
See docs/spec/interfaces/issue-operations.md
Sourcepub async fn get_issue_comment(
&self,
owner: &str,
repo: &str,
comment_id: u64,
) -> Result<Comment, ApiError>
pub async fn get_issue_comment( &self, owner: &str, repo: &str, comment_id: u64, ) -> Result<Comment, ApiError>
Get a specific comment by ID.
See docs/spec/interfaces/issue-operations.md
Sourcepub async fn create_issue_comment(
&self,
owner: &str,
repo: &str,
issue_number: u64,
request: CreateCommentRequest,
) -> Result<Comment, ApiError>
pub async fn create_issue_comment( &self, owner: &str, repo: &str, issue_number: u64, request: CreateCommentRequest, ) -> Result<Comment, ApiError>
Create a comment on an issue.
See docs/spec/interfaces/issue-operations.md
Sourcepub async fn update_issue_comment(
&self,
owner: &str,
repo: &str,
comment_id: u64,
request: UpdateCommentRequest,
) -> Result<Comment, ApiError>
pub async fn update_issue_comment( &self, owner: &str, repo: &str, comment_id: u64, request: UpdateCommentRequest, ) -> Result<Comment, ApiError>
Update an existing comment.
See docs/spec/interfaces/issue-operations.md
Source§impl InstallationClient
impl InstallationClient
Sourcepub async fn list_organization_projects(
&self,
_org: &str,
) -> Result<Vec<ProjectV2>, ApiError>
pub async fn list_organization_projects( &self, _org: &str, ) -> Result<Vec<ProjectV2>, ApiError>
List all Projects v2 for an organisation.
See docs/spec/interfaces/project-operations.md
Sourcepub async fn list_user_projects(
&self,
_username: &str,
) -> Result<Vec<ProjectV2>, ApiError>
pub async fn list_user_projects( &self, _username: &str, ) -> Result<Vec<ProjectV2>, ApiError>
List all Projects v2 for a user.
See docs/spec/interfaces/project-operations.md
Sourcepub async fn get_project(
&self,
_owner: &str,
_project_number: u64,
) -> Result<ProjectV2, ApiError>
pub async fn get_project( &self, _owner: &str, _project_number: u64, ) -> Result<ProjectV2, ApiError>
Get details about a specific project.
See docs/spec/interfaces/project-operations.md
Sourcepub async fn add_item_to_project(
&self,
owner: &str,
project_number: u64,
content_node_id: &str,
) -> Result<ProjectV2Item, ApiError>
pub async fn add_item_to_project( &self, owner: &str, project_number: u64, content_node_id: &str, ) -> Result<ProjectV2Item, ApiError>
Add an issue or pull request to a project.
Resolves the project node ID from owner + project_number (trying organisation
first, then falling back to user), then calls the addProjectV2ItemById GraphQL
mutation to attach the content.
§Arguments
owner- Organisation or user login nameproject_number- Project number (unique within owner)content_node_id- Node ID of the issue or pull request to add
§Returns
Ok(ProjectV2Item)— the newly created project itemErr(ApiError::NotFound)— project not found for this ownerErr(ApiError::AuthorizationFailed)— no write access to the projectErr(ApiError)— other transport or GraphQL errors
Sourcepub async fn get_issue_linked_projects(
&self,
owner: &str,
repo: &str,
issue_number: u64,
) -> Result<Vec<ProjectV2>, ApiError>
pub async fn get_issue_linked_projects( &self, owner: &str, repo: &str, issue_number: u64, ) -> Result<Vec<ProjectV2>, ApiError>
Get all Projects v2 linked to a specific issue.
Queries the GitHub GraphQL API for all Projects v2 that contain the given issue.
Returns an empty Vec when the issue exists but is not linked to any projects.
Results are fetched in pages of 20; all pages are retrieved automatically and
returned as a single combined Vec.
§Arguments
owner- Repository owner (organisation or user login)repo- Repository nameissue_number- Issue number
§Returns
Ok(Vec<ProjectV2>)— all projects linked to the issue (may be empty)Err(ApiError::NotFound)— repository or issue does not existErr(ApiError::AuthenticationFailed)— token is invalidErr(ApiError)— other transport or GraphQL errors
Source§impl InstallationClient
impl InstallationClient
Sourcepub async fn list_pull_requests(
&self,
owner: &str,
repo: &str,
state: Option<&str>,
page: Option<u32>,
) -> Result<PagedResponse<PullRequest>, ApiError>
pub async fn list_pull_requests( &self, owner: &str, repo: &str, state: Option<&str>, page: Option<u32>, ) -> Result<PagedResponse<PullRequest>, ApiError>
List pull requests in a repository.
Returns a paginated response with pull requests and pagination metadata. Use the pagination information to fetch subsequent pages if needed.
§Arguments
owner- Repository ownerrepo- Repository namestate- Filter by state ("open","closed", or"all")page- Page number (1-indexed, omit for first page)
§Examples
// Get first page
let response = client.list_pull_requests("owner", "repo", None, None).await?;
println!("Got {} pull requests", response.items.len());
// Check if more pages exist
if response.has_next() {
if let Some(next_page) = response.next_page_number() {
let next_response = client.list_pull_requests("owner", "repo", None, Some(next_page)).await?;
println!("Got {} more PRs", next_response.items.len());
}
}See docs/spec/interfaces/pull-request-operations.md
Sourcepub async fn get_pull_request(
&self,
owner: &str,
repo: &str,
pull_number: u64,
) -> Result<PullRequest, ApiError>
pub async fn get_pull_request( &self, owner: &str, repo: &str, pull_number: u64, ) -> Result<PullRequest, ApiError>
Get a specific pull request by number.
See docs/spec/interfaces/pull-request-operations.md
Sourcepub async fn create_pull_request(
&self,
owner: &str,
repo: &str,
request: CreatePullRequestRequest,
) -> Result<PullRequest, ApiError>
pub async fn create_pull_request( &self, owner: &str, repo: &str, request: CreatePullRequestRequest, ) -> Result<PullRequest, ApiError>
Create a new pull request.
See docs/spec/interfaces/pull-request-operations.md
Sourcepub async fn update_pull_request(
&self,
owner: &str,
repo: &str,
pull_number: u64,
request: UpdatePullRequestRequest,
) -> Result<PullRequest, ApiError>
pub async fn update_pull_request( &self, owner: &str, repo: &str, pull_number: u64, request: UpdatePullRequestRequest, ) -> Result<PullRequest, ApiError>
Update an existing pull request.
See docs/spec/interfaces/pull-request-operations.md
Sourcepub async fn merge_pull_request(
&self,
owner: &str,
repo: &str,
pull_number: u64,
request: MergePullRequestRequest,
) -> Result<MergeResult, ApiError>
pub async fn merge_pull_request( &self, owner: &str, repo: &str, pull_number: u64, request: MergePullRequestRequest, ) -> Result<MergeResult, ApiError>
Merge a pull request.
See docs/spec/interfaces/pull-request-operations.md
Sourcepub async fn set_pull_request_milestone(
&self,
owner: &str,
repo: &str,
pull_number: u64,
milestone_number: Option<u64>,
) -> Result<PullRequest, ApiError>
pub async fn set_pull_request_milestone( &self, owner: &str, repo: &str, pull_number: u64, milestone_number: Option<u64>, ) -> Result<PullRequest, ApiError>
Set the milestone on a pull request.
See docs/spec/interfaces/pull-request-operations.md
Sourcepub async fn list_reviews(
&self,
owner: &str,
repo: &str,
pull_number: u64,
) -> Result<Vec<Review>, ApiError>
pub async fn list_reviews( &self, owner: &str, repo: &str, pull_number: u64, ) -> Result<Vec<Review>, ApiError>
List reviews on a pull request.
See docs/spec/interfaces/pull-request-operations.md
Sourcepub async fn get_review(
&self,
owner: &str,
repo: &str,
pull_number: u64,
review_id: u64,
) -> Result<Review, ApiError>
pub async fn get_review( &self, owner: &str, repo: &str, pull_number: u64, review_id: u64, ) -> Result<Review, ApiError>
Get a specific review by ID.
See docs/spec/interfaces/pull-request-operations.md
Sourcepub async fn create_review(
&self,
owner: &str,
repo: &str,
pull_number: u64,
request: CreateReviewRequest,
) -> Result<Review, ApiError>
pub async fn create_review( &self, owner: &str, repo: &str, pull_number: u64, request: CreateReviewRequest, ) -> Result<Review, ApiError>
Create a review on a pull request.
See docs/spec/interfaces/pull-request-operations.md
Sourcepub async fn update_review(
&self,
owner: &str,
repo: &str,
pull_number: u64,
review_id: u64,
request: UpdateReviewRequest,
) -> Result<Review, ApiError>
pub async fn update_review( &self, owner: &str, repo: &str, pull_number: u64, review_id: u64, request: UpdateReviewRequest, ) -> Result<Review, ApiError>
Update a pending review.
See docs/spec/interfaces/pull-request-operations.md
Sourcepub async fn dismiss_review(
&self,
owner: &str,
repo: &str,
pull_number: u64,
review_id: u64,
request: DismissReviewRequest,
) -> Result<Review, ApiError>
pub async fn dismiss_review( &self, owner: &str, repo: &str, pull_number: u64, review_id: u64, request: DismissReviewRequest, ) -> Result<Review, ApiError>
Dismiss a review.
See docs/spec/interfaces/pull-request-operations.md
Sourcepub async fn list_pull_request_comments(
&self,
owner: &str,
repo: &str,
pull_number: u64,
) -> Result<Vec<PullRequestComment>, ApiError>
pub async fn list_pull_request_comments( &self, owner: &str, repo: &str, pull_number: u64, ) -> Result<Vec<PullRequestComment>, ApiError>
List comments on a pull request.
See docs/spec/interfaces/pull-request-operations.md
Sourcepub async fn create_pull_request_comment(
&self,
owner: &str,
repo: &str,
pull_number: u64,
request: CreatePullRequestCommentRequest,
) -> Result<PullRequestComment, ApiError>
pub async fn create_pull_request_comment( &self, owner: &str, repo: &str, pull_number: u64, request: CreatePullRequestCommentRequest, ) -> Result<PullRequestComment, ApiError>
Create a comment on a pull request.
See docs/spec/interfaces/pull-request-operations.md
Source§impl InstallationClient
impl InstallationClient
Sourcepub async fn list_releases(
&self,
owner: &str,
repo: &str,
) -> Result<Vec<Release>, ApiError>
pub async fn list_releases( &self, owner: &str, repo: &str, ) -> Result<Vec<Release>, ApiError>
List releases in a repository.
Retrieves all releases for a repository, including drafts and prereleases.
§Arguments
owner- Repository ownerrepo- Repository name
§Returns
Returns vector of releases ordered by creation date (newest first).
§Errors
ApiError::NotFound- Repository does not existApiError::AuthorizationFailed- Insufficient permissions
§Example
let releases = client.list_releases("owner", "repo").await?;
for release in releases {
println!("Release: {} ({})", release.name.unwrap_or_default(), release.tag_name);
}Sourcepub async fn get_latest_release(
&self,
owner: &str,
repo: &str,
) -> Result<Release, ApiError>
pub async fn get_latest_release( &self, owner: &str, repo: &str, ) -> Result<Release, ApiError>
Get the latest published release.
Returns the most recent non-draft, non-prerelease release.
§Arguments
owner- Repository ownerrepo- Repository name
§Returns
Returns the latest published Release.
§Errors
ApiError::NotFound- Repository or no published releases existApiError::AuthorizationFailed- Insufficient permissions
§Example
let release = client.get_latest_release("owner", "repo").await?;
println!("Latest: {} ({})", release.name.unwrap_or_default(), release.tag_name);Sourcepub async fn get_release_by_tag(
&self,
owner: &str,
repo: &str,
tag: &str,
) -> Result<Release, ApiError>
pub async fn get_release_by_tag( &self, owner: &str, repo: &str, tag: &str, ) -> Result<Release, ApiError>
Get a release by tag name.
Retrieves a release by its git tag name.
§Arguments
owner- Repository ownerrepo- Repository nametag- Git tag name
§Returns
Returns the Release with the specified tag.
§Errors
ApiError::NotFound- Release with tag does not existApiError::AuthorizationFailed- Insufficient permissions
§Example
let release = client.get_release_by_tag("owner", "repo", "v1.0.0").await?;
println!("Release: {}", release.tag_name);Sourcepub async fn get_release(
&self,
owner: &str,
repo: &str,
release_id: u64,
) -> Result<Release, ApiError>
pub async fn get_release( &self, owner: &str, repo: &str, release_id: u64, ) -> Result<Release, ApiError>
Get a release by ID.
Retrieves a release by its unique identifier.
§Arguments
owner- Repository ownerrepo- Repository namerelease_id- Release ID
§Returns
Returns the Release with the specified ID.
§Errors
ApiError::NotFound- Release does not existApiError::AuthorizationFailed- Insufficient permissions
§Example
let release = client.get_release("owner", "repo", 12345).await?;
println!("Release: {}", release.tag_name);Sourcepub async fn create_release(
&self,
owner: &str,
repo: &str,
request: CreateReleaseRequest,
) -> Result<Release, ApiError>
pub async fn create_release( &self, owner: &str, repo: &str, request: CreateReleaseRequest, ) -> Result<Release, ApiError>
Create a new release.
Creates a new release for a repository. Can create published releases, drafts, or prereleases.
§Arguments
owner- Repository ownerrepo- Repository namerequest- Release creation parameters
§Returns
Returns the created Release.
§Errors
ApiError::InvalidRequest- Tag already exists or invalid parametersApiError::AuthorizationFailed- Insufficient permissions
§Example
let request = CreateReleaseRequest {
tag_name: "v1.0.0".to_string(),
name: Some("Version 1.0.0".to_string()),
body: Some("Release notes".to_string()),
draft: Some(false),
prerelease: Some(false),
target_commitish: None,
generate_release_notes: None,
};
let release = client.create_release("owner", "repo", request).await?;
println!("Created release: {}", release.tag_name);Sourcepub async fn update_release(
&self,
owner: &str,
repo: &str,
release_id: u64,
request: UpdateReleaseRequest,
) -> Result<Release, ApiError>
pub async fn update_release( &self, owner: &str, repo: &str, release_id: u64, request: UpdateReleaseRequest, ) -> Result<Release, ApiError>
Update an existing release.
Updates release properties. Only specified fields are modified.
§Arguments
owner- Repository ownerrepo- Repository namerelease_id- Release IDrequest- Fields to update
§Returns
Returns the updated Release.
§Errors
ApiError::NotFound- Release does not existApiError::InvalidRequest- Invalid parametersApiError::AuthorizationFailed- Insufficient permissions
§Example
let request = UpdateReleaseRequest {
name: Some("Updated name".to_string()),
body: Some("Updated notes".to_string()),
..Default::default()
};
let release = client.update_release("owner", "repo", 12345, request).await?;
println!("Updated release: {}", release.tag_name);Sourcepub async fn delete_release(
&self,
owner: &str,
repo: &str,
release_id: u64,
) -> Result<(), ApiError>
pub async fn delete_release( &self, owner: &str, repo: &str, release_id: u64, ) -> Result<(), ApiError>
Delete a release.
Deletes a release. Does not delete the associated git tag.
§Arguments
owner- Repository ownerrepo- Repository namerelease_id- Release ID
§Returns
Returns Ok(()) on successful deletion.
§Errors
ApiError::NotFound- Release does not existApiError::AuthorizationFailed- Insufficient permissions
§Example
client.delete_release("owner", "repo", 12345).await?;
println!("Release deleted");Source§impl InstallationClient
impl InstallationClient
Sourcepub async fn get_repository(
&self,
owner: &str,
repo: &str,
) -> Result<Repository, ApiError>
pub async fn get_repository( &self, owner: &str, repo: &str, ) -> Result<Repository, ApiError>
Get repository metadata.
Retrieves complete metadata for a repository including owner information, visibility settings, default branch, and timestamps.
§Arguments
owner- Repository owner (username or organization)repo- Repository name
§Returns
Returns Repository with complete metadata on success.
§Errors
ApiError::NotFound- Repository does not exist or is not accessibleApiError::AuthorizationFailed- Insufficient permissions to access repositoryApiError::HttpError- GitHub API returned an error
§Example
let repo = client.get_repository("octocat", "Hello-World").await?;
println!("Repository: {}", repo.full_name);
println!("Default branch: {}", repo.default_branch);Sourcepub async fn list_branches(
&self,
owner: &str,
repo: &str,
) -> Result<Vec<Branch>, ApiError>
pub async fn list_branches( &self, owner: &str, repo: &str, ) -> Result<Vec<Branch>, ApiError>
List all branches in a repository.
Returns an array of all branches with their commit information and protection status.
§Arguments
owner- Repository ownerrepo- Repository name
§Returns
Returns Vec<Branch> with all repository branches.
§Errors
ApiError::NotFound- Repository does not existApiError::AuthorizationFailed- Insufficient permissions
§Example
let branches = client.list_branches("octocat", "Hello-World").await?;
for branch in branches {
println!("Branch: {} (protected: {})", branch.name, branch.protected);
}Sourcepub async fn get_branch(
&self,
owner: &str,
repo: &str,
branch: &str,
) -> Result<Branch, ApiError>
pub async fn get_branch( &self, owner: &str, repo: &str, branch: &str, ) -> Result<Branch, ApiError>
Get a specific branch by name.
Retrieves detailed information about a single branch including commit SHA and protection status.
§Arguments
owner- Repository ownerrepo- Repository namebranch- Branch name
§Returns
Returns Branch with branch details.
§Errors
ApiError::NotFound- Branch or repository does not existApiError::AuthorizationFailed- Insufficient permissions
§Example
let branch = client.get_branch("octocat", "Hello-World", "main").await?;
println!("Branch {} at commit {}", branch.name, branch.commit.sha);Sourcepub async fn get_git_ref(
&self,
owner: &str,
repo: &str,
ref_name: &str,
) -> Result<GitRef, ApiError>
pub async fn get_git_ref( &self, owner: &str, repo: &str, ref_name: &str, ) -> Result<GitRef, ApiError>
Get a Git reference (branch or tag).
Retrieves information about a Git reference including the SHA it points to.
§Arguments
owner- Repository ownerrepo- Repository nameref_name- Reference name (e.g., “heads/main” or “tags/v1.0.0”)
§Returns
Returns GitRef with reference details.
§Errors
ApiError::NotFound- Reference does not exist
§Example
let git_ref = client.get_git_ref("octocat", "Hello-World", "heads/main").await?;
println!("Ref {} points to {}", git_ref.ref_name, git_ref.object.sha);Sourcepub async fn create_git_ref(
&self,
owner: &str,
repo: &str,
ref_name: &str,
sha: &str,
) -> Result<GitRef, ApiError>
pub async fn create_git_ref( &self, owner: &str, repo: &str, ref_name: &str, sha: &str, ) -> Result<GitRef, ApiError>
Create a new Git reference (branch or tag).
Creates a new reference pointing to the specified SHA.
§Arguments
owner- Repository ownerrepo- Repository nameref_name- Full reference name (e.g., “refs/heads/new-branch”)sha- SHA that the reference should point to
§Returns
Returns GitRef for the newly created reference.
§Errors
ApiError::InvalidRequest- Reference already exists or invalid SHA
§Example
let git_ref = client.create_git_ref(
"octocat",
"Hello-World",
"refs/heads/new-feature",
"aa218f56b14c9653891f9e74264a383fa43fefbd"
).await?;Sourcepub async fn update_git_ref(
&self,
owner: &str,
repo: &str,
ref_name: &str,
sha: &str,
force: bool,
) -> Result<GitRef, ApiError>
pub async fn update_git_ref( &self, owner: &str, repo: &str, ref_name: &str, sha: &str, force: bool, ) -> Result<GitRef, ApiError>
Update an existing Git reference.
Updates a reference to point to a new SHA. Use force=true to allow
non-fast-forward updates.
§Arguments
owner- Repository ownerrepo- Repository nameref_name- Reference name (e.g., “heads/main”)sha- New SHA for the referenceforce- Allow non-fast-forward updates
§Returns
Returns GitRef with updated reference details.
§Errors
ApiError::NotFound- Reference does not existApiError::InvalidRequest- Invalid SHA or non-fast-forward without force
§Example
let git_ref = client.update_git_ref(
"octocat",
"Hello-World",
"heads/feature",
"bb218f56b14c9653891f9e74264a383fa43fefbd",
false
).await?;Sourcepub async fn delete_git_ref(
&self,
owner: &str,
repo: &str,
ref_name: &str,
) -> Result<(), ApiError>
pub async fn delete_git_ref( &self, owner: &str, repo: &str, ref_name: &str, ) -> Result<(), ApiError>
Delete a Git reference.
Permanently deletes a Git reference. Use with caution as this operation cannot be undone.
§Arguments
owner- Repository ownerrepo- Repository nameref_name- Reference name (e.g., “heads/old-feature”)
§Errors
ApiError::NotFound- Reference does not exist
§Example
client.delete_git_ref("octocat", "Hello-World", "heads/old-feature").await?;List all tags in a repository.
Returns an array of all tags with their associated commit information.
§Arguments
owner- Repository ownerrepo- Repository name
§Returns
Returns Vec<Tag> with all repository tags. Returns empty vector if no tags exist.
§Errors
ApiError::NotFound- Repository does not existApiError::AuthorizationFailed- Insufficient permissions
§Example
let tags = client.list_tags("octocat", "Hello-World").await?;
for tag in tags {
println!("Tag: {} at {}", tag.name, tag.commit.sha);
}Sourcepub async fn create_branch(
&self,
owner: &str,
repo: &str,
branch_name: &str,
from_sha: &str,
) -> Result<GitRef, ApiError>
pub async fn create_branch( &self, owner: &str, repo: &str, branch_name: &str, from_sha: &str, ) -> Result<GitRef, ApiError>
Create a new branch (convenience wrapper around create_git_ref).
Creates a new branch reference pointing to the specified commit. This is a convenience method that automatically adds the “refs/heads/” prefix.
§Arguments
owner- Repository ownerrepo- Repository namebranch_name- Branch name (without “refs/heads/” prefix)from_sha- SHA of the commit to branch from
§Returns
Returns GitRef for the newly created branch.
§Errors
ApiError::InvalidRequest- Branch already exists or invalid SHA
§Example
let branch = client.create_branch(
"octocat",
"Hello-World",
"new-feature",
"aa218f56b14c9653891f9e74264a383fa43fefbd"
).await?;
println!("Created branch: {}", branch.ref_name);Sourcepub async fn create_tag(
&self,
owner: &str,
repo: &str,
tag_name: &str,
from_sha: &str,
) -> Result<GitRef, ApiError>
pub async fn create_tag( &self, owner: &str, repo: &str, tag_name: &str, from_sha: &str, ) -> Result<GitRef, ApiError>
Create a new tag (convenience wrapper around create_git_ref).
Creates a new tag reference pointing to the specified commit. This is a convenience method that automatically adds the “refs/tags/” prefix.
§Arguments
owner- Repository ownerrepo- Repository nametag_name- Tag name (without “refs/tags/” prefix)from_sha- SHA of the commit to tag
§Returns
Returns GitRef for the newly created tag.
§Errors
ApiError::InvalidRequest- Tag already exists or invalid SHA
§Example
let tag = client.create_tag(
"octocat",
"Hello-World",
"v1.0.0",
"aa218f56b14c9653891f9e74264a383fa43fefbd"
).await?;
println!("Created tag: {}", tag.ref_name);Source§impl InstallationClient
impl InstallationClient
Sourcepub async fn list_workflows(
&self,
owner: &str,
repo: &str,
) -> Result<Vec<Workflow>, ApiError>
pub async fn list_workflows( &self, owner: &str, repo: &str, ) -> Result<Vec<Workflow>, ApiError>
List workflows in a repository.
Retrieves all GitHub Actions workflows for a repository.
§Arguments
owner- Repository ownerrepo- Repository name
§Returns
Returns vector of workflows.
§Errors
ApiError::NotFound- Repository does not existApiError::AuthorizationFailed- Insufficient permissions
§Example
let workflows = client.list_workflows("owner", "repo").await?;
for workflow in workflows {
println!("Workflow: {} ({})", workflow.name, workflow.state);
}Sourcepub async fn get_workflow(
&self,
owner: &str,
repo: &str,
workflow_id: u64,
) -> Result<Workflow, ApiError>
pub async fn get_workflow( &self, owner: &str, repo: &str, workflow_id: u64, ) -> Result<Workflow, ApiError>
Get a specific workflow by ID.
Retrieves details about a single workflow.
§Arguments
owner- Repository ownerrepo- Repository nameworkflow_id- Workflow ID
§Returns
Returns the Workflow with the specified ID.
§Errors
ApiError::NotFound- Workflow does not existApiError::AuthorizationFailed- Insufficient permissions
§Example
let workflow = client.get_workflow("owner", "repo", 123456).await?;
println!("Workflow: {} at {}", workflow.name, workflow.path);Sourcepub async fn trigger_workflow(
&self,
owner: &str,
repo: &str,
workflow_id: u64,
request: TriggerWorkflowRequest,
) -> Result<(), ApiError>
pub async fn trigger_workflow( &self, owner: &str, repo: &str, workflow_id: u64, request: TriggerWorkflowRequest, ) -> Result<(), ApiError>
Trigger a workflow run.
Manually triggers a workflow run using workflow_dispatch event.
§Arguments
owner- Repository ownerrepo- Repository nameworkflow_id- Workflow IDrequest- Trigger parameters (ref and optional inputs)
§Returns
Returns Ok(()) on successful trigger.
§Errors
ApiError::NotFound- Workflow does not existApiError::InvalidRequest- Workflow not configured for manual dispatchApiError::AuthorizationFailed- Insufficient permissions
§Example
let request = TriggerWorkflowRequest {
git_ref: "main".to_string(),
inputs: None,
};
client.trigger_workflow("owner", "repo", 123456, request).await?;
println!("Workflow triggered");Sourcepub async fn list_workflow_runs(
&self,
owner: &str,
repo: &str,
workflow_id: u64,
) -> Result<Vec<WorkflowRun>, ApiError>
pub async fn list_workflow_runs( &self, owner: &str, repo: &str, workflow_id: u64, ) -> Result<Vec<WorkflowRun>, ApiError>
List workflow runs for a workflow.
Retrieves workflow runs for a specific workflow.
§Arguments
owner- Repository ownerrepo- Repository nameworkflow_id- Workflow ID
§Returns
Returns vector of workflow runs.
§Errors
ApiError::NotFound- Workflow does not existApiError::AuthorizationFailed- Insufficient permissions
§Example
let runs = client.list_workflow_runs("owner", "repo", 123456).await?;
for run in runs {
println!("Run #{}: {} ({})", run.run_number, run.status, run.conclusion.unwrap_or_default());
}Sourcepub async fn get_workflow_run(
&self,
owner: &str,
repo: &str,
run_id: u64,
) -> Result<WorkflowRun, ApiError>
pub async fn get_workflow_run( &self, owner: &str, repo: &str, run_id: u64, ) -> Result<WorkflowRun, ApiError>
Get a specific workflow run by ID.
Retrieves details about a single workflow run.
§Arguments
owner- Repository ownerrepo- Repository namerun_id- Workflow run ID
§Returns
Returns the WorkflowRun with the specified ID.
§Errors
ApiError::NotFound- Workflow run does not existApiError::AuthorizationFailed- Insufficient permissions
§Example
let run = client.get_workflow_run("owner", "repo", 987654).await?;
println!("Run #{}: {}", run.run_number, run.status);Sourcepub async fn cancel_workflow_run(
&self,
owner: &str,
repo: &str,
run_id: u64,
) -> Result<(), ApiError>
pub async fn cancel_workflow_run( &self, owner: &str, repo: &str, run_id: u64, ) -> Result<(), ApiError>
Cancel a workflow run.
Cancels a workflow run that is in progress.
§Arguments
owner- Repository ownerrepo- Repository namerun_id- Workflow run ID
§Returns
Returns Ok(()) on successful cancellation.
§Errors
ApiError::NotFound- Workflow run does not existApiError::InvalidRequest- Workflow run cannot be cancelledApiError::AuthorizationFailed- Insufficient permissions
§Example
client.cancel_workflow_run("owner", "repo", 987654).await?;
println!("Workflow run cancelled");Sourcepub async fn rerun_workflow_run(
&self,
owner: &str,
repo: &str,
run_id: u64,
) -> Result<(), ApiError>
pub async fn rerun_workflow_run( &self, owner: &str, repo: &str, run_id: u64, ) -> Result<(), ApiError>
Re-run a workflow run.
Re-runs a completed workflow run.
§Arguments
owner- Repository ownerrepo- Repository namerun_id- Workflow run ID
§Returns
Returns Ok(()) on successful re-run trigger.
§Errors
ApiError::NotFound- Workflow run does not existApiError::InvalidRequest- Workflow run cannot be re-runApiError::AuthorizationFailed- Insufficient permissions
§Example
client.rerun_workflow_run("owner", "repo", 987654).await?;
println!("Workflow run re-triggered");Trait Implementations§
Source§impl Clone for InstallationClient
impl Clone for InstallationClient
Source§fn clone(&self) -> InstallationClient
fn clone(&self) -> InstallationClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more