Showing results for 
Search instead for 
Did you mean: 

Tech Tip: Using the RESTful Control API with Python - deletepool

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 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
import requests
import sys

poolName = 'pytest'
url = '' + poolName

client = requests.Session()
client.auth = ('admin', 'admin')
client.verify = False

    response = client.delete(url)
except requests.exceptions.ConnectionError:
    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


Read More




Version history
Revision #:
3 of 3
Last update:
‎01-06-2021 04:42:PM
Updated by:
Labels (1)