Skip to main content

InstallationClient

Struct InstallationClient 

Source
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

Source

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 login
  • repo - Repository name
  • ref_name - Commit SHA (full or abbreviated), branch name, or tag name
§Returns

Returns a FullCommit with complete metadata.

§Errors
§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

Source

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 login
  • repo - Repository name
  • sha - SHA or branch name to start listing from (default: repository default branch)
  • path - Only return commits that modified this file path or directory
  • author - Filter by GitHub username or commit author email address
  • since - 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..=100
  • page - Page number for pagination (1-based, default: 1)
§Returns

Returns a Vec<FullCommit> in reverse chronological order.

§Errors
§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_page is 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

Source

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 login
  • repo - Repository name
  • base - Base ref (SHA, branch, or tag) — the starting point
  • head - Head ref (SHA, branch, or tag) — the ending point
§Returns

Returns a Comparison with commits, file changes, and statistics.

§Errors
§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
StatusMeaning
"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

Source

pub fn new(client: Arc<GitHubClient>, installation_id: InstallationId) -> Self

Create a new installation client.

§Arguments
  • client - Parent GitHubClient
  • installation_id - Installation ID to bind to
Source

pub fn installation_id(&self) -> InstallationId

Get the installation ID this client is bound to.

Source

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.

Source

pub async fn post<T: Serialize>( &self, path: &str, body: &T, ) -> Result<Response, ApiError>

Make an authenticated POST request to the GitHub API.

Includes automatic retry logic for transient errors.

§Arguments
  • path - API path
  • body - Request body (will be serialized to JSON)
§Errors

Returns ApiError for HTTP errors, serialization failures, or network issues.

Source

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.

Source

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.

Source

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 string
  • variables - Variables object (serialised to JSON)
§Returns

Returns the data field from the GraphQL response as a serde_json::Value.

§Errors
  • ApiError::GraphQlError — GitHub returned .errors in the body
  • ApiError::GraphQlError — response body contains neither .errors nor a non-null .data field (malformed or unexpected response shape)
  • ApiError::AuthenticationFailed — HTTP 401
  • ApiError::JsonError — response body could not be parsed
  • Any other ApiError variant for HTTP-level failures
Source

pub async fn patch<T: Serialize>( &self, path: &str, body: &T, ) -> Result<Response, ApiError>

Make an authenticated PATCH request to the GitHub API.

Includes automatic retry logic for transient errors.

Source§

impl InstallationClient

Source

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 owner
  • repo - Repository name
  • state - 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());
    }
}
Source

pub async fn get_issue( &self, owner: &str, repo: &str, issue_number: u64, ) -> Result<Issue, ApiError>

Get a specific issue by number.

Source

pub async fn create_issue( &self, owner: &str, repo: &str, request: CreateIssueRequest, ) -> Result<Issue, ApiError>

Create a new issue.

Source

pub async fn update_issue( &self, owner: &str, repo: &str, issue_number: u64, request: UpdateIssueRequest, ) -> Result<Issue, ApiError>

Update an existing issue.

Source

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.

Source

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

Source

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

Source

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

Source

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

Source

pub async fn delete_label( &self, owner: &str, repo: &str, name: &str, ) -> Result<(), ApiError>

Delete a label.

See docs/spec/interfaces/issue-operations.md

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

pub async fn delete_issue_comment( &self, owner: &str, repo: &str, comment_id: u64, ) -> Result<(), ApiError>

Delete a comment.

See docs/spec/interfaces/issue-operations.md

Source§

impl InstallationClient

Source

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

Source

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

Source

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

Source

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 name
  • project_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 item
  • Err(ApiError::NotFound) — project not found for this owner
  • Err(ApiError::AuthorizationFailed) — no write access to the project
  • Err(ApiError) — other transport or GraphQL errors
Source

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 name
  • issue_number - Issue number
§Returns
  • Ok(Vec<ProjectV2>) — all projects linked to the issue (may be empty)
  • Err(ApiError::NotFound) — repository or issue does not exist
  • Err(ApiError::AuthenticationFailed) — token is invalid
  • Err(ApiError) — other transport or GraphQL errors
Source

pub async fn remove_item_from_project( &self, _owner: &str, _project_number: u64, _item_id: &str, ) -> Result<(), ApiError>

Remove an item from a project.

See docs/spec/interfaces/project-operations.md

Source§

impl InstallationClient

Source

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 owner
  • repo - Repository name
  • state - 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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

pub async fn add_labels_to_pull_request( &self, owner: &str, repo: &str, pull_number: u64, labels: Vec<String>, ) -> Result<Vec<Label>, ApiError>

Add labels to a pull request.

See docs/spec/interfaces/pull-request-operations.md

Source

pub async fn remove_label_from_pull_request( &self, owner: &str, repo: &str, pull_number: u64, name: &str, ) -> Result<(), ApiError>

Remove a label from a pull request.

See docs/spec/interfaces/pull-request-operations.md

Source§

impl InstallationClient

Source

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 owner
  • repo - Repository name
§Returns

Returns vector of releases ordered by creation date (newest first).

§Errors
  • ApiError::NotFound - Repository does not exist
  • ApiError::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);
}
Source

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 owner
  • repo - Repository name
§Returns

Returns the latest published Release.

§Errors
  • ApiError::NotFound - Repository or no published releases exist
  • ApiError::AuthorizationFailed - Insufficient permissions
§Example
let release = client.get_latest_release("owner", "repo").await?;
println!("Latest: {} ({})", release.name.unwrap_or_default(), release.tag_name);
Source

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 owner
  • repo - Repository name
  • tag - Git tag name
§Returns

Returns the Release with the specified tag.

§Errors
  • ApiError::NotFound - Release with tag does not exist
  • ApiError::AuthorizationFailed - Insufficient permissions
§Example
let release = client.get_release_by_tag("owner", "repo", "v1.0.0").await?;
println!("Release: {}", release.tag_name);
Source

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 owner
  • repo - Repository name
  • release_id - Release ID
§Returns

Returns the Release with the specified ID.

§Errors
  • ApiError::NotFound - Release does not exist
  • ApiError::AuthorizationFailed - Insufficient permissions
§Example
let release = client.get_release("owner", "repo", 12345).await?;
println!("Release: {}", release.tag_name);
Source

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 owner
  • repo - Repository name
  • request - Release creation parameters
§Returns

Returns the created Release.

§Errors
  • ApiError::InvalidRequest - Tag already exists or invalid parameters
  • ApiError::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);
Source

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 owner
  • repo - Repository name
  • release_id - Release ID
  • request - Fields to update
§Returns

Returns the updated Release.

§Errors
  • ApiError::NotFound - Release does not exist
  • ApiError::InvalidRequest - Invalid parameters
  • ApiError::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);
Source

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 owner
  • repo - Repository name
  • release_id - Release ID
§Returns

Returns Ok(()) on successful deletion.

§Errors
  • ApiError::NotFound - Release does not exist
  • ApiError::AuthorizationFailed - Insufficient permissions
§Example
client.delete_release("owner", "repo", 12345).await?;
println!("Release deleted");
Source§

impl InstallationClient

Source

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 accessible
  • ApiError::AuthorizationFailed - Insufficient permissions to access repository
  • ApiError::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);
Source

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 owner
  • repo - Repository name
§Returns

Returns Vec<Branch> with all repository branches.

§Errors
  • ApiError::NotFound - Repository does not exist
  • ApiError::AuthorizationFailed - Insufficient permissions
§Example
let branches = client.list_branches("octocat", "Hello-World").await?;
for branch in branches {
    println!("Branch: {} (protected: {})", branch.name, branch.protected);
}
Source

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 owner
  • repo - Repository name
  • branch - Branch name
§Returns

Returns Branch with branch details.

§Errors
  • ApiError::NotFound - Branch or repository does not exist
  • ApiError::AuthorizationFailed - Insufficient permissions
§Example
let branch = client.get_branch("octocat", "Hello-World", "main").await?;
println!("Branch {} at commit {}", branch.name, branch.commit.sha);
Source

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 owner
  • repo - Repository name
  • ref_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);
Source

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 owner
  • repo - Repository name
  • ref_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?;
Source

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 owner
  • repo - Repository name
  • ref_name - Reference name (e.g., “heads/main”)
  • sha - New SHA for the reference
  • force - Allow non-fast-forward updates
§Returns

Returns GitRef with updated reference details.

§Errors
  • ApiError::NotFound - Reference does not exist
  • ApiError::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?;
Source

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 owner
  • repo - Repository name
  • ref_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?;
Source

pub async fn list_tags( &self, owner: &str, repo: &str, ) -> Result<Vec<Tag>, ApiError>

List all tags in a repository.

Returns an array of all tags with their associated commit information.

§Arguments
  • owner - Repository owner
  • repo - Repository name
§Returns

Returns Vec<Tag> with all repository tags. Returns empty vector if no tags exist.

§Errors
  • ApiError::NotFound - Repository does not exist
  • ApiError::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);
}
Source

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 owner
  • repo - Repository name
  • branch_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);
Source

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 owner
  • repo - Repository name
  • tag_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

Source

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 owner
  • repo - Repository name
§Returns

Returns vector of workflows.

§Errors
  • ApiError::NotFound - Repository does not exist
  • ApiError::AuthorizationFailed - Insufficient permissions
§Example
let workflows = client.list_workflows("owner", "repo").await?;
for workflow in workflows {
    println!("Workflow: {} ({})", workflow.name, workflow.state);
}
Source

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 owner
  • repo - Repository name
  • workflow_id - Workflow ID
§Returns

Returns the Workflow with the specified ID.

§Errors
  • ApiError::NotFound - Workflow does not exist
  • ApiError::AuthorizationFailed - Insufficient permissions
§Example
let workflow = client.get_workflow("owner", "repo", 123456).await?;
println!("Workflow: {} at {}", workflow.name, workflow.path);
Source

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 owner
  • repo - Repository name
  • workflow_id - Workflow ID
  • request - Trigger parameters (ref and optional inputs)
§Returns

Returns Ok(()) on successful trigger.

§Errors
  • ApiError::NotFound - Workflow does not exist
  • ApiError::InvalidRequest - Workflow not configured for manual dispatch
  • ApiError::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");
Source

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 owner
  • repo - Repository name
  • workflow_id - Workflow ID
§Returns

Returns vector of workflow runs.

§Errors
  • ApiError::NotFound - Workflow does not exist
  • ApiError::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());
}
Source

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 owner
  • repo - Repository name
  • run_id - Workflow run ID
§Returns

Returns the WorkflowRun with the specified ID.

§Errors
  • ApiError::NotFound - Workflow run does not exist
  • ApiError::AuthorizationFailed - Insufficient permissions
§Example
let run = client.get_workflow_run("owner", "repo", 987654).await?;
println!("Run #{}: {}", run.run_number, run.status);
Source

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 owner
  • repo - Repository name
  • run_id - Workflow run ID
§Returns

Returns Ok(()) on successful cancellation.

§Errors
  • ApiError::NotFound - Workflow run does not exist
  • ApiError::InvalidRequest - Workflow run cannot be cancelled
  • ApiError::AuthorizationFailed - Insufficient permissions
§Example
client.cancel_workflow_run("owner", "repo", 987654).await?;
println!("Workflow run cancelled");
Source

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 owner
  • repo - Repository name
  • run_id - Workflow run ID
§Returns

Returns Ok(()) on successful re-run trigger.

§Errors
  • ApiError::NotFound - Workflow run does not exist
  • ApiError::InvalidRequest - Workflow run cannot be re-run
  • ApiError::AuthorizationFailed - Insufficient permissions
§Example
client.rerun_workflow_run("owner", "repo", 987654).await?;
println!("Workflow run re-triggered");

Trait Implementations§

Source§

impl Clone for InstallationClient

Source§

fn clone(&self) -> InstallationClient

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for InstallationClient

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more