One of the most powerful aspects of the Flex platform is the ability to be able to write scripts to perform custom processing.
For example, you could make an external HTTP REST call, inserting the results as asset metadata values. Within scripts, Flex provides an SDK that allows you to manipulate configuration and objects in a standard and well-defined manner.
There are 2 ways to write scripts within Flex:
- Groovy scripts
- External scripts - compiled JVM-compatible code in JARs (e.g. Groovy, Java, Scala)
Groovy scripts are added to supported actions, either by referencing an external Git repository (the prefered method) or by adding them manually to the configuration.
Note that Flex currently supports Groovy v4.
The following is an example script, which could be executed in a JEF Script action, which creates a new media placeholder asset:
def execute() {
def asset = new NewAssetPlaceholder()
asset.setType('media-asset')
asset.setName('demo asset 1')
flexSdkClient.assetService.createAsset(asset)
}
External scripts are compiled code packaged in to JARs, and hosted via a standard URL (e.g. HTTP, file). These allow customers to write re-usable and testable binaries (see External Scripts for more information).
Getting the Documentation
Flex SDK documentation can be obtained from the Sonatype Nexus repository when you get the SDKs.
Go here and select the Flex version to find the matching SDK version.
https://help.dalet.com/daletflex/admin/developer_guide/apis/apis.html.
To access the Nexus Repository when using the London VPN (you need the Full VPN and not ‘split’).
https://nexus-internal.ooflex.net/
Click search on the left and build your search.
Click on flex-sdk-external, you will see the files you will need.
The one circled red is the documentation, the green circled files is the library and related POM file (used if using Apache Maven to manage your projects build).
Click each one to get its summary, and a clickable link to download; for the POM you might need to right-click and save as.
The link to the Javadoc is: https://nexus-internal.ooflex.net/#browse/search=keyword%3Dflex-sdk-external%20AND%20version%3D6.3.15.7:7000856c6cd9d79646cce941976de468:938c5ea312f2f64bd28abb1da087c8a9
Once you’ve downloaded the Javadoc, rename the extension from .jar to .zip, and extract the documentation and view it as it, by opening index.html (if you don’t want to have the documentation in your IntelliJ project).
Scriptable Actions
The following actions provide support for scripting:
Actions
Type | New Action | Legacy Action | Purpose |
Decision | JEF Script Decision | Groovy Scripted Decision Action | Controls workflow simple branch execution via the return boolean value of a groovy script |
Decision | JEF Script Multi-Decision | Groovy Scripted Multi-Decision Action | Controls workflow complex branch execution via the return string value of a groovy script |
Message | JEF HTTP Message | Scripted HTTP Message | Sends an HTTP message, allowing the request and/or response to be processed via groovy script |
Script | JEF Script | Groovy Script Action | Executes either internal or external scripts |
Wait | JEF Wait For Named Signal | Groovy Scripted Wait For Named Signal Action | Pauses workflow execution until a signal is received. Groovy script can be used to control whether the action should wait for the signal |
Wait | JEF Wait For Script | Groovy Scripted Wait Action | Pauses workflow execution until a groovy script returns true, or times out |
Timed Actions
New Action | Legacy Action | Purpose |
JEF HTTP Message | Timed HTTP Message | Sends an HTTP message on a schedule, allowing the response to be processed via groovy script |
JEF Script | Timed Groovy Script | Executes internal or external groovy scripts on a schedule |
The new actions execute via the flex-jobasyncexecutor-service, and as such, any scripting interactions with Flex occur via its REST APIs.
Help writing scripts
The following pages are useful guides to help accelerate the writing of Flex scripts:
- Flex Scripting: Best Scripting Advice
- Flex Scripting: Best Practices
- Flex Scripting: Locking
- Flex Scripting: Transactions Within Scripting
- Flex Scripting: Things to Avoid
- Flex Scripting: Defensive Script Writing
- Flex Scripting: Writing External Scripts
- Flex Scripting: Scripting Examples
Comments
1 comment
Benjamin KAHANE Thank you for the article !
Can we please add here a link to the SDK documentation ?
I went through a few articles but couldn't find it
+ the latest documentation I could find sits on an old/unsupported/https broken link :
https://flexapi.ooyala.com/dalet_flex_sdk/flex73_sdkdocs/index.html
Thank you !
FYI Brett CHAMBERS Vikas Sood
Please sign in to leave a comment.