machines/restart.js

  1. 'use strict';
  2. var method = require('./../method');
  3. var assign = require('lodash.assign');
  4. /**
  5. * @memberof machines
  6. * @method restart
  7. * @description Restart an individual machine. If the machine is already restarting,
  8. * this action will request the machine be restarted again.
  9. * This action can only be performed by the user who owns the machine.
  10. * @param {object} params - Machine restart parameters
  11. * @param {string} params.machineId - Id of the machine to restart
  12. * @param {function} cb - Node-style error-first callback function
  13. * @example
  14. * paperspace.machines.restart({
  15. * machineId: 'ps123abc',
  16. * }, function(err, res) {
  17. * // handle error or result
  18. * });
  19. * @example
  20. * $ paperspace machines restart --machineId "ps123abc"
  21. * @example
  22. * # HTTP request:
  23. * https://api.paperspace.io
  24. * POST /machines/ps123abc/restart
  25. * x-api-key: 1ba4f98e7c0...
  26. * # Returns 204 on success
  27. */
  28. function restart(params, cb) {
  29. return method(restart, params, cb);
  30. }
  31. assign(restart, {
  32. auth: true,
  33. group: 'machines',
  34. name: 'restart',
  35. method: 'post',
  36. route: '/machines/:machineId/restart',
  37. requires: {
  38. machineId: 'string',
  39. },
  40. returns: {},
  41. });
  42. module.exports = restart;