-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfetch.php
43 lines (43 loc) · 1.12 KB
/
fetch.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
/**
* @author Addshore
* @author Ladsgroup
* Quick script for grabbing a list of dashboards
*/
$dashboards = [
'grafana' => [
'ores',
'ores-extension'
],
'grafana-labs' => [
'ores-labs',
'ores-beta-cluster',
'ores-extension',
]
];
if ( array_key_exists( 1, $argv ) ) {
$requestedDashboard = $argv[1];
if( in_array( $requestedDashboard, $dashboards ) ) {
$dashboards = array( $requestedDashboard );
} else {
echo "Requested dashboard '$requestedDashboard' was not in the dashboard list\n";
exit;
}
}
foreach( $dashboards as $realm => $dashList ) {
echo "Getting dashboards in $realm\n";
foreach ( $dashList as $dashboard ) {
echo "Getting dashboard $dashboard\n";
$response = file_get_contents( "https://$realm.wikimedia.org/api/dashboards/db/$dashboard" );
if( $response === false || $response === null ) {
echo "Skipping $dashboard, something went wrong...\n";
continue;
}
$data = json_decode( $response, true );
$data = $data['dashboard'];
$json = json_encode( $data, JSON_PRETTY_PRINT );
file_put_contents( __DIR__ . '/' . "$dashboard ($realm).json", $json );
}
}
echo "Done";
exit;