Skip to main content
Data Infrastructure Insights
本繁體中文版使用機器翻譯,譯文僅供參考,若與英文版本牴觸,應以英文版本為準。

透過API存取報告資料庫

貢獻者

Data Infrastructure Insights 強大的 API 可讓使用者直接查詢 Data Infrastructure Insights Reporting 資料庫、而無需瀏覽 Cognos Reporting 環境。

註 本文件是指 Data Infrastructure Insights Premium Edition 中提供的 Data Infrastructure Insights Reporting 功能。

OData

Data Infrastructure Insights Reporting API 遵循"OData v4"(開放式資料傳輸協定)標準來查詢報告資料庫。如需更多資訊或深入瞭解、請參閱 "本教學課程"OData 。

所有申請都將以 URL https://<Data 基礎架構洞見 URL>/rest/v1/dwh-management / oData_ 開始

產生APIKey

瞭解更多關於"Data Infrastructure Insights API"的資訊。

若要產生API金鑰、請執行下列動作:

  • 登入您的 Data Infrastructure Insights 環境、然後選取 * 管理 > API 存取 * 。

  • 按一下「+ API存取權杖」。

  • 輸入名稱與說明。

  • 針對類型、選擇_Data倉儲。

  • 將權限設為讀取/寫入。

  • 設定期望到期日。

  • 按一下「Save(儲存)」、然後*複製金鑰並將其儲存*到安全的地方。您稍後將無法存取完整金鑰。

APIkeys 很適合 SyncAsynSync

直接查詢資料表

有了API金鑰、現在就能直接查詢報告資料庫。長 URL 可簡化為 https://…​/odata/ 以供顯示、而非完整的 https://<Data 基礎架構洞見 URL>/rest / v1/dwh-management / OData/

請嘗試類似的簡單查詢

  • https://<Data 基礎架構洞見 URL>/rest / v1/dwh-management / oData/dwh_cCustom

  • https://<Data 基礎架構洞見 URL>/rest / v1/dwh-management / oData/dwh_inventory

  • https://<Data 基礎架構洞見 URL>/rest / v1/dwh-management / oData/dwh_inventory/storage

  • https://<Data 基礎架構洞見 URL>/rest / v1/dwh-management / oData/dwh_inventory/disk

  • https://…​/odata/dwh_custom/custom_queries

REST API範例

所有通話的 URL 為 https://<Data 基礎架構洞見 URL>/rest / v1/dwh-management / oData_ 。

  • Get /{schema}/*-從報告資料庫擷取資料。

格式: https://<Data 基礎架構洞見 URL>/rest / v1/dwh-management / <schema_name> / <query> _

範例:

 https://<domain>/rest/v1/dwh-management/odata/dwh_inventory/fabric?$count=true&$orderby=name
結果:
{
   "@odata.context": "$metadata#fabric",
   "@odata.count": 2,
   "value": [
       {
           "id": 851,
           "identifier": "10:00:50:EB:1A:40:3B:44",
           "wwn": "10:00:50:EB:1A:40:3B:44",
           "name": "10:00:50:EB:1A:40:3B:44",
           "vsanEnabled": "0",
           "vsanId": null,
           "zoningEnabled": "0",
           "url": "https://<domain>/web/#/assets/fabrics/941716"
       },
       {
           "id": 852,
           "identifier": "10:00:50:EB:1A:40:44:0C",
           "wwn": "10:00:50:EB:1A:40:44:0C",
           "name": "10:00:50:EB:1A:40:44:0C",
           "vsanEnabled": "0",
           "vsanId": null,
           "zoningEnabled": "0",
           "url": "https://<domain>/web/#/assets/fabrics/941836"
        }
    ]
}

實用秘訣

使用報告API查詢時、請謹記下列事項。

  • 查詢有效負載必須是有效的Json字串

  • 查詢有效負載必須包含在單一行中

  • 雙引號必須轉義、例如:「

  • 索引標籤支援為\t

  • 避免留言

  • 支援大小寫較低的表格名稱

此外:

  • 需要2個標頭:

    • 名稱「X-CloudInsights - ApikKey」

    • 屬性值「<apikey>」

您的 API 金鑰將專屬於您的 Data Infrastructure Insights 環境。

同步或非同步?

根據預設、 API 命令會以 Synchronity 模式運作、這表示您傳送要求、並立即傳回回應。不過、有時候查詢可能需要很長時間才能執行、這可能會導致要求逾時。若要解決此問題、您可以執行要求 _ 非同步 _ 。在非同步模式中、要求會傳回可監控執行的 URL 。URL 會在準備好時傳回結果。

若要以非同步模式執行查詢、請新增標頭 Prefer: respond-async 以達成此要求。成功執行後、回應將包含下列標頭:

Status Code: 202 (which means ACCEPTED)
preference-applied: respond-async
location: https://<Data Infrastructure Insights URL>/rest/v1/dwh-management/odata/dwh_custom/asyncStatus/<token>

如果回應尚未就緒、查詢位置 URL 會傳回相同的標頭、如果回應準備好、則會傳回狀態 200 。回應內容將為文字類型、包含原始查詢的 http 狀態和部分中繼資料、然後是原始查詢的結果。

HTTP/1.1 200 OK
 OData-Version: 4.0
 Content-Type: application/json;odata.metadata=minimal
 oDataResponseSizeCounted: true

 { <JSON_RESPONSE> }

若要查看所有非同步查詢的清單、以及其中哪些查詢已就緒、請使用下列命令:

 GET https://<Data Infrastructure Insights URL>/rest/v1/dwh-management/odata/dwh_custom/asyncList
回應的格式如下:
{
   "queries" : [
       {
           "Query": "https://<Data Infrastructure Insights URL>/rest/v1/dwh-management/odata/dwh_custom/heavy_left_join3?$count=true",
           "Location": "https://<Data Infrastructure Insights URL>/rest/v1/dwh-management/odata/dwh_custom/asyncStatus/<token>",
           "Finished": false
       }
   ]
}