MCPcopy Index your code
hub / github.com/cloudquery/cloudquery / NewClient

Function NewClient

cli/internal/api/client.go:22–38  ·  view source on GitHub ↗
(token string, opts ...cloudquery_api.ClientOption)

Source from the content-addressed store, hash-verified

20)
21
22func NewClient(token string, opts ...cloudquery_api.ClientOption) (*cloudquery_api.ClientWithResponses, error) {
23 requestEditorOpt := cloudquery_api.WithRequestEditorFn(func(ctx context.Context, req *http.Request) error {
24 req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", token))
25 return nil
26 })
27
28 clientOpts := append([]cloudquery_api.ClientOption{requestEditorOpt}, opts...)
29
30 c, err := cloudquery_api.NewClientWithResponses(
31 env.GetEnvOrDefault(envAPIURL, defaultAPIURL),
32 clientOpts...,
33 )
34 if err != nil {
35 return nil, fmt.Errorf("failed to create api client: %w", err)
36 }
37 return c, nil
38}
39
40func NewAnonymousClient() (*cloudquery_api.ClientWithResponses, error) {
41 c, err := cloudquery_api.NewClientWithResponses(env.GetEnvOrDefault(envAPIURL, defaultAPIURL))

Callers

nothing calls this directly

Calls 2

ErrorfMethod · 0.80
SetMethod · 0.45

Tested by

no test coverage detected