landscape-api

Landscape API

To install the package, simply run:

$ sudo add-apt-repository –update ppa:landscape/landscape-api
$ sudo apt-get install landscape-api

To avoid having to pass the access key, secret key and endpoint URL everytime you call landscape-api, you can put them in a file and source it. For example, you can create a ~/.landscape-api.rc file with:

#!/bin/bash
export LANDSCAPE_API_KEY=”<API access key>”
export LANDSCAPE_API_SECRET=”<API secret key>”
export LANDSCAPE_API_URI=”https://<lds-hostname>/api/”

If you are using a custom Certificate Authority (CA), you will also need to tell the API tool where to find that certificate:

$ export LANDSCAPE_API_SSL_CA_FILE=”/path/to/ca/file”

All these variables can also be specified as command-line options to the landscape-api tool.

Now, before making an API request, just source that file and you are ready to go:

$ source ~/.landscape-api.rc

 

for i in `landscape-api get-computers  –query alert:computer-offline | grep \’id\’ | cut -d: -f2 | sed ‘s/,//g’`; do echo landscape-api remove-computers $i; done