Skip to main content

Crate sandogasa_github

Crate sandogasa_github 

Source
Expand description

HTTP client for the GitHub REST API.

Scoped to the surface sandogasa-report needs for activity reports: user identity lookup, token validation, paginated user events (to find which repos a user touched in a window), the Search API for pull requests, and per-repo authored-commit counts.

Mirrors sandogasa-gitlab in shape so downstream tools can treat the two forges the same way structurally — host-keyed tokens and identities, optional org/group filter, etc.

use sandogasa_github::Client;

let client = Client::new("https://api.github.com", "ghp_token")?;
let user = client.user_by_username("octocat")?.expect("user exists");
let prs = client.search_pull_requests(
    &format!("type:pr author:{} created:2026-01-01..2026-03-31", user.login),
)?;
for pr in prs {
    println!("{}: {}", pr.number, pr.title);
}

Structs§

AnnotatedTag
An annotated-tag object from /repos/{owner}/{repo}/git/tags/{sha}. Only annotated tags carry tagger metadata; lightweight tags don’t have an addressable tag object.
Client
Blocking GitHub REST client.
Event
One entry from /users/{username}/events. Fields are sparse; we keep just enough to identify the event type, associated repo, and the actor.
GitObject
The thing a Git ref points at. object_type is "commit" for lightweight tags and "tag" for annotated ones.
GitTagRef
One entry from /repos/{owner}/{repo}/git/refs/tags. The underlying object distinguishes lightweight tags (point directly to a commit) from annotated tags (point to a Tag object that carries tagger info).
PullRequest
A pull request as returned by the Search Issues endpoint when filtering on type:pr. The Search API actually returns “issue” objects with PR-specific fields populated, so we shape this around the union of useful fields rather than the fuller /repos/{owner}/{repo}/pulls/{number} model.
PullRequestRef
Auxiliary block on a search-result issue when it’s actually a pull request. The Search Issues endpoint signals “is PR” by populating this; merged state lives here too.
Repository
A repository as returned by event payloads and PR responses.
Tagger
name + email + date triple stamped on annotated-tag creation. date is ISO 8601 (e.g. 2026-05-15T17:03:15Z).
User
A GitHub user as returned by /users/{username}. Only the fields downstream tools currently consume.

Constants§

DEFAULT_BASE_URL
Default production base URL for the GitHub REST API.

Functions§

validate_token
Check whether token works against base_url by hitting /user. Returns Ok(true) for valid tokens, Ok(false) for 401s, and Err for other transport / server errors so callers can distinguish “tried and was rejected” from “couldn’t reach the server”.