- Source:
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
|
||||||||||||||||||||||||||||||||
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
|
||||||
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
|
||||||||||||||||||||||||||||||||||||
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
|
||||||
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
|
||||||
cb |
function | Node-style error-first callback function |
Returns:
script - The script JSON object
- Type
- string