Skip to content

Commit

Permalink
Merge pull request #4956 from open-formulieren/feature/4908-json-regi…
Browse files Browse the repository at this point in the history
…stration-backend

Feature/4908 json registration backend
  • Loading branch information
viktorvanwijk authored Jan 21, 2025
2 parents 1717537 + 29b11fa commit 8c29ae8
Show file tree
Hide file tree
Showing 35 changed files with 1,637 additions and 0 deletions.
15 changes: 15 additions & 0 deletions docker/docker-compose.json-dump.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: '3.8'

name: json-dump

services:
flask_app:
build: ./json-dump
ports:
- "80:80"
volumes:
- ./json-dump/:/app/

networks:
open-forms-dev:
name: open-forms-dev
17 changes: 17 additions & 0 deletions docker/json-dump/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Use the official Python image from the Docker Hub
FROM python:3.12-slim

# Set the working directory
WORKDIR /app

# Copy the current directory contents into the container at /app
COPY . /app

# Install the dependencies
RUN pip install Flask

# Make port 80 available to the world outside this container
EXPOSE 80

# Run app.py when the container launches
CMD ["python", "app.py"]
18 changes: 18 additions & 0 deletions docker/json-dump/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# JSON dump registration plugin

The `docker-compose.json-dump.yml` compose file is available to run a mock service intended
to simulate a receiving server to test the JSON dump registration backend plugin. It contains an
endpoint for sending json data (`json_plugin`) and testing the connection (`test_connection`).

The `json_plugin` endpoint returns a confirmation message that the data was received, together with the
received data. The `test_connection` endpoint just returns an 'OK' message.

## docker compose

Start an instance in your local environment from the parent directory:

```bash
docker compose -f docker-compose.json-dump.yml up -d
```

This starts a flask application at http://localhost:80/ with the endpoints `json_plugin` and `test_connection`.
23 changes: 23 additions & 0 deletions docker/json-dump/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import json

from flask import Flask, jsonify, request

app = Flask(__name__)

@app.route("/json_plugin", methods=["POST"])
def json_plugin_post():
data = request.get_json()

app.logger.info(f"Data received: {data}")

message = "No data" if data is None else "Data received"
return jsonify({"message": message, "data": json.loads(data)}), 201


@app.route("/test_connection", methods=["GET"])
def test_connection():
return jsonify({"message": "OK"}), 200


if __name__ == "__main__":
app.run(host="0.0.0.0", port=80, debug=True)
1 change: 1 addition & 0 deletions pyright.pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ include = [
# Registrations
"src/openforms/registrations/tasks.py",
"src/openforms/registrations/contrib/email/",
"src/openforms/registrations/contrib/json_dump/",
"src/openforms/registrations/contrib/stuf_zds/options.py",
"src/openforms/registrations/contrib/stuf_zds/plugin.py",
"src/openforms/registrations/contrib/stuf_zds/typing.py",
Expand Down
1 change: 1 addition & 0 deletions src/openforms/conf/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@
"openforms.registrations.contrib.objects_api",
"openforms.registrations.contrib.microsoft_graph.apps.MicrosoftGraphApp",
"openforms.registrations.contrib.camunda.apps.CamundaApp",
"openforms.registrations.contrib.json_dump",
"openforms.prefill",
"openforms.prefill.contrib.demo.apps.DemoApp",
"openforms.prefill.contrib.kvk.apps.KVKPrefillApp",
Expand Down
54 changes: 54 additions & 0 deletions src/openforms/js/compiled-lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,12 @@
"value": "User defined"
}
],
"5rj0a+": [
{
"type": 0,
"value": "Service"
}
],
"5uaKBM": [
{
"type": 0,
Expand Down Expand Up @@ -1231,6 +1237,12 @@
"value": "Something went wrong while retrieving the available role types defined in the selected case. Please check that the services in the selected API group are configured correctly."
}
],
"AkG8Zu": [
{
"type": 0,
"value": "Plugin configuration: JSON"
}
],
"AtBVAV": [
{
"type": 0,
Expand Down Expand Up @@ -1523,6 +1535,12 @@
"value": "length"
}
],
"CZ774U": [
{
"type": 0,
"value": "Which variables to include in the data to be sent"
}
],
"Cf5zSF": [
{
"type": 0,
Expand Down Expand Up @@ -2245,6 +2263,12 @@
"value": " is unknown. We can only display the JSON definition."
}
],
"Ibejpf": [
{
"type": 0,
"value": "Path relative to the Service API root"
}
],
"Igt0Rc": [
{
"type": 0,
Expand Down Expand Up @@ -2487,6 +2511,12 @@
"value": "Manually defined"
}
],
"Kl9yvd": [
{
"type": 0,
"value": "Path"
}
],
"KrJ+rN": [
{
"type": 0,
Expand Down Expand Up @@ -2883,6 +2913,12 @@
"value": "Advanced"
}
],
"OpkUgV": [
{
"type": 0,
"value": "Whether to include this variable in the data to be sent."
}
],
"Orf0vr": [
{
"type": 0,
Expand Down Expand Up @@ -3803,6 +3839,12 @@
"value": "Remove"
}
],
"XyDeaD": [
{
"type": 0,
"value": "Variables"
}
],
"Y4oNhH": [
{
"type": 0,
Expand Down Expand Up @@ -5673,6 +5715,12 @@
"value": "Something went wrong while retrieving the available object type versions."
}
],
"nZZkHx": [
{
"type": 0,
"value": "Include variable"
}
],
"neCqv9": [
{
"type": 0,
Expand Down Expand Up @@ -5985,6 +6033,12 @@
"value": "This template is evaluated with the submission data when the payment is received. The resulting JSON is sent to the objects API to update (the payment fields of) the earlier created object."
}
],
"qPiUic": [
{
"type": 0,
"value": "Which service to send the data to"
}
],
"qUYLVg": [
{
"type": 0,
Expand Down
54 changes: 54 additions & 0 deletions src/openforms/js/compiled-lang/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,12 @@
"value": "Gebruikersvariabelen"
}
],
"5rj0a+": [
{
"type": 0,
"value": "Service"
}
],
"5uaKBM": [
{
"type": 0,
Expand Down Expand Up @@ -1235,6 +1241,12 @@
"value": "Er ging iets fout bij het ophalen van de beschikbare roltypen in het geselecteerde zaaktype. Controleer of de services in de geselecteerde API-groep goed ingesteld zijn."
}
],
"AkG8Zu": [
{
"type": 0,
"value": "Plugin configuration: JSON"
}
],
"AtBVAV": [
{
"type": 0,
Expand Down Expand Up @@ -1527,6 +1539,12 @@
"value": "length"
}
],
"CZ774U": [
{
"type": 0,
"value": "Which variables to include in the data to be sent"
}
],
"Cf5zSF": [
{
"type": 0,
Expand Down Expand Up @@ -2266,6 +2284,12 @@
"value": " is niet bekend. We kunnen enkel de JSON-definitie weergeven."
}
],
"Ibejpf": [
{
"type": 0,
"value": "Path relative to the Service API root"
}
],
"Igt0Rc": [
{
"type": 0,
Expand Down Expand Up @@ -2504,6 +2528,12 @@
"value": "Handmatig ingesteld"
}
],
"Kl9yvd": [
{
"type": 0,
"value": "Path"
}
],
"KrJ+rN": [
{
"type": 0,
Expand Down Expand Up @@ -2900,6 +2930,12 @@
"value": "Geavanceerd"
}
],
"OpkUgV": [
{
"type": 0,
"value": "Whether to include this variable in the data to be sent."
}
],
"Orf0vr": [
{
"type": 0,
Expand Down Expand Up @@ -3816,6 +3852,12 @@
"value": "Verwijderen"
}
],
"XyDeaD": [
{
"type": 0,
"value": "Variables"
}
],
"Y4oNhH": [
{
"type": 0,
Expand Down Expand Up @@ -5691,6 +5733,12 @@
"value": "Er ging iets fout bij het ophalen van de objecttypeversies."
}
],
"nZZkHx": [
{
"type": 0,
"value": "Include variable"
}
],
"neCqv9": [
{
"type": 0,
Expand Down Expand Up @@ -6003,6 +6051,12 @@
"value": "Dit sjabloon wordt geëvalueerd met de inzendingsgegevens wanneer de betaling ontvangen is. De resulterende JSON wordt naar de Objecten-API gestuurd om (de betaalattributen van) het eerder aangemaakte object bij te werken."
}
],
"qPiUic": [
{
"type": 0,
"value": "Which service to send the data to"
}
],
"qUYLVg": [
{
"type": 0,
Expand Down
Loading

0 comments on commit 8c29ae8

Please sign in to comment.