Interacting with the Acquia Cloud API using Python
The Acquia Cloud API makes it easy to manage sites on the platform. The API allows you to perform many administrative tasks including creating, destroying and copying databases, deploying code, managing domains and copying files.
Acquia offers 2 official clients. The primary client is a drush plugin which can only be downloaded from Acquia Insight. The other is a PHP library which states in the README that it is “[n]ot ready for production usage”.
On a recent project using WF Tools we needed some pretty advanced deployment scripts for sites hosted on Acquia Cloud. We had tried using a mix of bash and PHP, but that created a maintenance nightmare, so we switched to Python.
I was unable to find a high quality Python library, so I wrote a python client for the Acquia Cloud API. The library implements all of the features that we needed, so there are a few things missing.
Chaining complex commands together is easy because the library implements a fluent interface. An extreme example of what is possible is below:
# Instantiate the client
c = acapi.Client('email@example.com', 'acquia-token')
# Copy the prod db to dev, make a backup of the dev db and download it to /tmp
Some of the code is “borrowed” from the Python client for Twilio. The library is licensed under the terms of the MIT license.
I am continuing to develop the library. Consider this a working alpha. Improving error handling, creating a comprehensive test suite and implementing the missing API calls are all on the roadmap. Pull requests are welcome.