CLI: Templates
Learn how to use the CLI to manage templates.
Table of Contents
The CLI references “skysync.” This is expected.
Overview
The CLI allows you to manage job templates, including listing, showing, creating, and deleting templates. In all examples, the authentication parameters are provided within the configuration file. For more information, see CLI: Authentication.
List Templates
Parameter | Description | Required | Default |
---|---|---|---|
kind | Job Template Kind | Optional | |
search q |
Search text | Optional | |
active | Only retrieve active job templates | Optional | |
offset | Search offset | Optional | 0 |
limit | Search page size | Optional | 20 |
List All Job Templates
Command
skysync-cli templates list
Example Results
ID Name Kind Enabled
382d78ab17784b6bb14844ba1ea819bc Example template 1 transfer true
8c92e69280b74d1aa8c66e6c992ac475 Example template 2 transfer true
Example JSON Results
[
{
"id": "382d78ab17784b6bb14844ba1ea819bc",
"name": "Example template 1",
"kind": "transfer",
"disabled": false,
"schedule": {
"mode": "manual"
}
},
{
"id": "8c92e69280b74d1aa8c66e6c992ac475",
"name": "Example template 2",
"kind": "transfer",
"disabled": false,
"schedule": {
"mode": "manual"
}
}
]
List Transfer Job Templates
Command
skysync-cli templates list --kind transfer
List Active Job Templates
Command
skysync-cli templates list --active
List Job Templates With Specific Text In Name
The following examples list jobs that contain the text “test” in the name.
Command
skysync-cli templates list --search test
or
skysync-cli templates list -q "test"
List Job Templates Using Offset
An offset allows you to skip profiles and start listing at a certain number. The following example skips the first five templates.
Command
skysync-cli templates list --offset=5
Show a Job Template
This command will show the details of the specified job template. The parameters within the two curly braces (including the braces) must be replaced with valid values.
Parameter | Description | Required |
---|---|---|
id | The ID of the job template for which details will be shown | Required |
Command With Variables
skysync-cli templates show {{id}}
Command With Sample Variables
skysync-cli templates show 382d78ab17784b6bb14844ba1ea819bc
Example Results
ID 382d78ab17784b6bb14844ba1ea819bc
Name Example template 1
Kind transfer
Enabled true
Example JSON Results
[
{
"id": "382d78ab17784b6bb14844ba1ea819bc",
"name": "Example template 1",
"kind": "transfer",
"disabled": false,
"schedule": {
"mode": "manual"
},
"transfer": {
"source": {
"options": null,
"connection": {
"id": "df48c59e4bb54a66bccf2270b316bd71",
"name": "Box Connection",
"platform": {
"id": "box",
"type": "platform"
},
"disabled": true,
"type": "connection"
},
"target": {
"item": {
"parent": {
"root": true,
"name": "Libraries"
},
"name": "Documents"
}
}
},
"destination": {
"options": null,
"connection": {
"id": "df48c59e4bb54a66bccf2270b316bd71",
"name": "Box Connection",
"platform": {
"id": "box",
"type": "platform"
},
"disabled": true,
"type": "connection"
},
"target": {
"item": {
"root": true,
"name": "transfer_destination"
}
}
},
"transfer_type": "copy",
"audit_level": "trace",
"type": "transfer"
}
}
]
Expected Results for Invalid ID
If the entered ID does not correspond to an existing profile (because the profile has been deleted, for example), the expected output is as follows.
ID
Name
Kind
Enabled true
Expected JSON Results for Invalid ID
null
Create a Job Template
This command will create a template. If both auto and manual are set to true, the job will be created to run manually.
Parameter | Description | Required | Default |
---|---|---|---|
kind | Job Template Kind | Required | transfer |
name | The job template name | Optional | |
auto | Schedule the job as automatic | Optional | true |
manual | Schedule the job as manual | Optional | false |
options-input in |
Read JSON options from stdin | ||
options-output file |
The options JSON file |
To create a job template that imports permissions or metadata, use the below examples in conjunction with the documentation for the permissions import or the metadata import.
Create a Job Template Providing Options From STDIN
This feature is only available with scripting, such as in a PowerShell or Node script. In this example, the template will be created by providing the JSON contents as a parameter, and the schedule will be set to manual.
This feature is not supported from a standard terminal, such as a command line; however, piping may be utilized to pass in the JSON option block via Node or PowerShell. See the example below.
PowerShell Command With Variables
'{"source": {"connection": {"id": "{{sourceConnectionId"}, "target": {"path": "{{sourcePath}}"}}, "destination": {"connection": {"id": "{{destinationConnectionId"}, "target": {"path": "{{destinationPath}}"}}}' | skysync-cli templates add --manual --in --name="Example Template"
Expected Results
ID 8b9ea3d812e24d7892d88d63acb40402
Name : to
Kind transfer
Enabled true
Create a Job Template Providing Options From a File
In this example, the template will be created by providing the location of the JSON options file, and the schedule will be set to manual. The authentication parameters are provided within the configuration file.
Command
skysync-cli templates add --name="Example Template" --manual --options-file=templateOptions.JSON
Contents of templateOptions.json With Variables
{
"source":
{
"connection":
{
"id": "{{sourceConnectionId}}"
},
"target":
{
"path": "{{sourcePath}}"
}
},
"destination":
{
"connection":
{
"id": "{{destinationConnectionId}}"
},
"target":
{
"path": "{{destinationPath}}"
}
}
}
Contents of templateOptions.json With Sample Values
{
"source":
{
"connection":
{
"id": "490d8c2eba054392bde988a548d88354"
},
"target":
{
"path": "/source"
}
},
"destination":
{
"connection":
{
"id": "fbc78a0fa9074d20b778e6e6fc1bd898"
},
"target":
{
"path": "/destination"
}
}
}
Expected Results
ID 8b9ea3d812e24d7892d88d63acb40402
Name Example Tempalte
Kind transfer
Enabled true
Delete a Job Template
This command will delete the specified job template. The parameters within the two curly braces (including the braces) must be replaced with valid values.
Parameter | Description | Required |
---|---|---|
id | The ID of the template to be deleted | Required |
Command
skysync-cli templates delete {{id}}
Command With Variables
skysync-cli templates delete 5dc531df34554edd96c31272262ad950
Expected Results
The template was deleted successfully.
Expected Results for Invalid ID
If the entered ID does not correspond to an existing template (for example, because the template has been deleted), the expected output is as follows. The response is only available in the default format. If JSON output is specified, no output will be provided.
The template could not be deleted.