05-28-2020 11:14 PM
05-28-2020 11:19 PM
05-28-2020 11:34 PM
05-29-2020 08:15 AM
import requests
url="https://:8443/wsg/api/public/v6_0/"
login=requests.post(url+'session',verify=False,json={'username':'admin','password':''})
cookies=login.cookies
#find the zone name and uuid you want
zones=requests.get(url+'rkszones', verify=False, cookies=cookies)
zones.json()
#get a list of all the APs
aps=requests.get(url+'aps', verify=False, cookies=cookies)
aps.json()
#get a filtered list of APs (The aps of a specific zone)
aprequest={'filters':[{'type':'APZONE', 'value': ''}]}
aps=requests.get(url+'aps', verify=False, cookies=cookies,json=aprequest)
#how many APs did we get? len(myaps['list'])
#define new names for the APs
newapnames={'E8:1D:A8:22:AC:30':'AP-PR-01-28',
'E8:1D:A8:22:91:00':'AP-PR-01-29',
'E8:1D:A8:22:C2:F0':'AP-PR-03-38',
'E8:1D:A8:22:87:C0':'AP-SE-PB-04',
'E8:1D:A8:22:DC:20':'AP-SE-PB-05',
'E8:1D:A8:22:86:30':'AP-SE-01-12',
'E8:1D:A8:22:D7:70':'AP-SE-01-13',
'E8:1D:A8:22:BE:10':'AP-SE-02-20',
'E8:1D:A8:22:94:90':'AP-BI-01-45',
'E8:1D:A8:22:87:20':'AP-BI-01-46',
'E8:1D:A8:22:DC:30':'AP-KI-PB-47',
'E8:1D:A8:22:E3:10':'AP-KI-PB-48',
'E8:1D:A8:22:D6:10':'AP-KI-PB-50',
'D8:38:FC:19:19:90':'AP-SE-01-11',
'D8:38:FC:19:05:D0':'AP-SE-01-15'}
#do the actual renaming
for apname in newapnames.keys():
print apname, newapnames[apname]
#originalap=requests.get(url+'aps/'+apname, verify=False,cookies=cookies)
#print originalap.json()
patchAp=requests.patch(url+'aps/'+apname, verify=False, json={'name':newapnames[apname]}, cookies=cookies)
print patchAp.status_code
You should run this line by line in a python shell... to be sure of what's happening. But it should get you going!
05-29-2020 08:42 AM