diff --git a/apimanager/apicollections/views.py b/apimanager/apicollections/views.py index 4bf588f1..928b3d1a 100644 --- a/apimanager/apicollections/views.py +++ b/apimanager/apicollections/views.py @@ -155,7 +155,7 @@ def apicollections_update(request): 'is_sharable': True if request.POST.get('api_collection_is_sharable').strip().lower() == "true" else False, 'description': request.POST.get('api_collection_description').strip() } - result = api.put(urlpath, payload=payload, version=settings.API_ROOT['v510']) + result = api.put(urlpath, payload=payload, version=settings.API_VERSION['v510']) return result diff --git a/apimanager/apimanager/settings.py b/apimanager/apimanager/settings.py index 2781d3cf..4b735c8e 100644 --- a/apimanager/apimanager/settings.py +++ b/apimanager/apimanager/settings.py @@ -117,7 +117,7 @@ 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', - 'base.context_processors.api_root', + 'base.context_processors.api_version_processor', 'base.context_processors.api_username', 'base.context_processors.api_user_id', 'base.context_processors.api_tester_url', @@ -322,8 +322,6 @@ # Global UNDEFINED = "" -API_ROOT_KEY = "v500" - # Local settings can replace any value ABOVE try: from apimanager.local_settings import * # noqa @@ -334,8 +332,8 @@ OBPv500 = API_HOST + '/obp/v5.0.0' OBPv510 = API_HOST + '/obp/v5.1.0' -# Settings here might use parts overwritten in local settings -API_ROOT = { +# API Versions +API_VERSION = { "v500": OBPv500, "v510": OBPv510 } diff --git a/apimanager/atms/views.py b/apimanager/atms/views.py index 2fa81b01..8e2f0e56 100644 --- a/apimanager/atms/views.py +++ b/apimanager/atms/views.py @@ -204,7 +204,7 @@ class UpdateAtmsView(LoginRequiredMixin, FormView): template_name = "atms/update.html" success_url = '/atms/list' form_class = CreateAtmForm - v510 = settings.API_ROOT['v510'] + v510 = settings.API_VERSION['v510'] def dispatch(self, request, *args, **kwargs): self.api = API(request.session.get('obp')) @@ -410,7 +410,7 @@ def atm_attribute_save(request): 'value': request.POST.get('value').strip(), 'is_active': True } - result = api.post(urlpath_save, payload = payload, version=settings.API_ROOT['v510']) + result = api.post(urlpath_save, payload = payload, version=settings.API_VERSION['v510']) return result @@ -428,7 +428,7 @@ def atm_attribute_update(request): 'value': request.POST.get('value').strip(), 'is_active': True } - result = api.put(urlpath_update, payload=payload, version=settings.API_ROOT['v510']) + result = api.put(urlpath_update, payload=payload, version=settings.API_VERSION['v510']) return result @@ -441,7 +441,7 @@ def atm_attribute_delete(request): api = API(request.session.get('obp')) urlpath_delete = '/banks/{}/atms/{}/attributes/{}'.format(bank_id, atm_id, atm_attribute_id) - result = api.delete(urlpath_delete, version=settings.API_ROOT['v510']) + result = api.delete(urlpath_delete, version=settings.API_VERSION['v510']) return result diff --git a/apimanager/banks/views.py b/apimanager/banks/views.py index 1e48b14e..e8f98381 100644 --- a/apimanager/banks/views.py +++ b/apimanager/banks/views.py @@ -81,7 +81,7 @@ class UpdateBanksView(LoginRequiredMixin, FormView): template_name = "banks/update.html" form_class = CreateBankForm success_url = '/banks/list' - v510 = settings.API_ROOT['v510'] + v510 = settings.API_VERSION['v510'] def dispatch(self, request, *args, **kwargs): self.api = API(request.session.get('obp')) @@ -177,7 +177,7 @@ def bank_attribute_save(request): 'value': request.POST.get('value').strip(), 'is_active': True } - result = api.post(urlpath_save, payload = payload, version=settings.API_ROOT['v510']) + result = api.post(urlpath_save, payload = payload, version=settings.API_VERSION['v510']) return result @@ -195,7 +195,7 @@ def bank_attribute_update(request): 'value': request.POST.get('value').strip(), 'is_active': True } - result = api.put(urlpath_update, payload=payload, version=settings.API_ROOT['v510']) + result = api.put(urlpath_update, payload=payload, version=settings.API_VERSION['v510']) return result @@ -206,6 +206,6 @@ def bank_attribute_delete(request): bank_attribute_id = request.POST.get('bank_attribute_id').strip() api = API(request.session.get('obp')) urlpath_delete = '/banks/{}/attributes/{}'.format(bank_id, bank_attribute_id) - result = api.delete(urlpath_delete, version=settings.API_ROOT['v510']) + result = api.delete(urlpath_delete, version=settings.API_VERSION['v510']) return result diff --git a/apimanager/base/context_processors.py b/apimanager/base/context_processors.py index 81b14988..d3dff76d 100644 --- a/apimanager/base/context_processors.py +++ b/apimanager/base/context_processors.py @@ -11,9 +11,9 @@ USER_CURRENT = "/users/current" -def api_root(request): - """Returns the configured API_ROOT""" - return {'API_ROOT': settings.API_ROOT['v500']} +def api_version_processor(request): + """Returns the configured API_VERSION""" + return {'API_VERSION': settings.API_VERSION['v500']} def portal_page(request): diff --git a/apimanager/methodrouting/views.py b/apimanager/methodrouting/views.py index 3a24a555..e79e8db1 100644 --- a/apimanager/methodrouting/views.py +++ b/apimanager/methodrouting/views.py @@ -50,7 +50,7 @@ def get_context_data(self, **kwargs): else: method_routings[i]['parameters'] = json.dumps(method_routings[i]['parameters'], sort_keys=False) - if(str(settings.API_ROOT).find("127.0.0.1") == -1): + if(str(settings.API_VERSION).find("127.0.0.1") == -1): method_Swagger_Url = '{}/message-docs?connector=stored_procedure_vDec2019#'.format(settings.API_HOST.replace(".openbankproject.", "-explorer.openbankproject.")) else: method_Swagger_Url = "http://127.0.0.1:8082/message-docs?connector=stored_procedure_vDec2019#" diff --git a/apimanager/metrics/views.py b/apimanager/metrics/views.py index fc4fa29f..62d9f06d 100644 --- a/apimanager/metrics/views.py +++ b/apimanager/metrics/views.py @@ -147,7 +147,7 @@ def get_metrics(self, cleaned_data): urlpath = '{}?{}'.format(self.api_urlpath, params) api = API(self.request.session.get('obp')) try: - metrics = api.get(urlpath) + metrics = api.get(urlpath, version=settings.API_VERSION["v510"]) metrics = self.to_django(metrics['metrics']) except APIError as err: error_once_only(self.request, err) diff --git a/apimanager/obp/api.py b/apimanager/obp/api.py index 55579896..4f2b7aa8 100644 --- a/apimanager/obp/api.py +++ b/apimanager/obp/api.py @@ -43,7 +43,7 @@ def __init__(self, session_data=None): self.start_session(session_data) self.session_data = session_data - def call(self, method='GET', url='', payload=None, version=settings.API_ROOT[settings.API_ROOT_KEY]): + def call(self, method='GET', url='', payload=None, version=settings.API_VERSION['v500']): """Workhorse which actually calls the API""" log(logging.INFO, '{} {}'.format(method, url)) if payload: @@ -64,11 +64,11 @@ def call(self, method='GET', url='', payload=None, version=settings.API_ROOT[set response.execution_time = elapsed return response - def get(self, urlpath='', version=settings.API_ROOT[settings.API_ROOT_KEY]): + def get(self, urlpath='', version=settings.API_VERSION['v500']): """ Gets data from the API - Convenience call which uses API_ROOT from settings + Convenience call which uses API_VERSION from settings """ url = version + urlpath response = self.handle_response(self.call('GET', url)) @@ -77,31 +77,31 @@ def get(self, urlpath='', version=settings.API_ROOT[settings.API_ROOT_KEY]): else: return response - def delete(self, urlpath, version=settings.API_ROOT[settings.API_ROOT_KEY]): + def delete(self, urlpath, version=settings.API_VERSION['v500']): """ Deletes data from the API - Convenience call which uses API_ROOT from settings + Convenience call which uses API_VERSION from settings """ url = version + urlpath response = self.call('DELETE', url) return self.handle_response(response) - def post(self, urlpath, payload, version=settings.API_ROOT[settings.API_ROOT_KEY]): + def post(self, urlpath, payload, version=settings.API_VERSION['v500']): """ Posts data to given urlpath with given payload - Convenience call which uses API_ROOT from settings + Convenience call which uses API_VERSION from settings """ url = version + urlpath response = self.call('POST', url, payload) return self.handle_response(response) - def put(self, urlpath, payload, version=settings.API_ROOT[settings.API_ROOT_KEY]): + def put(self, urlpath, payload, version=settings.API_VERSION['v500']): """ Puts data on given urlpath with given payload - Convenience call which uses API_ROOT from settings + Convenience call which uses API_VERSION from settings """ url = version + urlpath response = self.call('PUT', url, payload) diff --git a/apimanager/obp/gatewaylogin.py b/apimanager/obp/gatewaylogin.py index fb05b3ce..33a82497 100644 --- a/apimanager/obp/gatewaylogin.py +++ b/apimanager/obp/gatewaylogin.py @@ -48,7 +48,7 @@ def create_jwt(self, data): def prepare_gateway_login_token(self, data): token = self.create_jwt(data) # Make a test call to see if the token works - url = '{}{}'.format(settings.API_ROOT, '/users/current') + url = '{}{}'.format(settings.API_VERSION, '/users/current') api = self.get_session() try: response = api.get(url)