Since release 3.0 of Sonus SBC 1000/2000 firmware, REST license is free of charge and you can use it for multiple scenarios.
REST APIs are provided for developers who want to programmatically integrate the Sonus SBC 1000/2000 into their applications, and for administrators who want to script interactions with the Sonus SBC 1000/2000.
One of these scenarios is scripting provisioning, that allows you to program multiple SBCs with same parameters, in a one shot execution instead of having to program manually one by one each SBCs.
This is often the case when you need to deploy multiple SBCs in a same country, creating the same routing and transformation tables manually each time.
Here are some quick start tips to let you easily jump into REST programming through Microsoft Powershell.
$host.version
### Load the Certificate x509 $CertPathDer = "C:\Users\plessisa\Desktop\Rest\Cert.der" $certDer = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2($CertPath) ### Login $BodyValue = "Username=restuser&Password=restpass" $url = "https://134.56.226.215/rest/login" Invoke-RestMethod -Uri $url -Certificate $certDer -Method Post -Body $BodyValue -SessionVariable ps
### Allow self Sign Cert add-type @" using System.Net; using System.Security.Cryptography.X509Certificates; public class IDontCarePolicy : ICertificatePolicy { public IDontCarePolicy() {} public bool CheckValidationResult( ServicePoint sPoint, X509Certificate cert, WebRequest wRequest, int certProb) { return true; } } "@ [System.Net.ServicePointManager]::CertificatePolicy = new-object IDontCarePolicy ### Login $BodyValue = "Username=restuser&Password=restpass" $url = "https://134.56.226.215/rest/login" Invoke-RestMethod -Uri $url -Method Post -Body $BodyValue -SessionVariable ps
$BodyValue = "Description=Default SIP Server" $url = "https://134.56.226.215/rest/sipservertable/8" Invoke-RestMethod -Uri $url -Method PUT -Body $BodyValue -WebSession $ps
$BodyValue = "Description=Default SIP TOTO" $url = "https://134.56.226.215/rest/sipservertable/8" Invoke-RestMethod -Uri $url -Method POST -Body $BodyValue -WebSession $ps
$url = "https://134.56.226.215/rest/sipservertable/8" Invoke-RestMethod -Uri $url -Method GET -WebSession $ps
$url = "https://134.56.226.215/rest/sipservertable/8" Invoke-RestMethod -Uri $url -Method DELETE -Body "" -WebSession $ps
$DestFile = "C:\Users\plessisa\Desktop\Rest\backup.tar.gz" $url = "https://134.56.226.215/rest/system?action=backup" Invoke-RestMethod -Uri $url -Method POST -Body "" -WebSession $ps -OutFile $DestFile
$url= "https://134.56.226.215/rest/system?action=importconfig" $body = "--MyBoundary`n" $body += 'Content-Disposition: form-data; name="Filename"; filename="symphonyconfig.xml"' $body += "`nContent-Type: application/xml`n`n" $body += $(get-content symphonyconfig.xml -raw) $body += "`n--MyBoundary--" Invoke-RestMethod -uri $url -method POST -ContentType "multipart/form-data; boundary=MyBoundary" -body $body -WebSession $ps
$url= "https://134.56.226.215/rest/partition/1?action=upgrade" $body = "--MyBoundary`n" $body += 'Content-Disposition: form-data; name="Filename"; filename="sbc1000-release-3.1.0.img"' $body += "`nContent-Type: application/octet-stream`n`n" $body += $(get-content sbc1000-release-3.1.0.img -raw) $body += "`n--MyBoundary--" Invoke-RestMethod -uri $url -method POST -ContentType "multipart/form-data; boundary=MyBoundary" -body $body -WebSession $ps
$url= "https://134.56.226.215/rest/sbaconfig?action=sbaupgrade"
$body = "--MyBoundary`n"
$body += 'Content-Disposition: form-data; name="sbaInstallFilename"; filename="Setup.msi"'
$body += "`nContent-Type: application/octet-stream`n`n"
$body += $(get-content Setup.msi -raw)
$body += "`n--MyBoundary--"
Invoke-RestMethod -uri $url -method POST -ContentType "multipart/form-data; boundary=MyBoundary" -body $body -WebSession $ps
Function BasicHandler { Param($ResultIn) [xml]$XmlResultIn = $ResultIn.Substring(5) if($XmlResultIn.root.status.http_code.contains("200")) { return "Success" } else { return "Error Code:<"+$XmlResultIn.root.status.app_status.app_status_entry.code+"> Param:<"+$XmlResultIn.root.status.app_status.app_status_entry.params+">" } } ####### Expected PS C:> BasicHandler $Result Success or Error Code:<20013> Param:<8|SIPServerTable>
[xml]$FinalResult= $Result.Substring(5) ####### Expected Result PS C:> $FinalResult.root.sipservertable.Description Default SIP TOTO