New updates
This commit is contained in:
parent
80711cd918
commit
6299b2f983
@ -9,58 +9,29 @@ class ApiConfig(AppConfig):
|
|||||||
verbose_name = _('API')
|
verbose_name = _('API')
|
||||||
verbose_name_plural = _('APIs')
|
verbose_name_plural = _('APIs')
|
||||||
|
|
||||||
# try:
|
try:
|
||||||
# assert settings.SWAGGER_SETTINGS
|
assert settings.SWAGGER_SETTINGS
|
||||||
# except AttributeError:
|
except AttributeError:
|
||||||
# # We only load this setting, if it is not available in the overall settings.py file
|
# We only load this setting, if it is not available in the overall settings.py file
|
||||||
# settings.SWAGGER_SETTINGS = {
|
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/<br /><strong>Ex header:</strong><br />\'Authorization\': \'Hawk mac="F4+S9cu7yZiZEgdtqzMpOOdudvqcV2V2Yzk2WcphECc=", hash="+7fKUX+djeQolvnLTxr0X47e//UHKbkRlajwMw3tx3w=", id="7FI5JET4", ts="1592905433", nonce="DlV-fL"\'',
|
|
||||||
# 'name': 'Authorization',
|
|
||||||
# 'in': 'header'
|
|
||||||
# }
|
|
||||||
# }
|
|
||||||
# }
|
|
||||||
|
|
||||||
# try:
|
try:
|
||||||
# assert settings.REST_FRAMEWORK
|
assert settings.REST_FRAMEWORK
|
||||||
# except AttributeError:
|
except AttributeError:
|
||||||
# # We only load this setting, if it is not available in the overall settings.py file
|
# 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:
|
# 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
|
# https://hawkrest.readthedocs.io/en/latest/usage.html#protecting-api-views-with-hawk
|
||||||
# settings.REST_FRAMEWORK = {
|
settings.REST_FRAMEWORK = {
|
||||||
|
|
||||||
# 'DEFAULT_AUTHENTICATION_CLASSES': (
|
# Use Django's standard `django.contrib.auth` permissions,
|
||||||
# 'apps.api.authentication.APIHawk',
|
# or allow read-only access for unauthenticated users.
|
||||||
# ),
|
# 'DEFAULT_PERMISSION_CLASSES': [
|
||||||
|
# 'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly'
|
||||||
# 'DEFAULT_PERMISSION_CLASSES': (
|
# ],
|
||||||
# 'rest_framework.permissions.IsAuthenticated',
|
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
|
||||||
# ),
|
'PAGE_SIZE': 10
|
||||||
|
}
|
||||||
# # '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
|
|
||||||
|
|
||||||
def ready(self):
|
def ready(self):
|
||||||
from . import signals
|
from . import signals
|
@ -7,53 +7,27 @@ from drf_yasg2 import openapi
|
|||||||
|
|
||||||
from . import views
|
from . import views
|
||||||
|
|
||||||
# from apps.dropoff.api.views import DatadropViewSet
|
from apps.synthea.api.views import SyntheaViewSet
|
||||||
# from apps.invitation.api.views import InvitationViewSet
|
from apps.synthea.api.serializers import SyntheaSerializer ,SyntheaModelsSerializer
|
||||||
# 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)
|
|
||||||
|
|
||||||
schema_view = get_schema_view(
|
schema_view = get_schema_view(
|
||||||
openapi.Info(
|
openapi.Info(
|
||||||
title="Synthea WebService API",
|
title="Synthea WebService API",
|
||||||
default_version='v1',
|
default_version='',
|
||||||
description="Info about Synthea WebServer API",
|
description="Info about Synthea WebServer API",
|
||||||
terms_of_service="https://www.rug.nl",
|
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"),
|
license=openapi.License(name="MIT License"),
|
||||||
),
|
),
|
||||||
public=True,
|
public=True,
|
||||||
permission_classes=(permissions.AllowAny,),
|
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
|
# Main namespace for the API urls
|
||||||
app_name = 'api'
|
app_name = 'api'
|
||||||
@ -68,8 +42,5 @@ urlpatterns = [
|
|||||||
|
|
||||||
path('states/', views.States.as_view(), name='states'),
|
path('states/', views.States.as_view(), name='states'),
|
||||||
path('modules/', views.Modules.as_view(), name='modules'),
|
path('modules/', views.Modules.as_view(), name='modules'),
|
||||||
path('generate/', views.Generate.as_view(), name='generate'),
|
path('generate/', generate_post, name='generate'),
|
||||||
|
|
||||||
# Add extra namespace for versioning the API
|
|
||||||
#path('v1/', include((api_router_v1.urls,'api'),namespace='v1')),
|
|
||||||
]
|
]
|
@ -1,8 +1,16 @@
|
|||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
|
|
||||||
from apps.synthea.models import Synthea
|
from apps.synthea.models import Synthea
|
||||||
|
|
||||||
class SyntheaSerializer(serializers.ModelSerializer):
|
class SyntheaSerializer(serializers.ModelSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Synthea
|
model = Synthea
|
||||||
fields = ['state', 'population', 'gender', 'age', 'module']
|
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)
|
||||||
|
13
webservice/apps/synthea/api/views.py
Normal file
13
webservice/apps/synthea/api/views.py
Normal file
@ -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
|
15
webservice/apps/synthea/templates/synthea/api.html
Normal file
15
webservice/apps/synthea/templates/synthea/api.html
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
{% extends 'base.html' %} <!-- Add this for inheritance -->
|
||||||
|
{% load i18n %}
|
||||||
|
|
||||||
|
{% block title %}{% trans "dHealth Synthea" %}{% endblock %}
|
||||||
|
{% block pagetitle %}{% trans "dHealth Synthea" %}{% endblock %}
|
||||||
|
|
||||||
|
{% block menu %}
|
||||||
|
{% include 'synthea/menu.html' %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h1>API</h1>
|
||||||
|
<p>Hier kunt u informatie vinden over de API zodat er ge-automatiseed patient data kan worden gegenereerd</p>
|
||||||
|
<p>Documentatie: <a href="redoc" target="_blank">Redoc / Swagger</a> </p>
|
||||||
|
{% endblock %}
|
@ -4,6 +4,6 @@ from . import views
|
|||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('', views.index, name='index'),
|
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'),
|
path('generate/', views.show_synthea_form, name='generator_form'),
|
||||||
]
|
]
|
@ -12,6 +12,10 @@ def index(request):
|
|||||||
template_name = 'synthea/index.html'
|
template_name = 'synthea/index.html'
|
||||||
return render(request,template_name,{})
|
return render(request,template_name,{})
|
||||||
|
|
||||||
|
def api(request):
|
||||||
|
template_name = 'synthea/api.html'
|
||||||
|
return render(request,template_name,{})
|
||||||
|
|
||||||
def show_synthea_form(request):
|
def show_synthea_form(request):
|
||||||
template_name = 'synthea/generator_form.html'
|
template_name = 'synthea/generator_form.html'
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user