MCPcopy Create free account
hub / github.com/algolia/cli / ListRegions

Method ListRegions

api/dashboard/client.go:510–533  ·  view source on GitHub ↗

ListRegions returns the allowed hosting regions for application creation.

(accessToken string)

Source from the content-addressed store, hash-verified

508
509// ListRegions returns the allowed hosting regions for application creation.
510func (c *Client) ListRegions(accessToken string) ([]Region, error) {
511 req, err := http.NewRequest(http.MethodGet, c.APIURL+"/1/hosting/regions", nil)
512 if err != nil {
513 return nil, err
514 }
515 c.setAPIHeaders(req, accessToken)
516
517 resp, err := c.client.Do(req)
518 if err != nil {
519 return nil, fmt.Errorf("list regions request failed: %w", err)
520 }
521 defer resp.Body.Close()
522
523 if resp.StatusCode != http.StatusOK {
524 return nil, fmt.Errorf("list regions failed with status: %d", resp.StatusCode)
525 }
526
527 var regionsResp RegionsResponse
528 if err := json.NewDecoder(resp.Body).Decode(&regionsResp); err != nil {
529 return nil, fmt.Errorf("failed to parse regions response: %w", err)
530 }
531
532 return regionsResp.RegionCodes, nil
533}
534
535// WriteACL is the set of permissions for API keys created by the CLI.
536var WriteACL = []string{

Callers 1

PromptRegionFunction · 0.80

Calls 3

setAPIHeadersMethod · 0.95
ErrorfMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected