Skip to content

Commit 1f58bb4

Browse files
Merge pull request #22 from yoshizzle/managedStats
new: Added endpoint/obj for managed stat, modified prebuild
2 parents 43e2ccd + 6abeda4 commit 1f58bb4

File tree

3 files changed

+46
-10
lines changed

3 files changed

+46
-10
lines changed

prebuild.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ function formatSchemaExample(schema, paginationKey) {
8989
const schemaExample = {};
9090

9191
if (!Array.isArray(schema)) {
92-
// TODO: Account for objects / clean this method up
9392
return schemaExample;
9493
}
9594

@@ -101,15 +100,7 @@ function formatSchemaExample(schema, paginationKey) {
101100
schemaExample[obj.name] = [schemaExample[obj.name]];
102101
}
103102
} else {
104-
let value = obj.value;
105-
if (Array.isArray(value)) {
106-
value = value.map(function (obj) {
107-
if (typeof obj === 'object' && obj !== null) {
108-
return formatSchemaExample(obj);
109-
}
110-
return obj;
111-
});
112-
}
103+
const value = obj.value;
113104

114105
schemaExample[obj.name] = value;
115106
}

src/data/endpoints/managed.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,3 +379,18 @@ endpoints:
379379
}
380380
}' \
381381
https://$api_root/$version/managed/linode_settings/$linode_settings_id
382+
/managed/stats:
383+
group: Stats
384+
type: Action
385+
authenticated: true
386+
description: >
387+
Returns CPU, disk, swap, and network in/out stats for the last 24 hours.
388+
methods:
389+
GET:
390+
response: ManagedStat
391+
description: >
392+
Returns statistics for the last 24 hours.
393+
examples:
394+
curl: |
395+
curl -H "Authorization: token $TOKEN" \
396+
https://$api_root/$version/managed/stats

src/data/objects/managedstat.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# vim: set et ts=2 sw=2 tw=80 :
2+
name: ManagedStat
3+
prefix: managed/stats
4+
description: >
5+
Graph data
6+
schema:
7+
data:
8+
type: Object
9+
description: >
10+
Graph data (if available) - data is in "[{x: timestamp, y: reading}]" array of dicts format
11+
cpu:
12+
type: Array
13+
value: [{"x": 1513753500000, "y": 8.34},{"x": 1513754599900, "y": 8.45}]
14+
description: Percentage of CPU(s) used
15+
swap:
16+
type: Array
17+
value: [{"x": 1513753500000, "y": 0}]
18+
description: blocks written
19+
disk:
20+
type: Array
21+
value: [{"x": 1513753500000, "y": 29.94}]
22+
description: blocks written
23+
net_in:
24+
type: Array
25+
value: [{"x": 1513753500000, "y": 5677.77}]
26+
description: network data used
27+
net_out:
28+
type: Array
29+
value: [{"x": 1513753500000, "y": 5644.45}]
30+
description: network data used

0 commit comments

Comments
 (0)