|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +var method = require('./../method'); |
| 4 | +var assign = require('lodash.assign'); |
| 5 | + |
| 6 | +/** |
| 7 | + * @memberof machines |
| 8 | + * @method setAccessForUser |
| 9 | + * @description Show machine information for the machine with the given id. |
| 10 | + * |
| 11 | + * The state property can take on the follow values: |
| 12 | + * - off |
| 13 | + * - starting - machine is in the process of changing to the ready or serviceready state |
| 14 | + * - stopping - machine is in the process of changing to the off state |
| 15 | + * - restarting - combines stopping follow immediately by starting |
| 16 | + * - serviceready - services are running on the machine but the Paperspace agent is not yet available |
| 17 | + * - ready - services are running on machine and the Paperspace agent is ready to stream or accept logins |
| 18 | + * - upgrading - the machine specification are being upgraded, which involves a shutdown and startup sequence |
| 19 | + * - provisioning - the machine is in the process of being created for the first time |
| 20 | + * |
| 21 | + * The updatesPending property is either true or false and reflects whether the operating system has scheduled updates |
| 22 | + * for the next machine state transition, e.g, stopping, starting, restarting or upgrading. |
| 23 | + * |
| 24 | + * Note: in some cases the operating system can force installation of critical updates immediately upon a state |
| 25 | + * transition, or automatically restart a machine to install updates. In such cases the updatesPending property |
| 26 | + * may not always be set accurately by the underlying os. |
| 27 | + * @param {object} params - Machine show parameters |
| 28 | + * @param {string} params.machineId - Id of the machine to show |
| 29 | + * @param {string} params.userId - Id of the user to enable machine access for |
| 30 | + * @param {boolean} params.enabeAccess- releases any assigned public ip address for the machine; defaults to false |
| 31 | + * @param {function} cb - Node-style error-first callback function |
| 32 | + * @returns {object} machine - The machine JSON object |
| 33 | + * @example |
| 34 | + * paperspace.machines.setAccessForUser({ |
| 35 | + * machineId: 'ps123abc', |
| 36 | + * userId: 'u123abc, |
| 37 | + * }, function(err, res) { |
| 38 | + * // handle error or result |
| 39 | + * }); |
| 40 | + * @example |
| 41 | + * $ paperspace machines setAccessForUser \ |
| 42 | + * --machineId "ps123abc" --userId "u12abc" |
| 43 | + * @example |
| 44 | + * # HTTP request: |
| 45 | + * https://api.paperspace.io |
| 46 | + * GET /machines/:machineId/setMachineAccessPublic?userId=u123abc |
| 47 | + * x-api-key: 1ba4f98e7c0... |
| 48 | + * # Returns 200 on success |
| 49 | + */ |
| 50 | + |
| 51 | +function setAccessForUser(params, cb) { |
| 52 | + return method(setAccessForUser, params, cb); |
| 53 | +} |
| 54 | + |
| 55 | +assign(setAccessForUser, { |
| 56 | + auth: true, |
| 57 | + group: 'machines', |
| 58 | + name: 'setAccessForUser', |
| 59 | + method: 'post', |
| 60 | + route: '/machines/:machineId/setMachineAccess', |
| 61 | + requires: { |
| 62 | + machineId: 'string', |
| 63 | + userId: "string", |
| 64 | + enableAccess: 'boolean', |
| 65 | + }, |
| 66 | + returns: {}, |
| 67 | +}); |
| 68 | + |
| 69 | +module.exports = setAccessForUser; |
0 commit comments