ecx

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2021 License: MIT Imports: 8 Imported by: 0

README

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

    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 Equinix Fabric REST client with a given baseURL and oauth's http.Client

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

Documentation

Overview

Package ecx implements Equinix Fabric client

Index

Constants

View Source
const (
	//ConnectionStatusNotAvailable indicates that request to create connection was not sent
	//to the provider. Applicable for provider status only
	ConnectionStatusNotAvailable = "NOT_AVAILABLE"
	//ConnectionStatusPendingApproval indicates that connection awaits provider's approval.
	ConnectionStatusPendingApproval = "PENDING_APPROVAL"
	//ConnectionStatusPendingAutoApproval indicates that connection is in process of
	//automatic approval
	ConnectionStatusPendingAutoApproval = "PENDING_AUTO_APPROVAL"
	//ConnectionStatusProvisioning indicates that connection is in creation process
	ConnectionStatusProvisioning = "PROVISIONING"
	//ConnectionStatusRejected indicates that provider has rejected the connection
	ConnectionStatusRejected = "REJECTED"
	//ConnectionStatusPendingBGPPeering indicates that connection was approved by provider and
	//awaits for BGP peering configuration on provider side
	ConnectionStatusPendingBGPPeering = "PENDING_BGP_PEERING"
	//ConnectionStatusPendingProviderVlan indicates that connection awaits for provider approval
	//and vlan assignment
	ConnectionStatusPendingProviderVlan = "PENDING_PROVIDER_VLAN"
	//ConnectionStatusProvisioned indicates that connection is created successfully
	ConnectionStatusProvisioned = "PROVISIONED"
	//ConnectionStatusAvailable indicates that connection is established.
	//Applicable for provider status only
	ConnectionStatusAvailable = "AVAILABLE"
	//ConnectionStatusPendingDelete indicates that connection is in deletion process and awaits
	//for providers approval to be removed
	ConnectionStatusPendingDelete = "PENDING_DELETE"
	//ConnectionStatusDeprovisioning indicates that connection is being removed
	ConnectionStatusDeprovisioning = "DEPROVISIONING"
	//ConnectionStatusDeprovisioned indicates that connection is removed
	ConnectionStatusDeprovisioned = "DEPROVISIONED"
	//ConnectionStatusDeleted indicates that connection was administratively deleted
	ConnectionStatusDeleted = "DELETED"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	GetUserPorts() ([]Port, error)

	GetL2OutgoingConnections(statuses []string) ([]L2Connection, 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 Equinix 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 Equinix 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
	ProviderStatus      string
	Notifications       []string
	PurchaseOrderNumber string
	PortUUID            string
	DeviceUUID          string
	DeviceInterfaceID   int
	VlanSTag            int
	VlanCTag            int
	NamedTag            string
	AdditionalInfo      []L2ConnectionAdditionalInfo
	ZSidePortUUID       string
	ZSideVlanSTag       int
	ZSideVlanCTag       int
	SellerRegion        string
	SellerMetroCode     string
	AuthorizationKey    string
	RedundantUUID       string
	RedundancyType      string
	Actions             []L2ConnectionAction
}

L2Connection describes layer 2 connection managed by Equinix Fabric

type L2ConnectionAction added in v1.2.0

type L2ConnectionAction struct {
	Type         string
	Message      string
	OperationID  string
	RequiredData []L2ConnectionActionData
}

L2ConnectionAction describes pending actions to complete connection provisioning

type L2ConnectionActionData added in v1.2.0

type L2ConnectionActionData struct {
	Key               string
	Label             string
	Value             string
	IsEditable        bool
	ValidationPattern string
}

L2ConnectionActionData describes data required for a given to complete

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 L2SellerProfileAdditionalInfo added in v1.1.0

type L2SellerProfileAdditionalInfo struct {
	Name             string
	Description      string
	DataType         string
	IsMandatory      bool
	IsCaptureInEmail bool
}

L2SellerProfileAdditionalInfo describces additional information that might be provided by service buyer when using given seller profile

type L2SellerProfileMetro added in v1.1.0

type L2SellerProfileMetro struct {
	Code    string
	Name    string
	IBXes   []string
	Regions map[string]string
}

L2SellerProfileMetro describces details of a metro in which service provices is present

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
	Metros                              []L2SellerProfileMetro
	AdditionalInfos                     []L2SellerProfileAdditionalInfo
	Encapsulation                       string
	GlobalOrganization                  string
	OrganizationName                    string
}

L2ServiceProfile describes layer 2 service profile managed by Equinix 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 Equinix Fabric's user port

type RestClient

type RestClient struct {
	*rest.Client
}

RestClient describes Equinix Fabric client that uses REST API

func NewClient

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

NewClient creates new Equinix Fabric 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 structure 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) GetL2OutgoingConnections added in v1.2.0

func (c RestClient) GetL2OutgoingConnections(statuses []string) ([]L2Connection, error)

GetL2OutgoingConnections retrieves list of all originating (a-side) layer 2 connections for a customer account associated with authenticated application

func (RestClient) GetL2SellerProfiles

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

GetL2SellerProfiles operations retrieves 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 Equinix Fabric 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 existing profile with a given profile structure. Target profile structure needs to have UUID defined

Directories

Path Synopsis
internal
api

Jump to

Keyboard shortcuts

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