Hosts

manage your hosts via the API

get
Get Hosts

https://api.cloudradar.io/v1/hosts/
This endpoint allows you to get all hosts from your account.
Request
Response
Headers
Authentication
required
string
Bearer <TOKEN>
200: OK
List of hosts successfully retrieved.
{
"hosts": [
{
"uuid": "be9b90f4-5dff-4fec-8ef4-bb2bea07bf5c",
"name": "12x.hostgum.eu",
"connect": "12x.hostgum.eu",
"description": "Nice host. Isn't it?",
"tags": [],
"active": true,
"cagent": false,
"cagentLastUpdate": 0,
"metrics": 0,
"dashboard": false,
"muted": false,
"frontman": {
"uuid": "24995c49-45ba-43d6-9205-4f5e83d32a11",
"location": "EU-WEST-Netherlands",
"lastHeartbeatTimestamp": 1556105815,
"type": "public"
}
}
]
}
curl -X GET \
https://api.cloudradar.xyz/v1/hosts/ \
-H 'Authorization: Bearer 33891543f62ead9e18c32e1252e320c2710f708d9085fd5b'

Example

get-hosts.py
#!/usr/bin/env python
import requests
import sys
token = '33891543f62ead9e18c32e1252e320c2710f708d9085fd5b'
url = 'https://api.cloudradar.io/v1/hosts/'
headers = { 'Authorization': 'Bearer '+token }
response = requests.request("GET", url, headers=headers)
if response.status_code != 200:
sys.stderr.write("Request failed. " + response.text)
sys.exit(response.status_code)
# Decode the json object to a python list
hosts = response.json()['hosts']
# Iterate over the list
for host in hosts:
print("Name: %s, Connect: %s, Muted: %s" % (host['name'],host['connect'],host['muted']))

post
Create a host

https://api.cloudradar.io/v1/hosts/
Create a new host for the monitoring. See schema specifications https://api.cloudradar.io/v1/hosts/post-schema.json.
Request
Response
Headers
Authentication
required
string
Bearer <TOEKEN>
200: OK
{
"success": true,
"error": null,
"details": "host created",
"host": {
"name": "test.hostgum.eu",
"connect": "test.hostgum.eu",
"description": "Nice host. Isn't it?",
"tags": [
"Tag 1",
"Location:Berlin",
"OS:Linux",
"Option 1"
],
"cagent": 1,
"dashboard": 1,
"uuid": "35ff5879-e9ab-4577-9778-577666490a64",
"teamUuid": "cd94b3e1-d3c9-48a2-859e-fc64057b8729",
"createTimestamp": 1556105956,
"createdByUuid": "b6e57228-dad2-49ec-82f3-88b1c52a314c",
"active": 1,
"muted": 0,
"hub_password": "Dz9pkkCrxtoc",
"hub_url": "https://hub.cloudradar.xyz/ctrapper/",
"frontman": {
"uuid": "24995c49-45ba-43d6-9205-4f5e83d32a11",
"location": "EU-WEST-Netherlands"
}
}
}
422: Unprocessable Entity
Failed host creation
{
"success": false,
"error": "Duplicate host",
"details": "A a host with the connect (FQDN/IP) '1.hostgum.eu' already exist.",
"host": {
"uuid": "4ad9936f-f6ff-4484-b1ae-fd2c2e0e3d10",
"name": "12.hostgum.eu",
"connect": "1.hostgum.eu",
"description": "Nice host. Isn't it?",
"tags": [
"Tag 1",
"Location:Berlin",
"OS:Linux",
"Option 1"
],
"hub_password": "wtEHsAFrhVys",
"hub_url": "https://hub.cloudradar.io/ctrapper/"
}
}
Add a host
curl -X POST \
https://api.cloudradar.io/v1/hosts/ \
-H 'Authorization: Bearer 33891543f62ead9e18c32e1252e320c2710f708d9085fd5b' \
-d '{
"name":"host.example.com",
"connect":"host.example.com",
"description":"Nice host. Isn'\''t it?",
"tags": ["Tag 1","Tag 2","Berlin","Server"],
"cagent":true,
"dashboard":true
}'

delete
Delete a host

https://api.cloudradar.io/v1/hosts/<HOST_UUID>
Delete a host and optionally purge historical data from the reports.
Request
Response
Path Parameters
Host UUID
required
string
Host UUID
Headers
Authentication
required
string
Bearer <TOKEN>
Query Parameters
purgeFromReports=1
optional
integer
Purge data from reports
200: OK
curl -X DELETE \
'https://api.cloudradar.xyz/v1/hosts/4ad9936f-f6ff-4484-b1ae-fd2c2e0e3d10?purgeFromReports=1' \
-H 'Authorization: Bearer 33891543f62ead9e18c32e1252e320c2710f708d9085fd5b'

patch
Update host properties

https://api.cloudradar.io/v1/hosts/<HOST_UUID>
Update the host or some properties of it. See schema specifications https://api.cloudradar.io/v1/hosts/patch-schema.json.
Request
Response
Headers
Authentication
required
string
Bearer <TOKEN>
200: OK
curl -X PATCH \
https://api.cloudradar.xyz/v1/hosts/be9b90f4-5dff-4fec-8ef4-bb2bea07bf5c \
-H 'Authorization: Bearer 33891543f62ead9e18c32e1252e320c2710f708d9085fd5b' \
-d '{
"name":"host2.example.com",
"connect":"1.1.1.1",
"tags":[],
"active": true,
"cagent": false
}'

The following example shows how to mute a host from the command line with a simple python script. The host UUID is expected as a command line parameter, for example python mute-host.py d25ad016-d40a-46e8-9aaa-b7df6929cfe0

Example

mute-host.py
#!/usr/bin/env python
import requests
import sys
import json
hostUUID = sys.argv[1]
token = '33891543f62ead9e18c32e1252e320c2710f708d9085fd5b'
url = 'https://api.cloudradar.io/v1/hosts/' + sys.argv[1]
headers = { 'Authorization': 'Bearer '+token }
payload = { 'muted': True }
response = requests.request("PATCH", url, data=json.dumps(payload), headers=headers)
if response.status_code != 200:
sys.stderr.write("Request failed. " + response.text + "\n")
sys.exit(response.status_code)
print("Request sent.")

Mute all hosts

mute-all-hosts.py
#!/usr/bin/env python
import requests
import sys
import json
token = '33891543f62ead9e18c32e1252e320c2710f708d9085fd5b'
url = 'https://api.cloudradar.io/v1/hosts/'
headers = { 'Authorization': 'Bearer '+token }
#
# Get list of all hosts
#
response = requests.request("GET", url, headers=headers)
if response.status_code != 200:
sys.stderr.write("Request failed. " + response.text)
sys.exit(response.status_code)
# Decode the json object to a python list
hosts = response.json()['hosts']
payload = { 'muted': True }
# Iterate over the list
for host in hosts:
url = 'https://api.cloudradar.io/v1/hosts/' + host['uuid']
response = requests.request("PATCH", url, data=json.dumps(payload), headers=headers)
if response.status_code != 200:
sys.stderr.write("Request failed. " + response.text + "\n")
sys.exit(response.status_code)
print("Host %s muted" % host['name'])