ecx

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 30, 2020 License: MIT Imports: 8 Imported by: 0

README

ECX Fabric Go client

Equinix Cloud Exchange (ECX) Fabric client library written in Go.

Purpose

ECXF client library was written in Go for purpose of managing ECX resources from Terraform provider plugin.

Library gives possibility to create L2 connections and service profiles on Equinix platform to any Cloud Service Provider, other Enterprise or between own devices.

Features

Client library consumes ECX Fabric's REST API and allows to:

  • manage ECXF 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 ECXF L2 service profiles
  • retrieve list of ECXF user ports
  • retrieve list of ECXF L2 seller profiles

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

Usage

Code
  1. 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"
    )
    
  2. Define baseURL that will be used in all REST API requests

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

    authConfig := oauth2.Config{
      ClientID:     "someClientId",
      ClientSecret: "someSecret",
      BaseURL:      baseURL}
    ctx := context.Background()
    authClient := authConfig.New(ctx)
    
  4. Create ECX REST client with a given baseURL and oauth's http.Client

    var ecxClient ecx.Client = ecx.NewClient(ctx, baseURL, authClient)
    
  5. Use ECX 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)
    }
    

Documentation

Overview

Package ecx implements ECX fabric client

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	GetUserPorts() ([]Port, error)
	GetL2Connection(uuid string) (*L2Connection, error)
	CreateL2Connection(conn L2Connection) (*L2Connection, error)
	CreateL2RedundantConnection(priConn L2Connection, secConn L2Connection) (*L2Connection, error)
	NewL2ConnectionUpdateRequest(uuid string) L2ConnectionUpdateRequest
	DeleteL2Connection(uuid string) error
	ConfirmL2Connection(uuid string, confirmConn L2ConnectionToConfirm) (*L2ConnectionConfirmation, error)

	GetL2SellerProfiles() ([]L2ServiceProfile, error)
	GetL2ServiceProfile(uuid string) (*L2ServiceProfile, error)
	CreateL2ServiceProfile(sp L2ServiceProfile) (*L2ServiceProfile, error)
	UpdateL2ServiceProfile(sp L2ServiceProfile) (*L2ServiceProfile, error)
	DeleteL2ServiceProfile(uuid string) error
}

Client describes operations provided by ECX Fabric client module

type Error

type Error struct {
	//ErrorCode is short error identifier
	ErrorCode string
	//ErrorMessage is textual description of an error
	ErrorMessage string
}

Error describes ECX Fabric error that occurs during API call processing

type L2Connection

type L2Connection struct {
	UUID                string
	Name                string
	ProfileUUID         string
	Speed               int
	SpeedUnit           string
	Status              string
	Notifications       []string
	PurchaseOrderNumber string
	PortUUID            string
	VlanSTag            int
	VlanCTag            int
	NamedTag            string
	AdditionalInfo      []L2ConnectionAdditionalInfo
	ZSidePortUUID       string
	ZSideVlanSTag       int
	ZSideVlanCTag       int
	SellerRegion        string
	SellerMetroCode     string
	AuthorizationKey    string
	RedundantUUID       string
}

L2Connection describes layer 2 connection managed by ECX Fabric

type L2ConnectionAdditionalInfo

type L2ConnectionAdditionalInfo struct {
	Name  string
	Value string
}

L2ConnectionAdditionalInfo additional info object used in L2 connections

type L2ConnectionConfirmation

type L2ConnectionConfirmation struct {
	PrimaryConnectionID string
	Message             string
}

L2ConnectionConfirmation describes a connection confirmed

type L2ConnectionToConfirm

type L2ConnectionToConfirm struct {
	AccessKey string
	SecretKey string
}

L2ConnectionToConfirm accepts the hosted connection in the seller side

type L2ConnectionUpdateRequest

type L2ConnectionUpdateRequest interface {
	WithName(name string) L2ConnectionUpdateRequest
	WithBandwidth(speed int, speedUnit string) L2ConnectionUpdateRequest
	Execute() error
}

L2ConnectionUpdateRequest describes composite request to update given Layer2 connection

type L2ServiceProfile

type L2ServiceProfile struct {
	UUID                                string
	State                               string
	AlertPercentage                     float64
	AllowCustomSpeed                    bool
	AllowOverSubscription               bool
	APIAvailable                        bool
	AuthKeyLabel                        string
	ConnectionNameLabel                 string
	CTagLabel                           string
	EnableAutoGenerateServiceKey        bool
	EquinixManagedPortAndVlan           bool
	Features                            L2ServiceProfileFeatures
	IntegrationID                       string
	Name                                string
	OnBandwidthThresholdNotification    []string
	OnProfileApprovalRejectNotification []string
	OnVcApprovalRejectionNotification   []string
	OverSubscription                    string
	Ports                               []L2ServiceProfilePort
	Private                             bool
	PrivateUserEmails                   []string
	RequiredRedundancy                  bool
	SpeedBands                          []L2ServiceProfileSpeedBand
	SpeedFromAPI                        bool
	TagType                             string
	VlanSameAsPrimary                   bool
	Description                         string
}

L2ServiceProfile describes layer 2 service profile managed by ECX Fabric

type L2ServiceProfileFeatures

type L2ServiceProfileFeatures struct {
	CloudReach  bool
	TestProfile bool
}

L2ServiceProfileFeatures describes features used in L2 service profile

type L2ServiceProfilePort

type L2ServiceProfilePort struct {
	ID        string
	MetroCode string
}

L2ServiceProfilePort describes port used in L2 service profile

type L2ServiceProfileSpeedBand

type L2ServiceProfileSpeedBand struct {
	Speed     int
	SpeedUnit string
}

L2ServiceProfileSpeedBand describes speed / bandwidth used in L2 service profile

type Port

type Port struct {
	UUID          string
	Name          string
	Region        string
	IBX           string
	MetroCode     string
	Priority      string
	Encapsulation string
	Buyout        bool
	Bandwidth     string
	Status        string
}

Port describes ECX Fabric's user port

type RestClient

type RestClient struct {
	*resty.Client
	// contains filtered or unexported fields
}

RestClient describes ECX Fabric client that uses REST API

func NewClient

func NewClient(ctx context.Context, baseURL string, httpClient *http.Client) *RestClient

NewClient creates new ECX REST API client with a given baseURL and http.Client

func (RestClient) ConfirmL2Connection

func (c RestClient) ConfirmL2Connection(uuid string, connToConfirm L2ConnectionToConfirm) (*L2ConnectionConfirmation, error)

ConfirmL2Connection operation accepts a hosted connection

func (RestClient) CreateL2Connection

func (c RestClient) CreateL2Connection(l2connection L2Connection) (*L2Connection, error)

CreateL2Connection operation creates non-redundant layer 2 connection with a given connection structure. Upon successful creation, connection structure, enriched with assigned UUID, will be returned

func (RestClient) CreateL2RedundantConnection

func (c RestClient) CreateL2RedundantConnection(primary L2Connection, secondary L2Connection) (*L2Connection, error)

CreateL2RedundantConnection operation creates redundant layer2 connection with given connection structures. Primary connection structure is used as a baseline for underlaying API call, whereas secondary connection strucutre provices supplementary information only. Upon successful creation, primary connection structure, enriched with assigned UUID and redundant connection UUID, will be returned

func (RestClient) CreateL2ServiceProfile

func (c RestClient) CreateL2ServiceProfile(l2profile L2ServiceProfile) (*L2ServiceProfile, error)

CreateL2ServiceProfile operation creates layer 2 service profile with a given profile structure. Upon successful creation, connection structure with assigned UUID will be returned

func (RestClient) DeleteL2Connection

func (c RestClient) DeleteL2Connection(uuid string) error

DeleteL2Connection deletes layer 2 connection with a given UUID

func (RestClient) DeleteL2ServiceProfile

func (c RestClient) DeleteL2ServiceProfile(uuid string) error

DeleteL2ServiceProfile deletes layer 2 service profile with a given UUID

func (RestClient) GetL2Connection

func (c RestClient) GetL2Connection(uuid string) (*L2Connection, error)

GetL2Connection operation retrieves layer 2 connection with a given UUID

func (RestClient) GetL2SellerProfiles

func (c RestClient) GetL2SellerProfiles() ([]L2ServiceProfile, error)

GetL2SellerProfiles operations retrievies available layer2 seller service profiles

func (RestClient) GetL2ServiceProfile

func (c RestClient) GetL2ServiceProfile(uuid string) (*L2ServiceProfile, error)

GetL2ServiceProfile operation retrieves layer 2 servie profile with a given UUID

func (RestClient) GetUserPorts

func (c RestClient) GetUserPorts() ([]Port, error)

GetUserPorts operation retrieves ECXF user ports

func (RestClient) NewL2ConnectionUpdateRequest

func (c RestClient) NewL2ConnectionUpdateRequest(uuid string) L2ConnectionUpdateRequest

NewL2ConnectionUpdateRequest creates new composite update request for a connection with a given UUID

func (RestClient) UpdateL2ServiceProfile

func (c RestClient) UpdateL2ServiceProfile(sp L2ServiceProfile) (*L2ServiceProfile, error)

UpdateL2ServiceProfile operation updates layer 2 service profile by replacing exisitng profile with a given profile structure. Target profile structure needs to have UUID defined

type RestError

type RestError struct {
	HTTPCode int
	Message  string
	Errors   []Error
}

RestError describe REST client error that occurs during operation processing

func (RestError) Error

func (e RestError) Error() string

Directories

Path Synopsis
internal
api

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL