diff --git a/webservice/apps/api/apps.py b/webservice/apps/api/apps.py
index 591460c..699c7d6 100644
--- a/webservice/apps/api/apps.py
+++ b/webservice/apps/api/apps.py
@@ -9,58 +9,29 @@ class ApiConfig(AppConfig):
verbose_name = _('API')
verbose_name_plural = _('APIs')
- # try:
- # assert settings.SWAGGER_SETTINGS
- # except AttributeError:
- # # We only load this setting, if it is not available in the overall settings.py file
- # settings.SWAGGER_SETTINGS = {
- # 'SECURITY_DEFINITIONS': {
- # 'Hawk': {
- # 'type': 'apiKey',
- # 'description': 'HTTP Holder-Of-Key Authentication Scheme, https://github.com/hapijs/hawk, https://hawkrest.readthedocs.io/en/latest/
Ex header:
\'Authorization\': \'Hawk mac="F4+S9cu7yZiZEgdtqzMpOOdudvqcV2V2Yzk2WcphECc=", hash="+7fKUX+djeQolvnLTxr0X47e//UHKbkRlajwMw3tx3w=", id="7FI5JET4", ts="1592905433", nonce="DlV-fL"\'',
- # 'name': 'Authorization',
- # 'in': 'header'
- # }
- # }
- # }
+ try:
+ assert settings.SWAGGER_SETTINGS
+ except AttributeError:
+ # We only load this setting, if it is not available in the overall settings.py file
+ settings.SWAGGER_SETTINGS = {
+ }
- # try:
- # assert settings.REST_FRAMEWORK
- # except AttributeError:
- # # We only load this setting, if it is not available in the overall settings.py file
- # # To protect all API views with Hawk by default, put this in your settings:
- # # https://hawkrest.readthedocs.io/en/latest/usage.html#protecting-api-views-with-hawk
- # settings.REST_FRAMEWORK = {
+ try:
+ assert settings.REST_FRAMEWORK
+ except AttributeError:
+ # We only load this setting, if it is not available in the overall settings.py file
+ # To protect all API views with Hawk by default, put this in your settings:
+ # https://hawkrest.readthedocs.io/en/latest/usage.html#protecting-api-views-with-hawk
+ settings.REST_FRAMEWORK = {
- # 'DEFAULT_AUTHENTICATION_CLASSES': (
- # 'apps.api.authentication.APIHawk',
- # ),
-
- # 'DEFAULT_PERMISSION_CLASSES': (
- # 'rest_framework.permissions.IsAuthenticated',
- # ),
-
- # # 'DEFAULT_AUTHENTICATION_CLASSES': (
- # # 'rest_framework.authentication.TokenAuthentication',
- # # ),
-
- # # 'DEFAULT_PERMISSION_CLASSES': (
- # # 'rest_framework.permissions.IsAuthenticated', ),
-
- # # Use Django's standard `django.contrib.auth` permissions,
- # # or allow read-only access for unauthenticated users.
- # #'DEFAULT_PERMISSION_CLASSES': [
- # # 'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly'
- # #],
- # 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
- # 'PAGE_SIZE': 10
- # }
-
- # try:
- # assert settings.HAWK_MESSAGE_EXPIRATION
- # except AttributeError:
- # # We only load this setting, if it is not available in the overall settings.py file
- # settings.HAWK_MESSAGE_EXPIRATION = 60
+ # Use Django's standard `django.contrib.auth` permissions,
+ # or allow read-only access for unauthenticated users.
+ # 'DEFAULT_PERMISSION_CLASSES': [
+ # 'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly'
+ # ],
+ 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
+ 'PAGE_SIZE': 10
+ }
def ready(self):
from . import signals
\ No newline at end of file
diff --git a/webservice/apps/api/urls.py b/webservice/apps/api/urls.py
index 9138647..bccd339 100644
--- a/webservice/apps/api/urls.py
+++ b/webservice/apps/api/urls.py
@@ -7,53 +7,27 @@ from drf_yasg2 import openapi
from . import views
-# from apps.dropoff.api.views import DatadropViewSet
-# from apps.invitation.api.views import InvitationViewSet
-# from apps.researcher.api.views import ResearcherViewSet
-# from apps.storage.api.views import StorageEngineViewSet, StorageLocationViewSet
-# from apps.study.api.views import StudyViewSet
-# from apps.virtual_machine.api.views import (VirtualMachineViewSet,
-# VirtualMachineOperatingSystemViewSet,
-# VirtualMachineProfileViewSet,
-# VirtualMachineMemoryViewSet,
-# VirtualMachineNetworkViewSet,
-# VirtualMachineStorageViewSet,
-# VirtualMachineGPUViewSet)
+from apps.synthea.api.views import SyntheaViewSet
+from apps.synthea.api.serializers import SyntheaSerializer ,SyntheaModelsSerializer
+
schema_view = get_schema_view(
openapi.Info(
title="Synthea WebService API",
- default_version='v1',
+ default_version='',
description="Info about Synthea WebServer API",
terms_of_service="https://www.rug.nl",
- contact=openapi.Contact(email="vre_team@rug.nl"),
+ contact=openapi.Contact(email="cit@rug.nl"),
license=openapi.License(name="MIT License"),
),
public=True,
permission_classes=(permissions.AllowAny,),
)
-#api_router_v1 = routers.DefaultRouter()
+generate_post = SyntheaViewSet.as_view({
+ 'post': 'create'
+})
-# api_router_v1.register(r'researchers', ResearcherViewSet)
-
-# api_router_v1.register(r'studies', StudyViewSet)
-
-# api_router_v1.register(r'dropoffs', DatadropViewSet)
-
-# api_router_v1.register(r'invitations', InvitationViewSet)
-
-# api_router_v1.register(r'storageengines', StorageEngineViewSet)
-# api_router_v1.register(r'storagelocations', StorageLocationViewSet)
-
-# # Order is important for virtual machines. Longest match first
-# api_router_v1.register(r'virtualmachines/profiles', VirtualMachineProfileViewSet)
-# api_router_v1.register(r'virtualmachines/storage', VirtualMachineStorageViewSet)
-# api_router_v1.register(r'virtualmachines/memory', VirtualMachineMemoryViewSet)
-# api_router_v1.register(r'virtualmachines/network', VirtualMachineNetworkViewSet)
-# api_router_v1.register(r'virtualmachines/gpu', VirtualMachineGPUViewSet)
-# api_router_v1.register(r'virtualmachines/os', VirtualMachineOperatingSystemViewSet)
-# api_router_v1.register(r'virtualmachines', VirtualMachineViewSet)
# Main namespace for the API urls
app_name = 'api'
@@ -68,8 +42,5 @@ urlpatterns = [
path('states/', views.States.as_view(), name='states'),
path('modules/', views.Modules.as_view(), name='modules'),
- path('generate/', views.Generate.as_view(), name='generate'),
-
- # Add extra namespace for versioning the API
- #path('v1/', include((api_router_v1.urls,'api'),namespace='v1')),
+ path('generate/', generate_post, name='generate'),
]
\ No newline at end of file
diff --git a/webservice/apps/synthea/api/serializers.py b/webservice/apps/synthea/api/serializers.py
index 460c287..918afd1 100644
--- a/webservice/apps/synthea/api/serializers.py
+++ b/webservice/apps/synthea/api/serializers.py
@@ -1,8 +1,16 @@
from rest_framework import serializers
-
from apps.synthea.models import Synthea
class SyntheaSerializer(serializers.ModelSerializer):
class Meta:
model = Synthea
- fields = ['state', 'population', 'gender', 'age', 'module']
\ No newline at end of file
+ fields = ['state', 'population', 'gender', 'age', 'module']
+
+class SyntheaModelsSerializer(serializers.Serializer):
+ id = serializers.CharField(max_length=200)
+ name = serializers.CharField(max_length=200)
+
+
+class SyntheaStatesSerializer(serializers.Serializer):
+ id = serializers.CharField(max_length=200)
+ name = serializers.CharField(max_length=200)
diff --git a/webservice/apps/synthea/api/views.py b/webservice/apps/synthea/api/views.py
new file mode 100644
index 0000000..7583bda
--- /dev/null
+++ b/webservice/apps/synthea/api/views.py
@@ -0,0 +1,13 @@
+from rest_framework import viewsets
+
+from .serializers import SyntheaSerializer
+from apps.synthea.models import Synthea
+
+
+class SyntheaViewSet(viewsets.ModelViewSet):
+
+ """
+ API endpoint for creating/reading/updating/deleting invitations.
+ """
+ queryset = Synthea.objects.all().order_by('-created_at')
+ serializer_class = SyntheaSerializer
diff --git a/webservice/apps/synthea/templates/synthea/api.html b/webservice/apps/synthea/templates/synthea/api.html
new file mode 100644
index 0000000..900be97
--- /dev/null
+++ b/webservice/apps/synthea/templates/synthea/api.html
@@ -0,0 +1,15 @@
+{% extends 'base.html' %}
+{% load i18n %}
+
+{% block title %}{% trans "dHealth Synthea" %}{% endblock %}
+{% block pagetitle %}{% trans "dHealth Synthea" %}{% endblock %}
+
+{% block menu %}
+ {% include 'synthea/menu.html' %}
+{% endblock %}
+
+{% block content %}
+
Hier kunt u informatie vinden over de API zodat er ge-automatiseed patient data kan worden gegenereerd
+Documentatie: Redoc / Swagger
+{% endblock %} diff --git a/webservice/apps/synthea/urls.py b/webservice/apps/synthea/urls.py index e8ed444..2d3fea1 100644 --- a/webservice/apps/synthea/urls.py +++ b/webservice/apps/synthea/urls.py @@ -4,6 +4,6 @@ from . import views urlpatterns = [ path('', views.index, name='index'), - path('api/', views.index, name='api_info'), + path('api/', views.api, name='api_info'), path('generate/', views.show_synthea_form, name='generator_form'), ] \ No newline at end of file diff --git a/webservice/apps/synthea/views.py b/webservice/apps/synthea/views.py index 5b1ffc9..fdfd0ef 100644 --- a/webservice/apps/synthea/views.py +++ b/webservice/apps/synthea/views.py @@ -12,6 +12,10 @@ def index(request): template_name = 'synthea/index.html' return render(request,template_name,{}) +def api(request): + template_name = 'synthea/api.html' + return render(request,template_name,{}) + def show_synthea_form(request): template_name = 'synthea/generator_form.html'