Skip to content

service_key_lookup

jvdspeare edited this page Feb 19, 2019 · 3 revisions

service_key_lookup

Lookup existing service keys for a specific Megaport.

Usage

import megalib
x = megalib.service_key_lookup(header, uid, prod)

Arguments

header (required) String Header

uid (required) String Service UID

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 String 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')

    # lookup service keys for a particular port using the megalib.service_key_function
    key = megalib.service_key_lookup(auth.header, input('port uid: '), prod=True)

    # Print response if call successful
    if key.status_code == 200:
        print(key.json)

    # Advise user if lookup failed
    else:
        print('service key lookup failed')

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

Megaport API documentation

Service Keys

Clone this wiki locally