Extreme API with Python

Table Of Contents
Extreme API with Python
Page | 139
Part no.9036931-00 Rev AA February 2021
AP3935 3
AP410 3
AP510 3
AP3915 4
AP3916 4
AP505 4
SA201 8
7.3 Use POST
The PUT or POST method is very similar to GET. The main difference is that you must pass the data
structure you want to add or modify during the REST API CALL.
For example, create a new role (for Policy) in Extreme Campus Controller. Name it Stef. According to the
documentation, there are three required types of information in the JSON you will send, and the
expected response should be a 201 status code.
Tweak your previous CALL to minimize the output length and store the information in a more practical
way. Next, issue a POST to create the new role, if it doesn’t already exist.
data = restGet('/management/v1/aps')
if data:
APList = []
print("There are {} APs".format(len(data)))
for ap in data:
APList.append(ap.get('platformName'))
new_list = []
for count, model in sorted(((APList).count(ap), ap) for ap in set(APList)):
entry = {}
entry['model'] = model
entry['count'] = count
new_list.append(entry)
print(new_list)
data = restGet('/management/v3/roles')
if data:
print("\nThere are {} roles".format(len(data)))
found = False
for name in data:
if name.get('name') == "Stef":
print("The role Stef already exists")
found = True