ecx

package module
v2.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2023 License: MIT Imports: 7 Imported by: 2

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

func Bool

func Bool(b bool) *bool

Bool returns pointer to a given bool value

func BoolValue

func BoolValue(b *bool) bool

BoolValue returns the value of a given bool pointer or false if the pointer is nil

func Float64

func Float64(f float64) *float64

Float64 returns pointer to a given float64 value

func Float64Value

func Float64Value(f *float64) float64

Float64Value returns the value of a given float64 pointer or 0 if the pointer is nil

func Int

func Int(i int) *int

Int returns pointer to a given int value

func Int64

func Int64(i int64) *int64

Int64 returns pointer to a given int64 value

func Int64Value

func Int64Value(i *int64) int64

Int64Value returns the value of a given int64 pointer or 0 if the pointer is nil

func IntValue

func IntValue(i *int) int

IntValue returns the value of a given int pointer or 0 if the pointer is nil

func String

func String(s string) *string

String returns pointer to a given string value

func StringValue

func StringValue(s *string) string

StringValue returns the value of a given string pointer or empty string if the pointer is nil

Types

type Client

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

	GetL2OutgoingConnections(statuses []string) ([]L2Connection, error)
	GetL2Connection(uuid string) (*L2Connection, error)
	CreateL2Connection(conn L2Connection) (*string, error)
	CreateL2RedundantConnection(priConn L2Connection, secConn L2Connection) (*string, *string, 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) (*string, error)
	UpdateL2ServiceProfile(sp 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
	RedundancyGroup     *string
	Actions             []L2ConnectionAction
	// ServiceToken is used to create connections with an a-side Equinix Fabric Token
	// Applicable for CREATE operations: CreateL2Connection, CreateL2RedundantConnection...
	//
	// Deprecated: ServiceToken (GET operations) - Starting with v2.3.0 this field should not be
	// used to populate the a-side token with which the connection was created. It is maintained
	// for historical compability but can contain both a-side/z-side tokens. To access the token
	// returned by a GET operation (GetL2Connection, GetL2OutgoingConnections...), use the
	// L2Connection.VendorToken string.
	ServiceToken *string
	// ZSideServiceToken is used to create connections using a z-side Equinix Fabric Token
	// Applicable for CREATE operations: CreateL2Connection, CreateL2RedundantConnection...
	ZSideServiceToken *string
	// VendorToken is used in GET Operations (GetL2Connection, GetL2OutgoingConnections...) to
	// populate the Equinix Fabric Token the connection was created with (if applicable). The token
	// can be any of ServiceToken (a-side) or ZSideServiceToken (z-side). Any mechanism to
	// determine the token type (a-side/z-side), must be implemented by the user/consumer of the
	// SDK.
	VendorToken *string
}

L2Connection describes layer 2 connection managed by Equinix Fabric

type L2ConnectionAction

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

L2ConnectionAction describes pending actions to complete connection provisioning

type L2ConnectionActionData

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
	WithSpeed(speed int) L2ConnectionUpdateRequest
	WithSpeedUnit(speedUnit string) L2ConnectionUpdateRequest
	Execute() error
}

L2ConnectionUpdateRequest describes composite request to update given Layer2 connection

type L2SellerProfileAdditionalInfo

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

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

type L2SellerProfileMetro

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

L2SellerProfileMetro describes 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) (*string, 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) (*string, *string, 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) (*string, 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

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) 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