diff --git a/lib/machines/index.js b/lib/machines/index.js index e7de981..911dcb7 100644 --- a/lib/machines/index.js +++ b/lib/machines/index.js @@ -16,4 +16,5 @@ module.exports = { update: require('./update'), utilization: require('./utilization'), waitfor: require('./waitfor'), + setAccessForUser: require('./setAccessForUser'), }; diff --git a/lib/machines/setAccessForUser.js b/lib/machines/setAccessForUser.js new file mode 100644 index 0000000..8551743 --- /dev/null +++ b/lib/machines/setAccessForUser.js @@ -0,0 +1,69 @@ +'use strict'; + +var method = require('./../method'); +var assign = require('lodash.assign'); + +/** + * @memberof machines + * @method setAccessForUser + * @description Show machine information for the machine with the given id. + * + * The state property can take on the follow values: + * - off + * - starting - machine is in the process of changing to the ready or serviceready state + * - stopping - machine is in the process of changing to the off state + * - restarting - combines stopping follow immediately by starting + * - serviceready - services are running on the machine but the Paperspace agent is not yet available + * - ready - services are running on machine and the Paperspace agent is ready to stream or accept logins + * - upgrading - the machine specification are being upgraded, which involves a shutdown and startup sequence + * - provisioning - the machine is in the process of being created for the first time + * + * The updatesPending property is either true or false and reflects whether the operating system has scheduled updates + * for the next machine state transition, e.g, stopping, starting, restarting or upgrading. + * + * Note: in some cases the operating system can force installation of critical updates immediately upon a state + * transition, or automatically restart a machine to install updates. In such cases the updatesPending property + * may not always be set accurately by the underlying os. + * @param {object} params - Machine show parameters + * @param {string} params.machineId - Id of the machine to show + * @param {string} params.userId - Id of the user to enable machine access for + * @param {boolean} params.enabeAccess- releases any assigned public ip address for the machine; defaults to false + * @param {function} cb - Node-style error-first callback function + * @returns {object} machine - The machine JSON object + * @example + * paperspace.machines.setAccessForUser({ + * machineId: 'ps123abc', + * userId: 'u123abc, + * }, function(err, res) { + * // handle error or result + * }); + * @example + * $ paperspace machines setAccessForUser \ + * --machineId "ps123abc" --userId "u12abc" + * @example + * # HTTP request: + * https://api.paperspace.io + * GET /machines/:machineId/setMachineAccessPublic?userId=u123abc + * x-api-key: 1ba4f98e7c0... + * # Returns 200 on success + */ + +function setAccessForUser(params, cb) { + return method(setAccessForUser, params, cb); +} + +assign(setAccessForUser, { + auth: true, + group: 'machines', + name: 'setAccessForUser', + method: 'post', + route: '/machines/:machineId/setMachineAccess', + requires: { + machineId: 'string', + userId: "string", + enableAccess: 'boolean', + }, + returns: {}, +}); + +module.exports = setAccessForUser;