{"modulePath":"github.com/cruxstack/github-ops-app","version":"v1.1.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package client\n\nPackage client is the GitHub API client. It authenticates as a GitHub App, checks merged pull requests for compliance, syncs team membership, and lists security alerts.\n\n## Constants\n\n```go\nconst (\n\tAlertTypeDependabot     = \"dependabot\"\n\tAlertTypeCodeScanning   = \"code_scanning\"\n\tAlertTypeSecretScanning = \"secret_scanning\"\n)\n```\nAlert types in a security alerts report.\n\n## Functions\n\n```go\nfunc ParsePrivateKey(privateKeyPEM []byte) (*rsa.PrivateKey, error)\n```\nParsePrivateKey parses a PEM-encoded RSA private key in PKCS#1 or PKCS#8 form. Escaped newlines (\"\\\\n\"), as found in single-line environment variables, are accepted.\n\n## Types\n\n```go\ntype Client struct {\n\t// contains filtered or unexported fields\n}\n```\nClient is a GitHub API client authenticated as a GitHub App installation. It is safe for concurrent use. Implements domain.GitHubClient.\n\n```go\nfunc New(opts Options) (*Client, error)\n```\nNew creates a Client. It makes no API calls: credentials are exchanged for an installation token on first use and refreshed before they expire.\n\n```go\nfunc (c *Client) CheckPRCompliance(ctx context.Context, owner, repo string, prNumber int) (*domain.PRComplianceResult, error)\n```\nCheckPRCompliance verifies whether a merged PR met the requirements of its base branch: the approving reviews and status checks required by legacy branch protection and by repository rulesets. When it did not, the merger's repository role is recorded as the likely reason it could merge.\n\n```go\nfunc (c *Client) GetAppSlug(ctx context.Context) (string, error)\n```\nGetAppSlug returns the GitHub App's slug, used to recognize changes the app made itself. It is fetched once and cached.\n\n```go\nfunc (c *Client) GetTeamMembers(ctx context.Context, teamSlug string) ([]string, error)\n```\nGetTeamMembers returns the logins of all team members.\n\n```go\nfunc (c *Client) ListOrgMembers(ctx context.Context) ([]string, error)\n```\nListOrgMembers returns the logins of all organization members. Outside collaborators are not members, so they are not included.\n\n```go\nfunc (c *Client) ListSecurityAlerts(ctx context.Context, minAgeDays int, minSeverity string) (*domain.SecurityAlertsReport, error)\n```\nListSecurityAlerts fetches open security alerts across the org that were created more than minAgeDays ago and are at or above minSeverity. It covers dependabot, code scanning, and secret scanning alerts. A source that fails is recorded in the report's errors and the others still run.\n\n```go\nfunc (c *Client) ResolveTeam(ctx context.Context, name, privacy string, create bool) (string, error)\n```\nResolveTeam returns the slug of the team with the given name, creating the team when it is missing and create is true.\n\n```go\nfunc (c *Client) SyncTeamMembers(ctx context.Context, teamSlug string, desiredMembers []string, safetyThreshold float64) (*domain.TeamSyncResult, error)\n```\nSyncTeamMembers adds and removes members so the team matches desiredMembers. Errors for individual users are collected and the rest continue. Members of child teams and users who are not org members are not removed, and no one is removed if more than safetyThreshold of the team's direct members would be, which guards against an empty or partial member list from Okta.\n\n```go\ntype Options struct {\n\tAppID int64\n\t// InstallationID is the app's installation on Org. When zero, the\n\t// installation is looked up on first use.\n\tInstallationID int64\n\t// PrivateKey is the app's PEM-encoded RSA private key.\n\tPrivateKey []byte\n\tOrg        string\n\t// BaseURL is the API base URL, such as https://ghe.example.com/api/v3\n\t// for GitHub Enterprise Server. Empty means https://api.github.com.\n\tBaseURL string\n\t// HTTPClient is the client requests are sent with. Its transport is\n\t// wrapped to add authentication. Defaults to a client with a timeout.\n\tHTTPClient *http.Client\n}\n```\nOptions configures a Client.\n\n","path":"github.com/cruxstack/github-ops-app/internal/github/client","name":"client","synopsis":"Package client is the GitHub API client.","isRedistributable":true}
