Deploy User Defined Directive
This article lays out steps to deploy a user defined directive via the UI and REST API. Deploying UDD involves two steps:
Uploading the artifact JAR file containing the logic for the directive.
Updating the artifact properties (if any) from the artifact json file.
Deploy via REST
The example builds example-directive to be deployed via REST API.
Deploying JAR
curl 'http://localhost:11011/api/v3/namespaces/default/artifacts/simple-udds' \
-X 'POST' -H 'Artifact-Version: 1.2.0-SNAPSHOT' \
-H 'Artifact-Extends: system:wrangler-transform[4.0.0,5.0.0)/system:wrangler-service[4.0.0,5.0.0)' \
-H 'Artifact-Plugins: ' \
-H 'Content-Type: application/octet-stream' \
--compressed \
--data-binary "@<path-to-example-directive>/example-directive/target/simple-udds-1.2.0-SNAPSHOT.jar"
Deploying Properties
Once the JAR file uploads successfully, now we can update the properties of the artifact via the properties API call.
curl 'http://localhost:11011/api/v3/namespaces/default/artifacts/simple-udds/versions/1.2.0-SNAPSHOT/properties' \
-X 'PUT' \
-d@example-directive-properties.json
Note: The example-directive-properties.json
is the properties property in simple-udds-1.2.0-SNAPSHOT.json
file. We only need the properties from the artifact json file. The simple-udds-1.2.0-SNAPSHOT.json
file is of the format,
{
"properties": {},
"parents": [
"system:wrangler-transform[4.0.0,5.0.0)",
"system:wrangler-service[4.0.0,5.0.0)"
]
}
In this specific case, the example-directive-properties.json
will be {}
Deploy via the UI
Deploying the user-defined directive via the UI is straightforward.
Navigate to the UI with the Green “+” button.
Click on the Upload button under the Directive section
Upload the jar and the json files built as part of the directive. In my screenshot, I have built example-directive and have uploaded the jar and json from the target directory.
Once the custom user-defined directive is uploaded, it can now be used from the power mode in Wrangler from the CLI mode. In this case, the example-directive introduces a
text-length
directive