The basic syntax for connecting to the SiteScope REST API is.
http://<SiteScope hostname or IP address>:<port>/SiteScope/<endpoint>
For example, let's say your SiteScope system has DNS name sitescope.example.com and is listening for HTTP connections on port 8080. The following URL would then be used.
http://sitescope.example.com:8080/SiteScope/api/templates/export
In this example, a GET request would be used. Connections to SiteScope require some form of authentication, such as basic auth (username / password) or via client certification authentication using a public certificate.
As a practical example, here is how you could submit the GET request using curl on Linux.
curl --request GET --user john.doe:itsasecret --url http://sitescope.example.com:8080/SiteScope/api/templates/export
Which should return JSON like this.
{
"1221424182": {
"AllowedCIs": "",
"ConfigurationID": "1221424182",
"Name": "Solaris Host",
"OS_TYPE": "",
"alertBlueprintChildren": {},
"estimatedNumberOfPoints": "0",
"groupBlueprintChildrenField": {},
"monitorBlueprintChildren": {},
"remoteMachinePlaceHolderChildren": {},
"templateContainerNames": [
"Solution Templates"
],
"templateDescription": null,
"templateType": "userDefinedTemplateType",
"variableBlueprintChildren": {}
}
}
The API is not limited to curl on Linux. For example, here is how you could submit the GET request using Python.
#!/usr/bin/python
import json, requests
from requests.auth import HTTPBasicAuth
try:
response = requests.get("http://sitescope.example.com:8080/SiteScope/api/templates/export", auth = HTTPBasicAuth('john.doe','itsasecret'))
except requests.exceptions.RequestException as e:
print("Got the following exception:")
print(e)
else:
print(response.json())
And here is how you could submit the GET request using Ansible.
---
- hosts: all
tasks:
- uri:
url: http://sitescope.example.com:8080/SiteScope/api/monitors
force_basic_auth: yes
url_username: john.doe
url_password: itsasecret
register: out
- debug:
var: out
...
Did you find this article helpful?
If so, consider buying me a coffee over at