Tags
Tags defined in Paragon Active Assurance can be applied to:
- monitors
- monitor templates
- Test Agents
- TWAMP reflectors.
For example, you can tag a monitor with the same tag as a subset of Test Agents that are going to run the monitor. This feature is particularly helpful if you have a large number of monitors and templates defined.
If you have set up an alarm with SNMP traps for a monitor, then the SNMP traps will be assigned the same tags as the monitor, if any.
Creating Tags
Below we show how to create a tag with name and color as defined by the JSON data.
# Request settings url = '%s/accounts/%s/tags/' % (args.ncc_url, args.account) test_agent_url = '%s/accounts/%s/test_agents/2/' % (args.ncc_url, args.account) json_data = json.dumps({ 'name': 'Tag', 'color': '#000' }) # Create tag response = requests.post(url=url, data=json_data, headers={ 'API-Token': args.token, 'Accept': 'application/json; indent=4', 'Content-Type': 'application/json', }) print 'Status code: %s' % response.status_code print json.dumps(response.json(), indent=4)
Assigning a Tag
Here is how to assign the tags found under tags
to the items found
under resources
. In this case, a single tag is assigned to a sole
Test Agent.
The other resource types are: monitor
,
monitor_template
, test_template
,
twamp_reflector
.
# Request settings url = '%s/accounts/%s/tags/assign/' % (args.ncc_url, args.account) json_data = json.dumps({ 'resources': [ { 'type': 'test_agent', 'ids': [2] } ], 'tags': [ 10 ], }) # Assign tags response = requests.post(url=url, data=json_data, headers={ 'API-Token': args.token, 'Accept': 'application/json; indent=4', 'Content-Type': 'application/json', }) print 'Status code: %s' % response.status_code print json.dumps(response.json(), indent=4)
Updating a Tag
This code example shows how to update the label and color of a tag. The tags remains assigned to the same resources as before.
# Request settings url = '%s/accounts/%s/tags/%s/' % (args.ncc_url, args.account, args.tag_id) json_data = json.dumps({ 'name': 'New tag name', 'color': '#eee', }) # Update tag response = requests.put(url=url, data=json_data, headers={ 'API-Token': args.token, 'Accept': 'application/json; indent=4', 'Content-Type': 'application/json', }) print 'Status code: %s' % response.status_code print json.dumps(response.json(), indent=4)
Unassigning a Tag
Below we unassign the tag "1" from the Test Agent with id = 2.
# Request settings url = '%s/accounts/%s/tags/unassign/' % (args.ncc_url, args.account) json_data = json.dumps({ 'resources': [ { 'type': 'test_agent', 'ids': [2] } ], 'tags': [ 1 ] }) # Unassign tag response = requests.post(url=url, data=json_data, headers={ 'API-Token': args.token, 'Accept': 'application/json; indent=4', 'Content-Type': 'application/json', }) print 'Status code: %s' % response.status_code if response.status_code != NO_CONTENT: print json.dumps(response.json(), indent=4)
Deleting a Tag
In order to delete a tag altogether from Control Center, the following code is used.
# Request settings url = '%s/accounts/%s/tags/%s/' % (args.ncc_url, args.account, args.tag_id) # Delete tag response = requests.delete(url=url, headers={'API-Token': args.token}) print 'Status code: %s' % response.status_code # delete does not return any content if response.status_code != NO_CONTENT: print json.dumps(response.json(), indent=4)