認証情報

Credentials APIを使用すると、NetCrunchで認証情報の情報を取得や削除ができます。

get-credential-types

認証情報タイプを取得する

認証情報タイプのリストを配列として取得します

GET/api/rest/2/credentials

cURL

curl --url "http://localhost/api/rest/2/credentials?api_key=<your-api-key>""

Node.js

const http = require('http'); http.get('http://localhost/api/rest/2/credentials?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/credentials?api_key=<your-api-key>"

Python

import requests requests.get('http://localhost/api/rest/2/credentials?api_key=<your-api-key>')

ステータスコード

ステータスコード 説明
200 OK
401 アクセスが拒否されました

結果

["BSD","ESXi","Linux","Mac OS X","Solaris","Windows","Database Connection","HTTP","Email incoming","IPMI","Email (SMTP)","Simple"]

get-names-of-defined-credentials

定義された認証情報の名前を取得する

定義された認証情報のリストを取得します

GET/api/rest/2/credentials/<type>

cURL

curl --url "http://localhost/api/rest/2/credentials/Windows?api_key=<your-api-key>"

Node.js

const http = require('http'); http.get('http://localhost/api/rest/2/credentials/Windows?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/credentials/Windows?api_key=<your-api-key>"

Python

import requests requests.get('http://localhost/api/rest/2/credentials/Windows?api_key=<your-api-key>')

パラメーター

名前 説明
type 認証情報のタイプ

ステータスコード

ステータスコード 説明
200 OK
401 アクセスが拒否されました

結果

["<Default>","New Profile"]

remove-credentials

認証情報を削除する

DELETE/api/rest/2/credentials/<type>/<name>

cURL

curl --request DELETE --url "http://localhost/api/rest/2/credentials/Windows/MyCredentials?api_key=<your-api-key>"

Node.js

const http = require('http'), options = { method: 'DELETE', hostname: 'localhost', path: '/api/rest/2/credentials/Windows/MyCredentials' , 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/credentials/Windows/MyCredentials" $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/credentials/Windows/MyCredentials' headers = { 'Content-Type': 'application/json', 'x-api-key': '<your-api-key>' } response = requests.delete(url, headers=headers)

パラメーター

名前 説明
type 認証情報のタイプ
name 削除する認証情報の名前

ステータスコード

ステータスコード 説明
200 OK
401 アクセスが拒否されました

結果

{"status":"success","message":"OK"}