Equinix REST client written in Go. Implementation is based on Resty client.
Purpose of this module is to wrap Resty REST client with Equinix specific error handling. In addition, module adds support for paginated query requests.
Module is used by other Equinix client libraries, like ECX Fabric Go client or Network Edge Go client.
- parses Equinix standardized error response body contents
GetPaginated
function queries for data on APIs with paginated responses. Pagination options can be configured by setting up attributes ofPagingConfig
-
Get recent equinix/rest-go module
go get -d github.com/equinix/rest-go
-
Create new Equinix REST client with default HTTP client
import ( "context" "net/http" "github.com/equinix/rest-go" ) func main() { c := rest.NewClient( context.Background(), "https://api.equinix.com", &http.Client{}) }
-
Use Equinix HTTP client with Equinix APIs
respBody := api.AccountResponse{} req := c.R().SetResult(&respBody) if err := c.Execute(req, "GET", "/ne/v1/device/account"); err != nil { //Equinix application error details will be included log.Printf("Got error: %s", err) }
Debug logging comes from Resty client and logs request and response details to stderr.
Such debug logging can be enabled by setting up EQUINIX_REST_LOG
environmental
variable to DEBUG