api

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2020 License: MPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EndpointProduction = "https://api.megaport.com"
	EndpointStaging    = "https://api-staging.megaport.com"

	Version   = "0.1"
	UserAgent = "megaport-api-go-client/" + Version

	ProductStatusCancelled       = "CANCELLED"
	ProductStatusCancelledParent = "CANCELLED_PARENT"
	ProductStatusConfigured      = "CONFIGURED"
	ProductStatusDecommissioned  = "DECOMMISSIONED"
	ProductStatusDeployable      = "DEPLOYABLE"
	ProductStatusLive            = "LIVE"
)
View Source
const (
	ProductTypePort = "MEGAPORT" // Virtual = false, ProductType = MEGAPORT
	ProductTypeMcr1 = "MEGAPORT" // Virtual = true,  ProductType = MEGAPORT
	ProductTypeMcr2 = "MCR2"     // Virtual = false, ProductType = MCR2
	ProductTypeVxc  = "VXC"
)
View Source
const (
	VxcTypePrivate = "private"
	VxcTypeAws     = "aws"
	VxcTypeGcp     = "gcp"
	VxcTypePartner = "partner"
)
View Source
const (
	VxcConnectTypeAws     = "AWS"
	VxcConnectTypeGoogle  = "GOOGLE"
	VxcConnectTypeVRouter = "VROUTER"
)

Variables

View Source
var (
	ErrNotFound = fmt.Errorf("megaport-api: not found")
)

Functions

func Bool

func Bool(v interface{}) *bool

func String

func String(v interface{}) *string

func Uint64

func Uint64(v interface{}) *uint64

func Uint64FromInt

func Uint64FromInt(v interface{}) *uint64

Types

type Client

type Client struct {
	BaseURL   string
	Token     string
	UserAgent string
	// contains filtered or unexported fields
}

func NewClient

func NewClient(baseURL string) *Client

func (*Client) CreateCloudVxc

func (c *Client) CreateCloudVxc(v *CloudVxcCreateInput) (*string, error)

func (*Client) CreateMcr

func (c *Client) CreateMcr(v McrCreateInput) (*string, error)

func (*Client) CreatePort

func (c *Client) CreatePort(v *PortCreateInput) (*string, error)

func (*Client) CreatePrivateVxc

func (c *Client) CreatePrivateVxc(v *PrivateVxcCreateInput) (*string, error)

func (*Client) DeleteMcr

func (c *Client) DeleteMcr(uid string) error

func (*Client) DeletePort

func (c *Client) DeletePort(uid string) error

func (*Client) DeleteVxc

func (c *Client) DeleteVxc(uid string) error

func (*Client) GetInternetExchanges

func (c *Client) GetInternetExchanges(locationId uint64) ([]*InternetExchange, error)

func (*Client) GetIxPrice

func (c *Client) GetIxPrice(ixType string, locationId, speed uint64) (*MegaportCharges, error)

func (*Client) GetLocations

func (c *Client) GetLocations() ([]*Location, error)

func (*Client) GetMcr

func (c *Client) GetMcr(uid string) (*Product, error)

func (*Client) GetMcr1Price

func (c *Client) GetMcr1Price(locationId, speed uint64, productUid string) (*MegaportCharges, error)

func (*Client) GetMcr2Price

func (c *Client) GetMcr2Price(locationId, speed uint64, productUid string) (*MegaportCharges, error)

func (*Client) GetMegaportPrice

func (c *Client) GetMegaportPrice(locationId, speed, term uint64, productUid string, buyoutPort bool) (*MegaportCharges, error)

func (*Client) GetMegaports

func (c *Client) GetMegaports() ([]*Megaport, error)

func (*Client) GetMegaportsForGcpPairingKey

func (c *Client) GetMegaportsForGcpPairingKey(pairingKey string) ([]*MegaportCloud, []uint64, error)

func (*Client) GetPort

func (c *Client) GetPort(uid string) (*Product, error)

func (*Client) GetPortVlanIdAvailable

func (c *Client) GetPortVlanIdAvailable(uid string, vlanId uint64) (bool, error)

func (*Client) GetVxc

func (c *Client) GetVxc(uid string) (*ProductAssociatedVxc, error)

func (*Client) GetVxcPrice

func (c *Client) GetVxcPrice(aLocationId, bLocationId, speed uint64) (*MegaportCharges, error)

func (*Client) IsResourceDeleted

func (c *Client) IsResourceDeleted(provisioningStatus string) bool

func (*Client) ListMcrs

func (c *Client) ListMcrs() ([]*Product, error)

func (*Client) ListPorts

func (c *Client) ListPorts() ([]*Product, error)

func (*Client) Login

func (c *Client) Login(username, password, otp string) error

func (*Client) Logout

func (c *Client) Logout() error

func (*Client) UpdateCloudVxc

func (c *Client) UpdateCloudVxc(v *CloudVxcUpdateInput) error

func (*Client) UpdateMcr

func (c *Client) UpdateMcr(v McrUpdateInput) error

func (*Client) UpdatePort

func (c *Client) UpdatePort(v *PortUpdateInput) error

func (*Client) UpdatePrivateVxc

func (c *Client) UpdatePrivateVxc(v *PrivateVxcUpdateInput) error

type CloudVxcCreateInput

type CloudVxcCreateInput struct {
	InvoiceReference *string
	Name             *string
	PartnerConfig    PartnerConfig
	ProductUidA      *string
	ProductUidB      *string
	RateLimit        *uint64
	VlanA            *uint64
}

type CloudVxcUpdateInput

type CloudVxcUpdateInput struct {
	InvoiceReference *string
	Name             *string
	ProductUid       *string
	PartnerConfig    PartnerConfig
	RateLimit        *uint64
	VlanA            *uint64
}

type CspConnection

type CspConnection interface {
	// contains filtered or unexported methods
}

type InternetExchange

type InternetExchange struct {
	ASN           uint64
	Description   string
	ECIX          bool
	GroupMetro    string `json:"group_metro"`
	Name          string
	NetworkRegion string `json:"network_region"`
	PrimaryIPv4   InternetExchangeIPAddress
	PrimaryIPv6   InternetExchangeIPAddress
	SecondaryIPv4 InternetExchangeIPAddress
	SecondaryIPv6 InternetExchangeIPAddress
	State         string
}

type InternetExchangeIPAddress

type InternetExchangeIPAddress struct {
	Type  string
	Value string
}

type Location

type Location struct {
	Address          LocationAddress
	Campus           string
	Country          string
	Id               uint64
	Latitude         float64
	LiveDate         uint64
	Longitude        float64
	Market           string
	Metro            string
	Name             string
	NetworkRegion    string
	Products         LocationProducts
	SiteCode         string
	Status           string
	VRouterAvailable bool
}

Location data

type LocationAddress

type LocationAddress struct {
	City     string
	Country  string
	Postcode string
	State    string
	Street   string
	Suburb   string
}

Address data

type LocationProducts

type LocationProducts struct {
	Mcr        bool
	McrVersion uint64
	Mcr1       []uint64
	Mcr2       []uint64
	Megaport   []uint64
}

type Mcr1UpdateInput

type Mcr1UpdateInput struct {
	InvoiceReference *string
	Name             *string
	ProductUid       *string
}

type Mcr2CreateInput

type Mcr2CreateInput struct {
	Asn              *uint64
	InvoiceReference *string
	LocationId       *uint64
	Name             *string
	RateLimit        *uint64
}

type Mcr2UpdateInput

type Mcr2UpdateInput struct {
	InvoiceReference *string
	Name             *string
	ProductUid       *string
}

type McrCreateInput

type McrCreateInput interface {
	// contains filtered or unexported methods
}

type McrUpdateInput

type McrUpdateInput interface {
	// contains filtered or unexported methods
}

type Megaport

type Megaport struct {
	AggregationId uint64 `json:"aggregation_id"`
	CompanyName   string
	CompanyUid    string
	ConnectType   string
	LagId         uint64 `json:"lag_id"`
	LagPrimary    bool   `json:"lag_primary"`
	LocationId    uint64
	ProductUid    string
	Rank          uint64
	Speed         uint64
	Title         string
	VxcPermitted  bool
}

type MegaportCharges

type MegaportCharges struct {
	Currency             string
	DailyRate            float64
	DailySetup           float64
	Empty                bool
	FixedRecurringCharge float64
	// ForceProductChange // TODO: haven't seen a value other than null
	HourlyRate  float64
	HourlySetup float64
	// Key string // TODO: haven't seen a value other than "no key"
	LongHaulMbpsRate float64
	MbpsRate         float64
	MonthlyRate      float64
	MonthlySetup     float64
	// PostPaidBaseRate // TODO: haven't seen a value other than "no base rate"
	ProductType string
}

type MegaportCloud

type MegaportCloud struct {
	CompanyName string
	CompanyId   uint64
	CompanyUid  string
	Country     string
	Description string
	LocationId  uint64
	Name        string
	NServiceId  uint64
	Port        uint64
	PortSpeed   uint64
	ProductId   uint64
	ProductUid  string
	State       string      // This refers to the geographical location
	Type        string      // Potentially only used for Oracle ports
	Vxc         interface{} // TODO: what is the appropriate type?
}

type PartnerConfig

type PartnerConfig interface {
	// contains filtered or unexported methods
}

type PartnerConfigAws

type PartnerConfigAws struct {
	AmazonIPAddress   *string
	AmazonPrefixes    []string
	AwsConnectionName *string
	AwsAccountId      *string
	BGPAuthKey        *string
	CustomerASN       *uint64
	CustomerIPAddress *string
	Type              *string
}

type PartnerConfigGcp

type PartnerConfigGcp struct {
	PairingKey *string
}

type PortCreateInput

type PortCreateInput struct {
	LocationId            *uint64
	MarketplaceVisibility *bool
	Name                  *string
	Speed                 *uint64
	Term                  *uint64
	InvoiceReference      *string
}

type PortUpdateInput

type PortUpdateInput struct {
	InvoiceReference      *string
	MarketplaceVisibility *bool
	Name                  *string
	ProductUid            *string
}

type PrivateVxcCreateInput

type PrivateVxcCreateInput struct {
	InvoiceReference *string
	Name             *string
	ProductUidA      *string
	ProductUidB      *string
	RateLimit        *uint64
	VlanA            *uint64
	VlanB            *uint64
}

type PrivateVxcUpdateInput

type PrivateVxcUpdateInput struct {
	InvoiceReference *string
	Name             *string
	ProductUid       *string
	RateLimit        *uint64
	VlanA            *uint64
	VlanB            *uint64
}

type Product

type Product struct {
	AdminLocked bool
	// AggregationId // TODO: haven't seen a value other than null
	// AssociatedIxs []ProductsAssociatedIx // TODO: haven't seen a value other than an empty list
	AssociatedVxcs []ProductAssociatedVxc
	// AttributeTags // TODO: haven't seen a value other than an empty map
	BuyoutPort         bool
	Cancelable         bool
	CompanyName        string
	CompanyUid         string
	ContractStartDate  uint64
	ContractEndDate    uint64
	ContractTermMonths uint64
	CostCentre         string
	CreateDate         uint64
	CreatedBy          string
	// LagId // TODO: haven't seen a value other than null
	LagPrimary            bool
	LiveDate              uint64
	LocationId            uint64
	Locked                bool
	Market                string
	MarketplaceVisibility bool
	PortSpeed             uint64
	ProductName           string
	ProductType           string
	ProductUid            string
	ProvisioningStatus    string
	Resources             ProductResources
	// SecondaryName // TODO: haven't seen a value other than null
	// TerminateDate // TODO: haven't seen a value other than null
	// UsageAlgorithm // TODO: haven't seen a value other than null
	Virtual         bool
	VxcPermitted    bool
	VxcAutoApproval bool
}

type ProductAssociatedVxc

type ProductAssociatedVxc struct {
	AdminLocked bool
	// AttributeTags // TODO: haven't seen a value other than an empty map
	AEnd               ProductAssociatedVxcEnd
	BEnd               ProductAssociatedVxcEnd
	Cancelable         bool
	ContractEndDate    uint64 // TODO: haven't seen a value other than null, despite the note in https://dev.megaport.com/#general-get-product-list
	ContractStartDate  uint64 // TODO: haven't seen a value other than null, despite the note in https://dev.megaport.com/#general-get-product-list
	ContractTermMonths uint64
	CostCentre         string
	CreatedBy          string // TODO: haven't seen a value other than null
	CreateDate         uint64
	DistanceBand       string
	Locked             bool
	// NServiceId // TODO: haven't seen a value other than null
	ProductName        string
	ProductType        string
	ProductUid         string
	ProvisioningStatus string
	RateLimit          uint64
	Resources          ProductAssociatedVxcResources // TODO: not documented - is the struct here the same as in Product?
	SecondaryName      string
	UsageAlgorithm     string
	VxcApproval        ProductAssociatedVxcApproval
}

func (*ProductAssociatedVxc) Type

func (v *ProductAssociatedVxc) Type() string

type ProductAssociatedVxcApproval

type ProductAssociatedVxcApproval struct {
}

type ProductAssociatedVxcEnd

type ProductAssociatedVxcEnd struct {
	LocationId  uint64
	Location    string
	OwnerUid    string
	ProductUid  string
	ProductName string
	Vlan        uint64
}

type ProductAssociatedVxcResources

type ProductAssociatedVxcResources struct {
	CspConnection []CspConnection `json:"-"`
}

func (*ProductAssociatedVxcResources) GetCspConnection

func (pr *ProductAssociatedVxcResources) GetCspConnection(connectType string) CspConnection

func (*ProductAssociatedVxcResources) UnmarshalJSON

func (pr *ProductAssociatedVxcResources) UnmarshalJSON(b []byte) (err error)

type ProductAssociatedVxcResourcesCspConnectionAws

type ProductAssociatedVxcResourcesCspConnectionAws struct {
	Account         string
	AmazonAsn       uint64 `json:"-"`
	AmazonAddress   string `json:"amazon_address"`
	AmazonIpAddress string
	// Amazon_Asn uint64 `json:"amazon_asn"`
	Asn     uint64 `json:"-"`
	AuthKey string
	// Auth_key string `json:"Auth_key"`
	ConnectType       string
	CustomerAddress   string `json:"customer_address"`
	CustomerIpAddress string
	Id                uint64 `json:"-"`
	Name              string
	OwnerAccount      string
	PeerAsn           uint64 `json:"-"`
	Prefixes          string
	ResourceName      string `json:"Resource_name"`
	ResourceType      string `json:"Resource_type"`
	Type              string
	VifId             string `json:"Vif_id"`
	Vlan              uint64 `json:"-"`
}

func (*ProductAssociatedVxcResourcesCspConnectionAws) UnmarshalJSON

func (pr *ProductAssociatedVxcResourcesCspConnectionAws) UnmarshalJSON(b []byte) (err error)

type ProductAssociatedVxcResourcesCspConnectionGcp

type ProductAssociatedVxcResourcesCspConnectionGcp struct {
	Bandwidth    uint64
	Bandwidths   []uint64
	ConnectType  string
	CspName      string `json:"csp_name"`
	Megaports    []ProductAssociatedVxcResourcesCspConnectionGcpMegaports
	PairingKey   string
	ResourceName string `json:"resource_name"`
	ResourceType string `json:"resource_type"`
}

type ProductAssociatedVxcResourcesCspConnectionGcpMegaports

type ProductAssociatedVxcResourcesCspConnectionGcpMegaports struct {
	Port uint64
	Vxc  uint64
}

type ProductAssociatedVxcResourcesCspConnectionVRouter

type ProductAssociatedVxcResourcesCspConnectionVRouter struct {
	ConnectType       string
	BGPPeers          []string          `json:"bgp_peers"`
	BGPStatus         map[string]uint64 `json:"bgp_status"`
	IpAddresses       []string          `json:"ip_addresses"`
	Interfaces        []ProductAssociatedVxcResourcesCspConnectionVRouterInterfaces
	ResourceName      string `json:"resource_name"`
	ResourceType      string `json:"resource_type"`
	VirtualRouterId   uint64
	VirtualRouterName string
	Vlan              uint64
}

type ProductAssociatedVxcResourcesCspConnectionVRouterInterfaces

type ProductAssociatedVxcResourcesCspConnectionVRouterInterfaces struct{}

type ProductResources

type ProductResources struct {
	// CrossConnect  ProductResourcesCrossConnect `json:"cross_connect"` // TODO: only referenced in https://dev.megaport.com/#general-get-product-list
	Interface     ProductResourcesInterface
	VirtualRouter ProductResourcesVirtualRouter `json:"virtual_router"`
	VLL           ProductResourcesVLL
}

type ProductResourcesInterface

type ProductResourcesInterface struct {
	Demarcation  string
	Description  string
	Id           uint64 `json:"-"`
	LoaTemplate  string `json:"loa_template"`
	Media        string
	Name         string
	PortSpeed    uint64 `json:"-"`
	ResourceName string `json:"resource_name"`
	ResourceType string `json:"resource_type"`
	// SupportedSpeeds []uint64 `json:"supported_speeds"` // TODO: only referenced in https://dev.megaport.com/#general-get-product-list
	Up uint64 `json:"-"`
}

func (*ProductResourcesInterface) UnmarshalJSON

func (pr *ProductResourcesInterface) UnmarshalJSON(b []byte) (err error)

type ProductResourcesVLL

type ProductResourcesVLL struct {
	AVLan        uint64 `json:"-"`
	BVLan        uint64 `json:"-"`
	Description  string
	Id           uint64 `json:"-"`
	Name         string
	RateLimit    uint64 `json:"-"`
	ResourceName string `json:"resource_name"`
	ResourceType string `json:"resource_type"`
	Up           uint64 `json:"-"`
}

func (*ProductResourcesVLL) UnmarshalJSON

func (pr *ProductResourcesVLL) UnmarshalJSON(b []byte) (err error)

type ProductResourcesVirtualRouter

type ProductResourcesVirtualRouter struct {
	Id           uint64 `json:"-"`
	McrASN       uint64 `json:"-"`
	Name         string
	ResourceName string `json:"resource_name"`
	ResourceType string `json:"resource_type"`
	Speed        uint64 `json:"-"`
}

func (*ProductResourcesVirtualRouter) UnmarshalJSON

func (pr *ProductResourcesVirtualRouter) UnmarshalJSON(b []byte) (err error)

Jump to

Keyboard shortcuts

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