项目作者: equinix

项目描述 :
Equinix Fabric client library in Go
高级语言: Go
项目地址: git://github.com/equinix/ecx-go.git
创建时间: 2020-07-30T07:11:48Z
项目社区:https://github.com/equinix/ecx-go

开源协议:MIT License

下载


Equinix Fabric Go client

Equinix Fabric client library written in Go.

Build Status
Go Report Card
GoDoc
GitHub


Purpose

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.

Features

Client library consumes Equinix Fabric’s REST API and allows to:

  • manage Fabric L2 connections
    • retrieve L2 connection details
    • create non redundant L2 connection
    • create redundant L2 connection
    • delete L2 connection
    • update L2 connection (name and speed)
  • manage Fabric L2 service profiles
  • retrieve list of Fabric user ports
  • retrieve list of Fabric L2 seller profiles

NOTE: scope of this library is limited to needs of Terraform provider plugin
and it is not providing full capabilities of Equinix Fabric API

Usage

Code

  1. Add ecx-go module to import statement.
    In below example, Equinix oauth2-go module is imported as well

    1. import (
    2. "github.com/equinix/oauth2-go"
    3. "github.com/equinix/ecx-go"
    4. )
  2. Define baseURL that will be used in all REST API requests

    1. baseURL := "https://sandboxapi.equinix.com"
  3. Create oAuth configuration and oAuth enabled http.Client

    1. authConfig := oauth2.Config{
    2. ClientID: "someClientId",
    3. ClientSecret: "someSecret",
    4. BaseURL: baseURL}
    5. ctx := context.Background()
    6. authClient := authConfig.New(ctx)
  4. Create Equinix Fabric REST client with a given baseURL and oauth’s http.Client

    1. var ecxClient ecx.Client = ecx.NewClient(ctx, baseURL, authClient)
  5. Use Equinix Fabric client to perform some operation i.e. fetch

    1. l2conn, err := ecxClient.GetL2Connection("myUUID")
    2. if err != nil {
    3. log.Printf("Error while fetching connection - %v", err)
    4. } else {
    5. log.Printf("Retrieved connection - %+v", l2conn)
    6. }