Sha256: a551c3b504e1d6f865ff01e0baeef978e09cf2f3a721b7e8e91d1d2494d7e8e9
Contents?: true
Size: 1.05 KB
Versions: 2
Compression:
Stored size: 1.05 KB
Contents
package planetscale import ( "context" "net/http" "github.com/pkg/errors" ) const regionsAPIPath = "v1/regions" type Region struct { Slug string `json:"slug"` Name string `json:"display_name"` Enabled bool `json:"enabled"` } type regionsResponse struct { Regions []*Region `json:"data"` } type ListRegionsRequest struct{} type RegionsService interface { List(ctx context.Context, req *ListRegionsRequest) ([]*Region, error) } type regionsService struct { client *Client } var _ RegionsService = ®ionsService{} func NewRegionsSevice(client *Client) *regionsService { return ®ionsService{ client: client, } } func (r *regionsService) List(ctx context.Context, listReq *ListRegionsRequest) ([]*Region, error) { req, err := r.client.newRequest(http.MethodGet, regionsAPIPath, nil) if err != nil { return nil, errors.Wrap(err, "error creating request for list regions") } regionsResponse := ®ionsResponse{} if err := r.client.do(ctx, req, ®ionsResponse); err != nil { return nil, err } return regionsResponse.Regions, nil }
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
planetscale-0.3.1 | vendor/github.com/planetscale/planetscale-go/planetscale/regions.go |
planetscale-0.3.0 | vendor/github.com/planetscale/planetscale-go/planetscale/regions.go |