File tree Expand file tree Collapse file tree 7 files changed +68
-1
lines changed
Expand file tree Collapse file tree 7 files changed +68
-1
lines changed Original file line number Diff line number Diff line change 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 ),
Original file line number Diff line number Diff line change 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. "
Original file line number Diff line number Diff line change 131131 "openbeheer.config" ,
132132 "openbeheer.health_checks" ,
133133 "openbeheer.catalogi" ,
134+ "openbeheer.services" ,
134135]
135136
136137MIDDLEWARE = [
Original file line number Diff line number Diff line change 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+
Original file line number Diff line number Diff line change 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+ ]
You can’t perform that action at this time.
0 commit comments