NetWorker:如何使命令列 REST API JSON 回應人類可讀

Summary: 命令列 REST 應用程式發展介面 (API) 回應採用未格式化的 JSON,可能難以剖析。本知識文章提供將 REST API 回應格式化為「人類可讀」輸出的方法。

This article applies to This article does not apply to This article is not tied to any specific product. Not all product versions are identified in this article.

Instructions

可在 Linux NetWorker 伺服器上,使用 NetWorker Representational State Transfer (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.toolcurl 命令為貴組織設定主要和次要 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 系統,這可以通過附加來實現 jqcurl 命令:

[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 完成,這需要額外的功能,通常涉及編寫指令碼。大多數 Windows 系統都使用使用者介面 (例如 Post-Man) 來格式化 REST API GET 要求。

Additional Information

Affected Products

NetWorker

Products

NetWorker Family
Article Properties
Article Number: 000356014
Article Type: How To
Last Modified: 12 Aug 2025
Version:  1
Find answers to your questions from other Dell users
Support Services
Check if your device is covered by Support Services.