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§
- Annotated
Tag - 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_typeis"commit"for lightweight tags and"tag"for annotated ones. - GitTag
Ref - One entry from
/repos/{owner}/{repo}/git/refs/tags. The underlyingobjectdistinguishes lightweight tags (point directly to a commit) from annotated tags (point to a Tag object that carries tagger info). - Pull
Request - 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. - Pull
Request Ref - 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+datetriple stamped on annotated-tag creation.dateis 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
tokenworks againstbase_urlby hitting/user. ReturnsOk(true)for valid tokens,Ok(false)for 401s, andErrfor other transport / server errors so callers can distinguish “tried and was rejected” from “couldn’t reach the server”.