Documentation ¶
Overview ¶
The `shared` package is houses functions that are used throughout the entire Megaport Go Library. They are not meant for general use outside of the Library.
The `shared` package is houses functions that are used throughout the entire Megaport Go Library. They are not meant for general use outside of the Library.
Index ¶
- func DumpObject(debugObject interface{})
- func GenerateOneTimePassword(credentials *credential.Credential) (string, error)
- func GenerateRandomNumber(lowerBound int, upperBound int) int
- func GenerateRandomVLAN() int
- func GetCurrentTimestamp() int64
- func GetSessionToken(credentials *credential.Credential) error
- func IsEmail(emailAddress string) bool
- func IsErrorResponse(response *http.Response, responseErr *error, expectedReturnCode int) (bool, error)
- func IsGuid(guid string) bool
- func MakeAPICall(verb string, url string, body []byte) (*http.Response, error)
- func PurchaseError(productID string, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DumpObject ¶
func DumpObject(debugObject interface{})
DumpObject uses the spew library to output variable contents
func GenerateOneTimePassword ¶
func GenerateOneTimePassword(credentials *credential.Credential) (string, error)
Generates a OTP using a Google Authenticator-compatible OTP Key. The field `one_time_password_key` must be set in your Megaport credentials file.
func GenerateRandomNumber ¶
GenerateRandomNumber generates a random number between an upper and lower bound.
func GenerateRandomVLAN ¶
func GenerateRandomVLAN() int
func GetCurrentTimestamp ¶
func GetCurrentTimestamp() int64
func GetSessionToken ¶
func GetSessionToken(credentials *credential.Credential) error
GetSessionToken connects to the Megaport API, passes the saved username, password, and a generated OTP (if otp key is set). The Megaport API returns a session token which is then saved in the session token file. The Session Token is also stored in the environment variable `MEGAPORT_SESSION_TOKEN`.
func IsErrorResponse ¶
func IsErrorResponse(response *http.Response, responseErr *error, expectedReturnCode int) (bool, error)
IsErrorResponse returns an error report if an error response is detected from the API.
func MakeAPICall ¶
MakeAPICall is a wrapper for HTTP calls against the Megaport API. It simply requires HTTP Verb, a URL, and the body of the request encoded as a byte array. It also sets generic headers such as content types, user agent. It also ensures the authentication tokesns are in the request headers.
func PurchaseError ¶
PurchaseError prints out details about a failed purchase.
Types ¶
This section is empty.