09-26-2018 01:28 AM
09-26-2018 07:29 AM
09-26-2018 07:45 AM
09-26-2018 09:03 AM
import requestsIf you're using a url and have proper certificates for the server then use the proper dns name. If you're using the "untrusted" ruckus cert for the controller, please use the parameter "verify=False" in all the calls to request. (see here http://docs.python-requests.org/en/latest/user/advanced/#ssl-cert-verification )
import json baseUrl="https://YOUR-IP-HERE:8443/wsg/api/public/v6_0" username="admin" password="YOUR-PASSWORD" zoneId="YOUR-ZONE-ID-AS-UUID" wlanId="YOUR-WLAN-ID-AS-INTGER-ID" enableWlan=True loginData={ "username": username, "password": password, "timeZoneUtcOffset": "+03:00" } headers = {"Content-Type": "application/json;charset=UTF-8"} login=requests.post(baseUrl + "/session", headers=headers, data=json.dumps(loginData)) print login.text print login.status_code if (login.status_code == requests.codes.ok): cookieJar=login.cookies # enable below to list zone and wlan ids you need to fill above # zoneRequests=requests.get( baseUrl + '/rkszones',cookies=cookieJar, headers=headers) # print zoneRequests.text # allWlansRequest=requests.get( baseUrl + '/rkszones/' +zoneId + '/wlans' ,cookies=cookieJar, headers=headers) # print allWlansRequest.text enableWlanData = {"type": "AlwaysOn" if enableWlan else "AlwaysOff"} wlanRequest=requests.patch(baseUrl + '/rkszones/' + zoneId + '/wlans/' + wlanId + '/schedule', cookies=cookieJar, headers=headers, data=json.dumps(enableWlanData)) print wlanRequest.status_code logoutRequest=requests.delete(baseUrl + '/session', headers=headers, cookies=cookieJar) print logoutRequest.status_code
09-27-2018 04:10 AM