// getAPI returns the API. This allows passing in a test CommitCommandAPI
// implementation.
173585
func (c *commitCommand) getAPI() (CommitCommandAPI, error) {
	if c.api != nil {
		return c.api, nil
	}
	api, err := c.NewAPIRoot()
	if err != nil {
		return nil, errors.Annotate(err, "opening API connection")
	}
	client := modelgeneration.NewClient(api)
	return client, nil
}
433539
func (a *InternalAPIEngine) GetDecode(m MetaContext, arg APIArg, v APIResponseWrapper) error {
	m = m.EnsureCtx().WithLogTag("API")
	return a.getDecode(m, arg, v)
}
709923
func (c *configCommand) getAPI() (configCommandAPI, error) {
	if c.api != nil {
		return c.api, nil
	}
	api, err := c.NewAPIRoot()
	if err != nil {
		return nil, errors.Annotate(err, "opening API connection")
	}
	client := modelconfig.NewClient(api)
	return client, nil
}
816860
func ConvertToAPI(serviceConfig *config.ServiceConfig, ctx project.Context, clientFactory composeclient.Factory) (*ConfigWrapper, error) {
	config, hostConfig, err := Convert(serviceConfig, ctx, clientFactory)
	if err != nil {
		return nil, err
	}

	result := ConfigWrapper{
		Config:     config,
		HostConfig: hostConfig,
	}
	return &result, nil
}
1157137
func (s *AwsApiCallAction) SetApi(v string) *AwsApiCallAction {
	s.Api = &v
	return s
}
675555
func NewAPI(ctx facade.Context) (*API, error) {
	if !ctx.Auth().AuthController() {
		return nil, common.ErrPerm
	}

	return &API{}, nil
}
157261
func NewAPI(url string) (api *API) {
	return &API{url: url, c: http.Client{}}
}
165243
func getBlockAPI(c newAPIRoot) (*apiblock.Client, error) {
	root, err := c.NewAPIRoot()
	if err != nil {
		return nil, err
	}
	return apiblock.NewClient(root), nil
}
805764
func NewAPI() *APIClient {
	c := &APIClient{}
	c.common.backend = DefaultBackend()

	c.ID = (*IDClient)(&c.common)
	c.Product = (*ProductClient)(&c.common)
	c.Products = (*ProductsClient)(&c.common)
	c.Resource = (*ResourceClient)(&c.common)
	c.Resources = (*ResourcesClient)(&c.common)

	return c
}
582290
func getBlockAPI(c *modelcmd.ModelCommandBase) (listBlocksAPI, error) {
	root, err := c.NewAPIRoot()
	if err != nil {
		return nil, errors.Trace(err)
	}
	return block.NewClient(root), nil
}
324438
func (cli *Client) getAPIPath(ctx context.Context, p string, query url.Values) string {
	var apiPath string
	if cli.negotiateVersion && !cli.negotiated {
		cli.NegotiateAPIVersion(ctx)
	}
	if cli.version != "" {
		v := strings.TrimPrefix(cli.version, "v")
		apiPath = path.Join(cli.basePath, "/v"+v, p)
	} else {
		apiPath = path.Join(cli.basePath, p)
	}
	return (&url.URL{Path: apiPath, RawQuery: query.Encode()}).String()
}
698957
func (k *Bootstrapper) GetAPIServerStatus(ip net.IP, apiserverPort int) (string, error) {
	url := fmt.Sprintf("https://%s:%d/healthz", ip, apiserverPort)
	// To avoid: x509: certificate signed by unknown authority
	tr := &http.Transport{
		TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
	}
	client := &http.Client{Transport: tr}
	resp, err := client.Get(url)
	glog.Infof("%s response: %v %+v", url, err, resp)
	// Connection refused, usually.
	if err != nil {
		return state.Stopped.String(), nil
	}
	if resp.StatusCode != http.StatusOK {
		return state.Error.String(), nil
	}
	return state.Running.String(), nil
}
1105144
func (im *imp) doUserAPI(ctx context.Context, accessToken string, result interface{}, apiPath string, keyval ...string) error {
	form := url.Values{}
	form.Set("oauth_token", accessToken)
	return im.doAPI(ctx, form, result, apiPath, keyval...)
}
760633
func (c *diffCommand) getAPI() (DiffCommandAPI, error) {
	if c.api != nil {
		return c.api, nil
	}
	api, err := c.NewAPIRoot()
	if err != nil {
		return nil, errors.Annotate(err, "opening API connection")
	}
	client := modelgeneration.NewClient(api)
	return client, nil
}
297772
func (v *HandshakeResponse) GetAPIVersion() (o int32) {
	if v != nil {
		o = v.APIVersion
	}
	return
}
468887
func NewAPI(rawurl, key, secret string) (*API, error) {
	client := oauth.NewConsumer(key, secret, oauth.ServiceProvider{})
	token := &oauth.AccessToken{}

	parsed, err := url.Parse(rawurl)
	if err != nil {
		return nil, err
	}

	return &API{
		url:    parsed,
		client: client,
		token:  token,
	}, nil
}
1084536
func GetAPIKey() (string, error) {
	mu.RLock()
	key := apiKey
	mu.RUnlock()
	if apiKey != "" {
		return key, nil
	}
	mu.Lock()
	defer mu.Unlock()

	dir, err := osutil.PerkeepConfigDir()
	if err != nil {
		return "", err
	}
	slurp, err := wkfs.ReadFile(filepath.Join(dir, apiKeyName))
	if os.IsNotExist(err) {
		return "", ErrNoGoogleKey
	}
	if err != nil {
		return "", err
	}
	key = strings.TrimSpace(string(slurp))
	if key == "" {
		return "", ErrNoGoogleKey
	}
	apiKey = key
	return key, nil
}