Skip to main content
Data Infrastructure Insights
日本語は機械翻訳による参考訳です。内容に矛盾や不一致があった場合には、英語の内容が優先されます。

API経由でレポートデータベースにアクセスする

共同作成者 netapp-alavoie

Data Infrastructure Insightsの強力な API を使用すると、ユーザーは Cognos Reporting 環境を経由せずに、 Data Infrastructure Insights Reporting データベースを直接クエリできます。

メモ このドキュメントは、 Data Infrastructure Insights Premium Edition で利用できるData Infrastructure Insightsレポート機能について説明しています。

小田田

Data Infrastructure InsightsサイトレポートAPIは、"OData v4"レポート データベースのクエリを実行するための Open Data Protocol (Open Data Protocol) 標準。さらに詳しい情報や詳細については、"このチュートリアル" OData で。

すべてのリクエストは、URL https://< Data Infrastructure Insights URL>/rest/v1/dwh-management/odata で始まります。

APIキーの生成

詳細はこちら"Data Infrastructure InsightsAPI"

API キーを生成するには、次の手順を実行します。

  • Data Infrastructure Insights環境にログインし、管理者 > API アクセス を選択します。

  • 「+ API アクセス トークン」をクリックします。

  • 名前と説明を入力します。

  • タイプには、「データ ウェアハウス」を選択します。

  • 権限を読み取り/書き込みに設定します。

  • 希望の有効期限を設定します。

  • 「保存」をクリックし、キーをコピーして安全な場所に保存します。後で完全なキーにアクセスすることはできません。

APIキーは次の用途に使えます同期 または 非同期

テーブルの直接クエリ

API キーを設定すると、レポート データベースへの直接クエリが可能になります。長い URL は、表示上の都合上、完全な https://< Data Infrastructure Insights URL>/rest/v1/dwh-management/odata/ ではなく、\https://…​/odata/ のように簡略化される場合があります。

次のような簡単なクエリを試してみましょう

  • https://<Data Infrastructure InsightsのURL>/rest/v1/dwh-management/odata/dwh_custom

  • https://<Data Infrastructure Insightsサイト URL>/rest/v1/dwh-management/odata/dwh_inventory

  • https://<Data Infrastructure InsightsURL>/rest/v1/dwh-management/odata/dwh_inventory/storage

  • https://<Data Infrastructure InsightsのURL>/rest/v1/dwh-management/odata/dwh_inventory/disk

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

REST APIの例

すべての呼び出しの URL は https://< Data Infrastructure Insights URL>/rest/v1/dwh-management/odata です。

  • GET /{schema}/** - レポート データベースからデータを取得します。

形式: https://< Data Infrastructure Insights URL>/rest/v1/dwh-management/odata/<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"
        }
    ]
}

役立つヒント

Reporting API クエリを使用するときは、次の点に留意してください。

  • クエリペイロードは有効なJSON文字列である必要があります

  • クエリペイロードは1行に含める必要があります

  • 二重引用符はエスケープする必要があります。例: \"

  • タブは\tとしてサポートされています

  • コメントを避ける

  • 小文字のテーブル名がサポートされています

さらに:

  • 2 つのヘッダーが必要です:

    • 名前を「X-CloudInsights-ApiKey」にする

    • 属性値 "<apikey>"

API キーは、Data Infrastructure Insights環境に固有のものになります。

同期か非同期か?

デフォルトでは、API コマンドは同期モードで動作します。つまり、リクエストを送信すると、すぐに応答が返されます。ただし、クエリの実行に長い時間がかかり、リクエストがタイムアウトになる場合があります。これを回避するには、リクエストを非同期的に実行します。非同期モードでは、リクエストは実行を監視できる 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
       }
   ]
}