@Mark, if you're still interested in this topic you might want to look at https://dev.to/philnash/google-spreadsheets-and-ruby
On 21 February 2017 at 10:10, Mark Rogers mark@more-solutions.co.uk wrote:
On 17 February 2017 at 21:26, Ewan Slater ewan.slater@gmail.com wrote:
Calling a REST API from Bash using curl is an exercise in masochism.
Maybe that's why it appeals :-)
I strongly recommend writing your scripts in Python using the requests package.
I've found various samples using whole Google Docs libraries to make life easier, but I'd settle for some sample Python that just uses basic libraries to handle the HTTP(S) side of things. From that I could probably work it out in Bash too.
However, where I'm stuck isn't (I don't think) so much at the "Calling a REST API from Bash using curl" stage, but in working out what combination of API keys and security credentials I need to set up first to make anything have a chance of working. I've read enough on the subject that it would have killed a couple of forests if I'd printed it first, but I'm still clueless.
What I've failed to find are any straightforward examples that aren't basically trivial because their first step is to include a library that hides all the complexity away. Not that I necessarily have anything against that, but I don't really want to have to install loads of dependencies on each VM/Pi/etc that I want to monitor when in principle all it should need is curl (or maybe Python with a couple of libraries that are probably already installed anyway). And if I do install all those dependencies and test the sample code I'm pretty sure I'm then still going to have to work out the same authentication/API key issues I'm stuck at now!
If you prefer Ruby I recommend the httpclient gem.
Masochist I may be, but I draw the line at Ruby....
-- Mark Rogers // More Solutions Ltd (Peterborough Office) // 0844 251 1450 Registered in England (0456 0902) 21 Drakes Mews, Milton Keynes, MK8 0ER
main@lists.alug.org.uk http://www.alug.org.uk/ https://lists.alug.org.uk/mailman/listinfo/main Unsubscribe? See message headers or the web site above!