Skip to content

new: Added endpoint/obj for managed stat, modified prebuild #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions prebuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ function formatSchemaExample(schema, paginationKey) {
const schemaExample = {};

if (!Array.isArray(schema)) {
// TODO: Account for objects / clean this method up
return schemaExample;
}

Expand All @@ -101,15 +100,7 @@ function formatSchemaExample(schema, paginationKey) {
schemaExample[obj.name] = [schemaExample[obj.name]];
}
} else {
let value = obj.value;
if (Array.isArray(value)) {
value = value.map(function (obj) {
if (typeof obj === 'object' && obj !== null) {
return formatSchemaExample(obj);
}
return obj;
});
}
const value = obj.value;

schemaExample[obj.name] = value;
}
Expand Down
15 changes: 15 additions & 0 deletions src/data/endpoints/managed.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -379,3 +379,18 @@ endpoints:
}
}' \
https://$api_root/$version/managed/linode_settings/$linode_settings_id
/managed/stats:
group: Stats
type: Action
authenticated: true
description: >
Returns CPU, disk, swap, and network in/out stats for the last 24 hours.
methods:
GET:
response: ManagedStat
description: >
Returns statistics for the last 24 hours.
examples:
curl: |
curl -H "Authorization: token $TOKEN" \
https://$api_root/$version/managed/stats
30 changes: 30 additions & 0 deletions src/data/objects/managedstat.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# vim: set et ts=2 sw=2 tw=80 :
name: ManagedStat
prefix: managed/stats
description: >
Graph data
schema:
data:
type: Object
description: >
Graph data (if available) - data is in "[{x: timestamp, y: reading}]" array of dicts format
cpu:
type: Array
value: [{"x": 1513753500000, "y": 8.34},{"x": 1513754599900, "y": 8.45}]
description: Percentage of CPU(s) used
swap:
type: Array
value: [{"x": 1513753500000, "y": 0}]
description: blocks written
disk:
type: Array
value: [{"x": 1513753500000, "y": 29.94}]
description: blocks written
net_in:
type: Array
value: [{"x": 1513753500000, "y": 5677.77}]
description: network data used
net_out:
type: Array
value: [{"x": 1513753500000, "y": 5644.45}]
description: network data used