REST transform¶
This transform can communicate with a REST service using HTTP requests.
Note that by default the REST transform will only attempt to parse responses with content-type “application/json”, if
the REST API provides other types of valid JSON, you can specify which in the json_content_types
property of
the associated REST system.
Responses which aren’t recognised as JSON will make the REST transform emit entities with a property containing the raw response body and - optionally - the content-type of the response for further processing with DTL and/or HTTP or REST transform(s).
Note that the shape of the entities piped to this transform must conform to certain criteria, see the notes later in the section.
Also note that, in contrast to the REST sink, the REST transform also supports the GET operation.
Prototype¶
{
"type": "rest",
"system" : "rest-system",
"operation": "the-default-operation",
"properties": {
"the-default": "properties"
},
"payload": {
"the-default": "payload"
},
"trigger_on": {
"key":"_trigger",
"value": "some-value*"
},
"rate_limiting_retries": 3,
"rate_limiting_delay": 60,
"response_property": "the-property-name-to-put-the-response-in",
"response_include_content_type": false,
"payload_property": "the-property-the-response-resides-in",
"id_expression": "{{ jinja_expression_for_the_id.property }}",
"updated_expression": "{{ jinja_expression_for_the_updated_property }}",
"ignored_status_codes": "404,444-450,501-599"
"if_transform_empty": "allow"
}
Properties¶
Property |
Type |
Description |
Default |
Req |
---|---|---|---|---|
|
String |
The id of the REST system to use. |
Yes |
|
|
Boolean |
Set to |
|
|
|
String |
The name of the property to store the result returned from the REST service. Note that if the |
|
|
|
String |
The name of the property to put the response headers in when emitting entities. Note that this property can be
defined in the REST system operation configuration as well. The configuration in the
transform will take precedence if both are defined. Also note that this property will only be set if
|
||
|
String |
The name of the property to put the response status code in when emitting entities. Note that this property can be
defined in the REST system operation configuration as well. The configuration in the transform
will take precedence if both are defined. Also note that this property will only be set if
|
||
|
Boolean |
This property controls if the entity should be replaced with the JSON contents of the response or if the
original entity should be kept. See the |
|
|
|
Boolean |
This property controls if the output entity should include the Content-Type of the response in a
|
|
|
|
String |
The default id of the operation to use if not present in the entity. |
||
|
Object |
An object containing the properties used for the |
||
|
Object |
Any non-payload properties you need can be specified in the |
||
|
Object |
A dictionary with two properties: |
||
|
Object, string or array |
The value to use as payload for the operation if not present in the entity. Note that this property can be
defined in the specified |
||
|
String |
The JSON response sub-property to use as the source of the emitted entities. Note that this property can be
defined in the specified |
||
|
String |
The property supports the |
||
|
String |
The property supports the |
||
|
String |
An expression in the form of single values or value ranges of HTTP status codes that will be allowed to be passed
through by the transform. The values are either comma separated integer values or a range of values with a hyphen separator
(i.e. a single Warning If you allow other status codes than the default, make sure that these are dealt with downstream. |
|
|
|
String |
An expression in the form of single values or value ranges of HTTP status codes that will be ignored by the
transform. HTTP responses with status codes matching this list will result in the response being omitted from
the result. The values are either comma separated integer values or a range of values with a hyphen separator
(i.e. a single Warning Any response with status codes listed here will be discarded with no traces to be found, making it next to impossible to audit the pipe. |
||
|
Enum<String> |
Determines the behaviour of the pipe when the REST transform does not produce any entities. The default value is
|
|
|
|
Integer |
If set and the REST service returns a HTTP 429 error code, the request will be retried the number of times
indicated. The time between retries can be adjusted by setting |
||
|
Integer |
If |
1 |
|
|
Boolean or Object |
This can be set to |
|
No |
|
Boolean |
If the |
|
No |
|
Integer |
If the |
100 |
No |
|
Boolean |
If the |
|
No |
|
Integer |
If the |
100 |
No |
|
Integer |
If the |
600 |
No |
Expected entity shape¶
The entities must be transformed into a particular form before being piped to the REST transform. The general form expected is:
{
"_id": "1",
"properties": {
"foo": "bar",
"zoo": 1,
"baz": [1,2,3]
},
"operation": "some-named-operation",
"payload": "<some>string-value</some>"
}
Property |
Type |
Description |
Default |
Req |
---|---|---|---|---|
|
Object |
Any non-payload properties you need should go into the toplevel child entity |
||
|
String |
The contents of this property must refer to one of the named |
||
|
String or Object |
The payload for the operation specified. It can be a string or an object. You can also omit it, in which case the empty string will be used instead (for example for “DELETE” methods). All string payloads will be encoded as UTF-8. |
Example entities:
String as payload:
{
"_id": "1",
"properties": {
"foo": "bar",
"zoo": 1,
"baz": [1,2,3]
},
"operation": "some-named-operation",
"payload": "<some>string-value</some>"
}
Object as payload (set operation payload-type
to “json”, “json-transit” or “form” in the REST system the transform uses):
{
"_id": "2",
"properties": {
"foo": "bar",
"zoo": 1,
"baz": [1,2,3]
},
"operation": "some-other-operation",
"payload": {
"payload": "property",
"child": {
"foo": "bar"
}
}
}
Multi-part form request if payload-type
is “form”, otherwise use “json” or “json-transit” for this type of entity:
{
"_id": "3",
"operation": "some-third-operation",
"payload": [
{
"foo": "bar"
},
{
"zoo": "foo"
}
]
}
Example configuration¶
See the REST system example section for how to configure the operations we refer to in these examples:
{
"type" : "pipe",
"transform" : {
"type" : "rest",
"system" : "our-rest-service",
"operation": "post-man",
"properties": {
"collection_name": "study-group-2"
}
}
}
Example input entities:
[
{
"_id": "bob",
"operation": "get-man",
"properties": {
"collection_name": "study-group-1"
}
}
]
Example output entities:
[
{
"_id": "bob",
"operation": "get-man",
"properties": {
"collection_name": "study-group-1"
},
"response": {
"name": "Bob Maker"
"email": "bob.maker@example.com"
}
}
]
Pagination support¶
See the the REST source examples for how to use pagination with the REST transform - the configuration set up is the same as with the REST source.