Skip to content
This repository was archived by the owner on Jun 6, 2023. It is now read-only.

Commit aaed978

Browse files
colin-welchsanfilip
authored andcommitted
feat: Add machines.utilization to get amount of time a machine has been used in the current month.
1 parent 8acd0f3 commit aaed978

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

lib/machines/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ module.exports = {
1212
show: require('./show'),
1313
start: require('./start'),
1414
stop: require('./stop'),
15+
utilization: require('./utilization'),
1516
waitfor: require('./waitfor'),
1617
};

lib/machines/utilization.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
'use strict';
2+
3+
var method = require('./../method');
4+
var assign = require('lodash.assign');
5+
6+
/**
7+
* @memberof machines
8+
* @method utilization
9+
* @description Show machine utilization data for the machine with the given id.
10+
* @param {string} params.machineId - Id of the machine to show
11+
* @param {function} cb - Node-style error-first callback function
12+
* @returns {object} machine - The utilization JSON object
13+
* @example
14+
* paperspace.machines.utilization({
15+
* machineId: 'ps123abc',
16+
* }, function(err, resp) {
17+
* // handle error or http response
18+
* });
19+
* @example
20+
* $ paperspace machines utilization \
21+
* --machineId "ps123abc"
22+
* @example
23+
* # HTTP request:
24+
* https://api.paperspace.io
25+
* GET /machines/getUtilization?machineId=ps123abc
26+
* x-api-key: 1ba4f98e7c0...
27+
* # Returns 200 on success
28+
* @example
29+
* //Example return value:
30+
* {
31+
* "machineId": "ps123abc",
32+
* "secondsUsed": 1000,
33+
* }
34+
*/
35+
36+
function utilization(params, cb) {
37+
return method(utilization, params, cb);
38+
}
39+
40+
assign(utilization, {
41+
auth: true,
42+
group: 'machines',
43+
name: 'utilization',
44+
method: 'get',
45+
route: '/machines/getUtilization',
46+
requires: {
47+
machineId: 'string',
48+
},
49+
returns: {},
50+
});
51+
52+
module.exports = utilization;

0 commit comments

Comments
 (0)