09-26-2017 10:47 PM
03-06-2019 02:10 PM
#!/usr/bin/env python
import csv, threading, requests
host = '<>'
adminname = '<>'
adminpassword = '<>'
zoneid = '<>'
wlanid = '<>'
newwifikey = '<>'
def loginRuckus():
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
session = requests.session()
urlsession = 'https://%s:8443/wsg/api/public/v8_0/session' % (host)
response = session.post(urlsession, json={"username":adminname, "password":adminpassword }, verify=False)
print(response.text)
return session
def change_enc_key(session):
url = 'https://%s:8443/wsg/api/public/v8_0/rkszones/%s/wlans/%s/encryption' % (host, zoneid, wlanid)
response = session.patch(url, json={"method":"WPA2","passphrase":newwifikey}, verify=False)
print(response.text)
print(response)
return
def main():
change_enc_key(loginRuckus())
return
if __name__ == '__main__':
main()
06-09-2019 05:58 PM
# Queries vSZ controllers using powershell
$UrlBase = "https://vsz:8443/wsg/api/public";
$apiVer = "v8_0"
$Body = [pscustomobject]@{
username = 'admin'
password = 'admin'
timeZoneUtcOffset = "+08:00"
}
$json = $Body | ConvertTo-Json
$session = Invoke-WebRequest -Uri $UrlBase/$apiVer/session -Method Post -Body $json -ContentType 'application/json' -SessionVariable websession
# Translate Cookie header into useable string
$stringCookie = [string]$session.Headers["Set-Cookie"]
$cookie = $stringCookie.substring(0,($stringCookie.length - 21))
# Add cookie to header
$headers = @{}
$headers.Add("Cookie",$cookie)
Invoke-RestMethod -Uri $UrlBase/$apiVer/session -Method GET -Headers $headers -ContentType 'application/json' -WebSession $websession
Invoke-RestMethod -Uri $UrlBase/apiInfo -Method GET -Headers $headers -ContentType 'application/json' -WebSession $websession