...
Info |
---|
Calling a command via HTTP GET means:
|
Here is an example to execute the log
command as HTTP GET request, and set its message
parameter to a string value using a HTTP request parameter:
...
Info | ||||||
---|---|---|---|---|---|---|
Calling a command via HTTP POST (default behaviour) means:
Since
?params=body :
|
Here is an example to execute a single command as HTTP POST request, and set the message
parameter to a log
command using a HTTP POST data body in curl
:
...
Executing a Pipeline
Execute by HTTP request
Executing a Pipeline with HTTP is simple:
Create the Pipeline YAML script
Upload this YAML script in a HTTP POST request to the server
The server then executes your Pipeline and returns with the final output message.
As an example let's assume a more sophisticated pipeline like this, with different parameter value formats:
Code Block |
---|
pipeline:
- drive.read:
path: /my.pdf
- pdf.stamp:
text: |
Hello World!
- drive.save:
path: '/my-stamped.pdf' |
You can execute a pipeline via HTTP request. Also see the Pipeline API docs: https://pipeforce.github.io/redoc.html#tag/Pipeline-API
Ad-hoc pipeline
Executing an ad-hoc pipeline (ad-hoc = not persisted) with HTTP requires these steps:
Set the pipeline YAML script in the body of a request
Set the
Content-Type
header of the request toapplication/yaml
if the body is a single YAML pipeline or tomultipart/form-data
if the body contains a YAML pipeline and additional files to be uploaded and to be provided as content collection to the body of thepipeline
. In the multipart request body, the pipeline part must have the namepipeline
and each file part must have the namefile
.
Send this request as HTTP POST to the server at
/api/v3/pipeline
The server then executes the pipeline and returns with the final body message of the pipeline as response body.
Here is an example, with a YAML pipeline in the body. This example loads a PDF file, sets a text on it and stores it back. In order to execute this Pipeline YAMLpipeline, you can send it to the server using curl
for example:
Code Block |
---|
curl -X POST "https://hub-ns.pipeforce.net/api/v3/pipeline" \ -H "Content-Type: application/yaml" \ -u "username:password" \ --data-binary @- << EOF pipeline: - drive.read: path: /my.pdf - pdf.stamp: text: "Hello World!" - drive.save: path: /my-stamped.pdf EOF |
NOTESummary
The HTTP endpoint must be
/api/v3/pipeline
The HTTP method must be
POST
The HTTP header Content-Type must be
application/yaml
ormultipart/form-data
When using cURL, the EOF
syntax is required here in order to preserve the intends of the YAML script. Optionally, you can write the YAML in a local file an pass this file as argument for the body. See the example below, where the pipeline is specified in a file with name mypipeline.yaml
:
...
See HTTP Execution Reference for an summary of all supported HTTP options.
Sending the Body Message with HTTP
You can also send the pipeline body in an HTTP request. See this example:
Code Block |
---|
pipeline:
- log:
message: "BODY: #{body.text}"
body: {"text": "Hello World!"} |
Note that the value of the body can be a primitive or a JSON without additional escaping required.
...
Persisted pipeline
In order to execute a pipeline which is persisted in the property store, send a HTTP POST to the /pipeline:{path}
endpoint whereas {path}
is the path of the pipeline to be executed.
The body of the request becomes the body to the pipeline.
The request parameters become the variables to the pipeline.
Example:
Code Block |
---|
curl -X POST "https://hub-ns..pipeforce.net/api/v3/pipeline" \ -H "Content-Type: application/yaml" \ -u "username:password" \ --data-binary @- << EOF pipeline: - log: message: "BODY: #{body.text}" body: {"text": "Hello World!"} EOF |
The log output will be:
Code Block |
---|
BODY: Hello World!:global/app/myapp/pipeline/mypipeline" \ -u "username:password" |
This executes the pipeline stored at path global/app/myapp/pipeline/mypipeline
in the property store and returns the final pipeline body as response body to the caller.
Execute in Portal
The portal offers an advanced online editor with syntax highlighting, code completion and debugging support, where you can write pipelines and execute them online. This is the easiest and most preferred way to ad-hoc execute and test your pipelines. Here you can see a simple pipeline after its ad-hoc execution in the online editor:
...