Skip to content

Commit

Permalink
[#4396] Added basic plugin and necessary views and endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
vaszig committed Aug 23, 2024
1 parent d59807b commit 0ee299f
Show file tree
Hide file tree
Showing 14 changed files with 354 additions and 238 deletions.
1 change: 1 addition & 0 deletions docs/configuration/prefill/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ Prefill plugins
kvk
stuf_bg
suwinet
objects_api
42 changes: 42 additions & 0 deletions docs/configuration/prefill/objects_api.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
.. _configuration_prefill_objects_api:

===========
Objects API
===========

`Objects API`_ can store objects which are defined (their schema and properties) in the `Objecttypes API`_.
With this prefill plugin we can have components/form fields which have pre-filled the values taken from the Objects API.

.. note::

This service contains sensitive data and requires a connection to a specific
client system. The forms which make use of this prefill plugin require DigiD/Eherkenning authentication
of the user.

.. _`Objects API`: https://objects-and-objecttypes-api.readthedocs.io/en/latest/
.. _`Objecttypes API`: https://objects-and-objecttypes-api.readthedocs.io/en/latest/


Configuration
=============

1. In Open Forms, navigate to: **Forms**
2. Click **Add form**
3. Define the necessary form details and add the desired components
4. Navigate to: **Variables** tab
5. Navigate to: **User defined** subtab
6. Click **Add variable** and fill in the data from the available options:

* **Plugin**: *Choose the Objects API plugin*
* **API Group**: *Choose the desired API Group *
(There must be at least one added-configured via **Miscellaneous** > **Objects API groups**)
* **Objecttype**: *Based on the selected API group above, you can choose the objecttype from the auto populated list*
* **Mappings**: *On the left we have the available form variables and on the right the available attributes which are
defined in the selected objecttype's schema properties. You can do the mappings accordingly*

7. Click **Save**
8. Save the form

The Objects API configuration is now complete.


3 changes: 3 additions & 0 deletions docs/developers/plugins/prefill_plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ You can find an example implementation in :mod:`openforms.prefill.contrib.demo`.
Implementation
--------------

Plugins must be added to the INSTALLED_APPS :mod:`openforms.conf.base`. See the demo app as an example
("openforms.prefill.contrib.demo.apps.DemoApp")

Plugins must implement the interface from :class:`openforms.prefill.base.BasePlugin`.
It's safe to use this as a base class.

Expand Down
130 changes: 130 additions & 0 deletions src/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3586,6 +3586,123 @@ paths:
$ref: '#/components/headers/X-Is-Form-Designer'
Content-Language:
$ref: '#/components/headers/Content-Language'
/api/v2/prefill/plugins/objects-api/objecttypes:
get:
operationId: prefill_plugins_objects_api_objecttypes_list
description: List the available prefill objecttypes for Objects API plugin.
summary: List available objecttypes for Objects API
parameters:
- in: query
name: objects_api_group
schema:
type: string
description: Which Objects API group to use.
tags:
- registration
security:
- cookieAuth: []
responses:
'200':
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Objecttype'
description: ''
headers:
X-Session-Expires-In:
$ref: '#/components/headers/X-Session-Expires-In'
X-CSRFToken:
$ref: '#/components/headers/X-CSRFToken'
X-Is-Form-Designer:
$ref: '#/components/headers/X-Is-Form-Designer'
Content-Language:
$ref: '#/components/headers/Content-Language'
/api/v2/prefill/plugins/objects-api/objecttypes/{objects_api_objecttype_uuid}/versions:
get:
operationId: prefill_plugins_objects_api_objecttypes_versions_list
description: List the available prefill objecttype versions for Objects API
plugin.
summary: List available objecttype versions for Objects API
parameters:
- in: query
name: objects_api_group
schema:
type: string
description: Which Objects API group to use.
- in: path
name: objects_api_objecttype_uuid
schema:
type: string
format: uuid
required: true
tags:
- registration
security:
- cookieAuth: []
responses:
'200':
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/ObjecttypeVersion'
description: ''
headers:
X-Session-Expires-In:
$ref: '#/components/headers/X-Session-Expires-In'
X-CSRFToken:
$ref: '#/components/headers/X-CSRFToken'
X-Is-Form-Designer:
$ref: '#/components/headers/X-Is-Form-Designer'
Content-Language:
$ref: '#/components/headers/Content-Language'
? /api/v2/prefill/plugins/objects-api/objecttypes/{objects_api_objecttype_uuid}/versions/{objects_api_objecttype_version}/attributes
: get:
operationId: prefill_plugins_objects_api_objecttypes_versions_attributes_list
description: List the available attributes for Objects API plugin.
summary: List available attributes for Objects API
parameters:
- in: query
name: objects_api_group
schema:
type: string
description: Which Objects API group to use.
- in: path
name: objects_api_objecttype_uuid
schema:
type: string
format: uuid
required: true
- in: path
name: objects_api_objecttype_version
schema:
type: integer
required: true
tags:
- prefill
security:
- cookieAuth: []
responses:
'200':
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/PrefillObjectsAPIAttribute'
description: ''
headers:
X-Session-Expires-In:
$ref: '#/components/headers/X-Session-Expires-In'
X-CSRFToken:
$ref: '#/components/headers/X-CSRFToken'
X-Is-Form-Designer:
$ref: '#/components/headers/X-Is-Form-Designer'
Content-Language:
$ref: '#/components/headers/Content-Language'
/api/v2/products:
get:
operationId: products_list
Expand Down Expand Up @@ -9465,6 +9582,19 @@ components:
description: |-
* `main` - Main
* `authorizee` - Authorizee
PrefillObjectsAPIAttribute:
type: object
properties:
value:
type: string
title: ID
description: The unique attribute identifier
label:
type: string
description: The human-readable name for an attribute.
required:
- label
- value
PrefillPlugin:
type: object
properties:
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 @@ -228,6 +228,7 @@
"openforms.prefill.contrib.stufbg.apps.StufBgApp",
"openforms.prefill.contrib.haalcentraal_brp.apps.HaalCentraalBRPApp",
"openforms.prefill.contrib.suwinet.apps.SuwinetApp",
"openforms.prefill.contrib.objects_api.apps.ObjectsApiApp",
"openforms.authentication",
"openforms.authentication.contrib.demo.apps.DemoApp",
"openforms.authentication.contrib.outage.apps.DemoOutageApp",
Expand Down
Loading

0 comments on commit 0ee299f

Please sign in to comment.