Skip to content

Commit af91ab4

Browse files
committed
✨ [#900] Implement health check
1 parent 1554ad9 commit af91ab4

File tree

3 files changed

+43
-3
lines changed

3 files changed

+43
-3
lines changed

backend/src/openarchiefbeheer/external_registers/contrib/openklant/migrations/0001_initial.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Generated by Django 4.2.26 on 2025-11-25 16:37
1+
# Generated by Django 4.2.26 on 2025-11-27 16:47
22

33
from django.db import migrations, models
44

@@ -24,12 +24,19 @@ class Migration(migrations.Migration):
2424
verbose_name="ID",
2525
),
2626
),
27+
(
28+
"enabled",
29+
models.BooleanField(
30+
default=True,
31+
help_text="Specifies whether the Open Klant plugin is enabled.",
32+
verbose_name="enabled",
33+
),
34+
),
2735
(
2836
"services",
2937
models.ManyToManyField(
3038
blank=True,
3139
help_text="Services to talk to Open Klant instances.",
32-
null=True,
3340
to="zgw_consumers.service",
3441
verbose_name="Open Klant API services",
3542
),

backend/src/openarchiefbeheer/external_registers/contrib/openklant/models.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55

66

77
class OpenKlantConfig(SingletonModel):
8+
enabled = models.BooleanField(
9+
verbose_name=_("enabled"),
10+
default=True,
11+
help_text=_("Specifies whether the Open Klant plugin is enabled."),
12+
)
813
services = models.ManyToManyField(
914
to="zgw_consumers.Service",
1015
verbose_name=_("Open Klant API services"),

backend/src/openarchiefbeheer/external_registers/contrib/openklant/plugin.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from typing import Iterable, Mapping, NoReturn
22

3+
from django.utils.translation import gettext as _
4+
35
from maykin_health_checks.types import HealthCheckResult
46

57
from openarchiefbeheer.external_registers.plugin import (
@@ -8,6 +10,7 @@
810
ServiceSlug,
911
)
1012
from openarchiefbeheer.external_registers.registry import register
13+
from openarchiefbeheer.utils.health_checks import CheckResult, ExtraInfo
1114

1215
from .models import OpenKlantConfig
1316
from .setup_configuration.models import OpenKlantConfigurationModel
@@ -22,7 +25,32 @@ class OpenKlantPlugin(AbstractBasePlugin):
2225
setup_configuration_step = OpenKlantConfigurationStep
2326

2427
def check_config(self) -> HealthCheckResult:
25-
raise NotImplementedError()
28+
config = OpenKlantConfig.get_solo()
29+
if not config.enabled:
30+
return CheckResult(
31+
identifier=self.identifier,
32+
success=True,
33+
message=_("The Open Klant plugin is disabled."),
34+
)
35+
36+
if not config.services.count() > 0:
37+
return CheckResult(
38+
identifier=self.identifier,
39+
success=False,
40+
message=_("No Open Klant API services configured."),
41+
extra=[
42+
ExtraInfo(
43+
code="missing_service",
44+
model="openarchiefbeheer.config.APIConfig",
45+
field="selectielijst_api_service",
46+
)
47+
],
48+
)
49+
return CheckResult(
50+
identifier=self.identifier,
51+
success=True,
52+
message=_("The Open Klant settings are properly configured."),
53+
)
2654

2755
def get_admin_url(self, resource_url: str) -> str:
2856
"""From the URL of the resource in the API, return the URL to the resource in the admin of the register."""

0 commit comments

Comments
 (0)