Tuesday, 29 January 2013

Serverlove API - Curl

Ok so now  I have a Linux PPTP VPN server ready to rock on demand.  Please see my previous post on the PPTP business.  All it needs is it to be automated, because I need to make this simple to use for my "users".  I.e. I want a simple way to start and sstop the server - keeping it running costs money.

Enter in the Serverlove API.  It has a standard REST API which accepts JSON or text commands, check the site for details.  For testing (and execution) I have installed Curl for Windows.  I spent quite a while trying to get the right call and Curl options, which was failing as the server "name" is actually a massive long string of numbers on the settings page, not actually the "name" of it, so the call kept failing.  After the usual belligerent attempts, the 5 minute break then reading the instructions I managed to get Curl to make successful calls to turn on and off the servers, on demand!  Yay.  It looks a bit like this from the command line:

curl -v -i -H "Accept: application/json" -H "Content-Type: application/json" -u username:password -X POST -k https://api.z1-man.serverlove.com/servers/SERVER/start

It is actually pretty straightforward - there is quite a good API there if you need to do remotey-on-demandy things to servers etc.  My tip is where the url says," .../servers/SERVER/start", then insert the servers UID.

No comments:

Post a Comment

Found this pointless and feel you must comment? Really, there is no need, we are fully aware of the pointlessness of this article. But if you must...

Google+ Followers