PDF

Widoki i foldery Atlasu

API widoków i folderów pozwala dodawać, usuwać, uzyskiwać dostęp i pobierać dane z folderów i widoków w NetCrunchu.

add-view

Dodaj widok

Dodaj statyczny widok do Atlasu. Jeśli folder nadrzędny nie zostanie podany, widok zostanie dodany z poziomu „Widoki własne".

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)

Parametry

Nazwa Opis
name Nazwa nowego widoku
parent ID, nazwa lub ścieżka do mapy nadrzędnej

Kody statusu

Kod statusu Opis
200 OK
400 Brak nazwy
400 Błąd żądania NetCruncha
401 Brak dostępu
412 Brak klucza API

Wynik

Wynik zawiera ID dodanego (lub znalezionego) widoku

{ "id": 1001 }

add-folder

Dodaj folder

Dodaj pusty folder do atlasu. Jeśli folder nadrzędny nie zostanie podany, zostanie dodany na poziomie „Widoki własne"

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)

Parametry

Nazwa Opis
name Nazwa nowego widoku
parent ID, nazwa lub ścieżka do mapy nadrzędnej

Kody statusu

Kod statusu Opis
200 OK
400 Brak nazwy
400 Błąd żądania NetCruncha
401 Brak dostępu
412 Brak klucza API

Wynik

{ "id": 1001 }

get-view-properties

Uzyskaj właściwości widoku

Uzyskaj właściwości widoku na podstawie filtru

Lista właściwości

Lista dodatkowych właściwości widoku sieci IP

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')

Parametry

Name Description
view ID widoku, nazwa lub ścieżka
filter Lista właściwości. Zwraca wszystkie właściwości, a w razie pominięcia wartość wynosi "all" lub "*"

Kody statusu

Kod statusu Opis
200 OK
401 Brak dostępu
404 Nie znaleziono widoku

Wynik

{  "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

Uzyskaj właściwość widoku

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

Lista właściwości

[Lista dodatkowych właściwości widoku sieci IP](@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>')

Parametry

Nazwa Opis
view Nazwa, ID lub ścieżka do widoku
property Nazwa właściwości do uzyskania

Kody statusu

Kod statusu Opis
200 OK
401 Brak dostępu
404 Nie znaleziono widoku

Wynik

{ "id": 1001 }

set-view-property

Ustaw właściwość widoku

Ustaw lub zmień właściwość widoku

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

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)

Parametry

Nazwa Opis
view ID widoku, nazwa lub ścieżka
property Nazwa właściwości do ustawienia

Kody statusu

Kod statusu Opis
200 OK
401 Brak dostępu
404 Nie znaleziono widoku

Wynik

{ "status": "ok" }

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

Uzyskaj listę węzłów w widoku

Uzyskaj listę węzłów obecnych w widoku

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>')

Parametry

Nazwa Opis
view Nazwa, ID lub ścieżka do widoku
property Nazwa właściwości do uzyskania

Kody statusu

Kod statusu Opis
200 OK
401 Brak dostępu
404 Nie znaleziono widoku

Wynik

[ {"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

Dodaj węzeł do widoku

Dodaj monitorowany węzeł do widoku

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)

Parametry

Nazwa Opis
view Nazwa, ID lub ścieżka do widoku
node ID, nazwa lub adres IP węzła do dodania

Kody statusu

Kod statusu Opis
200 OK
401 Brak dostępu
404 Nie znaleziono widoku lub węzła

Wynik

{ "status":"ok" }

remove-node-from-the-view

Usuń węzeł z widoku

Usuń węzeł z widoku

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)

Parametry

Nazwa Opis
view Nazwa, ID lub ścieżka do widoku
node ID, nazwa lub adres IP węzła do usunięcia

Kody statusu

Kod statusu Opis
200 OK
401 Brak dostępu
404 Nie znaleziono widoku lub węzła

Wynik

{ "status":"ok" }

enable-ip-network-view-monitoring

Włącz monitorowanie widoku sieci IP

Włącz monitorowanie wszystkich węzłów w widoku

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)

Parametry

Nazwa Opis
view ID widoku, nazwa lub ścieżka

Kody statusu

Kod statusu Opis
200 OK
401 Brak dostępu
404 Nie znaleziono widoku

Wynik

{ "status":"ok" }

disable-ip-network-view-monitoring

Wyłącz monitorowanie widoku sieci IP

Wyłącz monitorowanie wszystkich węzłów w widoku

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)

Parametry

Nazwa Opis
view ID widoku, nazwa lub ścieżka
disabledFrom 2018-03-08T13:27:34.876Z
disabledUntil 2018-03-09T13:27:34.876Z

Kody statusu

Kod statusu Opis
200 OK
401 Brak dostępu
404 Nie znaleziono widoku

Wynik

{ "status":"ok" }

delete-view

Usuń widok

Usuń widok z atlasu

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)

Parametry

Nazwa Opis
view Nazwa, ID lub ścieżka widoku do usunięcia

Kody statusu

Kod statusu Opis
200 OK
401 Brak dostępu
404 Nie znaleziono widoku

Wynik

{ "id": 1001 }