github.com/GoogleCloudPlatform/testgrid@v0.0.174/web/src/APIClient.ts (about) 1 import { 2 ListDashboardsResponse, 3 ListDashboardGroupsResponse, 4 } from './gen/pb/api/v1/data.js'; 5 6 export interface APIClient { 7 getDashboards(): Array<String>; 8 getDashboardGroups(): Array<String>; 9 } 10 11 export class APIClientImpl implements APIClient { 12 host: String = 'testgrid-data.k8s.io'; 13 14 public getDashboards(): Array<String> { 15 const dashboards: Array<String> = []; 16 17 fetch(`${this.host}/api/v1/dashboards`).then(async response => { 18 const resp = ListDashboardsResponse.fromJson(await response.json()); 19 resp.dashboards.forEach(db => { 20 dashboards.push(db.name); 21 }); 22 }); 23 24 return dashboards; 25 } 26 27 public getDashboardGroups(): Array<String> { 28 const dashboardGroups: Array<String> = []; 29 30 fetch(`${this.host}/api/v1/dashboard-groups`).then(async response => { 31 const resp = ListDashboardGroupsResponse.fromJson(await response.json()); 32 resp.dashboardGroups.forEach(db => { 33 dashboardGroups.push(db.name); 34 }); 35 }); 36 37 return dashboardGroups; 38 } 39 }