public class GitHubCli
extends java.lang.Object
gh CLI (gh api ...) instead of direct HTTP.
The CLI supplies its own authentication and higher (authenticated) rate limits, so no access token
needs to be configured. Each call is adapted back into an OkHttp Response so the surrounding
response-handling and JSON parsing in GitHub stay unchanged.
| Constructor and Description |
|---|
GitHubCli(GitHubLogger logger) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
isAvailable()
Checks whether the
gh CLI is installed and runnable. |
okhttp3.Response |
request(java.lang.String url,
java.lang.String method,
java.lang.String jsonBody)
Performs a GitHub REST request via
gh api and adapts the result into an OkHttp Response. |
public GitHubCli(GitHubLogger logger)
logger - the logger for diagnostics.public boolean isAvailable()
gh CLI is installed and runnable. The result is probed once and cached.gh --version succeeds.public okhttp3.Response request(java.lang.String url,
java.lang.String method,
java.lang.String jsonBody)
throws java.io.IOException
gh api and adapts the result into an OkHttp Response.url - the full GitHub API URL (also accepted as a bare path by gh api).method - the HTTP method, e.g. "GET" or "POST".jsonBody - the JSON request body for writes, or null for reads.Response carrying the CLI's status code and body.java.io.IOException - if the CLI process cannot be started or its I/O fails.