-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #524 from maykinmedia/feature/458-add-django-confi…
…g-zgw [#458] Add django setup configuration and ZGW steps
- Loading branch information
Showing
15 changed files
with
287 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/sh | ||
|
||
# Waiting for database to be up | ||
until pg_isready; do | ||
>&2 echo "Waiting for database connection..." | ||
sleep 1 | ||
done | ||
|
||
# Waiting for migrations to be done | ||
attempt_counter=0 | ||
max_attempts=${CHECK_MIGRATIONS_MAX_ATTEMPT:-10} | ||
|
||
while ! python src/manage.py migrate --check; do | ||
attempt_counter=$((attempt_counter + 1)) | ||
|
||
if [ $attempt_counter -ge $max_attempts ]; then | ||
>&2 echo "Timed out while waiting for django migrations." | ||
exit 1 | ||
fi | ||
|
||
>&2 echo "Attempt $attempt_counter/$max_attempts: Waiting for migrations to be done..." | ||
sleep 10 | ||
done | ||
|
||
# Run setup configuration | ||
python src/manage.py setup_configuration --yaml-file setup_configuration/data.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
zgw_consumers_config_enable: True | ||
zgw_consumers: | ||
services: | ||
- identifier: zaken-test | ||
label: Open Zaak - Zaken API | ||
api_root: http://localhost:8003/zaken/api/v1/ | ||
api_type: zrc | ||
auth_type: zgw | ||
client_id: test-vcr | ||
secret: test-vcr | ||
- identifier: documenten-test | ||
label: Open Zaak - Documenten API | ||
api_root: http://localhost:8003/documenten/api/v1/ | ||
api_type: drc | ||
auth_type: zgw | ||
client_id: test-vcr | ||
secret: test-vcr | ||
- identifier: catalogi-test | ||
label: Open Zaak - Catalogi API | ||
api_root: http://localhost:8003/catalogi/api/v1/ | ||
api_type: ztc | ||
auth_type: zgw | ||
client_id: test-vcr | ||
secret: test-vcr | ||
- identifier: besluiten-test | ||
label: Open Zaak - Besluiten API | ||
api_root: http://localhost:8003/besluiten/api/v1/ | ||
api_type: brc | ||
auth_type: zgw | ||
client_id: test-vcr | ||
secret: test-vcr | ||
- identifier: selectielijst | ||
label: Open Zaak (public) - Selectielijst API | ||
api_root: https://selectielijst.openzaak.nl/api/v1/ | ||
api_type: orc | ||
auth_type: no_auth | ||
|
||
api_configuration_enabled: True | ||
api_configuration: | ||
selectielijst_service_identifier: selectielijst |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
10 changes: 10 additions & 0 deletions
10
backend/src/openarchiefbeheer/config/setup_configuration/models.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from django_setup_configuration import ConfigurationModel | ||
from django_setup_configuration.fields import DjangoModelRef | ||
|
||
from ..models import APIConfig | ||
|
||
|
||
class APIConfigConfigurationModel(ConfigurationModel): | ||
selectielijst_service_identifier: str = DjangoModelRef( | ||
APIConfig, "selectielijst_api_service" | ||
) |
30 changes: 30 additions & 0 deletions
30
backend/src/openarchiefbeheer/config/setup_configuration/steps.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from django_setup_configuration import BaseConfigurationStep | ||
from django_setup_configuration.exceptions import ConfigurationRunFailed | ||
from zgw_consumers.models import Service | ||
|
||
from ..models import APIConfig | ||
from .models import APIConfigConfigurationModel | ||
|
||
|
||
class APIConfigConfigurationStep(BaseConfigurationStep[APIConfigConfigurationModel]): | ||
"""Configure API settings""" | ||
|
||
config_model = APIConfigConfigurationModel | ||
enable_setting = "api_configuration_enabled" | ||
namespace = "api_configuration" | ||
verbose_name = "API Configuration" | ||
|
||
def execute(self, model: APIConfigConfigurationModel) -> None: | ||
config = APIConfig.get_solo() | ||
|
||
try: | ||
config.selectielijst_api_service = Service.objects.get( | ||
slug=model.selectielijst_service_identifier | ||
) | ||
except Service.DoesNotExist: | ||
raise ConfigurationRunFailed( | ||
f"Could not find an existing `selectielijst` service with identifier `{model.selectielijst_service_identifier}`." | ||
" Make sure it is already configured, manually or by first running the configuration step of `zgw_consumers`." | ||
) | ||
|
||
config.save(update_fields=["selectielijst_api_service"]) |
Empty file.
3 changes: 3 additions & 0 deletions
3
backend/src/openarchiefbeheer/config/setup_configuration/tests/files/setup_config_api.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
api_configuration_enabled: True | ||
api_configuration: | ||
selectielijst_service_identifier: selectielijst |
Oops, something went wrong.