Skip to content

Commit b210736

Browse files
authored
Merge pull request #527 from maykinmedia/feature/521-setup-config-docs
📝 [#521] Update docs for setup-config
2 parents 58dcb82 + 395ffaf commit b210736

File tree

13 files changed

+168
-221
lines changed

13 files changed

+168
-221
lines changed

.github/workflows/ci.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,12 @@ jobs:
8686
id: image-name
8787

8888
open-api-ci:
89-
uses: maykinmedia/open-api-workflows/.github/workflows/ci.yml@v3.0.2
89+
uses: maykinmedia/open-api-workflows/.github/workflows/ci.yml@v4.1.0
9090
needs:
9191
- store-reusable-workflow-vars
9292
with:
9393
main-branch: 'master'
94+
apt-packages: 'libgdal-dev gdal-bin'
9495
run-docs: true
9596
django-settings-module: objects.conf.ci
9697
python-version: '3.11'

.readthedocs.yaml

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ sphinx:
88
configuration: docs/conf.py
99

1010
build:
11-
os: 'ubuntu-20.04'
11+
os: 'ubuntu-22.04'
1212
apt_packages:
1313
- libxml2-dev
1414
- libxmlsec1-dev
1515
- libxmlsec1-openssl
1616
- wget
17+
- libgdal-dev
18+
- gdal-bin
1719
tools:
1820
python: '3.11'
1921

docs/conf.py

+14
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,16 @@
88
import os
99
import sys
1010

11+
import django
12+
from django.utils.translation import activate
13+
1114
sys.path.insert(0, os.path.abspath("../src"))
1215

1316
import objects # noqa isort:skip
17+
from objects.setup import setup_env # noqa isort:skip
18+
19+
setup_env()
20+
django.setup()
1421

1522
# from objects.setup import setup_env # noqa isort:skip
1623

@@ -41,6 +48,9 @@
4148
"sphinx.ext.todo",
4249
"sphinx_tabs.tabs",
4350
"recommonmark",
51+
"sphinx.ext.autodoc",
52+
"django_setup_configuration.documentation.setup_config_example",
53+
"django_setup_configuration.documentation.setup_config_usage",
4454
# "sphinx_markdown_tables",
4555
]
4656

@@ -54,6 +64,10 @@
5464
# Usually you set "language" from the command line for these cases.
5565
language = "en"
5666

67+
# Also set the language to English for Django, to make sure that any translatable text
68+
# is also shown in English (for instance the help texts for setup configuration examples)
69+
activate("en")
70+
5771
# List of patterns, relative to source directory, that match files and
5872
# directories to ignore when looking for source files.
5973
# This pattern also affects html_static_path and html_extra_path.

docs/installation/config_cli.rst

+48-191
Original file line numberDiff line numberDiff line change
@@ -5,216 +5,73 @@
55
Configuration (CLI)
66
===================
77

8-
After deploying Objecttypes API and Objects API, they need to be configured to be fully functional. The
9-
command line tool `setup_configuration`_ assist with this configuration:
10-
11-
You can get the full command documentation with:
12-
13-
.. code-block:: bash
14-
15-
src/manage.py setup_configuration --help
16-
17-
.. warning:: This command is declarative - if configuration is manually changed after
18-
running the command and you then run the exact same command again, the manual
19-
changes will be reverted.
20-
21-
.. _`setup_configuration`: https://github.com/maykinmedia/django-setup-configuration/
22-
23-
Preparation
24-
===========
25-
26-
The command executes the list of pluggable configuration steps, and each step
27-
requires specific configuration information, that should be prepared.
28-
Here is the description of all available configuration steps and the configuration
29-
format, use by each step.
8+
.. setup-config-usage::
9+
:show_command_usage: true
10+
:show_steps: false
11+
:show_steps_toc: false
12+
:show_steps_autodoc: false
3013

3114
Objects API
3215
===========
3316

34-
Objecttypes configuration
35-
-------------------------
36-
37-
To configure objecttypes the following configuration could be used:
38-
39-
.. code-block:: yaml
40-
41-
zgw_consumers_config_enable: true
42-
zgw_consumers:
43-
services:
44-
- identifier: objecttypen-foo
45-
label: Objecttypen API Foo
46-
api_root: http://objecttypen.foo/api/v1/
47-
api_type: orc
48-
auth_type: api_key
49-
header_key: Authorization
50-
header_value: Token ba9d233e95e04c4a8a661a27daffe7c9bd019067
51-
52-
- identifier: objecttypen-bar
53-
label: Objecttypen API Bar
54-
api_root: http://objecttypen.bar/api/v1/
55-
api_type: orc
56-
auth_type: api_key
57-
header_key: Authorization
58-
header_value: Token b9f100590925b529664ed9d370f5f8da124b2c20
59-
60-
objecttypes_config_enable: true
61-
objecttypes:
62-
items:
63-
- uuid: b427ef84-189d-43aa-9efd-7bb2c459e281
64-
name: Object Type 1
65-
service_identifier: objecttypen-foo
66-
67-
- uuid: b0e8553f-8b1a-4d55-ab90-6d02f1bcf2c2
68-
name: Object Type 2
69-
service_identifier: objecttypen-bar
70-
...
71-
72-
.. note:: The ``uuid`` field will be used to lookup existing ``ObjectType``'s.
73-
74-
Objecttypes require a corresponding ``Service`` to work correctly. Creating
75-
these ``Service``'s can be done by defining these in the same yaml file. ``Service``
76-
instances will be created before the ``ObjectType``'s are created.
77-
78-
Objecttypes connection configuration
79-
------------------------------------
80-
81-
In order to be able to retrieve objecttypes, a corresponding ``Service`` should be
82-
created. An example of a configuration could be seen below:
17+
.. setup-config-usage::
18+
:show_command_usage: false
8319

84-
.. code-block:: yaml
85-
86-
zgw_consumers_config_enable: true
87-
zgw_consumers:
88-
services:
89-
- identifier: objecttypes-api-1
90-
label: Objecttypes API 1
91-
api_root: http://objecttypes-1.local/api/v1/
92-
api_connection_check_path: objecttypes
93-
api_type: orc
94-
auth_type: api_key
95-
header_key: Authorization
96-
header_value: Token ba9d233e95e04c4a8a661a27daffe7c9bd019067
97-
- identifier: objecttypes-api-2
98-
label: Objecttypes API 2
99-
api_root: http://objecttypes-2.local/api/v1/
100-
api_connection_check_path: objecttypes
101-
api_type: orc
102-
auth_type: api_key
103-
header_key: Authorization
104-
header_value: Token b9f100590925b529664ed9d370f5f8da124b2c20
105-
106-
107-
Tokens configuration
108-
--------------------
109-
Create or update the (single) YAML configuration file with your settings:
110-
111-
.. code-block:: yaml
20+
Objecttypes API
21+
===============
11222

113-
tokenauth_config_enable: true
114-
tokenauth:
115-
items:
116-
- identifier: token-1
117-
token: ba9d233e95e04c4a8a661a27daffe7c9bd019067
118-
contact_person: Person 1
119-
email: person-1@example.com
120-
organization: Organization XYZ # optional
121-
application: Application XYZ # optional
122-
administration: Administration XYZ # optional
123-
permissions:
124-
- object_type: b427ef84-189d-43aa-9efd-7bb2c459e281
125-
mode: read_and_write
126-
127-
- identifier: token-2
128-
token: 7b2b212d9f16d171a70a1d927cdcfbd5ca7a4799
129-
contact_person: Person 2
130-
email: person-2@example.com
131-
permissions:
132-
- object_type: b0e8553f-8b1a-4d55-ab90-6d02f1bcf2c2
133-
mode: read_only
134-
use_fields: true
135-
fields:
136-
'1':
137-
- record__data__leeftijd
138-
- record__data__kiemjaar
139-
140-
.. note:: To ensure the proper functioning of the tokens, it is essential to first configure the ``objecttypes``.
141-
Then, the token configuration must be completed to guarantee the correct configuration of the ``Permissions``.
142-
143-
144-
Mozilla-django-oidc-db
145-
----------------------
146-
147-
Create or update the (single) YAML configuration file with your settings:
23+
.. FIXME these can currently only be included manually, because these docs are built in
24+
.. the objects API repo
14825
149-
.. code-block:: yaml
26+
.. autoclass:: django_setup_configuration.contrib.sites.steps.SitesConfigurationStep
27+
:noindex:
28+
.. setup-config-example:: django_setup_configuration.contrib.sites.steps.SitesConfigurationStep
15029

151-
oidc_db_config_enable: true
152-
oidc_db_config_admin_auth:
153-
items:
154-
- identifier: admin-oidc
155-
oidc_rp_client_id: client-id
156-
oidc_rp_client_secret: secret
157-
endpoint_config:
158-
oidc_op_authorization_endpoint: https://example.com/realms/test/protocol/openid-connect/auth
159-
oidc_op_token_endpoint: https://example.com/realms/test/protocol/openid-connect/token
160-
oidc_op_user_endpoint: https://example.com/realms/test/protocol/openid-connect/userinfo
30+
.. autoclass:: mozilla_django_oidc_db.setup_configuration.steps.AdminOIDCConfigurationStep
31+
:noindex:
32+
.. setup-config-example:: mozilla_django_oidc_db.setup_configuration.steps.AdminOIDCConfigurationStep
16133

162-
# workaround for https://github.com/maykinmedia/django-setup-configuration/issues/27
163-
userinfo_claims_source: id_token
16434

165-
More details about configuring mozilla-django-oidc-db through ``setup_configuration``
166-
can be found at the _`documentation`: https://mozilla-django-oidc-db.readthedocs.io/en/latest/setup_configuration.html.
35+
**objecttypes.setup_configuration.steps.token_auth.TokenAuthConfigurationStep**
36+
-------------------------------------------------------------------------------
16737

168-
Sites configuration
169-
-------------------
38+
Configure tokens with permissions for other applications to access Objectstypes API
17039

17140
.. code-block:: yaml
17241
173-
sites_config_enable: true
174-
sites_config:
175-
items:
176-
- domain: example.com
177-
name: Example site
178-
- domain: test.example.com
179-
name: Test site
42+
tokenauth_config_enable: true
43+
tokenauth:
18044
181-
More details about sites configuration through ``setup_configuration``
182-
can be found at the _`site documentation`: https://github.com/maykinmedia/django-setup-configuration/blob/main/docs/sites_config.rst
183-
184-
185-
Notifications configuration
186-
---------------------------
187-
188-
To configure sending notifications for the application ensure there is a ``services``
189-
item present that matches the ``notifications_api_service_identifier`` in the
190-
``notifications_config`` namespace:
191-
192-
.. code-block:: yaml
45+
# REQUIRED: true
46+
items:
47+
-
19348
194-
zgw_consumers_config_enable: true
195-
zgw_consumers:
196-
services:
197-
- identifier: notifications-api
198-
label: Notificaties API
199-
api_root: http://notificaties.local/api/v1/
200-
api_connection_check_path: notificaties
201-
api_type: nrc
202-
auth_type: api_key
49+
# DESCRIPTION: A human-friendly label to refer to this token
50+
# REQUIRED: true
51+
identifier: objects-api
20352
204-
notifications_config_enable: true
205-
notifications_config:
206-
notifications_api_service_identifier: notifications-api
207-
notification_delivery_max_retries: 1
208-
notification_delivery_retry_backoff: 2
209-
notification_delivery_retry_backoff_max: 3
53+
# REQUIRED: true
54+
token: modify-this
21055
211-
Execution
212-
=========
56+
# DESCRIPTION: Name of the person in the organization who can access the API
57+
# REQUIRED: true
58+
contact_person: example_string
21359
60+
# DESCRIPTION: Email of the person, who can access the API
61+
# REQUIRED: true
62+
email: example_string
21463
215-
With the full command invocation, everything is configured at once and immediately
216-
tested.
64+
# DESCRIPTION: Organization which has access to the API
65+
# DEFAULT VALUE: ""
66+
# REQUIRED: false
67+
organization: example_string
21768
218-
.. code-block:: bash
69+
# DESCRIPTION: Application which has access to the API
70+
# DEFAULT VALUE: ""
71+
# REQUIRED: false
72+
application: example_string
21973
220-
src/manage.py setup_configuration --yaml-file /path/to/config.yaml
74+
# DESCRIPTION: Administration which has access to the API
75+
# DEFAULT VALUE: ""
76+
# REQUIRED: false
77+
administration: example_string

requirements/base.txt

+10-4
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ django-sendfile2==0.7.0
148148
# via django-privates
149149
django-sessionprofile==3.0.0
150150
# via open-api-framework
151-
django-setup-configuration==0.5.0
151+
django-setup-configuration==0.7.1
152152
# via
153153
# -r requirements/base.in
154154
# mozilla-django-oidc-db
@@ -183,6 +183,8 @@ djangorestframework-gis==1.0
183183
# via open-api-framework
184184
djangorestframework-inclusions==1.2.0
185185
# via open-api-framework
186+
docutils==0.21.2
187+
# via django-setup-configuration
186188
drf-nested-routers==0.94.1
187189
# via commonground-api-common
188190
drf-spectacular==0.27.2
@@ -236,11 +238,11 @@ maykin-2fa==1.0.1
236238
# via open-api-framework
237239
mozilla-django-oidc==4.0.0
238240
# via mozilla-django-oidc-db
239-
mozilla-django-oidc-db==0.21.1
241+
mozilla-django-oidc-db==0.22.0
240242
# via
241243
# -r requirements/base.in
242244
# open-api-framework
243-
notifications-api-common==0.4.0
245+
notifications-api-common==0.6.0
244246
# via
245247
# -r requirements/base.in
246248
# commonground-api-common
@@ -312,6 +314,10 @@ requests==2.32.3
312314
# zgw-consumers
313315
requests-mock==1.12.1
314316
# via commonground-api-common
317+
ruamel-yaml==0.18.10
318+
# via django-setup-configuration
319+
ruamel-yaml-clib==0.2.12
320+
# via ruamel-yaml
315321
sentry-sdk==2.12.0
316322
# via open-api-framework
317323
setuptools==75.6.0
@@ -360,7 +366,7 @@ webencodings==0.5.1
360366
# via bleach
361367
wrapt==1.14.1
362368
# via elastic-apm
363-
zgw-consumers==0.36.1
369+
zgw-consumers==0.37.0
364370
# via
365371
# -r requirements/base.in
366372
# commonground-api-common

0 commit comments

Comments
 (0)