Examples: Inventory Items
Creating (importing) and managing inventory items such as TWAMP reflectors and Y.1731 MEPs is done in a similar way as for Test Agents. Below is Python code for defining such entities in Paragon Active Assurance through the REST API and for retrieving lists of the items defined.
TWAMP Reflectors
Creating a TWAMP Reflector
# Request settings url = '%s/accounts/%s/twamp_reflectors/' % (args.ncc_url, args.account) # JSON content json_data = json.dumps({ 'ctrl_port': 862, # Control port (optional) 'host': '10.0.33.1', # Host name or IP address 'name': 'TWAMP Reflector A', 'port': 9876 # Test port }) # Create TWAMP reflector response = requests.post(url=url, data=json_data, headers={ 'API-Token': args.token, 'Accept': 'application/json; indent=4', 'Content-Type': 'application/json', })
Retrieving TWAMP Reflectors
Here is how to retrieve all TWAMP reflectors defined in an account.
# Request settings # NOTE: User is able to pass additional parameters as a query string ?limit=100&offset=111: # limit: Changes number of elements returned from API # offset: Changes element from which results will be returned url = '%s/accounts/%s/twamp_reflectors/%s' % (args.ncc_url, args.account, args.query_params) # Get list of TWAMP reflectors response = requests.get(url=url, headers={'API-Token': args.token})
Running this code gives output like that below:
{ "count": 1, "items": [ { "ctrl_port": 862, "gps_lat": 22.222222, "gps_long": -33.333333, "host": "10.0.33.1", "id": 1, "name": "TWAMP Reflector A", "port": 9876, "tags": [] } ], "limit": 10, "next": null, "offset": 0, "previous": null }
Y.1731 MEPs
Creating a Y.1731 MEP
# Request settings url = '%s/accounts/%s/y1731_meps/' % (args.ncc_url, args.account) # JSON content json_data = json.dumps({ 'mac': '00:11:22:33:AA:BB', # MAC address 'meg_level': 2, # MEG (Maintenance Entity Group) level 'name': 'Y.1731 MEP 1' }) # Create Y.1731 MEP response = requests.post(url=url, data=json_data, headers={ 'API-Token': args.token, 'Accept': 'application/json; indent=4', 'Content-Type': 'application/json', })
Retrieving Y.1731 MEPs
Here is how to retrieve all Y.1731 MEPs defined in an account.
# Request settings # NOTE: User is able to pass additional parameters as a query string ?limit=100&offset=111: # limit: Changes number of elements returned from API # offset: Changes element from which results will be returned url = '%s/accounts/%s/y1731_meps/%s' % (args.ncc_url, args.account, args.query_params) # Get list of Y.1731 MEPs response = requests.get(url=url, headers={'API-Token': args.token})
Running this code gives output like that below:
{ "count": 1, "items": [ { "id": 1, "mac": "00:11:22:33:AA:BB", "meg_level": 2, "name": "Y.1731 MEP 1" } ], "limit": 10, "next": null, "offset": 0, "previous": null }
IPTV Channels
Creating an IPTV Channel
url = '%s/accounts/%s/iptv_channels/' % (args.ncc_url, args.account) # Parameter settings for IPTV channel json_data = json.dumps({ "name": 'Some TV Channel', "ip": '224.5.0.0', # IPv4 multicast address of IPTV channel "port": 5500, # UDP destination port in IPTV multicast stream "source": "172.16.0.1", # Multicast source address (optional) "pnum": 1, # Program number (in Multi Program Transport Stream) }) # Create IPTV channel response = requests.post(url=url, data=json_data, headers={ 'API-Token': args.token, 'Accept': 'application/json; indent=4', 'Content-Type': 'application/json', })
Retrieving IPTV Channels
Below is code for retrieving all IPTV channels defined in an account.
# Request settings # NOTE: User is able to pass additional parameters as a query string ?limit=100&offset=111: # limit: Changes number of elements returned from API # offset: Changes element from which results will be returned url = '%s/accounts/%s/iptv_channels/%s' % (args.ncc_url, args.account, args.query_params) # Get list of IPTV channels response = requests.get(url=url, headers={'API-Token': args.token})
Running this code gives output like that below:
{ "count": 1, "items": [ { "id": 1, "ip": "224.5.0.0", "name": "Some TV Channel", "pnum": 1, "port": 5500, "source": "172.16.0.1" } ], "limit": 10, "next": null, "offset": 0, "previous": null }
SIP Accounts
Creating a SIP Account
# Request settings url = '%s/accounts/%s/sip_accounts/' % (args.ncc_url, args.account) # Parameter settings for SIP account json_data = json.dumps({ "sip_domain": "example.com", # SIP domain name "registrar": "10.10.10.10", # Domain name/IP address of SIP registrar (optional) "username": "my_user", # User name for registration "password": "my_password", # Password for registration "proxy": "example.com", # Proxy server IP (optional) "user_auth": "my_auth_id", # User ID for authentication (optional) "uri_rewrite": "abc" # User ID in URI as rewritten by SIP server (optional) }) # Create IPTV channel response = requests.post(url=url, data=json_data, headers={ 'API-Token': args.token, 'Accept': 'application/json; indent=4', 'Content-Type': 'application/json', })
Retrieving SIP Accounts
To retrieve all SIP accounts defined in a Paragon Active Assurance account, do as follows.
# Request settings # NOTE: User is able to pass additional parameters as a query string ?limit=100&offset=111: # limit: Changes number of elements returned from API # offset: Changes element from which results will be returned url = '%s/accounts/%s/sip_accounts/%s' % (args.ncc_url, args.account, args.query_params) # Get list of SIP accounts response = requests.get(url=url, headers={'API-Token': args.token})
Running this code gives output like that below:
{ "count": 1, "items": [ { "password": "my_password", "proxy": "192.168.0.1", "registrar": "", "sip_domain": "example.com", "uri_rewrite": "", "user_auth": "my_auth_id", "username": "my_user" } ], "limit": 10, "next": null, "offset": 0, "previous": null }