megaport

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: May 30, 2024 License: MPL-2.0 Imports: 16 Imported by: 0

README

Megaport Go

Go Reference

Overview

This is the Megaport Go Library. It allows users to orchestrate the creation of Megaport Services.

Before using this library, please ensure you read Megaport's Terms and Conditions.

The Megaport API Documentation is also available online.

Getting started

package main

import (
	"context"
	"fmt"

	megaport "github.com/megaport/megaportgo"
)

// Create a new client using your credentials and interact with the Megaport API
func main() {
	// Creates a new client using the default HTTP cleint with the specified credentials against the staging environment
	client, err := megaport.New(nil,
		megaport.WithCredentials("ACCESS_KEY", "SECRET_KEY"),
		megaport.WithEnvironment(megaport.EnvironmentStaging),
	)
	if err != nil {
		// ...
	}

	// Authorize the client using the client's credentials
	authInfo, err := client.Authorize(context.TODO())
	if err != nil {
		// ...
	}
	fmt.Println(authInfo.AccessToken)
	fmt.Println(authInfo.Expiration) // You can use the expiration here to reauthorize the client when your access token expires

	// After you have authorized you can interact with the API
	locations, err := client.LocationService.ListLocations(context.TODO())
	if err != nil {
		// ...
	}

	for _, location := range locations {
		fmt.Println(location.Name)
	}
}

Testing

For mock tests go test ./...

To run integration tests against the Megaport API you will need to generate an API key

export MEGAPORT_ACCESS_KEY=YOUR_KEY
export MEGAPORT_SECRET_KEY=YOUR_KEY

go test -timeout 20m -integration ./... 

Contributing

Contributions via pull request are welcome. Familiarize yourself with these guidelines to increase the likelihood of your pull request being accepted.

All contributions are subject to the Megaport Contributor Licence Agreement. The CLA clarifies the terms of the Mozilla Public Licence 2.0 used to Open Source this respository and ensures that contributors are explictly informed of the conditions. Megaport requires all contributors to accept these terms to ensure that the Megaport Terraform Provider remains available and licensed for the community.

The main themes of the Megaport Contributor Licence Agreement cover the following conditions:

  • Clarifying the Terms of the Mozilla Public Licence 2.0, used to Open Source this project.
  • As a contributor, you have permission to agree to the License terms.
  • As a contributor, you are not obligated to provide support or warranty for your contributions.
  • Copyright is assigned to Megaport to use as Megaport determines, including within commercial products.
  • Grant of Patent Licence to Megaport for any contributions containing patented or future patented works.

The Megaport Contributor Licence Agreement is the authoritative document over these conditions and any other communications unless explicitly stated otherwise.

When you open a Pull Request, all authors of the contributions are required to comment on the Pull Request confirming acceptance of the CLA terms. Pull Requests can not be mMegaport_Contributor_Licence_Agreementerged until this is complete.

The Megaport Contributor Licence Agreement applies to contributions. All users are free to use the megaportgo project under the MPL-2.0 Open Source Licence.

Megaport users are also bound by the Acceptable Use Policy.

Getting Started

Prior to working on new code, review the Open Issues. Check whether your issue has already been raised, and consider working on an issue with votes or clear demand.

If you don't see an open issue for your need, open one and let others know what you are working on. Avoid lengthy or complex changes that rewrite the repository or introduce breaking changes. Straightforward pull requests based on discussion or ideas and Megaport feedback are the most likely to be accepted.

Megaport is under no obligation to accept any pull requests or to accept them in full. You are free to fork and modify the code for your own use as long is it is published under the MPL-2.0 License.

Notes

What's new in V1

The new V1 release of the megaportgo project has several changes users should be aware of:

  • All API methods now take context
  • More configurable
    • Custom HTTP client support
    • Structured logging is configurable and is handled using the slog package
  • Documentation is improved
  • Errors are easier to work with and are defined at the package level
  • All APIs are now available in the megaport package rather than multiple packages in the service directory
  • General code cleanup and linting rule enforcement
  • Missing types have been implemented

Documentation

Overview

Package megaport holds the Megaport Go Library. It allows users to orchestrate the creation of Megaport Services.

Before using this library, please ensure you read Megaport's Terms and Conditions.

The Megaport API Documentation is also available online.

Example

Create a new client using your credentials and interact with the Megaport API

package main

import (
	"context"
	"fmt"

	megaport "github.com/megaport/megaportgo"
)

func main() {
	// Creates a new client using the default HTTP cleint with the specified credentials against the staging environment
	client, err := megaport.New(nil,
		megaport.WithCredentials("ACCESS_KEY", "SECRET_KEY"),
		megaport.WithEnvironment(megaport.EnvironmentStaging),
	)
	if err != nil {
		// ...
	}

	// Authorize the client using the client's credentials
	authInfo, err := client.Authorize(context.TODO())
	if err != nil {
		// ...
	}
	fmt.Println(authInfo.AccessToken)
	fmt.Println(authInfo.Expiration) // You can use the expiration here to reauthorize the client when your access token expires

	// After you have authorized you can interact with the API
	locations, err := client.LocationService.ListLocations(context.TODO())
	if err != nil {
		// ...
	}

	for _, location := range locations {
		fmt.Println(location.Name)
	}
}
Output:

Example (Logger)

Example with a custom logger

package main

import (
	"context"
	"log/slog"
	"os"

	megaport "github.com/megaport/megaportgo"
)

func main() {
	// A handler that logs JSON logs to stdout but only errors
	handler := slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{
		Level: slog.LevelError,
	})

	// Create a new client with your custom log handler
	client, err := megaport.New(nil,
		megaport.WithCredentials("ACCESS_KEY", "SECRET_KEY"),
		megaport.WithEnvironment(megaport.EnvironmentStaging),
		megaport.WithLogHandler(handler),
	)
	if err != nil {
		// ...
	}

	client.Logger.ErrorContext(context.Background(), "testing") // will print
	client.Logger.InfoContext(context.Background(), "testing")  // won't print
}
Output:

Index

Examples

Constants

View Source
const (
	SERVICE_CONFIGURED = "CONFIGURED" // The CONFIGURED service state.
	SERVICE_LIVE       = "LIVE"       // The LIVE service state.

	// Product types
	PRODUCT_MEGAPORT = "megaport"
	PRODUCT_VXC      = "vxc"
	PRODUCT_MCR      = "mcr2"
	PRODUCT_MVE      = "mve"
	PRODUCT_IX       = "ix"

	// Cancellation states
	STATUS_DECOMMISSIONED = "DECOMMISSIONED"
	STATUS_CANCELLED      = "CANCELLED"

	// Port Types
	SINGLE_PORT = "Single"
	LAG_PORT    = "LAG"

	// AWS VXC Types
	CONNECT_TYPE_AWS_VIF               = "AWS"
	CONNECT_TYPE_AWS_HOSTED_CONNECTION = "AWSHC"
)
View Source
const PARTNER_AWS string = "AWS"
View Source
const PARTNER_AZURE string = "AZURE"

Partner Providers

View Source
const PARTNER_GOOGLE string = "GOOGLE"
View Source
const PARTNER_OCI string = "ORACLE"

Variables

View Source
var ErrCostCentreTooLong = errors.New("cost centre must be less than 255 characters")

ErrCostCentreTooLong is returned when a cost centre is longer than 255 characters

View Source
var ErrInvalidTerm = errors.New("invalid term, valid values are 1, 12, 24, and 36")

ErrInvalidTerm is returned for an invalid product term

View Source
var ErrLocationNotFound = errors.New("unable to find location")

ErrLocationNotFound is returned when a location can't be found

View Source
var ErrMCRInvalidPortSpeed = errors.New("invalid port speed, valid speeds are 1000, 2500, 5000, and 10000")

ErrMCRInvalidPortSpeed is returned for an invalid MCR port speed

View Source
var ErrNoAvailableVxcPorts = errors.New("there are no available ports for you to connect to")

ErrNoAvailableVxcPorts is returned when there are no available ports for a user to connect to

View Source
var ErrNoMatchingLocations = errors.New("could not find any matching locations from search")

ErrNoMatchingLocations is returned when a fuzzy search for a location doesn't return any results

View Source
var ErrNoPartnerPortsFound = errors.New("sorry there were no results returned based on the given filters")

ErrNoPartnerPortsFound is returned when no partner ports could be found matching the filters provided

View Source
var ErrPortAlreadyLocked = errors.New("that port is already locked, cannot lock")

ErrPortAlreadyLocked is returned when a port is already locked

View Source
var ErrPortNotLocked = errors.New("that port not locked, cannot unlock")

ErrPortNotLocked is returned when a port is not locked

View Source
var ErrWrongProductModify = errors.New("you can only update Ports, MCR, and MVE using this method")

ErrWrongProductModify is returned when a user attempts to modify a product that can't be modified

View Source
var (
	// SERVICE_STATE_READY is a list of service states that are considered ready for use.
	SERVICE_STATE_READY = []string{SERVICE_CONFIGURED, SERVICE_LIVE}
)

Functions

func CheckResponse

func CheckResponse(r *http.Response) error

CheckResponse checks the API response for errors, and returns them if present. A response is considered an error if it has a status code outside the 200 range. API error responses are expected to have either no response body, or a JSON response body that maps to ErrorResponse. Any other response body will be silently ignored. If the API error response does not include the request ID in its body, the one from its header will be used.

func DoRequest

func DoRequest(ctx context.Context, req *http.Request) (*http.Response, error)

DoRequest submits an HTTP request.

func DoRequestWithClient

func DoRequestWithClient(
	ctx context.Context,
	client *http.Client,
	req *http.Request) (*http.Response, error)

DoRequestWithClient submits an HTTP request using the specified client.

func PtrTo

func PtrTo[T any](v T) *T

PtrTo returns a pointer to the provided input.

Types

type AWSVXCOrder

type AWSVXCOrder struct {
	AssociatedVXCs []AWSVXCOrderConfiguration `json:"associatedVxcs"`
	PortID         string                     `json:"productUid"`
}

AWSVXCOrder represents the request to order an AWS VXC from the Megaport Products API.

type AWSVXCOrderConfiguration

type AWSVXCOrderConfiguration struct {
	Name      string                        `json:"productName"`
	RateLimit int                           `json:"rateLimit"`
	AEnd      VXCOrderEndpointConfiguration `json:"aEnd"`
	BEnd      VXCOrderEndpointConfiguration `json:"bEnd"`
}

AWSVXCOrderConfiguration represents the configuration of an AWS VXC to be ordered from the Megaport Products API.

type AccessTokenResponse

type AccessTokenResponse struct {
	AccessToken  string `json:"access_token"`
	TokenType    string `json:"token_type"`
	ExpiresIn    int    `json:"expires_in"`
	RefreshToken string `json:"refresh_token,omitempty"`
	Error        string `json:"error"`
}

AccessTokenResponse is the response structure for the Login method containing the access token and expiration time.

type ArubaConfig

type ArubaConfig struct {
	VendorConfig
	Vendor      string `json:"vendor"`
	ImageID     int    `json:"imageId"`
	ProductSize string `json:"productSize"`
	MVELabel    string `json:"mveLabel"`
	AccountName string `json:"accountName"`
	AccountKey  string `json:"accountKey"`
	SystemTag   string `json:"systemTag"`
}

ArubaConfig represents the configuration for an Aruba MVE.

type AuthInfo

type AuthInfo struct {
	Expiration  time.Time
	AccessToken string
}

type BfdConfig

type BfdConfig struct {
	TxInterval int `json:"txInterval,omitempty"`
	RxInterval int `json:"rxInterval,omitempty"`
	Multiplier int `json:"multiplier,omitempty"`
}

BfdConfig represents the configuration of BFD.

type BgpConnectionConfig

type BgpConnectionConfig struct {
	PeerAsn         int      `json:"peerAsn"`
	LocalIpAddress  string   `json:"localIpAddress"`
	PeerIpAddress   string   `json:"peerIpAddress"`
	Password        string   `json:"password,omitempty"`
	Shutdown        bool     `json:"shutdown"`
	Description     string   `json:"description,omitempty"`
	MedIn           int      `json:"medIn,omitempty"`
	MedOut          int      `json:"medOut,omitempty"`
	BfdEnabled      bool     `json:"bfdEnabled"`
	ExportPolicy    string   `json:"exportPolicy,omitempty"`
	PermitExportTo  []string `json:"permitExportTo,omitempty"`
	DenyExportTo    []string `json:"denyExportTo,omitempty"`
	ImportWhitelist int      `json:"importWhitelist,omitempty"`
	ImportBlacklist int      `json:"importBlacklist,omitempty"`
	ExportWhitelist int      `json:"exportWhitelist,omitempty"`
	ExportBlacklist int      `json:"exportBlacklist,omitempty"`
}

BgpConnectionConfig represents the configuration of a BGP connection.

type BuyMCRRequest

type BuyMCRRequest struct {
	LocationID    int
	Name          string
	DiversityZone string
	Term          int
	PortSpeed     int
	MCRAsn        int
	CostCentre    string

	WaitForProvision bool          // Wait until the MCR provisions before returning
	WaitForTime      time.Duration // How long to wait for the MCR to provision if WaitForProvision is true (default is 5 minutes)
}

BuyMCRRequest represents a request to buy an MCR

type BuyMCRResponse

type BuyMCRResponse struct {
	TechnicalServiceUID string
}

BuyMCRResponse represents a response from buying an MCR

type BuyMVERequest

type BuyMVERequest struct {
	LocationID    int
	Name          string
	Term          int
	VendorConfig  VendorConfig
	Vnics         []MVENetworkInterface
	DiversityZone string

	WaitForProvision bool          // Wait until the MVE provisions before returning
	WaitForTime      time.Duration // How long to wait for the MVE to provision if WaitForProvision is true (default is 5 minutes)
}

BuyMVERequest represents a request to buy an MVE

type BuyMVEResponse

type BuyMVEResponse struct {
	TechnicalServiceUID string
}

BuyMVEResponse represents a response from buying an MVE

type BuyPortRequest

type BuyPortRequest struct {
	Name                  string `json:"name"`
	Term                  int    `json:"term"`
	PortSpeed             int    `json:"portSpeed"`
	LocationId            int    `json:"locationId"`
	Market                string `json:"market"`
	LagCount              int    `json:"lagCount"` // A lag count of 1 or higher will order the port as a single LAG
	MarketPlaceVisibility bool   `json:"marketPlaceVisibility"`
	DiversityZone         string `json:"diversityZone"`
	CostCentre            string `json:"costCentre"`

	WaitForProvision bool          // Wait until the VXC provisions before returning
	WaitForTime      time.Duration // How long to wait for the VXC to provision if WaitForProvision is true (default is 5 minutes)
}

BuyPortRequest represents a request to buy a port.

type BuyPortResponse

type BuyPortResponse struct {
	TechnicalServiceUIDs []string
}

BuyPortResponse represents a response from buying a port.

type BuyVXCRequest

type BuyVXCRequest struct {
	PortUID           string
	VXCName           string
	RateLimit         int
	Term              int
	Shutdown          bool
	AEndConfiguration VXCOrderEndpointConfiguration
	BEndConfiguration VXCOrderEndpointConfiguration

	WaitForProvision bool          // Wait until the VXC provisions before returning
	WaitForTime      time.Duration // How long to wait for the VXC to provision if WaitForProvision is true (default is 5 minutes)
}

BuyVXCRequest represents a request to buy a VXC from the Megaport VXC API.

type BuyVXCResponse

type BuyVXCResponse struct {
	TechnicalServiceUID string
}

BuyVXCResponse represents a response from buying a VXC from the Megaport VXC API.

type CSPConnection

type CSPConnection struct {
	CSPConnection []CSPConnectionConfig
}

CSPConnection represents the configuration of a CSP connection.

func (*CSPConnection) UnmarshalJSON

func (c *CSPConnection) UnmarshalJSON(data []byte) error

UnmarshalJSON is a custom unmarshaler for the CSPConnection type.

type CSPConnectionAWS

type CSPConnectionAWS struct {
	CSPConnectionConfig
	ConnectType       string `json:"connectType"`
	ResourceName      string `json:"resource_name"`
	ResourceType      string `json:"resource_type"`
	VLAN              int    `json:"vlan"`
	Account           string `json:"account"`
	AmazonAddress     string `json:"amazon_address"`
	ASN               int    `json:"asn"`
	AuthKey           string `json:"authKey"`
	CustomerAddress   string `json:"customer_address"`
	CustomerIPAddress string `json:"customerIpAddress"`
	ID                int    `json:"id"`
	Name              string `json:"name"`
	OwnerAccount      string `json:"ownerAccount"`
	PeerASN           int    `json:"peerAsn"`
	Type              string `json:"type"`
	VIFID             string `json:"vif_id"`
}

CSPConnectionAWS represents the configuration of a CSP connection for AWS Virtual Interface.

type CSPConnectionAWSHC

type CSPConnectionAWSHC struct {
	CSPConnectionConfig
	ConnectType  string `json:"connectType"`
	ResourceName string `json:"resource_name"`
	ResourceType string `json:"resource_type"`
	Bandwidth    int    `json:"bandwidth"`
	Name         string `json:"name"`
	OwnerAccount string `json:"ownerAccount"`
	Bandwidths   []int  `json:"bandwidths"`
	ConnectionID string `json:"connectionId"`
}

CSPConnectionAWSHC represents the configuration of a CSP connection for AWS Hosted Connection.

type CSPConnectionAzure

type CSPConnectionAzure struct {
	CSPConnectionConfig
	ConnectType  string                       `json:"connectType"`
	ResourceName string                       `json:"resource_name"`
	ResourceType string                       `json:"resource_type"`
	Bandwidth    int                          `json:"bandwidth"`
	Managed      bool                         `json:"managed"`
	Megaports    []CSPConnectionAzureMegaport `json:"megaports"`
	Ports        []CSPConnectionAzurePort     `json:"ports"`
	ServiceKey   string                       `json:"service_key"`
	VLAN         int                          `json:"vlan"`
}

CSPConnectionAzure represents the configuration of a CSP connection for Azure ExpressRoute.

type CSPConnectionAzureMegaport

type CSPConnectionAzureMegaport struct {
	Port int    `json:"port"`
	Type string `json:"type"`
	VXC  int    `json:"vxc,omitempty"`
}

CSPConnectionAzureMegaport represents the configuration of a CSP connection for Azure ExpressRoute megaport.

type CSPConnectionAzurePort

type CSPConnectionAzurePort struct {
	ServiceID     int    `json:"service_id"`
	Type          string `json:"type"`
	VXCServiceIDs []int  `json:"vxc_service_ids"`
}

CSPConnectionAzurePort represents the configuration of a CSP connection for Azure ExpressRoute port.

type CSPConnectionConfig

type CSPConnectionConfig interface {
	IsCSPConnectionConfig()
}

CSPConnectionConfig represents the configuration of a CSP connection.

type CSPConnectionGoogle

type CSPConnectionGoogle struct {
	CSPConnectionConfig
	Bandwidth    int                           `json:"bandwidth"`
	ConnectType  string                        `json:"connectType"`
	ResourceName string                        `json:"resource_name"`
	ResourceType string                        `json:"resource_type"`
	Bandwidths   []int                         `json:"bandwidths"`
	Megaports    []CSPConnectionGoogleMegaport `json:"megaports"`
	Ports        []CSPConnectionGooglePort     `json:"ports"`
	CSPName      string                        `json:"csp_name"`
	PairingKey   string                        `json:"pairingKey"`
}

CSPConnectionGoogle represents the configuration of a CSP connection for Google Cloud Interconnect.

type CSPConnectionGoogleMegaport

type CSPConnectionGoogleMegaport struct {
	Port int `json:"port"`
	VXC  int `json:"vxc"`
}

CSPConnectionGoogleMegaport represents the configuration of a CSP connection for Google Cloud Interconnect megaport.

type CSPConnectionGooglePort

type CSPConnectionGooglePort struct {
	ServiceID     int   `json:"service_id"`
	VXCServiceIDs []int `json:"vxc_service_ids"`
}

CSPConnectionGooglePort represents the configuration of a CSP connection for Google Cloud Interconnect port.

type CSPConnectionOther

type CSPConnectionOther struct {
	CSPConnectionConfig
	CSPConnection map[string]interface{}
}

CSPConnectionOther represents the configuration of a CSP connection for any other CSP that is not presently defined.

type CSPConnectionTransit

type CSPConnectionTransit struct {
	CSPConnectionConfig
	ConnectType        string `json:"connectType"`
	ResourceName       string `json:"resource_name"`
	ResourceType       string `json:"resource_type"`
	CustomerIP4Address string `json:"customer_ip4_address"`
	CustomerIP6Network string `json:"customer_ip6_network"`
	IPv4GatewayAddress string `json:"ipv4_gateway_address"`
	IPv6GatewayAddress string `json:"ipv6_gateway_address"`
}

CSPConnectionTransit represents the configuration of a CSP connection for a Transit VXC.

type CSPConnectionVirtualRouter

type CSPConnectionVirtualRouter struct {
	CSPConnectionConfig
	ConnectType       string                                `json:"connectType"`
	ResourceName      string                                `json:"resource_name"`
	ResourceType      string                                `json:"resource_type"`
	VLAN              int                                   `json:"vlan"`
	Interfaces        []CSPConnectionVirtualRouterInterface `json:"interfaces"`
	IPAddresses       []string                              `json:"ip_addresses"`
	VirtualRouterName string                                `json:"virtualRouterName"`
}

CSPConnectionVirtualRouter represents the configuration of a CSP connection for Virtual Router.

type CSPConnectionVirtualRouterInterface

type CSPConnectionVirtualRouterInterface struct {
	IPAddresses []string `json:"ipAddresses"`
}

CSPConnectionVirtualRouterInterface represents the configuration of a CSP connection for Virtual Router interface.

type CiscoConfig

type CiscoConfig struct {
	VendorConfig
	Vendor             string `json:"vendor"`
	ImageID            int    `json:"imageId"`
	ProductSize        string `json:"productSize"`
	MVELabel           string `json:"mveLabel"`
	ManageLocally      bool   `json:"manageLocally"`
	AdminSSHPublicKey  string `json:"adminSshPublicKey"`
	SSHPublicKey       string `json:"sshPublicKey"`
	CloudInit          string `json:"cloudInit"`
	FMCIPAddress       string `json:"fmcIpAddress"`
	FMCRegistrationKey string `json:"fmcRegistrationKey"`
	FMCNatID           string `json:"fmcNatId"`
}

CiscoConfig represents the configuration for a Cisco MVE.

type Client

type Client struct {
	// HTTP Client used to communicate with the Megaport API
	HTTPClient *http.Client

	// Logger for client
	Logger *slog.Logger

	// Base URL
	BaseURL *url.URL

	// User agent for client
	UserAgent string

	// The access key for the API token
	AccessKey string

	// The secret key for the API token
	SecretKey string

	// PortService provides methods for interacting with the Ports API
	PortService PortService
	// PartnerService provides methods for interacting with the Partners API
	PartnerService PartnerService
	// ProductService provides methods for interacting with the Products API
	ProductService ProductService
	// LocationService provides methods for interacting with the Locations API
	LocationService LocationService
	// VXCService provides methods for interacting with the VXCs API
	VXCService VXCService
	// MCRService provides methods for interacting with the MCRs API
	MCRService MCRService
	// MVEService provides methods for interacting with the MVEs API
	MVEService MVEService
	// contains filtered or unexported fields
}

Client manges communication with the Megaport API

func New

func New(httpClient *http.Client, opts ...ClientOpt) (*Client, error)

New returns a new Megaport API client instance.

func NewClient

func NewClient(httpClient *http.Client, base *url.URL) *Client

NewClient returns a new Megaport API client, using the given http.Client to perform all requests.

func (*Client) Authorize

func (c *Client) Authorize(ctx context.Context) (*AuthInfo, error)

Authorize performs an OAuth-style login using the client's AccessKey and SecretKey and updates the client's access token on a successful response.

func (*Client) Do

func (c *Client) Do(ctx context.Context, req *http.Request, v interface{}) (*http.Response, error)

Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred. If v implements the io.Writer interface, the raw response will be written to v, without attempting to decode it.

func (*Client) NewRequest

func (c *Client) NewRequest(ctx context.Context, method, urlStr string, body interface{}) (*http.Request, error)

NewRequest creates an API request. A relative URL can be provided in urlStr, which will be resolved to the BaseURL of the Client. Relative URLS should always be specified without a preceding slash. If specified, the value pointed to by body is JSON encoded and included in as the request body.

func (*Client) SetOnRequestCompleted

func (c *Client) SetOnRequestCompleted(rc RequestCompletionCallback)

SetOnRequestCompleted sets the Megaport API request completion callback

type ClientOpt

type ClientOpt func(*Client) error

ClientOpt are options for New.

func WithBaseURL

func WithBaseURL(bu string) ClientOpt

WithBaseURL is a client option for setting the base URL.

func WithCredentials

func WithCredentials(accessKey, secretKey string) ClientOpt

WithCredentials sets the client's API credentials

func WithCustomHeaders

func WithCustomHeaders(headers map[string]string) ClientOpt

WithCustomHeaders sets optional HTTP headers on the client that are sent on each HTTP request.

func WithEnvironment

func WithEnvironment(e Environment) ClientOpt

WithEnvironment is a helper for setting a BaseURL by environment

func WithLogHandler

func WithLogHandler(h slog.Handler) ClientOpt

WithLogHandler is an option to pass in a custom slog handler

func WithUserAgent

func WithUserAgent(ua string) ClientOpt

WithUserAgent is a client option for setting the user agent.

type CompanyEnablement

type CompanyEnablement struct {
	TradingName string `json:"tradingName"`
}

CompanyEnablement represents a company enablement in the Megaport API.

type Country

type Country struct {
	Code      string `json:"code"`
	Name      string `json:"name"`
	Prefix    string `json:"prefix"`
	SiteCount int    `json:"siteCount"`
}

Country represents a country in the Megaport Locations API.

type CountryInnerResponse

type CountryInnerResponse struct {
	Countries     []*Country `json:"countries"`
	NetworkRegion string     `json:"networkRegion"`
}

CountriesInnerResponse represents the inner response from the Megaport Network Regions API.

type CountryResponse

type CountryResponse struct {
	Message string                  `json:"message"`
	Terms   string                  `json:"terms"`
	Data    []*CountryInnerResponse `json:"data"`
}

CountryResponse represents the response from the Megaport Network Regions API.

type CreateMCRPrefixFilterListRequest

type CreateMCRPrefixFilterListRequest struct {
	MCRID            string
	PrefixFilterList MCRPrefixFilterList
}

CreateMCRPrefixFilterListRequest represents a request to create a prefix filter list on an MCR

type CreateMCRPrefixFilterListResponse

type CreateMCRPrefixFilterListResponse struct {
	IsCreated bool
}

CreateMCRPrefixFilterListResponse represents a response from creating a prefix filter list on an MCR

type DeleteMCRRequest

type DeleteMCRRequest struct {
	MCRID     string
	DeleteNow bool
}

DeleteMCRRequest represents a request to delete an MCR

type DeleteMCRResponse

type DeleteMCRResponse struct {
	IsDeleting bool
}

DeleteMCRResponse represents a response from deleting an MCR

type DeleteMVERequest

type DeleteMVERequest struct {
	MVEID string
}

DeleteMVERequest represents a request to delete an MVE

type DeleteMVEResponse

type DeleteMVEResponse struct {
	IsDeleted bool
}

DeleteMVEResponse represents a response from deleting an MVE

type DeletePortRequest

type DeletePortRequest struct {
	PortID    string
	DeleteNow bool
}

DeletePortRequest represents a request to delete a port.

type DeletePortResponse

type DeletePortResponse struct {
	IsDeleting bool
}

DeletePortResponse represents a response from deleting a port.

type DeleteProductRequest

type DeleteProductRequest struct {
	ProductID string
	DeleteNow bool
}

DeleteProductRequest represents a request to delete a product in the Megaport Products API.

type DeleteProductResponse

type DeleteProductResponse struct{}

DeleteProductResponse represents a response from the Megaport Products API after deleting a product.

type DeleteVXCRequest

type DeleteVXCRequest struct {
	DeleteNow bool
}

DeleteVXCRequest represents a request to delete a VXC in the Megaport VXC API.

type DeleteVXCResponse

type DeleteVXCResponse struct {
	IsDeleting bool
}

DeleteVXCResponse represents a response from deleting a VXC in the Megaport VXC API.

type Environment

type Environment string
const (
	EnvironmentStaging    Environment = "https://api-staging.megaport.com/"
	EnvironmentProduction Environment = "https://api.megaport.com/"
)

type ErrorResponse

type ErrorResponse struct {
	// HTTP response that caused this error
	Response *http.Response

	// Error message
	Message string `json:"message"`

	// Error Data
	Data string `json:"data"`

	// Trace ID returned from the API.
	TraceID string `json:"trace_id"`
}

An ErrorResponse reports the error caused by an API request

func (*ErrorResponse) Error

func (r *ErrorResponse) Error() string

Error returns the string representation of the error

type FortinetConfig

type FortinetConfig struct {
	VendorConfig
	Vendor            string `json:"vendor"`
	ImageID           int    `json:"imageId"`
	ProductSize       string `json:"productSize"`
	MVELabel          string `json:"mveLabel"`
	AdminSSHPublicKey string `json:"adminSshPublicKey"`
	SSHPublicKey      string `json:"sshPublicKey"`
	LicenseData       string `json:"licenseData"`
}

FortinetConfig represents the configuration for a Fortinet MVE.

type GetPortRequest

type GetPortRequest struct {
	PortID string
}

GetPortRequest represents a request to get a port.

type IpRoute

type IpRoute struct {
	Prefix      string `json:"prefix"`
	Description string `json:"description,omitempty"`
	NextHop     string `json:"nextHop"`
}

IpRoute represents an IP route.

type Location

type Location struct {
	Name             string            `json:"name"`
	Country          string            `json:"country"`
	LiveDate         *Time             `json:"liveDate"`
	SiteCode         string            `json:"siteCode"`
	NetworkRegion    string            `json:"networkRegion"`
	Address          map[string]string `json:"address"`
	Campus           string            `json:"campus"`
	Latitude         float64           `json:"latitude"`
	Longitude        float64           `json:"longitude"`
	Products         *LocationProducts `json:"products"`
	Market           string            `json:"market"`
	Metro            string            `json:"metro"`
	VRouterAvailable bool              `json:"vRouterAvailable"`
	ID               int               `json:"id"`
	Status           string            `json:"status"`
}

Location represents a location in the Megaport API.

type LocationMVE

type LocationMVE struct {
	Sizes             []string             `json:"sizes"`
	Details           []LocationMVEDetails `json:"details"`
	MaxCPUCount       int                  `json:"maxCpuCount"`
	Version           string               `json:"version"`
	Product           string               `json:"product"`
	Vendor            string               `json:"vendor"`
	VendorDescription string               `json:"vendorDescription"`
	ID                int                  `json:"id"`
	ReleaseImage      bool                 `json:"releaseImage"`
}

LocationMVE represents the MVE product available at a location in the Megaport API.

type LocationMVEDetails

type LocationMVEDetails struct {
	Size          string `json:"size"`
	Label         string `json:"label"`
	CPUCoreCount  int    `json:"cpuCoreCount"`
	RamGB         int    `json:"ramGB"`
	BandwidthMbps int    `json:"bandwidthMbps"`
}

LocationMVEDetails represents the details of the MVE product available at a location in the Megaport API.

type LocationProducts

type LocationProducts struct {
	MCR        bool          `json:"mcr"`
	MCRVersion int           `json:"mcrVersion"`
	Megaport   []int         `json:"megaport"`
	MVE        []LocationMVE `json:"mve"`
	MCR1       []int         `json:"mcr1"`
	MCR2       []int         `json:"mcr2"`
}

LocationProducts represent the products available at a location in the Megaport API.

type LocationResponse

type LocationResponse struct {
	Message string      `json:"message"`
	Terms   string      `json:"terms"`
	Data    []*Location `json:"data"`
}

LocationsResponse represents the response from the Megaport Locations API.

type LocationService

type LocationService interface {
	// ListLocations returns a list of all locations in the Megaport Locations API.
	ListLocations(ctx context.Context) ([]*Location, error)
	// GetLocationByID returns a location by its ID in the Megaport Locations API.
	GetLocationByID(ctx context.Context, locationID int) (*Location, error)
	// GetLocationByName returns a location by its name in the Megaport Locations API.
	GetLocationByName(ctx context.Context, locationName string) (*Location, error)
	// GetLocationByNameFuzzy returns a location by its name in the Megaport Locations API using fuzzy search.
	GetLocationByNameFuzzy(ctx context.Context, search string) ([]*Location, error)
	// ListCountries returns a list of all countries in the Megaport Network Regions API.
	ListCountries(ctx context.Context) ([]*Country, error)
	// ListMarketCodes returns a list of all market codes in the Megaport Network Regions API.
	ListMarketCodes(ctx context.Context) ([]string, error)
	// IsValidMarketCode checks if a market code is valid in the Megaport Network Regions API.
	IsValidMarketCode(ctx context.Context, marketCode string) (bool, error)
	// FilterLocationsByMarketCode filters locations by market code in the Megaport Locations API.
	FilterLocationsByMarketCode(ctx context.Context, marketCode string, locations []*Location) ([]*Location, error)
	// FilterLocationsByMcrAvailability filters locations by MCR availability in the Megaport Locations API.
	FilterLocationsByMcrAvailability(ctx context.Context, mcrAvailable bool, locations []*Location) []*Location
}

LocationService is an interface for interfacing with the Location endpoints of the Megaport API.

type LocationServiceOp

type LocationServiceOp struct {
	Client *Client
}

LocationServiceOp handles communication with Location methods of the Megaport API.

func NewLocationService

func NewLocationService(c *Client) *LocationServiceOp

NewLocationService creates a new instance of the Location Service.

func (*LocationServiceOp) FilterLocationsByMarketCode

func (svc *LocationServiceOp) FilterLocationsByMarketCode(ctx context.Context, marketCode string, locations []*Location) ([]*Location, error)

FilterLocationsByMarketCode filters locations by market code in the Megaport Locations API.

func (*LocationServiceOp) FilterLocationsByMcrAvailability

func (svc *LocationServiceOp) FilterLocationsByMcrAvailability(ctx context.Context, mcrAvailable bool, locations []*Location) []*Location

FilterLocationsByMcrAvailability filters locations by MCR availability in the Megaport Locations API.

func (*LocationServiceOp) GetLocationByID

func (svc *LocationServiceOp) GetLocationByID(ctx context.Context, locationID int) (*Location, error)

GetLocationByID returns a location by its ID in the Megaport Locations API.

func (*LocationServiceOp) GetLocationByName

func (svc *LocationServiceOp) GetLocationByName(ctx context.Context, locationName string) (*Location, error)

GetLocationByName returns a location by its name in the Megaport Locations API.

func (*LocationServiceOp) GetLocationByNameFuzzy

func (svc *LocationServiceOp) GetLocationByNameFuzzy(ctx context.Context, search string) ([]*Location, error)

GetLocationByNameFuzzy returns a location by its name in the Megaport Locations API using fuzzy search.

func (*LocationServiceOp) IsValidMarketCode

func (svc *LocationServiceOp) IsValidMarketCode(ctx context.Context, marketCode string) (bool, error)

IsValidMarketCode checks if a market code is valid in the Megaport Network Regions API.

func (*LocationServiceOp) ListCountries

func (svc *LocationServiceOp) ListCountries(ctx context.Context) ([]*Country, error)

ListCountries returns a list of all countries in the Megaport Network Regions API.

func (*LocationServiceOp) ListLocations

func (svc *LocationServiceOp) ListLocations(ctx context.Context) ([]*Location, error)

ListLocations returns a list of all locations in the Megaport Locations API.

func (*LocationServiceOp) ListMarketCodes

func (svc *LocationServiceOp) ListMarketCodes(ctx context.Context) ([]string, error)

ListMarketCodes returns a list of all market codes in the Megaport Network Regions API.

type LockPortRequest

type LockPortRequest struct {
	PortID string
}

LockPortRequest represents a request to lock a port.

type LockPortResponse

type LockPortResponse struct {
	IsLocking bool
}

LockPortResponse represents a response from locking a port.

type LookupPartnerPortsRequest

type LookupPartnerPortsRequest struct {
	Key       string
	PortSpeed int
	Partner   string
	ProductID string
}

LookupPartnerPortsRequest represents a request to lookup available partner ports in the Megaport VXC API.

type LookupPartnerPortsResponse

type LookupPartnerPortsResponse struct {
	ProductUID string
}

LookupPartnerPortsResponse represents a response from looking up available partner ports in the Megaport VXC API.

type MCR

type MCR struct {
	ID                    int                     `json:"productId"`
	UID                   string                  `json:"productUid"`
	Name                  string                  `json:"productName"`
	Type                  string                  `json:"productType"`
	ProvisioningStatus    string                  `json:"provisioningStatus"`
	CreateDate            *Time                   `json:"createDate"`
	CreatedBy             string                  `json:"createdBy"`
	CostCentre            string                  `json:"costCentre"`
	PortSpeed             int                     `json:"portSpeed"`
	TerminateDate         *Time                   `json:"terminateDate"`
	LiveDate              *Time                   `json:"liveDate"`
	Market                string                  `json:"market"`
	LocationID            int                     `json:"locationId"`
	UsageAlgorithm        string                  `json:"usageAlgorithm"`
	MarketplaceVisibility bool                    `json:"marketplaceVisibility"`
	VXCPermitted          bool                    `json:"vxcpermitted"`
	VXCAutoApproval       bool                    `json:"vxcAutoApproval"`
	SecondaryName         string                  `json:"secondaryName"`
	LAGPrimary            bool                    `json:"lagPrimary"`
	LAGID                 int                     `json:"lagId"`
	AggregationID         int                     `json:"aggregationId"`
	CompanyUID            string                  `json:"companyUid"`
	CompanyName           string                  `json:"companyName"`
	ContractStartDate     *Time                   `json:"contractStartDate"`
	ContractEndDate       *Time                   `json:"contractEndDate"`
	ContractTermMonths    int                     `json:"contractTermMonths"`
	AttributeTags         map[string]string       `json:"attributeTags"`
	Virtual               bool                    `json:"virtual"`
	BuyoutPort            bool                    `json:"buyoutPort"`
	Locked                bool                    `json:"locked"`
	AdminLocked           bool                    `json:"adminLocked"`
	Cancelable            bool                    `json:"cancelable"`
	Resources             MCRResources            `json:"resources"`
	LocationDetails       *ProductLocationDetails `json:"locationDetail"`
}

MCR represents a Megaport Cloud Router in the Megaport MCR API.

type MCROrder

type MCROrder struct {
	LocationID int            `json:"locationId"`
	Name       string         `json:"productName"`
	Term       int            `json:"term"`
	Type       string         `json:"productType"`
	PortSpeed  int            `json:"portSpeed"`
	CostCentre string         `json:"costCentre"`
	Config     MCROrderConfig `json:"config"`
}

MCROrder represents a request to buy an MCR from the Megaport Products API.

type MCROrderConfig

type MCROrderConfig struct {
	ASN           int    `json:"mcrAsn,omitempty"`
	DiversityZone string `json:"diversityZone,omitempty"`
}

MCROrderConfig represents the configuration for an MCR order.

type MCROrderConfirmation

type MCROrderConfirmation struct {
	TechnicalServiceUID string `json:"technicalServiceUid"`
}

MCROrderConfirmation represents a response from the Megaport Products API after ordering an MCR.

type MCROrderResponse

type MCROrderResponse struct {
	Message string                  `json:"message"`
	Terms   string                  `json:"terms"`
	Data    []*MCROrderConfirmation `json:"data"`
}

MCROrdersResponse represents a response from the Megaport Products API after ordering an MCR.

type MCRPrefixFilterList

type MCRPrefixFilterList struct {
	Description   string                `json:"description"`
	AddressFamily string                `json:"addressFamily"`
	Entries       []*MCRPrefixListEntry `json:"entries"`
}

MCRPrefixFilterList represents a prefix filter list associated with an MCR.

type MCRPrefixFilterListResponse

type MCRPrefixFilterListResponse struct {
	Message string              `json:"message"`
	Terms   string              `json:"terms"`
	Data    []*PrefixFilterList `json:"data"`
}

MCRPrefixFilterListResponse represents a response from the Megaport MCR API after querying an MCR's prefix filter list.

type MCRPrefixListEntry

type MCRPrefixListEntry struct {
	Action string `json:"action"`
	Prefix string `json:"prefix"`
	Ge     int    `json:"ge,omitempty"`
	Le     int    `json:"le,omitempty"`
}

MCRPrefixListEntry represents an entry in a prefix filter list.

type MCRResources

type MCRResources struct {
	Interface     PortInterface    `json:"interface"`
	VirtualRouter MCRVirtualRouter `json:"virtual_router"`
}

MCRResources represents the resources associated with an MCR.

type MCRResponse

type MCRResponse struct {
	Message string `json:"message"`
	Terms   string `json:"terms"`
	Data    *MCR   `json:"data"`
}

MCRResponse represents a response from the Megaport MCR API after querying an MCR.

type MCRService

type MCRService interface {
	// BuyMCR buys an MCR from the Megaport MCR API.
	BuyMCR(ctx context.Context, req *BuyMCRRequest) (*BuyMCRResponse, error)
	// GetMCR gets details about a single MCR from the Megaport MCR API.
	GetMCR(ctx context.Context, mcrId string) (*MCR, error)
	// CreatePrefixFilterList creates a Prefix Filter List on an MCR from the Megaport MCR API.
	CreatePrefixFilterList(ctx context.Context, req *CreateMCRPrefixFilterListRequest) (*CreateMCRPrefixFilterListResponse, error)
	// GetMCRPrefixFilterLists returns prefix filter lists for the specified MCR2 from the Megaport MCR API.
	GetMCRPrefixFilterLists(ctx context.Context, mcrId string) ([]*PrefixFilterList, error)
	// ModifyMCR modifies an MCR in the Megaport MCR API.
	ModifyMCR(ctx context.Context, req *ModifyMCRRequest) (*ModifyMCRResponse, error)
	// DeleteMCR deletes an MCR in the Megaport MCR API.
	DeleteMCR(ctx context.Context, req *DeleteMCRRequest) (*DeleteMCRResponse, error)
	// RestoreMCR restores a deleted MCR in the Megaport MCR API.
	RestoreMCR(ctx context.Context, mcrId string) (*RestoreMCRResponse, error)
}

MCRService is an interface for interfacing with the MCR endpoints of the Megaport API.

type MCRServiceOp

type MCRServiceOp struct {
	Client *Client
}

MCRServiceOp handles communication with MCR methods of the Megaport API.

func NewMCRService

func NewMCRService(c *Client) *MCRServiceOp

NewMCRService creates a new instance of the MCR Service.

func (*MCRServiceOp) BuyMCR

func (svc *MCRServiceOp) BuyMCR(ctx context.Context, req *BuyMCRRequest) (*BuyMCRResponse, error)

BuyMCR purchases an MCR from the Megaport MCR API.

func (*MCRServiceOp) CreatePrefixFilterList

CreatePrefixFilterList creates a Prefix Filter List on an MCR from the Megaport MCR API.

func (*MCRServiceOp) DeleteMCR

func (svc *MCRServiceOp) DeleteMCR(ctx context.Context, req *DeleteMCRRequest) (*DeleteMCRResponse, error)

DeleteMCR deletes an MCR in the Megaport MCR API.

func (*MCRServiceOp) GetMCR

func (svc *MCRServiceOp) GetMCR(ctx context.Context, mcrId string) (*MCR, error)

GetMCR returns the details of a single MCR in the Megaport MCR API.

func (*MCRServiceOp) GetMCRPrefixFilterLists

func (svc *MCRServiceOp) GetMCRPrefixFilterLists(ctx context.Context, mcrId string) ([]*PrefixFilterList, error)

GetMCRPrefixFilterLists returns prefix filter lists for the specified MCR2 from the Megaport MCR API.

func (*MCRServiceOp) ModifyMCR

func (svc *MCRServiceOp) ModifyMCR(ctx context.Context, req *ModifyMCRRequest) (*ModifyMCRResponse, error)

ModifyMCR modifies an MCR in the Megaport MCR API.

func (*MCRServiceOp) RestoreMCR

func (svc *MCRServiceOp) RestoreMCR(ctx context.Context, mcrId string) (*RestoreMCRResponse, error)

Restore restores a deleted MCR in the Megaport MCR API.

type MCRVirtualRouter

type MCRVirtualRouter struct {
	ID           int    `json:"id"`
	ASN          int    `json:"mcrAsn"`
	Name         string `json:"name"`
	ResourceName string `json:"resource_name"`
	ResourceType string `json:"resource_type"`
	Speed        int    `json:"speed"`
}

MCRVirtualRouter represents the virtual router associated with an MCR.

type MVE

type MVE struct {
	ID                    int                     `json:"productId"`
	UID                   string                  `json:"productUid"`
	Name                  string                  `json:"productName"`
	Type                  string                  `json:"productType"`
	ProvisioningStatus    string                  `json:"provisioningStatus"`
	CreateDate            *Time                   `json:"createDate"`
	CreatedBy             string                  `json:"createdBy"`
	TerminateDate         *Time                   `json:"terminateDate"`
	LiveDate              *Time                   `json:"liveDate"`
	Market                string                  `json:"market"`
	LocationID            int                     `json:"locationId"`
	UsageAlgorithm        string                  `json:"usageAlgorithm"`
	MarketplaceVisibility bool                    `json:"marketplaceVisibility"`
	VXCPermitted          bool                    `json:"vxcpermitted"`
	VXCAutoApproval       bool                    `json:"vxcAutoApproval"`
	SecondaryName         string                  `json:"secondaryName"`
	CompanyUID            string                  `json:"companyUid"`
	CompanyName           string                  `json:"companyName"`
	ContractStartDate     *Time                   `json:"contractStartDate"`
	ContractEndDate       *Time                   `json:"contractEndDate"`
	ContractTermMonths    int                     `json:"contractTermMonths"`
	AttributeTags         map[string]string       `json:"attributeTags"`
	Virtual               bool                    `json:"virtual"`
	BuyoutPort            bool                    `json:"buyoutPort"`
	Locked                bool                    `json:"locked"`
	AdminLocked           bool                    `json:"adminLocked"`
	Cancelable            bool                    `json:"cancelable"`
	Resources             *MVEResources           `json:"resources"`
	Vendor                string                  `json:"vendor"`
	Size                  string                  `json:"mveSize"`
	NetworkInterfaces     []*MVENetworkInterface  `json:"vnics"`
	LocationDetails       *ProductLocationDetails `json:"locationDetail"`
}

MVE represents a Megaport Virtual Edge from the Megaport MVE API.

type MVEInstanceSize

type MVEInstanceSize string

InstanceSize encodes the available MVE instance sizes.

const (
	MVE_SMALL  MVEInstanceSize = "SMALL"
	MVE_MEDIUM MVEInstanceSize = "MEDIUM"
	MVE_LARGE  MVEInstanceSize = "LARGE"
	MVE_XLARGE MVEInstanceSize = "X_LARGE_12"
)

MVE instance sizes.

type MVENetworkInterface

type MVENetworkInterface struct {
	Description string `json:"description"`
	VLAN        int    `json:"vlan"`
}

MVENetworkInterface represents a vNIC.

type MVEOrderConfig

type MVEOrderConfig struct {
	LocationID        int                   `json:"locationId"`
	Name              string                `json:"productName"`
	Term              int                   `json:"term"`
	ProductType       string                `json:"productType"`
	DiversityZone     string                `json:"diversityZone"`
	NetworkInterfaces []MVENetworkInterface `json:"vnics"`
	VendorConfig      VendorConfig          `json:"vendorConfig"`
}

MVEOrderConfig represents a request to buy an MVE from the Megaport Products API.

type MVEOrderConfirmation

type MVEOrderConfirmation struct {
	TechnicalServiceUID string `json:"technicalServiceUid"`
}

MVEOrderConfirmation represents the response to an MVE order request.

type MVEOrderResponse

type MVEOrderResponse struct {
	Message string                  `json:"message"`
	Terms   string                  `json:"terms"`
	Data    []*MVEOrderConfirmation `json:"data"`
}

MVEOrderResponse represents the response to an MVE order request.

type MVEResources

type MVEResources struct {
	Interface       *PortInterface       `json:"interface"`
	VirtualMachines []*MVEVirtualMachine `json:"virtual_machine"`
}

MVEResources represents the resources associated with an MVE.

type MVEResponse

type MVEResponse struct {
	Message string `json:"message"`
	Terms   string `json:"terms"`
	Data    *MVE   `json:"data"`
}

MVEResponse represents the response to an MVE request.

type MVEService

type MVEService interface {
	// BuyMVE buys an MVE from the Megaport MVE API.
	BuyMVE(ctx context.Context, req *BuyMVERequest) (*BuyMVEResponse, error)
	// GetMVE gets details about a single MVE from the Megaport MVE API.
	GetMVE(ctx context.Context, mveId string) (*MVE, error)
	// ModifyMVE modifies an MVE in the Megaport MVE API.
	ModifyMVE(ctx context.Context, req *ModifyMVERequest) (*ModifyMVEResponse, error)
	// DeleteMVE deletes an MVE in the Megaport MVE API.
	DeleteMVE(ctx context.Context, req *DeleteMVERequest) (*DeleteMVEResponse, error)
}

MVEService is an interface for interfacing with the MVE endpoints of the Megaport API.

type MVEServiceOp

type MVEServiceOp struct {
	Client *Client
}

MVEServiceOp handles communication with MVE methods of the Megaport API.

func NewMVEService

func NewMVEService(c *Client) *MVEServiceOp

NewMVEService creates a new instance of the MVE Service.

func (*MVEServiceOp) BuyMVE

func (svc *MVEServiceOp) BuyMVE(ctx context.Context, req *BuyMVERequest) (*BuyMVEResponse, error)

BuyMVE buys an MVE from the Megaport MVE API.

func (*MVEServiceOp) DeleteMVE

func (svc *MVEServiceOp) DeleteMVE(ctx context.Context, req *DeleteMVERequest) (*DeleteMVEResponse, error)

DeleteMVE deletes an MVE in the Megaport MVE API.

func (*MVEServiceOp) GetMVE

func (svc *MVEServiceOp) GetMVE(ctx context.Context, mveId string) (*MVE, error)

GetMVE retrieves a single MVE from the Megaport MVE API.

func (*MVEServiceOp) ModifyMVE

func (svc *MVEServiceOp) ModifyMVE(ctx context.Context, req *ModifyMVERequest) (*ModifyMVEResponse, error)

ModifyMVE modifies an MVE in the Megaport MVE API.

type MVEVirtualMachine

type MVEVirtualMachine struct {
	ID           int                     `json:"id"`
	CpuCount     int                     `json:"cpu_count"`
	Image        *MVEVirtualMachineImage `json:"image"`
	ResourceType string                  `json:"resource_type"`
	Up           bool                    `json:"up"`
	Vnics        []*MVENetworkInterface  `json:"vnics"`
}

MVEVirtualMachine represents a virtual machine associated with an MVE.

type MVEVirtualMachineImage

type MVEVirtualMachineImage struct {
	ID      int    `json:"id"`
	Vendor  string `json:"vendor"`
	Product string `json:"product"`
	Version string `json:"version"`
}

MVVEVirtualMachineImage represents the image associated with an MVE virtual machine.

type ManageProductLockRequest

type ManageProductLockRequest struct {
	ProductID  string
	ShouldLock bool
}

ManageProductLockRequest represents a request to lock or unlock a product in the Megaport Products API.

type ManageProductLockResponse

type ManageProductLockResponse struct{}

ManageProductLockResponse represents a response from the Megaport Products API after locking or unlocking a product.

type Market

type Market struct {
	Currency               string `json:"currencyEnum"`
	Language               string `json:"language"`
	CompanyLegalIdentifier string `json:"companyLegalIdentifier"`
	CompanyLegalName       string `json:"companyLegalName"`
	BillingContactName     string `json:"billingContactName"`
	BillingContactPhone    string `json:"billingContactPhone"`
	BillingContactEmail    string `json:"billingContactEmail"`
	AddressLine1           string `json:"address1"`
	AddressLine2           string `json:"address2"`
	City                   string `json:"city"`
	State                  string `json:"state"`
	Postcode               string `json:"postcode"`
	Country                string `json:"country"`
	PONumber               string `json:"yourPoNumber"`
	TaxNumber              string `json:"taxNumber"`
	FirstPartyID           int    `json:"firstPartyId"`
}

Market represents a market in the Megaport API.

type MerakiConfig

type MerakiConfig struct {
	VendorConfig
	Vendor      string `json:"vendor"`
	ImageID     int    `json:"imageId"`
	ProductSize string `json:"productSize"`
	MVELabel    string `json:"mveLabel"`
	Token       string `json:"token"`
}

MerakiConfig represents the configuration for a Meraki MVE.

type ModifyMCRRequest

type ModifyMCRRequest struct {
	MCRID                 string
	Name                  string
	CostCentre            string
	MarketplaceVisibility *bool

	WaitForUpdate bool          // Wait until the MCR updates before returning
	WaitForTime   time.Duration // How long to wait for the MCR to update if WaitForUpdate is true (default is 5 minutes)
}

ModifyMCRRequest represents a request to modify an MCR

type ModifyMCRResponse

type ModifyMCRResponse struct {
	IsUpdated bool
}

ModifyMCRResponse represents a response from modifying an MCR

type ModifyMVERequest

type ModifyMVERequest struct {
	MVEID                 string
	Name                  string
	MarketplaceVisibility *bool

	WaitForUpdate bool          // Wait until the MCVEupdates before returning
	WaitForTime   time.Duration // How long to wait for the MVE to update if WaitForUpdate is true (default is 5 minutes)
}

ModifyMVERequest represents a request to modify an MVE

type ModifyMVEResponse

type ModifyMVEResponse struct {
	MVEUpdated bool
}

ModifyMVEResponse represents a response from modifying an MVE

type ModifyPortRequest

type ModifyPortRequest struct {
	PortID                string
	Name                  string
	MarketplaceVisibility *bool
	CostCentre            string

	WaitForUpdate bool          // Wait until the Port updates before returning
	WaitForTime   time.Duration // How long to wait for the Port to update if WaitForUpdate is true (default is 5 minutes)
}

ModifyPortRequest represents a request to modify a port.

type ModifyPortResponse

type ModifyPortResponse struct {
	IsUpdated bool
}

ModifyPortResponse represents a response from modifying a port.

type ModifyProductRequest

type ModifyProductRequest struct {
	ProductID             string
	ProductType           string
	Name                  string `json:"name,omitempty"`
	CostCentre            string `json:"costCentre,omitempty"`
	MarketplaceVisibility *bool  `json:"marketplaceVisibility,omitempty"`
}

ModifyProductRequest represents a request to modify a product in the Megaport Products API.

type ModifyProductResponse

type ModifyProductResponse struct {
	IsUpdated bool
}

ModifyProductResponse represents a response from the Megaport Products API after modifying a product.

type PaloAltoConfig

type PaloAltoConfig struct {
	VendorConfig
	Vendor            string `json:"vendor"`
	ImageID           int    `json:"imageId"`
	ProductSize       string `json:"productSize"`
	MVELabel          string `json:"mveLabel"`
	AdminSSHPublicKey string `json:"adminSshPublicKey"`
	AdminPasswordHash string `json:"adminPasswordHash"`
	LicenseData       string `json:"licenseData"`
}

PaloAltoConfig represents the configuration for a Palo Alto MVE.

type ParsedProductsResponse

type ParsedProductsResponse struct {
	Message string        `json:"message"`
	Terms   string        `json:"terms"`
	Data    []interface{} `json:"data"`
}

ParsedProductsResponse represents a response from the Megaport Products API prior to parsing the response.

type PartnerConfigInterface

type PartnerConfigInterface struct {
	IpAddresses    []string              `json:"ipAddresses,omitempty"`
	IpRoutes       []IpRoute             `json:"ipRoutes,omitempty"`
	NatIpAddresses []string              `json:"natIpAddresses,omitempty"`
	Bfd            BfdConfig             `json:"bfd,omitempty"`
	BgpConnections []BgpConnectionConfig `json:"bgpConnections,omitempty"`
}

PartnerConfigInterface represents the configuration of a partner interface.

type PartnerLookup

type PartnerLookup struct {
	Bandwidth    int                 `json:"bandwidth"`
	Bandwidths   []int               `json:"bandwidths"`
	Megaports    []PartnerLookupItem `json:"megaports"`
	Peers        []Peer              `json:"peers"`
	ResourceType string              `json:"resource_type"`
	ServiceKey   string              `json:"service_key"`
	VLAN         int                 `json:"vlan"`
}

PartnerLookup represents the response from the Partner Lookup API.

type PartnerLookupItem

type PartnerLookupItem struct {
	ID          int    `json:"port"`
	Type        string `json:"type"`
	VXC         int    `json:"vxc"`
	ProductID   int    `json:"productId"`
	ProductUID  string `json:"productUid"`
	Name        string `json:"name"`
	ServiceID   int    `json:"nServiceId"`
	Description string `json:"description"`
	CompanyID   int    `json:"companyId"`
	CompanyName string `json:"companyName"`
	PortSpeed   int    `json:"portSpeed"`
	LocationID  int    `json:"locationId"`
	State       string `json:"state"`
	Country     string `json:"country"`
}

PartnerLookupItem represents an item in the Partner Lookup response.

type PartnerLookupResponse

type PartnerLookupResponse struct {
	Message string        `json:"message"`
	Data    PartnerLookup `json:"data"`
	Terms   string        `json:"terms"`
}

PartnerLookupResponse represents a response from the Megaport API after looking up a Partner Megaport.

type PartnerMegaport

type PartnerMegaport struct {
	ConnectType   string `json:"connectType"`
	ProductUID    string `json:"productUid"`
	ProductName   string `json:"title"`
	CompanyUID    string `json:"companyUid"`
	CompanyName   string `json:"companyName"`
	DiversityZone string `json:"diversityZone"`
	LocationId    int    `json:"locationId"`
	Speed         int    `json:"speed"`
	Rank          int    `json:"rank"`
	VXCPermitted  bool   `json:"vxcPermitted"`
}

PartnerMegaport represents a Partner Megaport in the Megaport API.

type PartnerMegaportResponse

type PartnerMegaportResponse struct {
	Message string             `json:"message"`
	Terms   string             `json:"terms"`
	Data    []*PartnerMegaport `json:"data"`
}

PartnerMegaportResponse represents a response from the Megaport API after querying a Partner Megaport.

type PartnerOrder

type PartnerOrder struct {
	PortID         string                 `json:"productUid"`
	AssociatedVXCs []PartnerOrderContents `json:"associatedVxcs"`
}

PartnerOrder represents the request to order a partner VXC from the Megaport Products API.

type PartnerOrderAzurePeeringConfig

type PartnerOrderAzurePeeringConfig struct {
	Type            string `json:"type"`
	PeerASN         string `json:"peer_asn"`
	PrimarySubnet   string `json:"primary_subnet"`
	SecondarySubnet string `json:"secondary_subnet"`
	Prefixes        string `json:"prefixes,omitempty"`
	SharedKey       string `json:"shared_key,omitempty"`
	VLAN            int    `json:"vlan"`
}

PartnerOrderAzurePeeringConfig represents the configuration of an Azure peering partner.

type PartnerOrderContents

type PartnerOrderContents struct {
	Name      string                        `json:"productName"`
	RateLimit int                           `json:"rateLimit"`
	AEnd      VXCOrderEndpointConfiguration `json:"aEnd"`
	BEnd      VXCOrderEndpointConfiguration `json:"bEnd"`
}

PartnerOrderContents represents the configuration of a partner VXC to be ordered from the Megaport Products API.

type PartnerService

type PartnerService interface {
	// ListPartnerMegaports gets a list of all partner megaports in the Megaport Marketplace via the Megaport API.
	ListPartnerMegaports(ctx context.Context) ([]*PartnerMegaport, error)
	// FilterPartnerMegaportByProductName filters a list of partner megaports by product name in the Megaport API.
	FilterPartnerMegaportByProductName(ctx context.Context, partners []*PartnerMegaport, productName string, exactMatch bool) ([]*PartnerMegaport, error)
	// FilterPartnerMegaportByConnectType filters a list of partner megaports by connect type in the Megaport API.
	FilterPartnerMegaportByConnectType(ctx context.Context, partners []*PartnerMegaport, connectType string, exactMatch bool) ([]*PartnerMegaport, error)
	// FilterPartnerMegaportByCompanyName filters a list of partner megaports by company name in the Megaport API.
	FilterPartnerMegaportByCompanyName(ctx context.Context, partners []*PartnerMegaport, companyName string, exactMatch bool) ([]*PartnerMegaport, error)
	// FilterPartnerMegaportByLocationId filters a list of partner megaports by location ID in the Megaport API.
	FilterPartnerMegaportByLocationId(ctx context.Context, partners []*PartnerMegaport, locationId int) ([]*PartnerMegaport, error)
	// FilterPartnerMegaportByDiversityZone filters a list of partner megaports by diversity zone in the Megaport API.
	FilterPartnerMegaportByDiversityZone(ctx context.Context, partners []*PartnerMegaport, diversityZone string, exactMatch bool) ([]*PartnerMegaport, error)
}

PartnerService is an interface for interfacing with the Partner Port endpoints of the Megaport API.

type PartnerServiceOp

type PartnerServiceOp struct {
	Client *Client
}

PartnerServiceOp handles communication with Partner Port methods of the Megaport API.

func NewPartnerService

func NewPartnerService(c *Client) *PartnerServiceOp

NewPartnerService creates a new instance of the PartnerService.

func (*PartnerServiceOp) FilterPartnerMegaportByCompanyName

func (svc *PartnerServiceOp) FilterPartnerMegaportByCompanyName(ctx context.Context, partners []*PartnerMegaport, companyName string, exactMatch bool) ([]*PartnerMegaport, error)

FilterPartnerMegaportByCompanyName filters a list of partner megaports by company name in the Megaport API.

func (*PartnerServiceOp) FilterPartnerMegaportByConnectType

func (svc *PartnerServiceOp) FilterPartnerMegaportByConnectType(ctx context.Context, partners []*PartnerMegaport, connectType string, exactMatch bool) ([]*PartnerMegaport, error)

FilterPartnerMegaportByConnectType filters a list of partner megaports by connect type in the Megaport API.

func (*PartnerServiceOp) FilterPartnerMegaportByDiversityZone

func (svc *PartnerServiceOp) FilterPartnerMegaportByDiversityZone(ctx context.Context, partners []*PartnerMegaport, diversityZone string, exactMatch bool) ([]*PartnerMegaport, error)

FilterPartnerMegaportByDiversityZone filters a list of partner megaports by diversity zone in the Megaport API.

func (*PartnerServiceOp) FilterPartnerMegaportByLocationId

func (svc *PartnerServiceOp) FilterPartnerMegaportByLocationId(ctx context.Context, partners []*PartnerMegaport, locationId int) ([]*PartnerMegaport, error)

FilterPartnerMegaportByLocationId filters a list of partner megaports by location ID in the Megaport API.

func (*PartnerServiceOp) FilterPartnerMegaportByProductName

func (svc *PartnerServiceOp) FilterPartnerMegaportByProductName(ctx context.Context, partners []*PartnerMegaport, productName string, exactMatch bool) ([]*PartnerMegaport, error)

FilterPartnerMegaportByProductName filters a list of partner megaports by product name in the Megaport API.

func (*PartnerServiceOp) ListPartnerMegaports

func (svc *PartnerServiceOp) ListPartnerMegaports(ctx context.Context) ([]*PartnerMegaport, error)

ListPartnerMegaports gets a list of all partner megaports in the Megaport Marketplace via the Megaport API.

type Peer

type Peer struct {
	PeerASN         int    `json:"peer_asn"`
	Prefixes        string `json:"prefixes"`
	PrimarySubnet   string `json:"primary_subnet"`
	SecondarySubnet string `json:"secondary_subnet"`
	Type            string `json:"type"`
	VLAN            int    `json:"vlan"`
	SharedKey       string `json:"shared_key"`
}

Peer represents a VXC Peer.

type Port

type Port struct {
	ID                    int                     `json:"productId"`
	UID                   string                  `json:"productUid"`
	Name                  string                  `json:"productName"`
	Type                  string                  `json:"productType"`
	ProvisioningStatus    string                  `json:"provisioningStatus"`
	CreateDate            *Time                   `json:"createDate"`
	CreatedBy             string                  `json:"createdBy"`
	PortSpeed             int                     `json:"portSpeed"`
	TerminateDate         *Time                   `json:"terminateDate"`
	LiveDate              *Time                   `json:"liveDate"`
	Market                string                  `json:"market"`
	LocationID            int                     `json:"locationId"`
	UsageAlgorithm        string                  `json:"usageAlgorithm"`
	MarketplaceVisibility bool                    `json:"marketplaceVisibility"`
	VXCPermitted          bool                    `json:"vxcpermitted"`
	VXCAutoApproval       bool                    `json:"vxcAutoApproval"`
	SecondaryName         string                  `json:"secondaryName"`
	LAGPrimary            bool                    `json:"lagPrimary"`
	LAGID                 int                     `json:"lagId"`
	AggregationID         int                     `json:"aggregationId"`
	CompanyUID            string                  `json:"companyUid"`
	CompanyName           string                  `json:"companyName"`
	CostCentre            string                  `json:"costCentre"`
	ContractStartDate     *Time                   `json:"contractStartDate"`
	ContractEndDate       *Time                   `json:"contractEndDate"`
	ContractTermMonths    int                     `json:"contractTermMonths"`
	AttributeTags         PortAttributeTags       `json:"attributeTags"`
	Virtual               bool                    `json:"virtual"`
	BuyoutPort            bool                    `json:"buyoutPort"`
	Locked                bool                    `json:"locked"`
	AdminLocked           bool                    `json:"adminLocked"`
	Cancelable            bool                    `json:"cancelable"`
	DiversityZone         string                  `json:"diversityZone"`
	VXCResources          PortResources           `json:"resources"`
	LocationDetails       *ProductLocationDetails `json:"locationDetail"`
}

Port represents a Megaport Port in the Megaport Port API.

type PortAttributeTags

type PortAttributeTags struct {
	TerminatedServiceDetails PortTerminatedServiceDetails `json:"terminatedServiceDetails"`
}

PortAttributes represents attributes associated with a Megaport Port.

type PortInterface

type PortInterface struct {
	Demarcation  string `json:"demarcation"`
	Description  string `json:"description"`
	ID           int    `json:"id"`
	LOATemplate  string `json:"loa_template"`
	Media        string `json:"media"`
	Name         string `json:"name"`
	PortSpeed    int    `json:"port_speed"`
	ResourceName string `json:"resource_name"`
	ResourceType string `json:"resource_type"`
	Up           int    `json:"up"`
}

PortInterface represents the interface associated with a Megaport Port.

type PortOrder

type PortOrder struct {
	Name                  string `json:"productName"`
	Term                  int    `json:"term"`
	ProductType           string `json:"productType"`
	PortSpeed             int    `json:"portSpeed"`
	LocationID            int    `json:"locationId"`
	CreateDate            int64  `json:"createDate"`
	Virtual               bool   `json:"virtual"`
	Market                string `json:"market"`
	CostCentre            string `json:"costCentre,omitempty"`
	LagPortCount          int    `json:"lagPortCount,omitempty"`
	MarketplaceVisibility bool   `json:"marketplaceVisibility"`
	DiversityZone         string `json:"diversityZone"`
}

PortOrder represents a Megaport Port Order from the Megaport Products API.

type PortOrderConfirmation

type PortOrderConfirmation struct {
	TechnicalServiceUID string `json:"technicalServiceUid"`
}

PortOrderConfirmation represents a response from the Megaport Products API after ordering a port.

type PortOrderResponse

type PortOrderResponse struct {
	Message string                  `json:"message"`
	Terms   string                  `json:"terms"`
	Data    []PortOrderConfirmation `json:"data"`
}

PortOrderResponse represents a response from the Megaport Products API after ordering a port.

type PortResources

type PortResources struct {
	Interface PortInterface `json:"interface"`
}

PortResources represents the resources associated with a Megaport Port.

type PortResourcesInterface

type PortResourcesInterface struct {
	Demarcation  string `json:"demarcation"`
	Description  string `json:"description"`
	ID           int    `json:"id"`
	LOATemplate  string `json:"loa_template"`
	Media        string `json:"media"`
	Name         string `json:"name"`
	PortSpeed    int    `json:"port_speed"`
	ResourceName string `json:"resource_name"`
	ResourceType string `json:"resource_type"`
	Up           int    `json:"up"`
}

PortResourcesInterface represents the resources interface associated with a Megaport Port.

type PortResponse

type PortResponse struct {
	Message string `json:"message"`
	Terms   string `json:"terms"`
	Data    Port   `json:"data"`
}

PortResponse represents a response from the Megaport Port API after querying a port.

type PortService

type PortService interface {
	// BuyPort buys a port from the Megaport Port API.
	BuyPort(ctx context.Context, req *BuyPortRequest) (*BuyPortResponse, error)
	// ListPorts lists all ports in the Megaport Port API.
	ListPorts(ctx context.Context) ([]*Port, error)
	// GetPort gets a single port in the Megaport Port API.
	GetPort(ctx context.Context, portId string) (*Port, error)
	// ModifyPort modifies a port in the Megaport Port API.
	ModifyPort(ctx context.Context, req *ModifyPortRequest) (*ModifyPortResponse, error)
	// DeletePort deletes a port in the Megaport Port API.
	DeletePort(ctx context.Context, req *DeletePortRequest) (*DeletePortResponse, error)
	// RestorePort restores a port in the Megaport Port API.
	RestorePort(ctx context.Context, portId string) (*RestorePortResponse, error)
	// LockPort locks a port in the Megaport Port API.
	LockPort(ctx context.Context, portId string) (*LockPortResponse, error)
	// UnlockPort unlocks a port in the Megaport Port API.
	UnlockPort(ctx context.Context, portId string) (*UnlockPortResponse, error)
}

PortService is an interface for interfacing with the Port endpoints of the Megaport API.

type PortServiceOp

type PortServiceOp struct {
	Client *Client
}

PortServiceOp handles communication with Port methods of the Megaport API.

func NewPortService

func NewPortService(c *Client) *PortServiceOp

NewPortService creates a new instance of the Port Service.

func (*PortServiceOp) BuyPort

func (svc *PortServiceOp) BuyPort(ctx context.Context, req *BuyPortRequest) (*BuyPortResponse, error)

BuyPort buys a port from the Megaport Port API.

func (*PortServiceOp) DeletePort

func (svc *PortServiceOp) DeletePort(ctx context.Context, req *DeletePortRequest) (*DeletePortResponse, error)

DeletePort deletes a port in the Megaport Port API.

func (*PortServiceOp) GetPort

func (svc *PortServiceOp) GetPort(ctx context.Context, portId string) (*Port, error)

GetPort gets a single port in the Megaport Port API.

func (*PortServiceOp) ListPorts

func (svc *PortServiceOp) ListPorts(ctx context.Context) ([]*Port, error)

ListPorts lists all ports in the Megaport Port API.

func (*PortServiceOp) LockPort

func (svc *PortServiceOp) LockPort(ctx context.Context, portId string) (*LockPortResponse, error)

LockPort locks a port in the Megaport Port API.

func (*PortServiceOp) ModifyPort

func (svc *PortServiceOp) ModifyPort(ctx context.Context, req *ModifyPortRequest) (*ModifyPortResponse, error)

ModifyPort modifies a port in the Megaport Port API.

func (*PortServiceOp) RestorePort

func (svc *PortServiceOp) RestorePort(ctx context.Context, portId string) (*RestorePortResponse, error)

RestorePort restores a port in the Megaport Port API.

func (*PortServiceOp) UnlockPort

func (svc *PortServiceOp) UnlockPort(ctx context.Context, portId string) (*UnlockPortResponse, error)

UnlockPort unlocks a port in the Megaport Port API.

type PortTerminatedServiceDetails

type PortTerminatedServiceDetails struct {
	Location  PortTerminatedServiceDetailsLocation  `json:"location"`
	Interface PortTerminatedServiceDetailsInterface `json:"interface"`
	Device    string                                `json:"device"`
}

PortTerminatedServiceDetails represents terminated service details associated with a Megaport Port.

type PortTerminatedServiceDetailsInterface

type PortTerminatedServiceDetailsInterface struct {
	ResourceType string `json:"resource_type"`
	Demarcation  string `json:"demarcation"`
	LOATemplate  string `json:"loa_template"`
	Media        string `json:"media"`
	PortSpeed    int    `json:"port_speed"`
	ResourceName string `json:"resource_name"`
	Up           int    `json:"up"`
	Shutdown     bool   `json:"shutdown"`
}

PortTerminatedServiceDetailsInterface represents the interface of a terminated service associated with a Megaport Port.

type PortTerminatedServiceDetailsLocation

type PortTerminatedServiceDetailsLocation struct {
	ID       int    `json:"id"`
	Name     string `json:"name"`
	SiteCode string `json:"site_code"`
}

PortTerminatedServiceDetailsLocation represents the location of a terminated service associated with a Megaport Port.

type PrefixFilterList

type PrefixFilterList struct {
	Id            int    `json:"id"`
	Description   string `json:"description"`
	AddressFamily string `json:"addressFamily"`
}

PrefixFilterList represents a prefix filter list associated with an MCR.

type ProductLocationDetails added in v1.0.2

type ProductLocationDetails struct {
	Name    string `json:"name"`
	City    string `json:"city"`
	Metro   string `json:"metro"`
	Country string `json:"country"`
}

ProductLocationDetails represents the location details of a product.

type ProductService

type ProductService interface {
	// ExecuteOrder is responsible for executing an order for a product in the Megaport Products API.
	ExecuteOrder(ctx context.Context, requestBody interface{}) (*[]byte, error)
	// ModifyProduct modifies a product in the Megaport Products API. The available fields to modify are Name, Cost Centre, and Marketplace Visibility.
	ModifyProduct(ctx context.Context, req *ModifyProductRequest) (*ModifyProductResponse, error)
	// DeleteProduct is responsible for either scheduling a product for deletion "CANCEL" or deleting a product immediately "CANCEL_NOW" in the Megaport Products API.
	DeleteProduct(ctx context.Context, req *DeleteProductRequest) (*DeleteProductResponse, error)
	// RestoreProduct is responsible for restoring a product in the Megaport Products API. The product must be in a "CANCELLED" state to be restored.
	RestoreProduct(ctx context.Context, productId string) (*RestoreProductResponse, error)
	// ManageProductLock is responsible for locking or unlocking a product in the Megaport Products API.
	ManageProductLock(ctx context.Context, req *ManageProductLockRequest) (*ManageProductLockResponse, error)
}

ProductService is an interface for interfacing with the Product endpoints of the Megaport API.

type ProductServiceOp

type ProductServiceOp struct {
	Client *Client
}

ProductServiceOp handles communication with Product methods of the Megaport API.

func NewProductService

func NewProductService(c *Client) *ProductServiceOp

NewProductService creates a new instance of the Product Service.

func (*ProductServiceOp) DeleteProduct

DeleteProduct is responsible for either scheduling a product for deletion "CANCEL" or deleting a product immediately "CANCEL_NOW" in the Megaport Products API.

func (*ProductServiceOp) ExecuteOrder

func (svc *ProductServiceOp) ExecuteOrder(ctx context.Context, requestBody interface{}) (*[]byte, error)

ExecuteOrder is responsible for executing an order for a product in the Megaport Products API.

func (*ProductServiceOp) ManageProductLock

ManageProductLock is responsible for locking or unlocking a product in the Megaport Products API.

func (*ProductServiceOp) ModifyProduct

ModifyProduct modifies a product in the Megaport Products API. The available fields to modify are Name, Cost Centre, and Marketplace Visibility.

func (*ProductServiceOp) RestoreProduct

func (svc *ProductServiceOp) RestoreProduct(ctx context.Context, productId string) (*RestoreProductResponse, error)

RestoreProduct is responsible for restoring a product in the Megaport Products API. The product must be in a "CANCELLED" state to be restored.

type RequestCompletionCallback

type RequestCompletionCallback func(*http.Request, *http.Response)

RequestCompletionCallback defines the type of the request callback function

type RestoreMCRResponse

type RestoreMCRResponse struct {
	IsRestored bool
}

RestoreMCRequest represents a request to restore a deleted MCR

type RestorePortRequest

type RestorePortRequest struct {
	PortID string
}

RestorePortRequest represents a request to restore a port.

type RestorePortResponse

type RestorePortResponse struct {
	IsRestored bool
}

RestorePortResponse represents a response from restoring a port.

type RestoreProductRequest

type RestoreProductRequest struct {
	ProductID string
}

RestoreProductRequest represents a request to restore a product in the Megaport Products API.

type RestoreProductResponse

type RestoreProductResponse struct{}

RestoreProductResponse represents a response from the Megaport Products API after restoring a product.

type Time

type Time struct {
	time.Time
}

Time is a custom time type that allows for unmarshalling of Unix timestamps.

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals a Unix timestamp into a Time type.

type UnlockPortRequest

type UnlockPortRequest struct {
	PortID string
}

UnlockPortRequest represents a request to unlock a port.

type UnlockPortResponse

type UnlockPortResponse struct {
	IsUnlocking bool
}

UnlockPortResponse represents a response from unlocking a port.

type UpdateVXCRequest

type UpdateVXCRequest struct {
	AEndVLAN       *int
	BEndVLAN       *int
	AEndProductUID *string
	BEndProductUID *string
	RateLimit      *int
	Name           *string
	CostCentre     *string
	Term           *int
	Shutdown       *bool

	WaitForUpdate bool          // Wait until the VXC updates before returning
	WaitForTime   time.Duration // How long to wait for the VXC to update if WaitForUpdate is true (default is 5 minutes)
}

UpdateVXCRequest represents a request to update a VXC in the Megaport VXC API.

type UpdateVXCResponse

type UpdateVXCResponse struct {
}

UpdateVXCResponse represents a response from updating a VXC in the Megaport VXC API.

type VLLConfig

type VLLConfig struct {
	AEndVLAN      int    `json:"a_vlan"`
	BEndVLAN      int    `json:"b_vlan"`
	Description   string `json:"description"`
	ID            int    `json:"id"`
	Name          string `json:"name"`
	RateLimitMBPS int    `json:"rate_limit_mbps"`
	ResourceName  string `json:"resource_name"`
	ResourceType  string `json:"resource_type"`
	Shutdown      bool   `json:"shutdown"`
}

VLLConfig represents the configuration of a VLL.

type VXC

type VXC struct {
	ID                 int                 `json:"productId"`
	UID                string              `json:"productUid"`
	ServiceID          int                 `json:"nServiceId"`
	Name               string              `json:"productName"`
	Type               string              `json:"productType"`
	RateLimit          int                 `json:"rateLimit"`
	DistanceBand       string              `json:"distanceBand"`
	ProvisioningStatus string              `json:"provisioningStatus"`
	AEndConfiguration  VXCEndConfiguration `json:"aEnd"`
	BEndConfiguration  VXCEndConfiguration `json:"bEnd"`
	SecondaryName      string              `json:"secondaryName"`
	UsageAlgorithm     string              `json:"usageAlgorithm"`
	CreatedBy          string              `json:"createdBy"`
	LiveDate           *Time               `json:"liveDate"`
	CreateDate         *Time               `json:"createDate"`
	Resources          *VXCResources       `json:"resources"`
	VXCApproval        *VXCApproval        `json:"vxcApproval"`
	Shutdown           bool                `json:"shutdown"`
	ContractStartDate  *Time               `json:"contractStartDate"`
	ContractEndDate    *Time               `json:"contractEndDate"`
	ContractTermMonths int                 `json:"contractTermMonths"`
	CompanyUID         string              `json:"companyUid"`
	CompanyName        string              `json:"companyName"`
	CostCentre         string              `json:"costCentre"`
	Locked             bool                `json:"locked"`
	AdminLocked        bool                `json:"adminLocked"`
	AttributeTags      map[string]string   `json:"attributeTags"`
	Cancelable         bool                `json:"cancelable"`
}

VXC represents a Virtual Cross Connect in the Megaport VXC API.

type VXCApproval

type VXCApproval struct {
	Status   string `json:"status"`
	Message  string `json:"message"`
	UID      string `json:"uid"`
	Type     string `json:"type"`
	NewSpeed int    `json:"newSpeed"`
}

VXCApproval represents the approval status of a VXC.

type VXCEndConfiguration

type VXCEndConfiguration struct {
	OwnerUID              string                  `json:"ownerUid"`
	UID                   string                  `json:"productUid"`
	Name                  string                  `json:"productName"`
	LocationID            int                     `json:"locationId"`
	Location              string                  `json:"location"`
	VLAN                  int                     `json:"vlan"`
	InnerVLAN             int                     `json:"innerVlan"`
	NetworkInterfaceIndex int                     `json:"vNicIndex"`
	SecondaryName         string                  `json:"secondaryName"`
	LocationDetails       *ProductLocationDetails `json:"locationDetail"`
}

VXCEndConfiguration represents the configuration of an endpoint of a VXC.

type VXCOrder

type VXCOrder struct {
	AssociatedVXCs []VXCOrderConfiguration `json:"associatedVxcs"`
	PortID         string                  `json:"productUid"`
}

VXCOrder represents the request to order a VXC from the Megaport Products API.

type VXCOrderAEndPartnerConfig

type VXCOrderAEndPartnerConfig struct {
	VXCPartnerConfiguration
	Interfaces []PartnerConfigInterface `json:"interfaces,omitempty"`
}

VXCOrderAEndPartnerConfig represents the configuration of a VXC A-End partner.

type VXCOrderConfiguration

type VXCOrderConfiguration struct {
	Name      string                        `json:"productName"`
	RateLimit int                           `json:"rateLimit"`
	Term      int                           `json:"term"`
	Shutdown  bool                          `json:"shutdown"`
	AEnd      VXCOrderEndpointConfiguration `json:"aEnd"`
	BEnd      VXCOrderEndpointConfiguration `json:"bEnd"`
}

VXCOrderConfiguration represents the configuration of a VXC to be ordered from the Megaport Products API.

type VXCOrderConfirmation

type VXCOrderConfirmation struct {
	TechnicalServiceUID string `json:"vxcJTechnicalServiceUid"`
}

VXCOrderConfirmation represents the confirmation of a VXC order from the Megaport Products API.

type VXCOrderEndpointConfiguration

type VXCOrderEndpointConfiguration struct {
	ProductUID    string                  `json:"productUid,omitempty"`
	VLAN          int                     `json:"vlan,omitempty"`
	PartnerConfig VXCPartnerConfiguration `json:"partnerConfig,omitempty"`
	*VXCOrderMVEConfig
}

VXCOrderEndpointConfiguration represents the configuration of an endpoint of a VXC to be ordered from the Megaport Products API.

type VXCOrderMVEConfig

type VXCOrderMVEConfig struct {
	InnerVLAN             int `json:"innerVlan,omitempty"`
	NetworkInterfaceIndex int `json:"vNicIndex"`
}

VXCOrderMVEConfig represents the configuration of a VXC endpoint for MVE.

type VXCOrderResponse

type VXCOrderResponse struct {
	Message string                 `json:"message"`
	Terms   string                 `json:"terms"`
	Data    []VXCOrderConfirmation `json:"data"`
}

VXCOrderResponse represents the response from the VXC Order API.

type VXCPartnerConfigAWS

type VXCPartnerConfigAWS struct {
	VXCPartnerConfiguration
	ConnectType       string `json:"connectType"`
	Type              string `json:"type"`
	OwnerAccount      string `json:"ownerAccount"`
	ASN               int    `json:"asn,omitempty"`
	AmazonASN         int    `json:"amazonAsn,omitempty"`
	AuthKey           string `json:"authKey,omitempty"`
	Prefixes          string `json:"prefixes,omitempty"`
	CustomerIPAddress string `json:"customerIpAddress,omitempty"`
	AmazonIPAddress   string `json:"amazonIpAddress,omitempty"`
	ConnectionName    string `json:"name,omitempty"`
}

VXCPartnerConfigAWS represents the configuration of a VXC partner for AWS Virtual Interface.

type VXCPartnerConfigAzure

type VXCPartnerConfigAzure struct {
	VXCPartnerConfiguration
	ConnectType string                           `json:"connectType"`
	ServiceKey  string                           `json:"serviceKey"`
	Peers       []PartnerOrderAzurePeeringConfig `json:"peers"`
}

VXCPartnerConfigAzure represents the configuration of a VXC partner for Azure ExpressRoute.

type VXCPartnerConfigGoogle

type VXCPartnerConfigGoogle struct {
	VXCPartnerConfiguration
	ConnectType string `json:"connectType"`
	PairingKey  string `json:"pairingKey"`
}

VXCPartnerConfigGoogle represents the configuration of a VXC partner for Google Cloud Interconnect.

type VXCPartnerConfigOracle

type VXCPartnerConfigOracle struct {
	VXCPartnerConfiguration
	ConnectType      string `json:"connectType"`
	VirtualCircuitId string `json:"virtualCircuitId"`
}

VXCPartnerConfigOracle represents the configuration of a VXC partner for Oracle Cloud Infrastructure FastConnect.

type VXCPartnerConfiguration

type VXCPartnerConfiguration interface {
	IsParnerConfiguration()
}

VXCPartnerConfiguration represents the configuration of a VXC partner.

type VXCResources

type VXCResources struct {
	Interface     []*PortInterface `json:"interface"`
	VirtualRouter *VirtualRouter   `json:"virtual_router"`
	CSPConnection *CSPConnection   `json:"csp_connection"`
	VLL           *VLLConfig       `json:"vll"`
}

VXCResources represents the resources associated with a VXC.

type VXCResponse

type VXCResponse struct {
	Message string `json:"message"`
	Terms   string `json:"terms"`
	Data    VXC    `json:"data"`
}

VXCResponse represents the response from the VXC API.

type VXCService

type VXCService interface {
	// BuyVXC buys a VXC from the Megaport VXC API.
	BuyVXC(ctx context.Context, req *BuyVXCRequest) (*BuyVXCResponse, error)
	// GetVXC gets details about a single VXC from the Megaport VXC API.
	GetVXC(ctx context.Context, id string) (*VXC, error)
	// DeleteVXC deletes a VXC in the Megaport VXC API.
	DeleteVXC(ctx context.Context, id string, req *DeleteVXCRequest) error
	// UpdateVXC updates a VXC in the Megaport VXC API.
	UpdateVXC(ctx context.Context, id string, req *UpdateVXCRequest) (*VXC, error)
	// LookupPartnerPorts looks up available partner ports in the Megaport VXC API.
	LookupPartnerPorts(ctx context.Context, req *LookupPartnerPortsRequest) (*LookupPartnerPortsResponse, error)
}

VXCService is an interface for interfacing with the VXC endpoints in the Megaport VXC API.

type VXCServiceOp

type VXCServiceOp struct {
	Client *Client
}

VXCServiceOp handles communication with the VXC related methods of the Megaport API.

func NewVXCService

func NewVXCService(c *Client) *VXCServiceOp

NewVXCService creates a new instance of the VXC Service.

func (*VXCServiceOp) BuyVXC

func (svc *VXCServiceOp) BuyVXC(ctx context.Context, req *BuyVXCRequest) (*BuyVXCResponse, error)

BuyVXC buys a VXC from the Megaport VXC API.

func (*VXCServiceOp) DeleteVXC

func (svc *VXCServiceOp) DeleteVXC(ctx context.Context, id string, req *DeleteVXCRequest) error

DeleteVXC deletes a VXC in the Megaport VXC API.

func (*VXCServiceOp) GetVXC

func (svc *VXCServiceOp) GetVXC(ctx context.Context, id string) (*VXC, error)

GetVXC gets details about a single VXC from the Megaport VXC API.

func (*VXCServiceOp) LookupPartnerPorts

LookupPartnerPorts looks up available partner ports in the Megaport VXC API.

func (*VXCServiceOp) UpdateVXC

func (svc *VXCServiceOp) UpdateVXC(ctx context.Context, id string, req *UpdateVXCRequest) (*VXC, error)

UpdateVXC updates a VXC in the Megaport VXC API.

type VXCUpdate

type VXCUpdate struct {
	Name           string `json:"name,omitempty"`
	RateLimit      *int   `json:"rateLimit,omitempty"`
	CostCentre     string `json:"costCentre,omitempty"`
	Shutdown       *bool  `json:"shutdown,omitempty"`
	AEndVLAN       *int   `json:"aEndVlan,omitempty"`
	BEndVLAN       *int   `json:"bEndVlan,omitempty"`
	AEndProductUID string `json:"aEndProductUid,omitempty"`
	BEndProductUID string `json:"bEndProductUid,omitempty"`
	Term           *int   `json:"term,omitempty"`
}

VXCUpdate represents the fields that can be updated on a VXC.

type VendorConfig

type VendorConfig interface {
	IsVendorConfig()
}

VendorConfig is an interface for MVE vendor configuration.

type VersaConfig

type VersaConfig struct {
	VendorConfig
	Vendor            string `json:"vendor"`
	ImageID           int    `json:"imageId"`
	ProductSize       string `json:"productSize"`
	MVELabel          string `json:"mveLabel"`
	DirectorAddress   string `json:"directorAddress"`
	ControllerAddress string `json:"controllerAddress"`
	LocalAuth         string `json:"localAuth"`
	RemoteAuth        string `json:"remoteAuth"`
	SerialNumber      string `json:"serialNumber"`
}

VersaConfig represents the configuration for a Versa MVE.

type VirtualRouter

type VirtualRouter struct {
	MCRAsn             int    `json:"mcrAsn"`
	ResourceName       string `json:"resource_name"`
	ResourceType       string `json:"resource_type"`
	Speed              int    `json:"speed"`
	BGPShutdownDefault bool   `json:"bgpShutdownDefault"`
}

VirtualRouter represents the configuration of a virtual router.

type VmwareConfig

type VmwareConfig struct {
	VendorConfig
	Vendor            string `json:"vendor"`
	ImageID           int    `json:"imageId"`
	ProductSize       string `json:"productSize"`
	MVELabel          string `json:"mveLabel"`
	AdminSSHPublicKey string `json:"adminSshPublicKey"`
	SSHPublicKey      string `json:"sshPublicKey"`
	VcoAddress        string `json:"vcoAddress"`
	VcoActivationCode string `json:"vcoActivationCode"`
}

VmwareConfig represents the configuration for a VMware MVE.

Jump to

Keyboard shortcuts

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