Skip to content

Commit 185207f

Browse files
SilviaAmAmCharString
authored andcommitted
✨ [#35] feat: Add services choices endpoint
1 parent e612c39 commit 185207f

File tree

7 files changed

+68
-1
lines changed

7 files changed

+68
-1
lines changed

backend/src/openbeheer/api/urls.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@
3838
include("openbeheer.api.authentication.urls", namespace="authentication"),
3939
),
4040
# ZTC endpoints
41+
path(
42+
"v1/service/", include("openbeheer.services.urls", namespace="services")
43+
),
4144
path(
4245
"v1/service/<slug:slug>/zaaktypen/", ZaakTypeListView.as_view(), name="zaaktype-list"
4346
),

backend/src/openbeheer/catalogi/api/views.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121

2222
@extend_schema(
23+
tags=["Catalogi"],
2324
summary=_("Get Open Zaak choices"),
2425
description=_(
2526
"Get the available Open Zaak catalogi instances. The value is the slug of the configured service, "
@@ -35,11 +36,17 @@ class ServiceChoicesView(MsgspecAPIView):
3536
def get(self, request: Request) -> Response:
3637
services = Service.objects.filter(api_type=APITypes.ztc)
3738

38-
data = [{"label": service.label, "value": service.slug} for service in services]
39+
data = [
40+
OBOption(
41+
label=service.label,
42+
value=service.slug
43+
) for service in services
44+
]
3945
return Response(data)
4046

4147

4248
@extend_schema(
49+
tags=["Catalogi"],
4350
summary=_("Get catalogue choices"),
4451
description=_(
4552
"Retrieve the catalogues available in an Open Zaak instance. "

backend/src/openbeheer/conf/base.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@
131131
"openbeheer.config",
132132
"openbeheer.health_checks",
133133
"openbeheer.catalogi",
134+
"openbeheer.services",
134135
]
135136

136137
MIDDLEWARE = [

backend/src/openbeheer/services/__init__.py

Whitespace-only changes.

backend/src/openbeheer/services/api/__init__.py

Whitespace-only changes.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
from django.utils.translation import gettext_lazy as _
2+
3+
from drf_spectacular.utils import extend_schema
4+
5+
from zgw_consumers.constants import APITypes
6+
from zgw_consumers.models import Service
7+
8+
from rest_framework.request import Request
9+
from rest_framework.permissions import IsAuthenticated
10+
from rest_framework.response import Response
11+
12+
from openbeheer.api.views import MsgspecAPIView
13+
14+
from openbeheer.types._open_beheer import OBOption
15+
16+
17+
18+
@extend_schema(
19+
tags=["Services"],
20+
summary=_("Get Open Zaak choices"),
21+
description=_(
22+
"Get the available Open Zaak catalogi instances. The value is the slug of the configured service, "
23+
"while the label is the name of the service."
24+
),
25+
# responses={
26+
# "200": list[OBOption[str]] # TODO blueprint of msgspec (Github #50)
27+
# }
28+
)
29+
class ServiceChoicesView(MsgspecAPIView):
30+
permission_classes = [IsAuthenticated]
31+
32+
def get(self, request: Request) -> Response:
33+
services = Service.objects.filter(api_type=APITypes.ztc)
34+
35+
data = [
36+
OBOption(
37+
label=service.label,
38+
value=service.slug
39+
) for service in services
40+
]
41+
return Response(data)
42+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from django.urls import path
2+
3+
from .api.views import ServiceChoicesView
4+
5+
6+
app_name = "services"
7+
8+
urlpatterns = [
9+
path(
10+
"choices/",
11+
ServiceChoicesView.as_view(),
12+
name="choices",
13+
),
14+
]

0 commit comments

Comments
 (0)