The tdscript
Command-Line Utility
The
tdscript
utility allows developers to script actions in the Titania
Delivery admin application using Javascript via the Nashorn Javascript engine included
with Java
8. This simplifies the development of applications leveraging the Java Client SDK.To execute a Javascript file using the classes and methods in the Java Client SDK,
simply
execute the command tdscript script-file
[parameters]
. Any command-line parameters specified past the script file
will be available within the script using an Array variable called
parameters.
The following script will create a project under a specific organization using a name
provided as a command-line parameter, and print the key of the new project to
stdout
.
var URL = "https://td.example.com/admin"; var USER = "demo@example.com"; var PASS = "MyP4ssword"; var ORG = "12345"; if (parameters.length === 0) { print("Must specify a project name."); return; } var sess = new com.titania.harp.client.HarpSession(URL); sess.login(USER, PASS); var p = sess.createOrgProject(parameters[0], ORG); print(p.key); sess.logout();
This script would be invoked via
tdscript mkproject.js "My Project"