Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
17 changes: 17 additions & 0 deletions API-strategie-modules/eventdrivenarchitecture/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
The W3C SOFTWARE NOTICE AND LICENSE (W3C)

https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document

This work is being provided by the copyright holders under the following license. By obtaining and/or copying this work, you (the licensee) agree that you have read, understood, and will comply with the following terms and conditions.

Permission to copy, modify, and distribute this work, with or without modification, for any purpose and without fee or royalty is hereby granted, provided that you include the following on ALL copies of the work or portions thereof, including modifications:
1. The full text of this NOTICE in a location viewable to users of the redistributed or derivative work.
2. Any pre-existing intellectual property disclaimers, notices, or terms and conditions. If none exist, the W3C Software and Document Short Notice (https://www.w3.org/Consortium/Legal/2015/copyright-software-short-notice.html) should be included.
3. Notice of any changes or modifications, through a copyright statement on the new code or document such as "This software or document includes material copied from or derived from [title and URI of the W3C document]. Copyright © [YEAR] W3C® (MIT, ERCIM, Keio, Beihang)."


THIS WORK IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE OR DOCUMENT WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.

COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENT.

The name and trademarks of copyright holders may NOT be used in advertising or publicity pertaining to the work without specific, written prior permission. Title to copyright in this work will at all times remain with copyright holders.
32 changes: 32 additions & 0 deletions API-strategie-modules/eventdrivenarchitecture/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
## Template document API Strategie Modulen

Deze folder bevat een template om nieuwe modulen te maken. Kopieer de files en pas de inhoud aan om een nieuw Respec document te maken wat de module specificeert.

### Gebruikers instructie
Om aanpassingen te maken zijn er 2 opties:
- De configuratie van het document aanpassing in de config files
- Markdown files toevoegen

De **configuratie files** bevat informatie over de organisatie en over
de status van het document. Bekijk de [Logius ReSpec wiki](https://github.com/Logius-standaarden/respec/wiki)
voor meer informatie over de configuratie opties. De files zijn gesplitst in 2 files:
[organisation-config.js](js/organisation-config.js) en [config.js](js/config.js)

De *organisation_config* bevat informatie over de organisatie, de informatie in deze file
zal bijna nooit veranderen zoals de naam van de organisatie. Het wordt aangeraden de file
zelf te hosten zodat hij in alle documentatie van de organisatie gebruikt kan worden en
niet elke keer gekopieerd te worden.

De *document_config* zal informatie bevatten die alleen relevant is voor het huidige document.

**Markdown files** bevatten de content van het document. Alle content
kan in 1 document, maar het is aan te raden om de content te splitsen
in verschillende files met een toepasselijke naam om onderhoud
makkelijker te maken.

Na het toevoegen van een nieuwe markdown file moet hij toegevoegd worden
aan de [index.html](index.html). Je voegt hem toe door
```<section data-include-format="markdown" data-include="filenaam.md"></section>```
toe te voegen aan de ```<body>``` van de index file. Vervang "filenaam.md" door de naam
van de markdown file die je toe wilt voegen.
De volgorde van de sections bepaald de volgorde in het resulterende document.
3 changes: 3 additions & 0 deletions API-strategie-modules/eventdrivenarchitecture/abstract.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Deze Event Driven Architecture module beschrijft de best practices voor het verwerken van Events in de context van APIs.

De module is gebaseerd op de content van [de notificatieservices repository van VNG Realisatie](https://github.com/VNG-Realisatie/notificatieservices) en de overige bonnen zoals vermeld.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Deze map bevat submappen met daarin producten die zijn opgeleverd binnen Project Notificatieservices.
U vindt een korte toelichting op de verschillende producten in [de startpagina](https://github.com/VNG-Realisatie/notificatieservices/blob/main/README.md) van het project.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Achtergrond documentatie

Het [Project Notificatieservices](https://github.com/VNG-Realisatie/notificatieservices) heeft naast het <a href="https://vng-realisatie.github.io/NL-GOV-profile-for-CloudEvents">NL GOV for CloudEvents profile</a> ook een aantal andere producten gemaakt. Deze zijn bedoeld om opgedane kennis binnen het project beschikbaar te stellen voor gebruik binnen projecten die zich richten op gebeurtenisgedreven inrichten van informatievoorziening in het algemeen en geautomatiseerd notificeren van applicaties in het bijzonder.

# Functionele handreikingen

Onderstaande handreikingen beschrijven op een toegankelijke manier een aantal belangrijke aspecten van gebeurtenisgedreven werken:

- [Introductie van notificeren](https://github.com/VNG-Realisatie/notificatieservices/blob/main/docs/achtergronddocumentatie/introductie_van_notificeren.pdf)
- [Het waarom van notificeren](https://github.com/VNG-Realisatie/notificatieservices/blob/main/docs/achtergronddocumentatie/waarom_notificeren.pdf)
- [Definiëren van gebeurtenistypes](https://github.com/VNG-Realisatie/notificatieservices/blob/main/docs/achtergronddocumentatie/gebeurtenistypes_definieren.pdf)
- [Randvoorwaardelijke aspecten](https://github.com/VNG-Realisatie/notificatieservices/blob/main/docs/achtergronddocumentatie/randvoorwaarden_notificeren.pdf)
- [Notificatiescenario's](https://github.com/VNG-Realisatie/notificatieservices/blob/main/docs/achtergronddocumentatie/notificatiescenarios.pdf)

# Architectuur handreiking

De uitgebreide handreiking [Notificatieservices Architectuur](https://github.com/VNG-Realisatie/notificatieservices/blob/main/docs/achtergronddocumentatie/notificatieservices_architectuur.pdf) beschrijft een breed scala aan architectuuraspecten met betrekking tot gebeurtenisgedreven werken. Er is hierbij gebruik gemaakt van wat wereldwijd aan kennis en ervaring op dit vlak bestaat.

# Diversen

- [Scope van project Notificatieservices](https://github.com/VNG-Realisatie/notificatieservices/blob/main/docs/achtergronddocumentatie/notificatieservices_scope.pdf) - Een toelichting op de scope van het uitgevoerde project Notificatieservices.
- [Bevindingen beproevingen 2021](https://github.com/VNG-Realisatie/notificatieservices/blob/main/docs/achtergronddocumentatie/beproevingen_2021.pdf) - In 2021 is de opgestelde concept-berichtstandaard beproefd tijdens een Hackathon ([demo](https://youtu.be/IdneTcAQFbA)). Met Logius is een beproeving gedaan om te onderzoeken of het mogelijk is om met gebruik van de concept-berichtstandaard notificaties vanuit de BRP te leveren.
- [Bevindingen beproevingen 2022](https://github.com/VNG-Realisatie/notificatieservices/blob/main/docs/achtergronddocumentatie/beproevingen_2022.pdf) - In de eerste helft 2022 is de concept-berichtstandaard op verschillende manieren beproefd. De standaard is gebruikt door een leverancier bij het ontwikkelen van software waarmee vanuit een gemeentelijke applicatie een applicatie bij een externe instelling wordt genotificeerd. Binnen het Kadaster zijn inzichten uit project Notificatieservices gebruikt bij het opstellen van gebeurtenisdefinities en is de concept-berichtenstandaard daarbij toegepast. De VNG heeft een nieuwe versie van een bestaande Notificatie-API ontwikkeld conform de concept-berichtenstandaard die tijdens een API-lab door meerdere leveranciers is beproefd.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Archief achtergrond documentatie

Deze map 'Archief' bevat producten die tijdens de uitvoering van het [Project Notificatieservices](https://github.com/VNG-Realisatie/notificatieservices) tussentijds zijn opgeleverd. Voor de meeste van deze producten geldt dat in de bovenliggende map 'achtergronddocumentatie' de versie staat die bij afronding van het project is opgeleverd.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Documentatie en bestanden voor het API-Lab juni 2022
Original file line number Diff line number Diff line change
@@ -0,0 +1,279 @@

# Tutorial notificeren

In deze tutorial configureren we de referentieimplementatie van de Notificatierouteringscomponent (NRC) voor het versturen en ontvangen van notificaties via de Gemeentelijke Generieke Notificatie API (gebaseerd op CloudEvents).

Overal waar in deze tutorial het woord `notificatie` voorkomt kan ook het begrip `event` gelezen worden. De term `event` wordt gebruikt door de internationale CloudEvents standaard.

## Wat zijn de vereisten voor deze tutorial?

* API-key voor authorisatie
* Voor het API-Lab is dat de API-Key:
eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ0ZXN0c3VpdGUiLCJpYXQiOjE2NTQwODk3NzAsImNsaWVudF9pZCI6Im5yYyIsInVzZXJfaWQiOiJ0ZXN0X3VzZXJfaWQiLCJ1c2VyX3JlcHJlc2VudGF0aW9uIjoiVGVzdCBVc2VyIn0.9CjhYTw-eREVXtdiTQbwyOsXAkAMln5sRj5lzmsaa1s
* Bekendheid met webhooks is een plus

Optioneel:
* `docker` en `docker-compose` zijn aanwezig.

**n.b. Tijdens het API-Lab kan geen ondersteuning verleend worden bij issues ivm installatie en werking van de docker-image.**

## Aan de slag

### Ontvangen en versturen van notificaties

In het notificatieproces zijn de volgende stappen te onderkennen:
1. Een bron maakt bij de Notificatierouteringscomponent (NRC) een domain aan (indien nog niet aanwezig).
2. Een afnemer abonneert zich bij de NRC een geeft daarbij eventuele filtercriteria op.
3. Een bron levert een notificatie (event) af bij de NRC zodat deze verspreid kan worden.
4. De NRC controleert, op basis van de filtercriteria in de abonnementen, bij welke afnemers het aangeleverde event afgeleverd moet worden.
5. De NRC levert de relevante events af bij de afnemer. (Door een POST uit te voeren op de door de afnemer in het abonnement opgegeven `sink` = end-point).

De events zijn in te zien op de NRC. Ga hiervoor naar [de hoofdpagina van de referentieimplementatie](https://notificaties-api.test.vng.cloud/) en klik op de knop 'Logviewer'.

De tutorial hieronder bestaat uit twee delen:
* [Events publiceren](#ik-wil-als-bron-events-publiceren)
* [Events ontvangen](#ik-wil-als-afnemer-events-ontvangen)

#### Ik wil als bron events publiceren

Zoals in het notificatieproces beschreven is het registreren van een domein een noodzakelijke stap om notificaties te kunnen distribueren.

**_Tip: Maak tijdens het API-lab een eigen domein en bijbehorende eventtypes aan zodat de uitgevoerde testen van elkaar gescheiden blijven._**

_Bijvoorbeeld: domein: nl.vng.zaken.leverancierX en dan als types: nl.vng.zaken.leverancierX.zaak_gesloten etc._

Stappen:

1. Bepaal de naam van het domein. Voor bijvoorbeeld zaken is dit `nl.vng.zaken.leverancierX`.

2. Zorg dat het domein bekend is bij het NRC. Je kan dit controleren door eerst de lijst met domeinen op te vragen:

```http
GET https://notificaties-api.test.vng.cloud/api/v1/domains HTTP/1.0
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ0ZXN0c3VpdGUiLCJpYXQiOjE2NTQwODk3NzAsImNsaWVudF9pZCI6Im5yYyIsInVzZXJfaWQiOiJ0ZXN0X3VzZXJfaWQiLCJ1c2VyX3JlcHJlc2VudGF0aW9uIjoiVGVzdCBVc2VyIn0.9CjhYTw-eREVXtdiTQbwyOsXAkAMln5sRj5lzmsaa1s
```
Het resultaat ziet er bijvoorbeeld als onderstaand uit:
```json
{
"name": "nl.vng.zaken.leverancierX",
"documentationLink": "https://github.com/VNG-Realisatie/notificatieservices/blob/main/docs/api-specification/voorbeeld_documentatielink_zaken_domein.md",
"filterAttributes": [
"bronorganisatie",
"vertrouwelijkheidsaanduiding",
"zaaktype"]
"url": "https://notificaties-api.test.vng.cloud/api/v1/domains/8ce0ae0d-941f-406e-99c8-5f1ac7ebc699"
}
```
Als het domein bestaat, kun je aan de hand van de UUID van het domein, de details van het domein opvragen (in dit geval zou dat dan 8ce0ae0d-941f-406e-99c8-5f1ac7ebc699 zijn)

```http
GET https://notificaties-api.test.vng.cloud/api/v1/domains/8ce0ae0d-941f-406e-99c8-5f1ac7ebc699 HTTP/1.0
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ0ZXN0c3VpdGUiLCJpYXQiOjE2NTQwODk3NzAsImNsaWVudF9pZCI6Im5yYyIsInVzZXJfaWQiOiJ0ZXN0X3VzZXJfaWQiLCJ1c2VyX3JlcHJlc2VudGF0aW9uIjoiVGVzdCBVc2VyIn0.9CjhYTw-eREVXtdiTQbwyOsXAkAMln5sRj5lzmsaa1s
```

3. Registreer het domein (indien het nog niet bestaat)

```http
POST https://notificaties-api.test.vng.cloud/api/v1/domains HTTP/1.0
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ0ZXN0c3VpdGUiLCJpYXQiOjE2NTQwODk3NzAsImNsaWVudF9pZCI6Im5yYyIsInVzZXJfaWQiOiJ0ZXN0X3VzZXJfaWQiLCJ1c2VyX3JlcHJlc2VudGF0aW9uIjoiVGVzdCBVc2VyIn0.9CjhYTw-eREVXtdiTQbwyOsXAkAMln5sRj5lzmsaa1s
Content-Type: application/json

{
"naam": "nl.vng.zaken.leverancierX",
"documentatieLink": "https://github.com/VNG-Realisatie/notificatieservices/blob/main/docs/api-specification/voorbeeld_documentatielink_zaken_domein.md",
"filterAttributes": [
"bronorganisatie",
"zaaktype",
"vertrouwelijkheidaanduiding"
]
}
```

De documentatielink hoort te documenteren welke kenmerken relevant zijn voor een domein en welke events gepubliceerd kunnen worden. Dit helpt afnemers om te bepalen waarop ze willen abonneren.

4. Verstuur een bericht

```http
POST https://notificaties-api.test.vng.cloud/api/v1/events HTTP/1.0
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ0ZXN0c3VpdGUiLCJpYXQiOjE2NTQwODk3NzAsImNsaWVudF9pZCI6Im5yYyIsInVzZXJfaWQiOiJ0ZXN0X3VzZXJfaWQiLCJ1c2VyX3JlcHJlc2VudGF0aW9uIjoiVGVzdCBVc2VyIn0.9CjhYTw-eREVXtdiTQbwyOsXAkAMln5sRj5lzmsaa1s
Content-Type: application/json

{
"id": "042eecb9-be40-4588-8c3c-8de1e0c27ae8",
"specversion": "1.0",
"source": "urn:nld:oin:00000001234567890000:systeem:Zaaksysteem",
"domain": "nl.vng.zaken.leverancierX",
"type": "nl.vng.zaken.leverancierX.zaak_gecreeerd",
"time": "2022-06-15T09:00:00.001Z",
"datacontenttype": "application/json",
"data": {
"foo": "bar"
},
"dataref": "https://www.vng.nl/"
}
```

#### Ik wil als afnemer events ontvangen

1. Zorg voor een endpoint om events te ontvangen. Gebruik bijvoorbeeld de [webhook-site](https://webhook.site) om events eenvoudig te ontvangen en bekijken.

**_Let op: Zorg dat het eindpoint als statuscode de code 204 retourneerd en niet de standaard 200._**

_Op webhook.site kan dit door rechtsboven op de optie `edit` te klikken en in vervolgens de default status code aan te passen naar 204._

_n.b. In de voorbeelden is geen sink/eind-point ingevuld._

2. Vraag op welke domeinen beschikbaar zijn:

```http
GET https://notificaties-api.test.vng.cloud/api/v1/domains HTTP/1.0
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ0ZXN0c3VpdGUiLCJpYXQiOjE2NTQwODk3NzAsImNsaWVudF9pZCI6Im5yYyIsInVzZXJfaWQiOiJ0ZXN0X3VzZXJfaWQiLCJ1c2VyX3JlcHJlc2VudGF0aW9uIjoiVGVzdCBVc2VyIn0.9CjhYTw-eREVXtdiTQbwyOsXAkAMln5sRj5lzmsaa1s
````

3. Registreer je abonnement bij het NRC:

```http
POST https://notificaties-api.test.vng.cloud/api/v1/subscription HTTP/1.0
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ0ZXN0c3VpdGUiLCJpYXQiOjE2NTQwODk3NzAsImNsaWVudF9pZCI6Im5yYyIsInVzZXJfaWQiOiJ0ZXN0X3VzZXJfaWQiLCJ1c2VyX3JlcHJlc2VudGF0aW9uIjoiVGVzdCBVc2VyIn0.9CjhYTw-eREVXtdiTQbwyOsXAkAMln5sRj5lzmsaa1s
Content-Type: application/json

{
"protocol": "HTTP",
"sink": "<your end-point here>",
"source": "urn:nld:oin:00000001234567890000:systeem:Zaaksysteem",
"protocolSettings": {
"headers": {
"X-Custom-Header": "foobar"
},
"method": "POST"
},
"sinkCredential": {
"credentialType": "ACCESSTOKEN",
"accessToken": "abcdef",
"accessTokenExpiresUtc": "2022-12-31T23:59:00.000Z",
"accessTokenType": "bearer"
},
"config": {
"property1":"string1",
"property1":"string2"
},
"domain": "nl.vng.zaken.leverancierX",
"types": [],
"filters":
[
{
"any": [
{
"all": [
{
"exact": {
"attribute": "domain",
"value": "nl.vng.zaken.leverancierX"
}
},
{
"any": [
{
"exact": {
"attribute": "type",
"value": "nl.vng.zaken.leverancierX.zaak_gesloten"
}
},
{
"exact": {
"attribute": "type",
"value": "nl.vng.zaken.leverancierX.zaak_geopend"
}
}
]
}
]
},
{
"all": [
{
"exact": {
"attribute": "domain",
"value": "nl.vng.burgerzaken"
}
},
{
"exact": {
"attribute": "type",
"value": "nl.vng.burgerzaken.kind_geboren_aangifte_elders"
}
}
]
}
]
}
],
"subscriberReference": "Ref"
}
```

* `protocol`: Enige toegestane protocol is HTTP.

* `protocolSettings`: Wordt gebruikt om headers door te sturen naar de afnemer.
* Als het end-point met access tokens werkt dan kunnen deze opgegeven worden in `sinkCredential`. Maakt het end-point nog gebruik van een username/password dan kunnen deze eventueel in de `protocolSettings` als `header` opgegeven worden.

* `sink`: De volledige URL naar je _eigen_ endpoint waar je de events wenst op te ontvangen.

* `sinkCredential`: Hier moet de informatie opgegeven worden over het access token dat nodig is om het end-point te kunnen benaderen. Voor `webhook.site` kunnen dummy waarden gebruikt worden.

* `source`: Filteroptie. Hier kan opgegeven worden van welke bron events afkomstig moeten zijn.

* `domain`: Filteroptie. Hier kan opgegeven worden van welke domein events afkomstig moeten zijn.

* `types`: Filteroptie. Hier kan opgegeven worden aan welke typen het type van het event moet voldoen.

* `filters`: Filteroptie. Hiërarchische structuur met daarin een logische expressie. In bovenstaande voorbeeld is onderstaand gefilterd uitgeschreven:

```
(
(domain = nl.vng.zaken.leverancierX)
AND
( (type = nl.vng.zaken.leverancierX.zaak_gesloten) OR (type = nl.vng.zaken.leverancierX.zaak_geopend) )
)
OR
(
(domein = nl.vng.burgerzaken) AND (type = nl.vng.burgerzaken.kind_geboren_aangifte_elders)
)
```
Zie ook https://github.com/VNG-Realisatie/notificatieservices/blob/main/docs/api-specification/gedrag.md#beoordelen-filtercriteria.

* `subscriberReference`: Deze referentie wordt opgenomen in events die doorgestuurd worden naar de afnemer op basis van dit abonnement. De afnemer kan deze informatie bijvoorbeeld gebruiken voor interne routering van het event.

4. Berichten worden nu naar je eigen endpoint gestuurd met een POST request

Hieronder staat een voorbeeld HTTP message zoals deze gepost wordt door de NRC op het end-point.

```http
POST <your end-point here> HTTP/1.0
Content-Type: application/json
Authorization: Bearer <your access token>

{
"id": "042eecb9-be40-4588-8c3c-8de1e0c27ae8",
"data":
{
"foo": "bar"
},
"time": "2018-03-07T15:47:57.420Z",
"type": "nl.vng.zaken.leverancierX.zaak_gecreeerd",
"domain": "nl.vng.zaken.leverancierX",
"source": "urn:nld:oin:00000001234567890000:systeem:Zaaksysteem",
"dataref": "https://www.vng.nl/",
"specversion": "1.0",
"datacontenttype": "application/json",
"subscriberReference": "<your reference>",
"subscription": "02b95def-c6be-4042-9672-6f73b094e997"
}
```

## Postman scripts ##

Om de API zelf te kunnen testen, zijn er enkele voorbeeld scripts gemaakt voor gebruik in Postman.

Zie [Postman scripts](./Notificaties%20API-Lab.postman_collection.zip) voor Postman scripts

Loading