MCPcopy
hub / github.com/cli/cli / NewCAPIClient

Function NewCAPIClient

pkg/cmd/agent-task/capi/client.go:36–43  ·  view source on GitHub ↗

NewCAPIClient creates a new CAPI client. Provide a token, the user's GitHub host, the resolved Copilot API URL, and an HTTP client which will be used as the base transport for CAPI requests. The provided HTTP client will be mutated for use with CAPI, so it should not be reused elsewhere.

(httpClient *http.Client, token string, host string, capiBaseURL string)

Source from the content-addressed store, hash-verified

34// The provided HTTP client will be mutated for use with CAPI, so it should not
35// be reused elsewhere.
36func NewCAPIClient(httpClient *http.Client, token string, host string, capiBaseURL string) *CAPIClient {
37 httpClient.Transport = newCAPITransport(token, capiBaseURL, httpClient.Transport)
38 return &CAPIClient{
39 httpClient: httpClient,
40 host: host,
41 capiBaseURL: capiBaseURL,
42 }
43}
44
45// capiTransport adds the Copilot auth headers
46type capiTransport struct {

Callers 7

CapiClientFuncFunction · 0.92
TestGetSessionFunction · 0.85
TestGetJobFunction · 0.85
TestCreateJobFunction · 0.85

Calls 1

newCAPITransportFunction · 0.85

Tested by 6

TestGetSessionFunction · 0.68
TestGetJobFunction · 0.68
TestCreateJobFunction · 0.68