Skip to content

Commit 007983a

Browse files
author
Josh Sager
committed
new: Added endpoint/obj for managed stat, modified prebuild
Prebuild was not able to properly recurse through objects if they didn't contain sub-objects.
1 parent 43e2ccd commit 007983a

File tree

3 files changed

+49
-2
lines changed

3 files changed

+49
-2
lines changed

prebuild.js

Lines changed: 4 additions & 2 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

@@ -102,10 +101,13 @@ function formatSchemaExample(schema, paginationKey) {
102101
}
103102
} else {
104103
let value = obj.value;
104+
let o;
105105
if (Array.isArray(value)) {
106106
value = value.map(function (obj) {
107107
if (typeof obj === 'object' && obj !== null) {
108-
return formatSchemaExample(obj);
108+
if (obj[o] !== null && typeof obj[o] === 'object') {
109+
return formatSchemaExample(obj);
110+
}
109111
}
110112
return obj;
111113
});

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)