Recently someone asked me how to reboot a Droplet with the DigitalOcean API so I decided to put to together a few examples on how to do that with different scripts including:
curl
commandHope that this helps!
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
According to the official API documentation, you can reboot a droplet with the following
curl
request:To do the same thing with PHP you could use the following script:
Quick rundown:
curl_init
we prepare our URL, note that you would need to installphp-curl
in order to be able to do socurl_setopt
we build up our CURL requestcurl_exec
we trigger the POST requestprint_r($result);
we print the result backAs an example I will use this Python module to manage digitalocean.com droplets:
https://www.digitalocean.com/community/tools/python-digitalocean
So just install it using php:
Then the script would look something like this:
For more information on how to use the DigitalOcean API with Python check the following tutorial:
https://www.digitalocean.com/community/tutorials/how-to-use-web-apis-in-python-3
This would be quite similar to the plain
curl
command but the benefit is that we could add some variables, comments and etc.If you have any other suggestions or examples, please feel free to share them here!
Regards, Bobby