When you execute Acquia CLI commands that invoke an Cloud Platform API endpoint, machine-readable JSON is returned. Depending on how large the response is, it can be a little intimidating to navigate through it.
Fortunately, JSON is a common format and there are open source tools to help you. Acquia recommends the following tools:
Below are a few examples where Acquia CLI leverages those tools to be more
productive and achieve typical use cases. jq
, in particular, is incredibly
powerful. We recommend you read the manual to discover all its possibilities.
You can use the limit
filter in jq
to only return a subset of the
results that you’re interested in.
$ acli api:applications:notification-list myapp | jq '[limit(3;.[] | {event, completed_at})]'
[
{
"event": "DatabaseBackupDownloaded",
"completed_at": "2021-02-24T16:13:37+00:00"
},
{
"event": "RemoteIdeCreatedEvent",
"completed_at": "2021-02-24T13:22:03+00:00"
},
{
"event": "DatabaseBackupDownloaded",
"completed_at": "2021-02-23T18:23:29+00:00"
}
]
You can pass a select
query to search a partial match in the JSON
output.
$ acli api:applications:list | jq '.[] | select(.hosting.id | contains ("thomas"))'
{
"id": 111241,
"uuid": "da76k877-fc7f-bcf4-2523-c801f469b9dc",
"name": "thomas",
"hosting": {
"type": "ace",
"id": "prod:thomas"
},
"subscription": {
"uuid": "1054c7fc-8954-4e52-b132-a4f5bc3a7d16",
"name": "Thomas - Sandbox"
},
"organization": {
"uuid": "d29ej812-7c03-11e4-b588-22000b04072f",
"name": "My Drupal 9 Application"
},
"flags": {
"remote_admin": false
},
"status": "normal",
"type": "drupal",
"platform": null,
"_links": {
"self": {
"href": "https://cloud.acquia.com/api/applications/da76k877-fc7f-bcf4-2523-c801f469b9dc"
},
"parent": {
"href": "https://cloud.acquia.com/api/applications"
}
},
"_embedded": {
"tags": []
}
}
You can use jq
to easily filter out the JSON response.
$ acli api:applications:environment-list myapp | jq '.[].name'
"dev"
"prod"
"test"
"ra"
"ama"
You can use jid
to scan through the JSON response until you find the
desired result.
You can use jtbl
that aids readability for the JSON response. If your output
isn’t too complex, pipe it to jtbl
and observe the formatted table.
$ acli api:distributions:list | jq -c '.[] | {title,version}' | jtbl
title version
--------------------------------- ----------
Drupal 9 9.0.3
Acquia Connector 8.x-1.9
Apigee Developer Portal Kickstart 8.x-1.7
Commerce Kickstart 7.x-2.62
DKAN 7.x-1.15.4
govCMS 7.x-3.6
Open Atrium 7.x-2.69
OpenPublic 7.x-1.9
Thunder 8.x-2.9
Web Experience Toolkit 7.x-4.9