Skip to content

ix_locations

jvdspeare edited this page Feb 18, 2019 · 4 revisions

ix_locations

Returns a list of available IX locations from a specific Data Centre location with details about each.

Usage

import megalib
x = megalib.ix_locations(header, loc_id, prod)

Arguments

header (required) String Header

loc_id (required) Integer Location ID

prod Boolean Environment, True = https://api.megaport.com, False = https://api-staging.megaport.com

Response

x.status_code Integer HTTPS Response Status Code

x.json Integer Response

Example

source

# Import megalib
import megalib

# Authenticate user credentials using the megalib.login function
auth = megalib.login(input('username: '), input('password: '), input('tfa (leave black if not enabled): '), prod=True)

# Check if logging was successful by observing the HTTP Status Code
if auth.status_code == 200:
    print('login successful')

    # Retrieve ix locations using the megalib.ix_locations function
    loc = megalib.ix_locations(auth.header, input('location id: '), prod=True)

    # Check if the ix locations call was successful by observing the HTTP Status Code
    if loc.status_code == 200:
        # Print the body of the response
        print(loc.json)

    # Advise user if the ix locations call failed
    else:
        print('failed')

# Advise user if login failed
else:
    print('login failed')

Megaport API documentation

Internet Exchanges IX

Clone this wiki locally