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, per-repo authored-commit counts, and through GraphQL, a user’s contributions over a period and their comments on issues and pull requests.

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.
Comments
A user’s comments on issues and pull requests.
CommitAuthor
A commit’s author as git recorded it.
CommitBody
The git-level part of a commit.
CommitCounts
Commits per repository, and the queries that failed.
Contributions
What a user contributed over a period, as GitHub’s contribution graph counts it: commits on a repository’s default branch (or gh-pages), and pull requests reviewed.
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.
GitRef
One side of a pull request: the branch name and the commit it points at.
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).
IssueComment
A comment of the user’s on an issue or a pull request.
ItemNode
An issue or pull request as GraphQL gives it.
Login
An account named only by its login.
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.
PullRequestDetail
The fuller pull-request object from /repos/{owner}/{repo}/pulls/{n}: the head and base refs the search result omits, and whether it merged.
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.
RecentTags
Repositories’ recent annotated tags, and the queries that failed.
RepoCommit
A commit from /pulls/{n}/commits or /commits: the sha, the message and the author of the commit itself (not the GitHub account).
RepoNode
A repository as GraphQL names it.
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).
Unreadable
Items GitHub withheld from an answer, such as those in an organization that refuses classic personal access tokens.
User
A GitHub user as returned by /users/{username}. Only the fields downstream tools currently consume.

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”.