jobs/show.js

  1. 'use strict';
  2. var method = require('./../method');
  3. var projectConfig = require('./../projectConfig');
  4. var assign = require('lodash.assign');
  5. /**
  6. * @memberof jobs
  7. * @method show
  8. * @description Show job information for the job with the given id.
  9. * @param {object} params - Job show parameters
  10. * @param {string} params.jobId - Id of the job to show
  11. * @param {function} cb - Node-style error-first callback function
  12. * @returns {object} job - The job JSON object
  13. * @example
  14. * paperspace.jobs.show({
  15. * jobId: 'j123abc',
  16. * }, function(err, res) {
  17. * // handle error or result
  18. * });
  19. * @example
  20. * $ paperspace jobs show \
  21. * --jobId "j123abc"
  22. * @example
  23. * # HTTP request:
  24. * https://api.paperspace.io
  25. * GET /jobs/getJob?jobId=j123abc
  26. * x-api-key: 1ba4f98e7c0...
  27. * # Returns 200 on success
  28. * @example
  29. * //Example return value:
  30. * {
  31. * "id": "j123abc",
  32. * "name": "job for project myproject",
  33. * "state": "Running",
  34. * "workspaceUrl": "myproject.zip",
  35. * "workingDirectory": "/paperspace",
  36. * "artifactsDirectory": "/artifacts",
  37. * "entrypoint": "echo Hello Paperspace",
  38. * "projectId": "pr456def",
  39. * "project": "myproject",
  40. * "container": "http://dockerhub.com/mycontainer",
  41. * "machineType": "P5000",
  42. * "cluster": "PS Jobs",
  43. * "usageRate": "P5000 hourly",
  44. * "startedByUserId": "u789ghi",
  45. * "parentJobId": null,
  46. * "jobError": null,
  47. * "dtCreated": "2017-11-30T18:46:10.394Z",
  48. * "dtModified": "2017-11-30T18:46:10.394Z",
  49. * "dtProvisioningStarted": "2017-11-30T18:46:50.467Z",
  50. * "dtProvisioningFinished": "2017-11-30T18:47:12.508Z",
  51. * "dtStarted": "2017-11-30T18:47:14.636Z",
  52. * "dtFinished": null,
  53. * "dtTeardownStarted": null,
  54. * "dtTeardownFinished": null,
  55. * "dtDeleted": null,
  56. * "exitCode": null
  57. * }
  58. */
  59. function show(params, cb) {
  60. params.jobId = projectConfig.getLastJobId(null, params.jobId);
  61. return method(show, params, cb);
  62. }
  63. assign(show, {
  64. auth: true,
  65. group: 'jobs',
  66. name: 'show',
  67. method: 'get',
  68. route: '/jobs/getJob',
  69. requires: {
  70. jobId: 'string',
  71. },
  72. returns: {},
  73. });
  74. module.exports = show;