mirror of
https://github.com/OpenBankProject/API-Manager.git
synced 2026-02-06 12:46:54 +00:00
Merge pull request #345 from nemozak1/develop
Change to use OBP v5.1.0 as default.
This commit is contained in:
commit
7e7a3db20b
@ -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
|
||||
|
||||
|
||||
|
||||
@ -117,7 +117,7 @@ TEMPLATES = [
|
||||
'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 @@ CALLBACK_BASE_URL = ""
|
||||
# Global
|
||||
UNDEFINED = "<undefined>"
|
||||
|
||||
API_ROOT_KEY = "v500"
|
||||
|
||||
# Local settings can replace any value ABOVE
|
||||
try:
|
||||
from apimanager.local_settings import * # noqa
|
||||
@ -334,8 +332,8 @@ except ImportError:
|
||||
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
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -11,9 +11,9 @@ from django.core.cache import cache
|
||||
|
||||
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):
|
||||
|
||||
@ -50,7 +50,7 @@ class IndexView(LoginRequiredMixin, FormView):
|
||||
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#"
|
||||
|
||||
@ -147,7 +147,7 @@ class MetricsView(LoginRequiredMixin, TemplateView):
|
||||
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)
|
||||
|
||||
@ -43,7 +43,7 @@ class API(object):
|
||||
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 @@ class API(object):
|
||||
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 @@ class API(object):
|
||||
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)
|
||||
|
||||
@ -48,7 +48,7 @@ class GatewayLoginAuthenticator(Authenticator):
|
||||
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)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user