scripts

scripts

Methods

(static) create(params, cb) → {object}

Source:

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.

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
});
$ paperspace scripts create \
    --scriptName "My Script" \
    --scriptDescription "A startup script" \
    --scriptText "services start nginx" \
    --isEnabled true \
    --runOnce false \
    --machineId "ps123abc"
# 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
// 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
}
Parameters:
Name Type Description
params object

Script create parameters

Properties
Name Type Attributes Description
scriptName string

A unique name for the script

scriptFile string <optional>

File path to a file containing the script data; either scriptFile or scriptText must be provide.

scriptText string <optional>

A string containing the script text; either scriptFile or scriptText must be provide.

scriptDescription string <optional>

Description of the script

isEnabled boolean <optional>

Determines if the script is enabled or not. Defaults to true

runOnce boolean <optional>

Determines if the script is run on first boot or every boot. Defaults to false

machineId string <optional>

Machine id of a machine that should execute this script at startup

cb function

Node-style error-first callback function

Returns:

script - The created script JSON object

Type
object

(static) destroy(params, cb)

Source:

Destroys the starup 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
});
$ paperspace scripts destroy --scriptId "sc123abc"
# 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
Name Type Description
scriptId string

The id of the script to destroy

cb function

Node-style error-first callback function

(static) list(filteropt, cb) → {array}

Source:

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
});
$ paperspace scripts list
# HTTP request:
https://api.paperspace.io
GET /scripts/getScripts
x-api-key: 1ba4f98e7c0...
# Returns 200 on success
//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
  }
]
Parameters:
Name Type Attributes Description
filter object <optional>

An optional filter object to limit the returned script objects

Properties
Name Type Attributes Description
id string <optional>

Optional script id to match on

ownerType string <optional>

Optional ownerType to match on, either 'user' or 'team'

ownerId string <optional>

Optional ownerId to match on, either a userId or teamId

name string <optional>

Optional name to match on

description string <optional>

Optional description to match on

dtCreated string <optional>

Optional datetime created value to match on

isEnabled boolean <optional>

Optional isEnabled value to match on, either true or false

runOnce boolean <optional>

Optional runOnce value to match on, either true or false

cb function

Node-style error-first callback function

Returns:

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

Type
array

(static) show(params, cb) → {object}

Source:

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
});
$ paperspace scripts show \
    --scriptId "sc123abc"
# HTTP request:
https://api.paperspace.io
GET /scripts/getScript?scriptId=sc123abc
x-api-key: 1ba4f98e7c0...
# Returns 200 on success
//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
    }
  ]
}
Parameters:
Name Type Description
params object

Script show parameters

Properties
Name Type Description
scriptId string

Id of the script to show

cb function

Node-style error-first callback function

Returns:

script - The script JSON object

Type
object

(static) text(params, cb) → {string}

Source:

Gets the text of the script with the given id.

Examples
paperspace.scripts.text({
  scriptId: 'sc123abc',
}, function(err, res) {
  // handle error or result
});
$ paperspace scripts text \
    --scriptId "sc123abc"
# HTTP request:
https://api.paperspace.io
GET /scripts/getScriptText?scriptId=sc123abc
x-api-key: 1ba4f98e7c0...
# Returns 200 on success
//Example return value:
"services start nginx"
Parameters:
Name Type Description
params object

Script text parameters

Properties
Name Type Description
scriptId string

Id of the script to get text for

cb function

Node-style error-first callback function

Returns:

script - The script JSON object

Type
string