{"modulePath":"github.com/TerracodeBA/vx","version":"v0.4.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package github\n\nPackage github is vx's client for the GitHub REST API as a GitHub App: the manifest flow, installations, installation tokens, OAuth sign-in, repository permissions and organization membership. It implements service.GitHubAPI. Base URLs are configurable for GitHub Enterprise and for tests, which run it against the fake in internal/github/githubtest.\n\nErrors never contain tokens, keys, client secrets or OAuth codes.\n\n## Constants\n\n```go\nconst (\n\tDefaultAPIURL = \"https://api.github.com\"\n\tDefaultWebURL = \"https://github.com\"\n)\n```\nDefault base URLs of github.com.\n\n## Variables\n\n```go\nvar ErrNotFound = errors.New(\"github: not found\")\n```\nErrNotFound matches (errors.Is) GitHub 404 responses.\n\n```go\nvar ErrRateLimited = errors.New(\"github: rate limited\")\n```\nErrRateLimited matches (errors.Is) rate-limited responses.\n\n```go\nvar ErrUnauthorized = errors.New(\"github: unauthorized\")\n```\nErrUnauthorized matches (errors.Is) GitHub 401 responses.\n\n## Functions\n\n```go\nfunc ParsePrivateKey(pemText string) (*rsa.PrivateKey, error)\n```\nParsePrivateKey parses an App private key in PEM.\n\n## Types\n\n```go\ntype Client struct {\n\t// contains filtered or unexported fields\n}\n```\nClient talks to GitHub as the App. It is safe for concurrent use.\n\n```go\nfunc FromCredentials(creds service.GitHubAppCredentials, apiURL, webURL string) (*Client, error)\n```\nFromCredentials returns a client for an App created by the manifest flow.\n\n```go\nfunc New(cfg Config) (*Client, error)\n```\nNew returns a client. A private key, when given, must be an RSA key in PEM (PKCS#1 or PKCS#8), as GitHub hands it out.\n\n```go\nfunc (c *Client) APIURL() string\n```\nAPIURL and WebURL return the configured base URLs.\n\n```go\nfunc (c *Client) AppJWT() (string, error)\n```\nAppJWT returns a JSON Web Token that authenticates as the App, valid for at most ten minutes (RS256, issued a minute in the past for clock skew).\n\n```go\nfunc (c *Client) AppSettings(ctx context.Context) (service.GitHubAppSettings, error)\n```\nAppSettings reads the App's permissions and webhook events (GET /app).\n\n```go\nfunc (c *Client) CreateAppFromManifest(ctx context.Context, code string) (service.GitHubAppCredentials, error)\n```\nCreateAppFromManifest completes the manifest flow: it converts the one-time code GitHub sent back into the new App's credentials.\n\n```go\nfunc (c *Client) CreateCheckRun(ctx context.Context, installationID int64, owner, repo string, run service.GitHubCheckRun) error\n```\nCreateCheckRun posts a completed check run on a commit of owner/repo. A refusal for want of the checks: write permission matches service.ErrGitHubForbidden.\n\n```go\nfunc (c *Client) ExchangeOAuthCode(ctx context.Context, code, redirectURI, codeVerifier string) (string, error)\n```\nExchangeOAuthCode turns a sign-in code into a user access token (PKCE).\n\n```go\nfunc (c *Client) ForgetInstallationToken(id int64)\n```\nForgetInstallationToken drops a cached token, for example after GitHub refused it or the installation was deleted.\n\n```go\nfunc (c *Client) Installation(ctx context.Context, id int64) (service.GitHubInstallation, error)\n```\nInstallation reads an installation of the App.\n\n```go\nfunc (c *Client) InstallationRepos(ctx context.Context, id int64) ([]service.GitHubRepo, error)\n```\nInstallationRepos lists every repository an installation can reach, following pagination.\n\n```go\nfunc (c *Client) InstallationToken(ctx context.Context, id int64) (string, time.Time, error)\n```\nInstallationToken returns a token for an installation, cached until shortly before it expires.\n\n```go\nfunc (c *Client) OrgMembership(ctx context.Context, installationID int64, org, login string) (string, error)\n```\nOrgMembership returns login's role in org: admin, member or none (pending invitations are none).\n\n```go\nfunc (c *Client) RepoPermission(ctx context.Context, installationID int64, owner, repo, login string) (string, error)\n```\nRepoPermission returns login's permission on owner/repo: admin, maintain, write, triage, read or none. Unknown users and repositories the installation cannot see are \"none\".\n\n```go\nfunc (c *Client) User(ctx context.Context, userToken string) (service.GitHubUser, error)\n```\nUser returns the user a user access token belongs to. Email is the primary verified email when GitHub shares it, else empty.\n\n```go\nfunc (c *Client) WebURL() string\n```\n\n```go\ntype Config struct {\n\t// APIURL is the REST API base: https://api.github.com, or\n\t// https://HOST/api/v3 for GitHub Enterprise Server. Empty: github.com.\n\tAPIURL string\n\t// WebURL is the browser base: https://github.com or https://HOST.\n\t// OAuth code exchange goes here. Empty: github.com.\n\tWebURL string\n\n\tAppID         int64\n\tPrivateKeyPEM string\n\tClientID      string\n\tClientSecret  string\n\n\t// HTTPClient defaults to a client with a 30 second timeout.\n\tHTTPClient *http.Client\n\t// Now defaults to time.Now.\n\tNow func() time.Time\n}\n```\nConfig configures a Client. Only the base URLs are needed to complete the manifest flow; everything else needs the App's credentials.\n\n```go\ntype Error struct {\n\tMethod, Path string\n\tStatus       int\n\tMessage      string\n\t// RateLimited is set when GitHub refused for a rate limit; Reset is\n\t// when the limit resets, if GitHub said.\n\tRateLimited bool\n\tReset       time.Time\n}\n```\nError is a failed GitHub request. Path never contains secrets.\n\n```go\nfunc (e *Error) Error() string\n```\n\n```go\nfunc (e *Error) Is(target error) bool\n```\n\n","path":"github.com/TerracodeBA/vx/internal/github","name":"github","synopsis":"Package github is vx's client for the GitHub REST API as a GitHub App: the manifest flow, installations, installation tokens, OAuth sign-in, repository permissions and organization membership.","isRedistributable":true}
