Documentation
¶
Overview ¶
Package github provides a low-level client for the GitHub REST and GraphQL APIs.
Index ¶
- Constants
- type CheckRun
- type CheckRuns
- type Client
- func (c *Client) Collaborators(ctx context.Context, owner, repo string) (map[string]string, error)
- func (c *Client) Do(ctx context.Context, path string) ([]byte, *Response, error)
- func (c *Client) Get(ctx context.Context, path string, v any) (*Response, error)
- func (c *Client) GraphQL(ctx context.Context, query string, variables map[string]any, result any) error
- func (c *Client) Raw(ctx context.Context, path string) (json.RawMessage, *Response, error)
- type Error
- type Option
- type Platform
- type Response
- type Ruleset
- type Transport
- type User
Constants ¶
const (
// API is the default GitHub API base URL.
API = "https://api.github.com"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CheckRun ¶
type CheckRun struct {
Name string `json:"name"`
StartedAt time.Time `json:"started_at"`
CompletedAt time.Time `json:"completed_at"`
Conclusion string `json:"conclusion"`
Status string `json:"status"`
Output struct {
Title string `json:"title"`
Summary string `json:"summary"`
} `json:"output"`
}
CheckRun represents a GitHub check run from the REST API.
type CheckRuns ¶
type CheckRuns struct {
CheckRuns []*CheckRun `json:"check_runs"`
}
CheckRuns represents a list of GitHub check runs.
type Client ¶
Client is a low-level client for interacting with the GitHub API.
func (*Client) Collaborators ¶
Collaborators fetches all users with repository access and their permission levels. Returns a map of username -> permission level ("admin", "write", "read", "none"). Uses affiliation=all to include direct collaborators, org members, and outside collaborators.
type Option ¶
type Option func(*Platform)
Option configures a Platform.
func WithBaseURL ¶
WithBaseURL sets a custom base URL for the GitHub API.
func WithHTTPClient ¶
WithHTTPClient sets a custom HTTP client for the GitHub platform.
func WithLogger ¶
WithLogger sets a custom logger for the GitHub platform.
type Platform ¶
type Platform struct {
// contains filtered or unexported fields
}
Platform implements the prx.Platform interface for GitHub.
func NewPlatform ¶
NewPlatform creates a new GitHub platform client.
func NewTestPlatform ¶
NewTestPlatform creates a Platform for testing with a custom base URL. Exported for use in prx package tests.
type Response ¶
type Response struct {
NextPage int
}
Response wraps a GitHub API response with pagination info.
type Ruleset ¶
type Ruleset struct {
Name string `json:"name"`
Target string `json:"target"`
Rules []struct {
Type string `json:"type"`
Parameters struct {
RequiredStatusChecks []struct {
Context string `json:"context"`
} `json:"required_status_checks"`
} `json:"parameters"`
} `json:"rules"`
}
Ruleset represents a repository ruleset from the REST API.
type Transport ¶
type Transport struct {
Base http.RoundTripper
}
Transport wraps an http.RoundTripper with retry logic using exponential backoff with jitter.