SINCE VERSION 6.0
What is a PIPEFORCE URI?
Whenever you need to load data from some internal or external location, you can use a URI to point to such a location. You do so already by using such URIs in your web browser, for example. Common URI types you might be familiar with, are:
https://www.google.com
ftp://smith:12345@ftp.host
file:/data/path/contract.docx
Besides such commonly known URI types, PIPEFORCE also supports custom URI types to simplify access to common resources used internally in PIPEFORCE. Such a custom URI is called a PIPEFORCE URI.
Custom PIPEFORCE URIs typically start with an additional prefix $uri:
followed by the concrete uri scheme (type).
They typically have a format like this:
$uri:<name>:<path><params>
Whereas:
<name>
must be replaced by the type name of the URI to be used such asdrive
,property
,pipeline
or similar for example (see below). It is the implementation type of the URI.<path>
must be replaced by the path or value which will be passed as input value to the URI implementation.<params>
is optional an can contain parameters in the format?param1=value1¶m2=value2
.
In most locations where a URI is accepted as an argument, for example in commands or utils, you can apply such a PIPEFORCE URI.
Here are some examples of common PIPEFORCE URIs:
URI | Description |
---|---|
| Loads a file from the |
| Loads a property |
| Loads only the value of a property from the property store. |
| Executes the persisted pipeline at given location and returns the final body content as result. |
| Executes the persisted pipeline at given location, passes the given parameters |
| Returns the information object of the given user with given username. |
|
|
Here is an example to apply a custom URI on a command:
pipeline: - mails.send: to: recipient@mail.tld subject: "Hello!" message: "Hello World!" attachments: $uri:property:global/app/myapp/resources/file
As you can see in this example, the attachments argument contains a PIPEFORCE URI pointing to a property in the property store. This property will be loaded and added as an attachment.
And in this example, a PIPEFORCE URI is used inside a PEL util instead:
pipeline: - body.set: value: ${@resolve.uri('$uri:drive:/someFolder/document.json')}
Resolving a PIPEFORCE URI
You have multiple options to resolve a PIPEFORCE URI: Resolving an URI means, loading the content this URI is pointing to.
By command
In case you use a PIPEFORCE URI as parameter to a supporting command, this URI will automatically resolved to its content data by this command, as you could see by the previous example:
pipeline: - mails.send: to: recipient@mail.tld subject: "Hello!" message": Hello World!" attachments: $uri:property:global/app/myapp/resources/file
By resolve
command
In order to explicitly resolve a PIPEFORCE URI, there is a special command resolve for this, which can resolve any URI and returns the content of it.
You can use it in a pipeline like this:
pipeline: - resolve: uri: $uri:property:gloabl/app/myapp/config/app
This example will return you the full property (metadata + value) of the given property path. For example like this:
{ "checksum": "sha-256=38334e50687bc68125e3b66121311a0bd1b848b8fa36c85dfe189d84313c5582", "path": "/pipeforce/ns/global/app/myapp/config/app", "uuid": "cc059f6e-fa6a-4ad8-bc51-04a85e33b965", "locked": false, "trashed": false, "value": "{ \"title\": \"My App\", ...}", "defaultValue": null, "type": "application/json", "created": 1669907722095, "updated": 1671171893712, "timeToLive": null }
In order to return only the value of a property, you can use the $uri:property-value
scheme instead:
pipeline: - resolve: uri: $uri:property-value:gloabl/app/myapp/config/app
This will return only the value part of the property as JSON:
{ "title": "My App", "description": "This is my app", "icon": "assignment", "tags": [ "myapp" ], ... }
And if you would like return only the title
text of the JSON property value, you can use the #
symbol which let you query the content of the returned JSON value by applying a PEL on it. For example:
pipeline: - resolve: uri: $uri:property:gloabl/app/myapp/config/app#title
This would return:
My App
In case you use the #
symbol as request parameter, you need to decode it before sending. Otherwise the server would strip it off. Alternatively, you can send the URI in a POST request, form-data
encoded in the body. In this case, no encoding is required.
Here is an example how to use this command with curl
on the terminal with URI encoded parameter (the symbol #
is encoded to %23
):
curl -X GET -u username:password 'https://hub-ns.pipeforce.net/api/v3/command/resolve?uri=$uri:property:gloabl/app/myapp/config/app%23title'
By the @resolve.uri
util
Another possibility inside a pipeline is to use the @resolve.uri
function:
pipeline: - body.set: value: "Content is: ${@resolve.uri('$uri:property-value:gloabl/app/myapp/config/app')}"
PIPEFORCE URI Types
$uri:drive
This custom URI points to a file on the data room service drive
.
$uri:drive:<PATH_TO_FILE_OR_FOLDER_ON_DRIVE>
Example:
pipeline: - mail.send: attachments: $uri:drive:/contracts/contract1.pdf
$uri:pipeline
This URI can be used to execute a persisted pipeline, and return the final body output of this pipeline as a result.
$uri:pipeline:<PATH_TO_PERSISTED_PIPELINE>
Let's assume you have a pipeline like this stored at global/app/myapp/pipeline/hello
:
vars: name: null pipeline: - body.set: "HELLO: + ${vars.name}"
To execute this pipeline and to output this hello world example, you could execute a URI like this:
pipeline: - resolve: $uri:pipeline:global/app/myapp/pipeline/hello?name=Sam
In this example the URI parameter name
is used inside the pipeline as variable name
.
This will create a log-entry like this:
Output: HELLO: Sam
Adhoc Pipeline URI
You can use the $uri:pipeline
scheme also in order to execute an adhoc pipeline. This is a combination of commands to be executed in serial, one after another from left to right. The format is like this:
$uri:pipeline:?commandA="param1:value1;param2:value2"&commandB
This approach is handy in case you would like to call one or more commands in serial without persisting a pipeline for this.
The path part of the URI is empty and only the query string is given, starting with ?
whereas the name of a query param is the name of the command. The optional query param value contains the parameters to the command whereas name and value is separated by a colon :
and multiple params are separated by by a semicolon ;
. For example:
$uri:pipeline:?uri.get="uri:http://host/path;body=abc"&data.filter.jmespath="query:[?id=12]"
In case a command parameter is a default command parameter, it can be used without any parameter name prefix in the URI. So the example from above can be simplified to this:
$uri:pipeline:?uri.get="http://host/path"&data.filter.jmespath="[?id=12]"
Since uri
of command uri.get
and query
of command data.filter.jmespath
are default parameters, these parameter names can be skipped. But this must be then the only parameter given to the command. If you need more than one parameter per command, the pipeline must be written including the parameter names.
$uri:property
This custom URI points to a property in the property store.
$uri:property:<PATH_OF_PROPERTY_IN_PROPERTY_STORE>
Example:
pipeline: - body.set: value: "${@resolve.uri('$uri:property:global/app/myapp/config')}"
Will return the property including metadata and value like this example:
{ "checksum": "sha-256=38334e50687bc68125e3b66121311a0bd1b848b8fa36c85dfe189d84313c5582", "path": "/pipeforce/ns/global/app/myapp/config/app", "uuid": "cc059f6e-fa6a-4ad8-bc51-04a85e33b965", "locked": false, "trashed": false, "value": "{ \"title\": \"My App\", ...}", "defaultValue": null, "type": "application/json", "created": 1669907722095, "updated": 1671171893712, "timeToLive": null }
$uri:property-value
This custom URI points to the value of a property in the property store:
$uri:property-value:<PATH_OF_PROPERTY_IN_PROPERTY_STORE>
Example:
pipeline: - resolve: $uri:property-value:global/app/myapp/config
Will return the value of the property as JSON:
{ "title": "My App", "description": "This is my app", "icon": "assignment", "tags": [ "myapp" ], ... }
Value Filter (JSON)
In case the value of a property is of type application/json
, you can apply an expression filter on the value in order to return just a subset from the JSON:
$uri:property-value:<PATH>#<VALUE_FILTER>
This filter only works in case the value of the property is of the type: application/json
!
Let's assume we have a property in the property store like this:
{ "path": "path/to/person", "type": "application/json", "value": { "name": "Max Master", "age": 35, "hobbies": [ "swimming", "hiking" ] } }
We can use a value filter in the property URI in order to directly return the name of the person, like this:
pipeline: - resolve: $uri:property-value:path/to/person#name
Which will return a value like this:
Max Master
It's possible to use the full power of the PEL to filter, for example:
pipeline: - resolve: $uri:property-value:path/to/person#@list.size(hobbies)
Which will return a value like this:
3
The value filter will be applied on the fully loaded property value attribute: It will be converted to JSON and then the expression will be applied, then the resulting value is returned.
In case you have a huge JSON and you have to avoid fully loading this JSON into memory first, consider to use deep JSON querying instead in order to filter out the required value directly in the database. For more details see: JSON Property Querying.
$uri:user
This uri is handy to load a user object given by a username or uuid.
$uri:user:<USERNAME>
or
$uri:user:uuid=<USER_UUID>
For example:
pipeline: - body.set: value: ${@resolve.uri('$uri:user:maria')}
This will return the user-info data similar to this:
{ "uuid": "someUuid", "username": "maria", "email": "some@email.tld", "firstName": "Maria", "lastName": "Meyer", ... }
The same is true when using the uuid of the user:
pipeline: - body.set: value: ${@resolve.uri('$uri:user:uuid=someUuid')}
Add Comment