Equinix Fabric client library in Go
Equinix Fabric client library written in Go.
Equinix Fabric client library was written in Go for purpose of managing Fabric
resources from Terraform provider plugin.
Library gives possibility to manage layer two connections and service profiles
on Equinix Fabric and connect to any Cloud Service Provider, other Enterprise
or between own ports.
Client library consumes Equinix Fabric’s REST API and allows to:
NOTE: scope of this library is limited to needs of Terraform provider plugin
and it is not providing full capabilities of Equinix Fabric API
Add ecx-go module to import statement.
In below example, Equinix oauth2-go
module is imported as well
import (
"github.com/equinix/oauth2-go"
"github.com/equinix/ecx-go"
)
Define baseURL that will be used in all REST API requests
baseURL := "https://sandboxapi.equinix.com"
Create oAuth configuration and oAuth enabled http.Client
authConfig := oauth2.Config{
ClientID: "someClientId",
ClientSecret: "someSecret",
BaseURL: baseURL}
ctx := context.Background()
authClient := authConfig.New(ctx)
Create Equinix Fabric REST client with a given baseURL
and oauth’s http.Client
var ecxClient ecx.Client = ecx.NewClient(ctx, baseURL, authClient)
Use Equinix Fabric client to perform some operation i.e. fetch
l2conn, err := ecxClient.GetL2Connection("myUUID")
if err != nil {
log.Printf("Error while fetching connection - %v", err)
} else {
log.Printf("Retrieved connection - %+v", l2conn)
}