Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADD improved and new transformations #4595

Merged
merged 10 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions Changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
- Upgrade cjexl version from 0.3.0 to 0.4.0 (new transformations: now, getTime and toIsoString)

4.0.0 (June 6th, 2024)

- Add: JEXL expression support in custom notification macro replacement (using cjexl 0.3.0) (#4004)
Expand Down Expand Up @@ -148,11 +150,11 @@

3.5.0 (January 28th, 2022)

- Fix: avoid duplicated attributes and metadata in arrays in POST /v2/subscriptions and PATCH /v2/subscriptions/{subId} (#2101)
- Fix: $each usage with $push operator to add several items to array (#744)
- Fix: allow HTTPS certificates larger than 2048 bytes (#4012)
- Fix: DateTime attribute macro rendering in custom notifications was numeric instead of ISO8601 (#3894)
- Fix: buffer overflow problem in logs subsystem for from= field, causing crash in some cases (#3884)
- Fix: avoid duplicated attributes and metadata in arrays in POST /v2/subscriptions and PATCH /v2/subscriptions/{subId} (#2101)
- Fix: $each usage with $push operator to add several items to array (#744)
- Fix: allow HTTPS certificates larger than 2048 bytes (#4012)
- Fix: DateTime attribute macro rendering in custom notifications was numeric instead of ISO8601 (#3894)
- Fix: buffer overflow problem in logs subsystem for from= field, causing crash in some cases (#3884)

3.4.0 (December 14th, 2021)

Expand Down
2 changes: 1 addition & 1 deletion ci/deb/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ rm -Rf /tmp/builder || true && mkdir -p /tmp/builder/{db1,db2,db,bu}
if [ -z "${REPO_ACCESS_TOKEN}" ]; then
echo "Builder: no REPO_ACCESS_TOKEN, skipping cjexl lib download"
else
bash /opt/fiware-orion/get_cjexl.sh 0.3.0 $REPO_ACCESS_TOKEN
bash /opt/fiware-orion/get_cjexl.sh 0.4.0 $REPO_ACCESS_TOKEN
fi

if [ -n "${branch}" ]; then
Expand Down
66 changes: 65 additions & 1 deletion doc/manuals/orion-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@
- [`keys`](#keys)
- [`arrSum`](#arrsum)
- [`arrAvg`](#arravg)
- [`now`](#now)
- [`toIsoString`](#toisostring)
- [`getTime](#gettime)
fgalan marked this conversation as resolved.
Show resolved Hide resolved
- [Failsafe cases](#failsafe-cases)
- [Known limitations](#known-limitations)
- [Oneshot Subscriptions](#oneshot-subscriptions)
Expand Down Expand Up @@ -2684,7 +2687,7 @@ foo bar

#### substring

Returns a substring between two positions.
Returns a substring between two positions or `null` in case of wrong parameters (eg. final position is longer than string, final position is leeser than initial position, etc.)

Extra arguments:
* Initial position
Expand Down Expand Up @@ -3146,6 +3149,67 @@ results in
3
```

#### now

Returns the current time (plus a number of seconds specified as argument) as seconds since Unix epoch time.

Extra arguments: none

Example (being current time August 1st, 2024 at 9:31:02):

```
0|new
fgalan marked this conversation as resolved.
Show resolved Hide resolved
```

results in

```
1722504662
```

It can be checked at https://www.epochconverter.com that time corresponds to August 1st, 2024 at 9:31:02

#### toIsoString

Returns the [ISO8601](https://en.wikipedia.org/wiki/ISO_8601) corresponding to a given timestamp (as seconds since Unix epoch time) passed as argument.

Extra arguments: none

Example (being context `{"c": 1720606949}`):

```
c|toIsoString
```

results in

```
"2024-07-10T10:22:29+00:00"
```

It can be checked at https://www.epochconverter.com that 1720606949 corresponds to 2024-07-10T10:22:29+00:00


#### getTime

Returns the timestamp (as seconds since Unix epoch time) correspoding to the [ISO8601](https://en.wikipedia.org/wiki/ISO_8601) passed as argument.

Extra arguments: none

Example (being context `{"c": "2024-07-10T10:22:29+00:00"}`):

```
c|getTime
```

results in

```
1720606949
```

It can be checked at https://www.epochconverter.com that 1720606949 corresponds to 2024-07-10T10:22:29+00:00

### Failsafe cases

As failsafe behaviour, evaluation returns `null` in the following cases:
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ RUN --mount=type=secret,id=repo_token,dst=/run/secrets/repo_token \
git clone https://github.com/${GIT_NAME}/fiware-orion && \
cd fiware-orion && \
git checkout ${GIT_REV_ORION} && \
bash get_cjexl.sh 0.3.0 $(cat /run/secrets/repo_token) && \
bash get_cjexl.sh 0.4.0 $(cat /run/secrets/repo_token) && \
make && \
make install && \
# reduce size of installed binaries
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.alpine
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ RUN --mount=type=secret,id=repo_token,dst=/run/secrets/repo_token \
git clone https://github.com/${GIT_NAME}/fiware-orion && \
cd fiware-orion && \
git checkout ${GIT_REV_ORION} && \
bash get_cjexl.sh 0.3.0 $(cat /run/secrets/repo_token) && \
bash get_cjexl.sh 0.4.0 $(cat /run/secrets/repo_token) && \
# patch bash and mktemp statement in build script, as in alpine is slightly different
sed -i 's/mktemp \/tmp\/compileInfo.h.XXXX/mktemp/g' scripts/build/compileInfo.sh && \
sed -i 's/bash/ash/g' scripts/build/compileInfo.sh && \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ payload='{
"AA",
"AB",
"AC",
"AD"
"AD",
"AE",
"AF",
"AG"
],
"httpCustom": {
"url": "http://127.0.0.1:'${LISTENER_PORT}'/notify",
Expand Down Expand Up @@ -205,6 +208,18 @@ payload='{
"AD": {
"type": "Number",
"value": "${AD|len}"
},
"AE": {
"type": "Number",
"value": "${AE|now}"
},
"AF": {
"type": "Text",
"value": "${AF|toIsoString}"
},
"AG": {
"type": "Number",
"value": "${AG|getTime}"
}
}
}
Expand Down Expand Up @@ -344,6 +359,18 @@ payload='{
"AD": {
"type": "StructuredValue",
"value": [1, 2, 3]
},
"AE": {
"type": "Number",
"value": 0
},
"AF": {
"type": "Number",
"value": 1722500129
},
"AG": {
"type": "Number",
"value": "1979-11-13T18:01:14+00:00"
}
}'
orionCurl --url /v2/entities --payload "$payload"
Expand Down Expand Up @@ -383,7 +410,7 @@ Content-Length: 0
==================================================
POST http://127.0.0.1:REGEX(\d+)/notify
Fiware-Servicepath: /
Content-Length: 1627
Content-Length: 1809
User-Agent: orion/REGEX(\d+\.\d+\.\d+.*)
Ngsiv2-Attrsformat: normalized
Host: 127.0.0.1:REGEX(\d+)
Expand Down Expand Up @@ -422,6 +449,21 @@ Fiware-Correlator: REGEX([0-9a-f\-]{36}); cbnotif=1
"type": "Number",
"value": 3
},
"AE": {
"metadata": {},
"type": "Number",
"value": REGEX(\d+)
},
"AF": {
"metadata": {},
"type": "Text",
"value": "2024-08-01T08:15:29+00:00"
},
"AG": {
"metadata": {},
"type": "Number",
"value": 311364074
},
"B": {
"metadata": {},
"type": "Text",
Expand Down
Loading
Loading