MCPcopy Create free account
hub / github.com/cli/cli / resolveCapiURL

Function resolveCapiURL

pkg/cmd/agent-task/shared/capi.go:49–69  ·  view source on GitHub ↗

resolveCapiURL queries the GitHub API for the Copilot API endpoint URL.

(httpClient *http.Client, host string)

Source from the content-addressed store, hash-verified

47
48// resolveCapiURL queries the GitHub API for the Copilot API endpoint URL.
49func resolveCapiURL(httpClient *http.Client, host string) (string, error) {
50 apiClient := api.NewClientFromHTTP(httpClient)
51
52 var resp struct {
53 Viewer struct {
54 CopilotEndpoints struct {
55 Api string `graphql:"api"`
56 } `graphql:"copilotEndpoints"`
57 } `graphql:"viewer"`
58 }
59
60 if err := apiClient.Query(host, "CopilotEndpoints", &resp, nil); err != nil {
61 return "", err
62 }
63
64 if resp.Viewer.CopilotEndpoints.Api == "" {
65 return "", errors.New("empty Copilot API URL returned")
66 }
67
68 return resp.Viewer.CopilotEndpoints.Api, nil
69}
70
71func IsSessionID(s string) bool {
72 return sessionIDRegexp.MatchString(s)

Callers 2

TestResolveCapiURLFunction · 0.85
CapiClientFuncFunction · 0.85

Calls 2

NewClientFromHTTPFunction · 0.92
QueryMethod · 0.65

Tested by 1

TestResolveCapiURLFunction · 0.68