PDF

Atlas Views and Folders

Views and Folders API allows us to add, remove, access, and retrieve Folders and Views data in NetCrunch.

add-view

Add View

Add a static view to the atlas. If no parent folder is provided, the view will be added on the "Custom Views" level.

POST/api/rest/2/views

cURL

curl --request POST --url "https://localhost/api/rest/2/views?api_key=<your-api-key>" --header "Content-Type: application/json" --data "{\"name\": \"New view\"}"

Node.js

const http = require('http'), options = { method: 'POST', hostname: 'localhost', path: '/api/rest/2/views', headers: { 'Content-Type': 'application/json', "x-api-key": '<your-api-key>' } }, viewData = { "name": "New View" }; const req = http.request(options, (res) => { res.setEncoding('utf8'); res.on('error', (error) => { console.log(error) }); res.on('data', (chunk) => { console.log(chunk) }) }); req.write(JSON.stringify(viewData)); req.end();

PowerShell

$url = "http://localhost/api/rest/2/views" $viewData = @{ name='New View' } $body = (ConvertTo-Json $viewData) $hdrs = @{} $hdrs.Add("X-API-KEY","<your-api-key>") $hdrs.Add("Content-Type","application/json") Invoke-RestMethod -Uri $url -Method Post -Body $body -Headers $hdrs

Python

import requests url = 'http://localhost/api/rest/2/views' data = { "name": "New View" } headers = { 'Content-Type': 'application/json', 'x-api-key': '<your-api-key>' } requests.post(url=url, data=data, headers=headers)

Parameters

Name Description
name Name of the new view
parent ID, name or path to parent map

Status Codes

Status Code Description
200 OK
400 Name is missing
400 NetCrunch request error
401 Access Denied
412 No API Key

Result

The result contains the id of the added (or found) view.

{ "id": 1001 }

add-folder

Add Folder

Add empty folder to the Atlas. If no parent folder is provided, it will be added on the "Custom Views" level.

POST/api/rest/2/views/folder

cURL

curl --request POST --url "https://localhost/api/rest/2/views/folder?api_key=<your-api-key>" --header "Content-Type: application/json" --data "{\"name\": \"New Folder\"}"

Node.js

const http = require('http'), options = { method: 'POST', hostname: 'localhost', path: '/api/rest/2/views/folder', headers: { 'Content-Type': 'application/json', "x-api-key": '<your-api-key>' } }, viewData = { "name": "New Folder" }; const req = http.request(options, (res) => { res.setEncoding('utf8'); res.on('error', (error) => { console.log(error) }); res.on('data', (chunk) => { console.log(chunk) }) }); req.write(JSON.stringify(viewData)); req.end();

PowerShell

$url = "http://localhost/api/rest/2/views/folder" $viewData = @{ name='New Folder' } $body = (ConvertTo-Json $viewData) $hdrs = @{} $hdrs.Add("X-API-KEY","<your-api-key>") $hdrs.Add("Content-Type","application/json") Invoke-RestMethod -Uri $url -Method Post -Body $body -Headers $hdrs

Python

import requests url = 'http://localhost/api/rest/2/views/folder' data = { "name": "New Folder" } headers = { 'Content-Type': 'application/json', 'x-api-key': '<your-api-key>' } requests.post(url=url, data=data, headers=headers)

Parameters

Name Description
name Name of the new view
parent ID, name or path to parent map

Status Codes

Status Code Description
200 OK
400 Name is missing
400 NetCrunch request error
401 Access denied
412 No API key

Result

{ "id": 1001 }

get-view-properties

Get View Properties

Get properties of the view based on the filter.

List of Properties

List Of Additional IP Network View Properties

GET/api/rest/2/views/<view>?properties=<filter>

cURL

curl --url "http://localhost/api/rest/2/views/Custom%20Views?api_key=<your-api-key>&properties=name,status"

Node.js

const http = require('http'); http.get('http://localhost/api/rest/2/views/Custom%20Views?api_key=<your-api-key>&properties=name,status', (res) => { res.setEncoding('utf8'); res.on('error', (error) => { console.log(error) }); res.on('data', (chunk) => { console.log(chunk) }) });

PowerShell

Invoke-RestMethod -Uri "http://localhost/api/rest/2/views/Custom%20Views?api_key=<your-api-key>&properties=name,status"

Python

import requests requests.get('http://localhost/api/rest/2/views/Custom%20Views?api_key=<your-api-key>&properties=name,status')

Parameters

Name Description
view View ID, name or path
filter List of properties. Returns all properties if omitted, value is "all" or "*"

Status Codes

Status Code Description
200 OK
401 Access denied
404 View not found

Result

{  "id": 1050,  "name": "Parent",  "status": "unknown",  "stats": {    "nodes": {      "total": 0,      "ok": 0,      "unknown": 0,      "warning": 0,      "error": 0,      "alerts": {        "active": 0,        "las24Hours": {          "unacknowledged": 0,          "total": 0,          "critical": 0,          "warning": 0        }      }    },    "maps": {      "total": 2,      "ok": 0,      "unknown": 0,      "warning": 2,      "error": 0    }  },  "path": "/Custom Views",  "isDynamic": true,  "isFolder": true,  "readOnly": false  }

get-view-property

Get View Property

Get a single property of the view.

GET/api/rest/2/views/<view>/<property>

List of Properties

[List Of Additional IP Network View Properties](@api-data-properties:ip-network-property-list

cURL

curl --url "http://localhost/api/rest/2/views/Custom%20Views/id?api_key=<your-api-key>"

Node.js

const http = require('http'); http.get('http://localhost/api/rest/2/views/Custom%20Views/id?api_key=<your-api-key>', (res) => { res.setEncoding('utf8'); res.on('error', (error) => { console.log(error) }); res.on('data', (chunk) => { console.log(chunk) }) });

PowerShell

Invoke-RestMethod -Uri "http://localhost/api/rest/2/views/Custom%20Views/id?api_key=<your-api-key>"

Python

import requests requests.get('http://localhost/api/rest/2/views/Custom%20Views/id?api_key=<your-api-key>')

Parameters

Name Description
view Name ID or path to the view
property Name of the property to get

Status Codes

Status Code Description
200 OK
401 Access denied
404 View not found

Result

{ "id": 1001 }

set-view-property

Set View Property

Set or change view property

PUT/api/rest/2/views/<view>

cURL

curl --request PUT --url "https://localhost/api/rest/2/views/1050?api_key=<your-api-key>" --header "Content-Type: application/json" --data "{\"name\": \"New Name\"}"

Node.js

const http = require('http'), options = { method: 'PUT', hostname: 'localhost', path: '/api/rest/2/views/1050', headers: { 'Content-Type': 'application/json', "x-api-key": '<your-api-key>' } }, viewData = { "name": "New Name" }; const req = http.request(options, (res) => { res.setEncoding('utf8'); res.on('error', (error) => { console.log(error) }); res.on('data', (chunk) => { console.log(chunk) }) }); req.write(JSON.stringify(viewData)); req.end();

PowerShell

$url = "http://localhost/api/rest/2/views/1050" $viewData = @{ name='New Name' } $body = (ConvertTo-Json $viewData) $hdrs = @{} $hdrs.Add("X-API-KEY","<your-api-key>") $hdrs.Add("Content-Type","application/json") Invoke-RestMethod -Uri $url -Method Put -Body $body -Headers $hdrs

Python

import requests url = 'http://localhost/api/rest/2/views/1050' data = { "name": "New Name" } headers = { 'Content-Type': 'application/json', 'x-api-key': '<your-api-key>' } requests.put(url=url, data=data, headers=headers)

Parameters

Name Description
view View ID, name or path
property Name of view property to set

Status Codes

Code Description
200 OK
401 Access denied
404 View Not Found

Result

{ "status": "ok" }

get-list-of-nodes-in-the-view

Get List of Nodes in the View

Get the list of Nodes Present in the View.

GET/api/rest/2/views/<view>/nodes

cURL

curl --url "http://localhost/api/rest/2/views/Unresponding%20Nodes/nodes?api_key=<your-api-key>"

Node.js

const http = require('http'); http.get('http://localhost/api/rest/2/views/Unresponding%20Nodes/nodes?api_key=<your-api-key>', (res) => { res.setEncoding('utf8'); res.on('error', (error) => { console.log(error) }); res.on('data', (chunk) => { console.log(chunk) }) });

PowerShell

Invoke-RestMethod -Uri "http://localhost/api/rest/2/views/Unresponding%20Nodes/nodes?api_key=<your-api-key>"

Python

import requests requests.get('http://localhost/api/rest/2/views/Unresponding%20Nodes/nodes?api_key=<your-api-key>')

Parameters

Name Description
view Name ID or path to the view
property Name of the property to get

Status Codes

Status Code Description
200 OK
401 Access denied
404 View not found

Result

[ {"id":1019,"name":"foo","networkAddress":"192.168.1.89","dnsName":"foo.test.com"}, {"id":1019,"name":"bar","networkAddress":"192.168.1.10","dnsName":"bar.test.com"} ]

add-node-to-the-view

Add Node to the View

Add the monitored node to a view.

POST/api/rest/2/views/<view>/nodes/<node>

cURL

curl --request POST --url "https://localhost/api/rest/2/views/New%20View/nodes/192.168.1.10?api_key=<your-api-key>"

Node.js

const http = require('http'), querystring = require('querystring'), options = { method: 'POST', hostname: 'localhost', path: '/api/rest/2/views/' + querystring.escape('New View') + '/nodes/192.168.1.10' , headers: { "x-api-key": '<your-api-key>' } }; const req = http.request(options, (res) => { res.setEncoding('utf8'); res.on('error', (error) => { console.log(error) }); res.on('data', (chunk) => { console.log(chunk) }) }); req.end();

PowerShell

$url = "http://localhost/api/rest/2/views/New%20View/nodes/192.168.1.10" $hdrs = @{} $hdrs.Add("X-API-KEY","<your-api-key>") $hdrs.Add("Content-Type","application/json") Invoke-RestMethod -Uri $url -Method Post -Headers $hdrs

Python

import requests url = 'http://localhost/api/rest/2/views/New%20View/nodes/192.168.1.10' headers = { 'Content-Type': 'application/json', 'x-api-key': '<your-api-key>' } response = requests.post(url=url, headers=headers)

Parameters

Name Description
view Name ID or path to the view
node ID, name or IP address of the node to add

Status Codes

Status Code Description
200 OK
401 Access denied
404 View or node not found

Result

{ "status":"ok" }

remove-node-from-the-view

Remove Node From the View

Remove the node from a view.

DELETE/api/rest/2/views/<view>/nodes/<node>

cURL

curl --request DELETE --url "https://localhost/api/rest/2/views/New%20View/nodes/192.168.1.10?api_key=<your-api-key>"

Node.js

const http = require('http'), querystring = require('querystring'), options = { method: 'DELETE', hostname: 'localhost', path: '/api/rest/2/views/' + querystring.escape('New View') + '/nodes/192.168.1.10', headers: { "x-api-key": '<your-api-key>' } }; const req = http.request(options, (res) => { res.setEncoding('utf8'); res.on('error', (error) => { console.log(error) }); res.on('data', (chunk) => { console.log(chunk) }) }); req.end();

PowerShell

$url = "http://localhost/api/rest/2/views/New%20View/nodes/192.168.1.10" $hdrs = @{} $hdrs.Add("X-API-KEY","<your-api-key>") $hdrs.Add("Content-Type","application/json") Invoke-RestMethod -Uri $url -Method Delete -Headers $hdrs

Python

import requests url = 'http://localhost/api/rest/2/views/New%20View/nodes/192.168.1.10' headers = { 'Content-Type': 'application/json', 'x-api-key': '<your-api-key>' } response = requests.delete(url=url, headers=headers)

Parameters

Name Description
view Name ID or path to the view
node ID, name or IP address of the node to remove

Status Codes

Status Code Description
200 OK
401 Access denied
404 View or node not found

Result

{ "status":"ok" }

enable-ip-network-view-monitoring

Enable IP Network View Monitoring

Enable monitoring of all nodes in the view

PUT/api/rest/2/views/<view>/enable

cURL

curl --request PUT --url "https://localhost/api/rest/2/views/1050/enable?api_key=<your-api-key>"

Node.js

const http = require('http'), options = { method: 'PUT', hostname: 'localhost', path: '/api/rest/2/views/1050/enable', headers: { 'Content-Type': 'application/json', "x-api-key": '<your-api-key>' } }; const req = http.request(options, (res) => { res.setEncoding('utf8'); res.on('error', (error) => { console.log(error) }); res.on('data', (chunk) => { console.log(chunk) }) }); req.end();

PowerShell

$url = "http://localhost/api/rest/2/views/1050/enable" $hdrs = @{} $hdrs.Add("X-API-KEY","<your-api-key>") $hdrs.Add("Content-Type","application/json") Invoke-RestMethod -Uri $url -Method Put -Headers $hdrs

Python

import requests url = 'http://localhost/api/rest/2/views/1050/enable' headers = { 'Content-Type': 'application/json', 'x-api-key': '<your-api-key>' } requests.put(url=url, headers=headers)

Parameters

Name Description
view View ID, name or path

Status Codes

Status Code Description
200 OK
401 Access denied
404 View not found

Result

{ "status":"ok" }

disable-ip-network-view-monitoring

Disable IP Network View Monitoring

Disable monitoring of all nodes in the view

PUT/api/rest/2/views/<view>/disable

cURL

curl --request PUT --url "https://localhost/api/rest/2/views/1050/disable?api_key=<your-api-key>" --header "Content-Type: application/json" --data "{\"disabledFrom\": \"2019-01-01T13:27:34.876Z\", \"disabledUntil\": \""2019-02-01T13:27:34.876Z"\"}"

Node.js

const http = require('http'), options = { method: 'PUT', hostname: 'localhost', path: '/api/rest/2/views/1050/disable', headers: { 'Content-Type': 'application/json', "x-api-key": '<your-api-key>' } }, viewData = { "disabledFrom": "2019-01-01T13:27:34.876Z", "disabledUntil": "2019-02-01T13:27:34.876Z" };

PowerShell

$url = "http://localhost/api/rest/2/views/1050/disable" $viewData = @{ disabledFrom: '2019-01-01T13:27:34.876Z', disabledUntil: '2019-02-01T13:27:34.876Z' } $body = (ConvertTo-Json $viewData) $hdrs = @{} $hdrs.Add("X-API-KEY","<your-api-key>") $hdrs.Add("Content-Type","application/json") Invoke-RestMethod -Uri $url -Method Put -Body $body -Headers $hdrs

Python

import requests url = 'http://localhost/api/rest/2/views/1050/disable' data = { "disabledFrom": "2019-01-01T13:27:34.876Z", "disabledUntil": "2019-02-01T13:27:34.876Z" } headers = { 'Content-Type': 'application/json', 'x-api-key': '<your-api-key>' } requests.put(url=url, data=data, headers=headers)

Parameters

Name Description
view View ID, name or path
disabledFrom 2018-03-08T13:27:34.876Z
disabledUntil 2018-03-09T13:27:34.876Z

Status Codes

Status Code Description
200 OK
401 Access denied
404 View not found

Result

{ "status":"ok" }

delete-view

Delete View

Remove view from the Atlas.

DELETE/api/rest/2/views/<view>

cURL

curl --request DELETE --url "https://localhost/api/rest/2/views/New%20View?api_key=<your-api-key>"

Node.js

const http = require('http'), querystring = require('querystring'), options = { method: 'DELETE', hostname: 'localhost', path: '/api/rest/2/views/' + querystring.escape('New View'), headers: { "x-api-key": '<your-api-key>' } }; const req = http.request(options, (res) => { res.setEncoding('utf8'); res.on('error', (error) => { console.log(error) }); res.on('data', (chunk) => { console.log(chunk) }) }); req.end();

PowerShell

$url = "http://localhost/api/rest/2/views/New%20View" $hdrs = @{} $hdrs.Add("X-API-KEY","<your-api-key>") $hdrs.Add("Content-Type","application/json") Invoke-RestMethod -Uri $url -Method Delete -Headers $hdrs

Python

import requests url = 'http://localhost/api/rest/2/views/New%20View' headers = { 'Content-Type': 'application/json', 'x-api-key': '<your-api-key>' } response = requests.delete(url=url, headers=headers)

Parameters

Name Description
view Name or ID or path of the view to delete

Status Codes

Status Code Description
200 OK
401 Access denied
404 View not found

Result

{ "id": 1001 }