-
Notifications
You must be signed in to change notification settings - Fork 2
port
jvdspeare edited this page Feb 19, 2019
·
7 revisions
Place or validate an order for a Megaport.
import megalib
x = megalib.port(header, loc_id, name, speed, market, term, validate, prod)
header (required) String
Header
loc_id (required) Integer
Location ID
name (required) String
Service Name
speed (required) Integer
Service Speed
market (required) String
Billing Market
term Integer
Contract Term in Months (1, 12, 24, 36)
validate Boolean
True = Validate, False = Order
prod Boolean
Environment, True = https://api.megaport.com, False = https://api-staging.megaport.com
x.status_code
Integer
HTTPS Response Status Code
x.json
Integer
Response
x.currency
String
Currency
x.monthly_rate
Integer
Monthly Cost
x.uid
String
TechnicalServiceUid
# 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=False)
# Check if logging was successful by observing the HTTP Status Code
if auth.status_code == 200:
print('login successful')
# Order port using the megalib.port function
port = megalib.port(auth.header, input('location id: '), input('service name: '), input('speed: '),
input('market: '), input('contract term: '), validate=False, prod=True)
# Advise user if port order was successful
if port.status_code == 200:
print('port ordered successfully')
# Advise user if port order failed
else:
print('port order failed')
# Advise user if login failed
else:
print('login failed')