The following code uses Stingray's RESTful API to delete a pool. The code is written in Perl. This program deletes the "pltest" pool created by the addpool.pl 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.
deletepool.pl
#!/usr/bin/perl use REST::Client; use MIME::Base64; use JSON; # Since Stingray is using a self-signed certificate we don't need to verify it $ENV{'PERL_LWP_SSL_VERIFY_HOSTNAME'} = 0; my $poolName = 'pltest'; my $url = "/api/tm/1.0/config/active/pools/$poolName"; # Set up the connection my $client = REST::Client->new(); $client->setHost("https://stingray.example.com:9070"); $client->addHeader("Authorization", "Basic " . encode_base64("admin:admin")); #First see if the pool already exists $client->DELETE($url); if ($client->responseCode == 204) { print "Pool $poolName deleted"; } elsif ($client->responseCode == 404) { print "Pool $poolName not found"; } else { print "Error deleting pool $poolName. Status: " . $client->responseCode . " URL: $url"; }
Running the example
This code was tested with Perl 5.14.2 and version 249 of the REST::Client module.
Run the Perl script as follows:
$ delelepool.pl
Pool pltest deleted
Read More