Skip to main content
Data Infrastructure Insights
La versione in lingua italiana fornita proviene da una traduzione automatica. Per eventuali incoerenze, fare riferimento alla versione in lingua inglese.

Accedi al database di reporting tramite API

Collaboratori netapp-alavoie

La potente API di Data Infrastructure Insights consente agli utenti di interrogare direttamente il database di reporting di Data Infrastructure Insights , senza passare attraverso l'ambiente di reporting di Cognos.

Nota Questa documentazione fa riferimento alla funzionalità di reporting di Data Infrastructure Insights , disponibile in Data Infrastructure Insights Premium Edition.

Odata

L'API di reporting di Data Infrastructure Insights segue"OData v4" (Open Data Protocol) standard per l'interrogazione del database di reporting. Per maggiori informazioni o per saperne di più, consulta"questo tutorial" su OData.

Tutte le richieste inizieranno con l'URL https://< URL Data Infrastructure Insights >/rest/v1/dwh-management/odata

Generazione di una APIKey

Per saperne di più"API Data Infrastructure Insights" .

Per generare una chiave API, procedere come segue:

  • Accedi al tuo ambiente Data Infrastructure Insights e seleziona Amministrazione > Accesso API.

  • Fare clic su "+ Token di accesso API".

  • Inserisci un nome e una descrizione.

  • Per il tipo, seleziona Data Warehouse.

  • Imposta i permessi come Lettura/Scrittura.

  • Imposta una data di scadenza per i desideri.

  • Fai clic su "Salva", quindi copia la chiave e salvala in un luogo sicuro. In seguito non sarà più possibile accedere alla chiave completa.

Le chiavi API sono utili perSincronizzazione o Asincrono .

Interrogazione diretta delle tabelle

Con la chiave API in atto, ora è possibile effettuare query dirette al database di reporting. Gli URL lunghi possono essere semplificati in https://…​/odata/ per scopi di visualizzazione anziché nel formato completo https://< URL Data Infrastructure Insights >/rest/v1/dwh-management/odata/

Prova semplici query come

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

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

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

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

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

Esempi di API REST

L'URL per tutte le chiamate è https://< URL Data Infrastructure Insights >/rest/v1/dwh-management/odata.

  • GET /{schema}/** - Recupera i dati dal database di reporting.

Formato: https://< URL Data Infrastructure Insights >/rest/v1/dwh-management/odata/<nome_schema>/<query>

Esempio:

 https://<domain>/rest/v1/dwh-management/odata/dwh_inventory/fabric?$count=true&$orderby=name
Risultato:
{
   "@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"
        }
    ]
}

Suggerimenti utili

Quando si utilizzano le query dell'API di reporting, tenere presente quanto segue.

  • Il payload della query deve essere una stringa JSON valida

  • Il payload della query deve essere contenuto in una singola riga

  • Le virgolette doppie devono essere precedute da escape, ad esempio \"

  • Le schede sono supportate come \t

  • Evita i commenti

  • Sono supportati i nomi delle tabelle in minuscolo

Inoltre:

  • Sono richieste 2 intestazioni:

    • Nome “X-CloudInsights-ApiKey”

    • Valore attributo “<apikey>”

La tua chiave API sarà specifica per il tuo ambiente Data Infrastructure Insights .

Sincrono o asincrono?

Per impostazione predefinita, un comando API funziona in modalità sincrona, ovvero quando si invia la richiesta, la risposta viene restituita immediatamente. Tuttavia, a volte l'esecuzione di una query potrebbe richiedere molto tempo, il che potrebbe causare il timeout della richiesta. Per aggirare questo problema, è possibile eseguire una richiesta in modo asincrono. In modalità asincrona, la richiesta restituirà un URL tramite il quale è possibile monitorare l'esecuzione. L'URL restituirà il risultato quando sarà pronto.

Per eseguire una query in modalità asincrona, aggiungere l'intestazione Prefer: respond-async alla richiesta. In caso di esecuzione corretta, la risposta conterrà le seguenti intestazioni:

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>

L'interrogazione dell'URL della posizione restituirà le stesse intestazioni se la risposta non è ancora pronta oppure restituirà lo stato 200 se la risposta è pronta. Il contenuto della risposta sarà di tipo testo e conterrà lo stato http della query originale e alcuni metadati, seguiti dai risultati della query originale.

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

 { <JSON_RESPONSE> }

Per visualizzare un elenco di tutte le query asincrone e quali di esse sono pronte, utilizzare il seguente comando:

 GET https://<Data Infrastructure Insights URL>/rest/v1/dwh-management/odata/dwh_custom/asyncList
La risposta ha il seguente formato:
{
   "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
       }
   ]
}