The following code uses Stingray's RESTful API to delete a pool. The code is written in Python. This program deletes the "pytest" pool created by the addpool.py example. To delete a resource you do a HTTP DELETE on the URI for the resource. If the delete is successful a 204 HTTP status code will be returned.
#! /usr/bin/env python
poolName = 'pytest'
url = 'https://stingray.example.com:9070/api/tm/1.0/config/active/pools/' + poolName
client = requests.Session()
client.auth = ('admin', 'admin')
client.verify = False
response = client.delete(url)
print "Error: Unable to connect to " + url
if response.status_code == 204:
print 'Pool %s deleted' %(poolName)
if response.status_code == 404:
print 'Pool %s not found' %(poolName)
print 'Error: Status=%d URL=%s' %(response.status_code, url)
Running the example
This code was tested with Python 2.7.3 and version 1.1.0 of the requests library.
Run the Python script as follows:
Pool pytest deleted