NetWorker:如何使命令行 REST API JSON 响应人类可读
摘要: 命令行 REST 应用程序编程接口 (API) 响应为未格式化的 JSON,这可能难以解析。本知识库文章提供了将 REST API 响应格式化为“人类可读”输出的方法。
本文章適用於
本文章不適用於
本文無關於任何特定產品。
本文未識別所有產品版本。
說明
可以使用以下命令从 Linux NetWorker 服务器上的命令行执行 NetWorker 表述性状态转移 (REST) API 调用: curl 命令为您的组织配置主要和次要 IT 联系人。例如:
curl -k -u USERNAME:'PASSWORD' https://localhost:9090/nwrestapi/v3/global/RESTAPI-ENDPOINT
提醒:将 USERNAME替换为用于向 NetWorker 进行身份验证的用户帐户。将 PASSWORD 替换为提供的用户帐户的密码。将 RESTAPI-ENDPOINT 替换为执行的 REST API 功能。REST API 文档可通过以下方式获得: https://developer.dell.com/apis/2378/versions/v3/docs/GettingStarted.md。
GET作的响应有效负载采用 JSON 格式。默认响应可能难以解析,因为它通常是连续行一次。例如:
nve:~ # curl -k -u Administrator:'!Password1' https://localhost:9090/nwrestapi/v3/global
{"links":[{"href":"https://localhost:9090/nwrestapi/v3/global/alerts","title":"List of alert messages"},{"href":"https://localhost:9090/nwrestapi/v3/global/auditlogconfig","title":"Audit log configuration"},{"href":"https://localhost:9090/nwrestapi/v3/global/auditlogconfigs","title":"Audit log configurations"},{"href":"https://localhost:9090/nwrestapi/v3/global/backups","title":"List of backups"},{"href":"https://localhost:9090/nwrestapi/v3/global/clients","title":"List of clients"},{"href":"https://localhost:9090/nwrestapi/v3/global/cloudboostappliances","title":"List of cloudboost appliances"},{"href":"https://localhost:9090/nwrestapi/v3/global/datadomainsystems","title":"List of data domain systems"},{"href":"https://localhost:9090/nwrestapi/v3/global/dddevicereplication","title":"DD device replication"},{"href":"https://localhost:9090/nwrestapi/v3/global/devices","title":"List of storage devices"},{"href":"https://localhost:9090/nwrestapi/v3/global/directives","title":"List of backup directives"},{"href":"https://localhost:9090/nwrestapi/v3/global/inspect","title":"Inspect remote/local server"},{"href":"https://localhost:9090/nwrestapi/v3/global/jobgroups","title":"List of job groups"},{"href":"https://localhost:9090/nwrestapi/v3/global/jobindications","title":"List of job indications"},{"href":"https://localhost:9090/nwrestapi/v3/global/jobs","title":"List of jobs"},{"href":"https://localhost:9090/nwrestapi/v3/global/jukeboxes","title":"List of jukeboxes"},{"href":"https://localhost:9090/nwrestapi/v3/global/labels","title":"List of volume label templates"},{"href":"https://localhost:9090/nwrestapi/v3/global/licenseconfig","title":"Server license configuration"},{"href":"https://localhost:9090/nwrestapi/v3/global/licenses","title":"List of license templates"},{"href":"https://localhost:9090/nwrestapi/v3/global/lockbox","title":"Lockbox resource"},{"href":"https://localhost:9090/nwrestapi/v3/global/mediaconfig","title":"Server media configuration"},{"href":"https://localhost:9090/nwrestapi/v3/global/mobilestorageunits","title":"Mobile storage units"},{"href":"https://localhost:9090/nwrestapi/v3/global/nasdevices","title":"List of NAS devices"},{"href":"https://localhost:9090/nwrestapi/v3/global/notifications","title":"List of notification settings"},{"href":"https://localhost:9090/nwrestapi/v3/global/nsrcloneconfig","title":"NSR Clone Configuration"},{"href":"https://localhost:9090/nwrestapi/v3/global/pools","title":"List of pools"},{"href":"https://localhost:9090/nwrestapi/v3/global/probes","title":"List of probes"},{"href":"https://localhost:9090/nwrestapi/v3/global/protectiongroups","title":"List of protection groups"},{"href":"https://localhost:9090/nwrestapi/v3/global/protectionpolicies","title":"List of protection policies"},{"href":"https://localhost:9090/nwrestapi/v3/global/recoverapps","title":"List of recovery applications"},{"href":"https://localhost:9090/nwrestapi/v3/global/recovers","title":"List of recover resources"},{"href":"https://localhost:9090/nwrestapi/v3/global/rules","title":"List of rules"},{"href":"https://localhost:9090/nwrestapi/v3/global/schedules","title":"List of schedules"},{"href":"https://localhost:9090/nwrestapi/v3/global/securityconfig","title":"Server security configuration"},{"href":"https://localhost:9090/nwrestapi/v3/global/serverconfig","title":"Server configuration"},{"href":"https://localhost:9090/nwrestapi/v3/global/servermessages","title":"List of server messages"},{"href":"https://localhost:9090/nwrestapi/v3/global/serverstatistics","title":"Server statistics"},{"href":"https://localhost:9090/nwrestapi/v3/global/sessions","title":"List of save/recover sessions"},{"href":"https://localhost:9090/nwrestapi/v3/global/storagenodes","title":"List of storage nodes"},{"href":"https://localhost:9090/nwrestapi/v3/global/tenants","title":"Restricted data zone protection"},{"href":"https://localhost:9090/nwrestapi/v3/global/timepolicies","title":"List of Time Policies"},{"href":"https://localhost:9090/nwrestapi/v3/global/unconfiguredlibraries","title":"List of unconfigured libraries"},{"href":"https://localhost:9090/nwrestapi/v3/global/usergroups","title":"List of user groups"},{"href":"https://localhost:9090/nwrestapi/v3/global/vmware","title":"View of VMware objects"},{"href":"https://localhost:9090/nwrestapi/v3/global/volumes","title":"List of volumes"}]}
JSON 输出未格式化,可能难以解析;但是,输出可以格式化为更易于阅读的“漂亮打印”格式。
对于 NetWorker Virtual Edition (NVE) 系统,您可以附加 python -m json.tool 到 curl 命令为您的组织配置主要和次要 IT 联系人。例如:
nve:~ # curl -k -u Administrator:'!Password1' https://localhost:9090/nwrestapi/v3/global | python -m json.tool
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 4374 0 4374 0 0 9751 0 --:--:-- --:--:-- --:--:-- 9763
{
"links": [
{
"href": "https://localhost:9090/nwrestapi/v3/global/alerts",
"title": "List of alert messages"
},
{
"href": "https://localhost:9090/nwrestapi/v3/global/auditlogconfig",
"title": "Audit log configuration"
},
{
"href": "https://localhost:9090/nwrestapi/v3/global/auditlogconfigs",
"title": "Audit log configurations"
},
{
"href": "https://localhost:9090/nwrestapi/v3/global/backups",
"title": "List of backups"
},
{
"href": "https://localhost:9090/nwrestapi/v3/global/clients",
"title": "List of clients"
},
******* Removed for brevity *******
]
}
对于其他 Linux 系统,这可以通过附加 jq 到 curl 命令执行此操作:
[root@nsr ~]# curl -k -u Administrator:'!Password1' https://localhost:9090/nwrestapi/v3/global | jq
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 4258 0 4258 0 0 7253 0 --:--:-- --:--:-- --:--:-- 7241
{
"links": [
{
"href": "https://localhost:9090/nwrestapi/v3/global/alerts",
"title": "List of alert messages"
},
{
"href": "https://localhost:9090/nwrestapi/v3/global/auditlogconfig",
"title": "Audit log configuration"
},
{
"href": "https://localhost:9090/nwrestapi/v3/global/auditlogconfigs",
"title": "Audit log configurations"
},
{
"href": "https://localhost:9090/nwrestapi/v3/global/backups",
"title": "List of backups"
},
{
"href": "https://localhost:9090/nwrestapi/v3/global/clients",
"title": "List of clients"
},
******* Removed for brevity *******
]
}
提醒:
jq 不包含在 NetWorker 中,这是可安装在系统上的第三方实用程序。请咨询系统管理员以进行安装 jq 或其他需要的 JSON 格式化实用程序。
对于 Windows 主机,不太可能使用命令行来实现此目的。这通常通过 PowerShell 完成,PowerShell需要额外的功能,通常涉及脚本编制。大多数基于 Windows 的系统使用 Post-Man 等用户界面来格式化 REST API GET 请求。
其他資訊
受影響的產品
NetWorker產品
NetWorker Family文章屬性
文章編號: 000356014
文章類型: How To
上次修改時間: 12 8月 2025
版本: 1
向其他 Dell 使用者尋求您問題的答案
支援服務
檢查您的裝置是否在支援服務的涵蓋範圍內。