Skip to content

Latest commit

 

History

History
352 lines (300 loc) · 7.75 KB

scripts.md

File metadata and controls

352 lines (300 loc) · 7.75 KB

Scripts

Creates a new startup script. Optionally specify a machine to use this startup script. For Linux machines, the script should be a bash script. For Windows machines, the script should be a PowerShell script. See the samples directory for sample startup scripts for Windows. Note: script data is limited to 16KB per script. See the Script Guide for more info on using scripts.

Create

Examples

paperspace.scripts.create({
  scriptName: 'My Script',
  scriptFile: './my_script_file.sh', // must specify either scriptFile or scriptText
  scriptDescription: 'A startup script', // optional
  isEnabled: true, // optional
  runOnce: false, // optional
  machineId: 'ps123abc', // optional
}, function(err, res) {
  // handle error or result
});
# HTTP request:
https://api.paperspace.io
POST /scripts/createScript {"scriptName": "My Script", "scriptDescription": "A startup script", "isEnabled": true, "runOnce": false, "machineId": "ps123abc"}
x-api-key: 1ba4f98e7c0...
(file contents as multipart form data)
# Returns 200 on success

Parameters

Name Type Description
params object

Script create parameters

Properties

cb function Node-style error-first callback function

Returns

script - The created script JSON object

Type object

// Example return value:
{
  "id": "sc123abc",
  "ownerType": "user",
  "ownerId": "u456def",
  "name": "My Script",
  "description": "my_script_file.sh",
  "dtCreated": "2017-06-15T19:22:13.507Z",
  "isEnabled": true,
  "runOnce": false
}

Destroy

Destroys the startup script with the given id. When this action is performed, the script is immediately disassociated from any machines it is assigned to as well.

Examples

paperspace.scripts.destroy({
  scriptId: 'sc123abc',
}, function(err, res) {
  // handle error or result
});
# HTTP request:
https://api.paperspace.io
POST /scripts/sc123abc/destroy
x-api-key: 1ba4f98e7c0...
# Returns 204 on success

Parameters

Name Type Description
params object

Script destroy parameters

Properties

cb function Node-style error-first callback function

List

List information about all scripts assigned to either the current authenticated user or the team, if the user belongs to a team. The list method takes an optional first argument to limit the returned script objects.

Examples

paperspace.scripts.list(function(err, res) {
  // handle error or result
});
# HTTP request:
https://api.paperspace.io
GET /scripts/getScripts
x-api-key: 1ba4f98e7c0...
# Returns 200 on success

Parameters

Name Type Attributes Description
filter object

An optional filter object to limit the returned script objects

Properties

cb function Node-style error-first callback function

Returns

[ script, ... ] - JSON array of script objects

Type array

//Example return value:
[
  {
    "id": "sc123abc",
    "ownerType": "user",
    "ownerId": "u456def",
    "name": "My Script",
    "description": "original file: my_script.sh",
    "dtCreated": "2017-05-30T14:49:16.724Z",
    "isEnabled": true,
    "runOnce": false
  }
]

Show

Show information for the script with the given id, except for the script text. Use the scripts text method retrieve the script text.

Examples

paperspace.scripts.show({
  scriptId: 'sc123abc',
}, function(err, res) {
  // handle error or result
});
# HTTP request:
https://api.paperspace.io
GET /scripts/getScript?scriptId=sc123abc
x-api-key: 1ba4f98e7c0...
# Returns 200 on success

Parameters

Name Type Description
params object

Script show parameters

Properties

cb function Node-style error-first callback function

Returns

script - The script JSON object

Type object

//Example return value:
{
  "id": "sc123abc",
  "ownerType": "user",
  "ownerId": "u456def",
  "name": "My Script",
  "description": "original file: my_script.sh",
  "dtCreated": "2017-05-30T14:49:16.724Z",
  "isEnabled": true,
  "runOnce": false
  "machines": [
    {
      "machineId": "ps123abc",
      "dtLastRun": "2017-07-06T12:38:17.325Z"
    },
    {
      "machineId": "ps456def",
      "dtLastRun": null
    }
  ]
}

Text

Gets the text of the script with the given id.

Examples

paperspace.scripts.text({
  scriptId: 'sc123abc',
}, function(err, res) {
  // handle error or result
});
# HTTP request:
https://api.paperspace.io
GET /scripts/getScriptText?scriptId=sc123abc
x-api-key: 1ba4f98e7c0...
# Returns 200 on success

Parameters

Name Type Description
params object

Script text parameters

Properties

cb function Node-style error-first callback function

Returns

script - The script JSON object

Type string

//Example return value:
"services start nginx"