MCPcopy Index your code
hub / github.com/cli/cli / resolveCapiURL

Function resolveCapiURL

pkg/cmd/agent-task/shared/capi.go:48–68  ·  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

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