MCPcopy Create free account
hub / github.com/github/gh-aw / ghAPIGetArray

Function ghAPIGetArray

pkg/cli/outcome_eval.go:248–266  ·  view source on GitHub ↗

ghAPIGetArray calls the GitHub REST API and returns a JSON array.

(endpoint string, repo string)

Source from the content-addressed store, hash-verified

246
247// ghAPIGetArray calls the GitHub REST API and returns a JSON array.
248func ghAPIGetArray(endpoint string, repo string) ([]map[string]any, error) {
249 ownerRepo, host := repoutil.NormalizeRepoForAPI(repo)
250 args := []string{"api", fmt.Sprintf("repos/%s/%s", ownerRepo, endpoint)}
251 var output []byte
252 var err error
253 if host != "" {
254 output, err = workflow.RunGHWithHost("Checking outcome...", host, args...)
255 } else {
256 output, err = workflow.RunGH("Checking outcome...", args...)
257 }
258 if err != nil {
259 return nil, fmt.Errorf("gh api %s: %w", endpoint, err)
260 }
261 var result []map[string]any
262 if err := json.Unmarshal(output, &result); err != nil {
263 return nil, fmt.Errorf("parsing response for %s: %w", endpoint, err)
264 }
265 return result, nil
266}
267
268// ghAPIGraphQL calls the GitHub GraphQL API via gh cli and returns the parsed JSON.
269func ghAPIGraphQL(query string, repo string) (map[string]any, error) {

Callers 7

evalAddLabelsFunction · 0.85
evalCreatePullRequestFunction · 0.85
evalCreateIssueFunction · 0.85
isClosedByBotFunction · 0.85
evalAddCommentFunction · 0.85
evalMarkReadyFunction · 0.85
evalAssignToAgentFunction · 0.85

Calls 4

NormalizeRepoForAPIFunction · 0.92
RunGHWithHostFunction · 0.92
RunGHFunction · 0.92
ErrorfMethod · 0.45

Tested by

no test coverage detected