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

Commit 70318b0

Browse files
committed
PS-4902 machines update method for public api and sdk
1 parent 64a125e commit 70318b0

File tree

3 files changed

+185
-0
lines changed

3 files changed

+185
-0
lines changed

docs/machines_update.js.html

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<title>machines/update.js - Documentation</title>
6+
7+
<script src="scripts/prettify/prettify.js"></script>
8+
<script src="scripts/prettify/lang-css.js"></script>
9+
<!--[if lt IE 9]>
10+
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
11+
<![endif]-->
12+
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
13+
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
14+
</head>
15+
<body>
16+
17+
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
18+
<label for="nav-trigger" class="navicon-button x">
19+
<div class="navicon"></div>
20+
</label>
21+
22+
<label for="nav-trigger" class="overlay"></label>
23+
24+
<nav>
25+
<h2><a href="index.html">Home</a></h2><h3>Namespaces</h3><ul><li><a href="jobs.html">jobs</a><ul class='methods'><li data-type='method'><a href="jobs.html#.artifactsDestroy">artifactsDestroy</a></li><li data-type='method'><a href="jobs.html#.artifactsGet">artifactsGet</a></li><li data-type='method'><a href="jobs.html#.artifactsList">artifactsList</a></li><li data-type='method'><a href="jobs.html#.artifactsShare">artifactsShare</a></li><li data-type='method'><a href="jobs.html#.clone">clone</a></li><li data-type='method'><a href="jobs.html#.create">create</a></li><li data-type='method'><a href="jobs.html#.destroy">destroy</a></li><li data-type='method'><a href="jobs.html#.list">list</a></li><li data-type='method'><a href="jobs.html#.logs">logs</a></li><li data-type='method'><a href="jobs.html#.show">show</a></li><li data-type='method'><a href="jobs.html#.stop">stop</a></li><li data-type='method'><a href="jobs.html#.waitfor">waitfor</a></li></ul></li><li><a href="machines.html">machines</a><ul class='methods'><li data-type='method'><a href="machines.html#.availability">availability</a></li><li data-type='method'><a href="machines.html#.create">create</a></li><li data-type='method'><a href="machines.html#.destroy">destroy</a></li><li data-type='method'><a href="machines.html#.list">list</a></li><li data-type='method'><a href="machines.html#.restart">restart</a></li><li data-type='method'><a href="machines.html#.show">show</a></li><li data-type='method'><a href="machines.html#.start">start</a></li><li data-type='method'><a href="machines.html#.stop">stop</a></li><li data-type='method'><a href="machines.html#.update">update</a></li><li data-type='method'><a href="machines.html#.utilization">utilization</a></li><li data-type='method'><a href="machines.html#.waitfor">waitfor</a></li></ul></li><li><a href="networks.html">networks</a><ul class='methods'><li data-type='method'><a href="networks.html#.list">list</a></li></ul></li><li><a href="scripts.html">scripts</a><ul class='methods'><li data-type='method'><a href="scripts.html#.create">create</a></li><li data-type='method'><a href="scripts.html#.destroy">destroy</a></li><li data-type='method'><a href="scripts.html#.list">list</a></li><li data-type='method'><a href="scripts.html#.show">show</a></li><li data-type='method'><a href="scripts.html#.text">text</a></li></ul></li><li><a href="templates.html">templates</a><ul class='methods'><li data-type='method'><a href="templates.html#.list">list</a></li></ul></li><li><a href="users.html">users</a><ul class='methods'><li data-type='method'><a href="users.html#.list">list</a></li></ul></li></ul>
26+
</nav>
27+
28+
<div id="main">
29+
30+
<h1 class="page-title">machines/update.js</h1>
31+
32+
33+
34+
35+
36+
37+
38+
<section>
39+
<article>
40+
<pre class="prettyprint source linenums"><code>'use strict';
41+
42+
var method = require('./../method');
43+
var assign = require('lodash.assign');
44+
45+
/**
46+
* @memberof machines
47+
* @method update
48+
* @description Update attributes of a machine.
49+
* @param {object} params - Machine update parameters
50+
* @param {string} params.machineId - Id of the machine to shut down
51+
* @param {string} [params.machineName] - New name for the machine
52+
* @param {number} [params.shutdownTimeoutInHours] - Number of hours before machine is shutdown if no one is logged in via the Paperspace client
53+
* @param {boolean} [params.shutdownTimeoutForces] - Force shutdown at shutdown timeout, even if there is a Paperspace client connection
54+
* @param {number} [params.autoSnapshotFrequency] - One of 'hour', 'day', 'week', or null
55+
* @param {number} [params.autoSnapshotSaveCount] - Number of snapshots to save
56+
* @param {boolean} [params.performAutoSnapshot] - Perform auto snapshots
57+
* @param {function} cb - Node-style error-first callback function
58+
* @example
59+
* paperspace.machines.update({
60+
* machineId: 'ps123abc',
61+
* machineName: 'New Machine Name',
62+
* shutdownTimeoutInHours: 24,
63+
* shutdownTimeoutForces: true,
64+
* performAutoSnapshot: true,
65+
* autoSnapshotFrequency: 'week',
66+
* autoSnapshotSaveCount: 4
67+
* }, function(err, resp) {
68+
* // handle error or http response
69+
* });
70+
* @example
71+
* $ paperspace machines update --machineId "ps123abc"
72+
* --machineName "New Machine Name" \
73+
* --shutdownTimeoutInHours 24 \
74+
* --shutdownTimeoutForces true \
75+
* --performAutoSnapshot true \
76+
* --autoSnapshotFrequency "week" \
77+
* --autoSnapshotSaveCount 4
78+
* @example
79+
* # HTTP request:
80+
* https://api.paperspace.io
81+
* POST /machines/ps123abc/update {"machineId": "ps123abc", "machineName": "New Machine Name", "shutdownTimeoutInHours": 24, "shutdownTimeoutForces": true, "performAutoSnapshot": true, "autoSnapshotFrequency": "week", "autoSnapshotSaveCount": 4}
82+
* x-api-key: 1ba4f98e7c0...
83+
* # Returns 204 on success
84+
*/
85+
86+
function start(params, cb) {
87+
return method(start, params, cb);
88+
}
89+
90+
assign(start, {
91+
auth: true,
92+
group: 'machines',
93+
name: 'start',
94+
method: 'post',
95+
route: '/machines/:machineId/updateMachinePublic',
96+
requires: {
97+
machineId: 'string',
98+
},
99+
returns: {},
100+
});
101+
102+
module.exports = start;
103+
</code></pre>
104+
</article>
105+
</section>
106+
107+
108+
109+
110+
</div>
111+
112+
<br class="clear">
113+
114+
<footer>
115+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Tue Nov 28 2017 19:04:58 GMT-0500 (EST) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
116+
</footer>
117+
118+
<script>prettyPrint();</script>
119+
<script src="scripts/linenumber.js"></script>
120+
</body>
121+
</html>

lib/machines/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ module.exports = {
1313
show: require('./show'),
1414
start: require('./start'),
1515
stop: require('./stop'),
16+
update: require('./update'),
1617
utilization: require('./utilization'),
1718
waitfor: require('./waitfor'),
1819
};

lib/machines/update.js

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
'use strict';
2+
3+
var method = require('./../method');
4+
var assign = require('lodash.assign');
5+
6+
/**
7+
* @memberof machines
8+
* @method update
9+
* @description Update attributes of a machine.
10+
* @param {object} params - Machine update parameters
11+
* @param {string} params.machineId - Id of the machine to shut down
12+
* @param {string} [params.machineName] - New name for the machine
13+
* @param {number} [params.shutdownTimeoutInHours] - Number of hours before machine is shutdown if no one is logged in via the Paperspace client
14+
* @param {boolean} [params.shutdownTimeoutForces] - Force shutdown at shutdown timeout, even if there is a Paperspace client connection
15+
* @param {number} [params.autoSnapshotFrequency] - One of 'hour', 'day', 'week', or null
16+
* @param {number} [params.autoSnapshotSaveCount] - Number of snapshots to save
17+
* @param {boolean} [params.performAutoSnapshot] - Perform auto snapshots
18+
* @param {function} cb - Node-style error-first callback function
19+
* @example
20+
* paperspace.machines.update({
21+
* machineId: 'ps123abc',
22+
* machineName: 'New Machine Name',
23+
* shutdownTimeoutInHours: 24,
24+
* shutdownTimeoutForces: true,
25+
* performAutoSnapshot: true,
26+
* autoSnapshotFrequency: 'week',
27+
* autoSnapshotSaveCount: 4
28+
* }, function(err, resp) {
29+
* // handle error or http response
30+
* });
31+
* @example
32+
* $ paperspace machines update --machineId "ps123abc"
33+
* --machineName "New Machine Name" \
34+
* --shutdownTimeoutInHours 24 \
35+
* --shutdownTimeoutForces true \
36+
* --performAutoSnapshot true \
37+
* --autoSnapshotFrequency "week" \
38+
* --autoSnapshotSaveCount 4
39+
* @example
40+
* # HTTP request:
41+
* https://api.paperspace.io
42+
* POST /machines/ps123abc/update {"machineId": "ps123abc", "machineName": "New Machine Name", "shutdownTimeoutInHours": 24, "shutdownTimeoutForces": true, "performAutoSnapshot": true, "autoSnapshotFrequency": "week", "autoSnapshotSaveCount": 4}
43+
* x-api-key: 1ba4f98e7c0...
44+
* # Returns 204 on success
45+
*/
46+
47+
function start(params, cb) {
48+
return method(start, params, cb);
49+
}
50+
51+
assign(start, {
52+
auth: true,
53+
group: 'machines',
54+
name: 'start',
55+
method: 'post',
56+
route: '/machines/:machineId/updateMachinePublic',
57+
requires: {
58+
machineId: 'string',
59+
},
60+
returns: {},
61+
});
62+
63+
module.exports = start;

0 commit comments

Comments
 (0)