From 7f46e9ead0b981ebf131fff4bc62dda95b6b50b0 Mon Sep 17 00:00:00 2001 From: Nikolay Stanchev <ns17@it-innovation.soton.ac.uk> Date: Thu, 21 Jun 2018 12:42:24 +0100 Subject: [PATCH] Simplifies the URL routing of the CLMC service --- src/service/clmcservice/__init__.py | 9 +-------- src/service/clmcservice/aggregationapi/views.py | 7 ++++++- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/service/clmcservice/__init__.py b/src/service/clmcservice/__init__.py index 648e1d8..3f29bc4 100644 --- a/src/service/clmcservice/__init__.py +++ b/src/service/clmcservice/__init__.py @@ -41,15 +41,8 @@ def main(global_config, **settings): config = Configurator(settings=settings) config.add_route('aggregator_config', '/aggregator/config') - config.add_view('clmcservice.aggregationapi.views.AggregatorConfig', attr='get', request_method='GET') - config.add_view('clmcservice.aggregationapi.views.AggregatorConfig', attr='put', request_method='PUT') - config.add_route('aggregator_controller', '/aggregator/control') - config.add_view('clmcservice.aggregationapi.views.AggregatorController', attr='get', request_method='GET') - config.add_view('clmcservice.aggregationapi.views.AggregatorController', attr='put', request_method='PUT') - config.add_route('round_trip_time_query', '/query/round-trip-time') - config.add_view('clmcservice.aggregationapi.views.RoundTripTimeQuery', attr='get', request_method='GET') - config.scan() + config.scan() # This method scans the packages and finds any views related to the routes added in the app configuration return config.make_wsgi_app() diff --git a/src/service/clmcservice/aggregationapi/views.py b/src/service/clmcservice/aggregationapi/views.py index 1e8c9db..9088eed 100644 --- a/src/service/clmcservice/aggregationapi/views.py +++ b/src/service/clmcservice/aggregationapi/views.py @@ -22,7 +22,7 @@ // Created for Project : FLAME """ -from pyramid.view import view_defaults +from pyramid.view import view_defaults, view_config from pyramid.httpexceptions import HTTPBadRequest, HTTPInternalServerError from influxdb import InfluxDBClient from urllib.parse import urlparse @@ -54,6 +54,7 @@ class AggregatorConfig(object): self.request = request + @view_config(request_method="GET") def get(self): """ A GET API call for the configuration of the aggregator. @@ -70,6 +71,7 @@ class AggregatorConfig(object): return config + @view_config(request_method="PUT") def put(self): """ A PUT API call for the status of the aggregator. @@ -141,6 +143,7 @@ class AggregatorController(object): self.request = request + @view_config(request_method="GET") def get(self): """ A GET API call for the status of the aggregator - running or not. @@ -160,6 +163,7 @@ class AggregatorController(object): return config + @view_config(request_method="PUT") def put(self): """ A PUT API call for the status of the aggregator. @@ -268,6 +272,7 @@ class RoundTripTimeQuery(object): self.request = request + @view_config(request_method="GET") def get(self): """ A GET API call for the averaged round trip time of a specific media service over a given time range. -- GitLab