diff --git a/apimanager/methodrouting/templates/methodrouting/index.html b/apimanager/methodrouting/templates/methodrouting/index.html index 3e8557f..dc0e56e 100644 --- a/apimanager/methodrouting/templates/methodrouting/index.html +++ b/apimanager/methodrouting/templates/methodrouting/index.html @@ -29,12 +29,12 @@
- {% for method_routhing in method_routhings %} + {% for method_routing in method_routings %}
- {{ method_routhing.method_name }}
+ {{ method_routing.method_name }}
+ name="bank_id_pattern">{{ method_routing.bank_id_pattern }}
+ name="parameters">{{ method_routing.parameters }}
diff --git a/apimanager/methodrouting/views.py b/apimanager/methodrouting/views.py index 426cf8d..ec47e27 100644 --- a/apimanager/methodrouting/views.py +++ b/apimanager/methodrouting/views.py @@ -33,185 +33,21 @@ class IndexView(LoginRequiredMixin, FormView): def get_context_data(self, **kwargs): context = super(IndexView, self).get_context_data(**kwargs) - method_routhings=json.loads("""{ - "method_routings": [ - { - "method_name": "getChallengeThreshold", - "connector_name": "rest_vMar2019", - "bank_id_pattern": "some_bankId_.+d", - "is_bank_id_exact_match": false, - "parameters": [ - { - "key": "url", - "value": "http://127.0.0.1:8088/bnpedapi" - } - ] - }, - { - "method_name": "getChargeLevel", - "connector_name": "akka_vDec2018", - "bank_id_pattern": "some_bankId_.[a-zA-Z]", - "is_bank_id_exact_match": false, - "parameters": [ - { - "key": "url", - "value": "http://127.0.0.1:8088/bnpedapi" - } - ] - }, - { - "method_name": "getBank", - "connector_name": "kafka_vMar2017", - "bank_id_pattern": "*", - "is_bank_id_exact_match": false, - "parameters": [ - { - "key": "url", - "value": "http://127.0.0.1:8088/bnpedapi" - } - ] + api = API(self.request.session.get('obp')) + urlpath = '/management/method_routings?active=true' - }, - { - "method_name": "getUser", - "connector_name": "mapped", - "bank_id_pattern": "some_bankId_[0-9]", - "is_bank_id_exact_match": false, - "parameters": [ - { - "key": "url", - "value": "http://127.0.0.1:8088/bnpedapi" - } - ] - }, - { - "method_name": "getBankAccounts", - "connector_name": "mapped", - "bank_id_pattern": "[a-z]{6}", - "is_bank_id_exact_match": false, - "parameters": [ - { - "key": "url", - "value": "http://127.0.0.1:8088/bnpedapi" - } - ] - }, - { - "method_name": "getCounterparty", - "connector_name": "mapped", - "bank_id_pattern": "some_bankId_[789][0-9]{9}", - "is_bank_id_exact_match": false, - "parameters": [ - { - "key": "url", - "value": "http://127.0.0.1:8088/bnpedapi" - } - ] - }, - { - "method_name": "getCoreBankAccounts", - "connector_name": "mapped", - "bank_id_pattern": "[0-9]{6}", - "is_bank_id_exact_match": false, - "parameters": [ - { - "key": "url", - "value": "http://127.0.0.1:8088/bnpedapi" - } - ] - - }, - { - "method_name": "getBankAccountByIban", - "connector_name": "mapped", - "bank_id_pattern": "some_bankId_.*", - "is_bank_id_exact_match": false, - "parameters": [ - { - "key": "url", - "value": "http://127.0.0.1:8088/bnpedapi" - } - ] - }, - { - "method_name": "getBankAccountByRouting", - "connector_name": "mapped", - "bank_id_pattern": "some_bankId_.*", - "is_bank_id_exact_match": false, - "parameters": [ - { - "key": "url", - "value": "http://127.0.0.1:8088/bnpedapi" - } - ] - }, - { - "method_name": "getBankAccountsBalances", - "connector_name": "mapped", - "bank_id_pattern": "some_bankId_.*", - "is_bank_id_exact_match": false, - "parameters": [ - { - "key": "url", - "value": "http://127.0.0.1:8088/bnpedapi" - } - ] - }, - { - "method_name": "checkBankAccountExists", - "connector_name": "mapped", - "bank_id_pattern": "some_bankId_.*", - "is_bank_id_exact_match": false, - "parameters": [ - { - "key": "url", - "value": "http://127.0.0.1:8088/bnpedapi" - } - ] - }, - { - "method_name": "getCounterpartiesFromTransaction", - "connector_name": "mapped", - "bank_id_pattern": "some_bankId_.*", - "is_bank_id_exact_match": false, - "parameters": [ - { - "key": "url", - "value": "http://127.0.0.1:8088/bnpedapi" - } - ] - }, - { - "method_name": "getCounterpartyTrait", - "connector_name": "mapped", - "bank_id_pattern": "some_bankId_.*", - "is_bank_id_exact_match": false, - "parameters": [ - { - "key": "url", - "value": "http://127.0.0.1:8088/bnpedapi" - } - ] - }, - { - "method_name": "getCounterparty", - "connector_name": "mapped", - "bank_id_pattern": "some_bankId_.*", - "is_bank_id_exact_match": false, - "parameters": [ - { - "key": "url", - "value": "http://127.0.0.1:8088/bnpedapi" - } - ] - } - ] -}""") - context.update({'method_routhings': method_routhings["method_routings"]}) + try: + response = api.get(urlpath) + except APIError as err: + messages.error(self.request, Exception("OBP-API server is not running or do not response properly. " + "Please check OBP-API server. " + "Details: " + str(err))) + except BaseException as err: + messages.error(self.request, (Exception("Unknown Error. Details:" + str(err)))) + else: + context.update(response) return context - - @csrf_exempt def methodrouting_save(request): method_name = request.POST.get('method_name') diff --git a/apimanager/webui/views.py b/apimanager/webui/views.py index 8f27516..e4db208 100644 --- a/apimanager/webui/views.py +++ b/apimanager/webui/views.py @@ -41,61 +41,7 @@ class IndexView(LoginRequiredMixin, FormView): urlpath = '/management/webui_props?active=true' try: - # response = api.get(urlpath) - response = json.loads("""{ - "webui_props": [ - { - "name": "webui_header_logo_left_url ", - "value": " /media/images/logo.png", - "web_ui_props_id": "default" - }, - { - "name": "webui_header_logo_right_url ", - "value": "", - "web_ui_props_id": "default" - }, - { - "name": "webui_index_page_about_section_background_image_url ", - "value": " /media/images/about-background.jpg", - "web_ui_props_id": "default" - }, - { - "name": "webui_top_text", - "value": "", - "web_ui_props_id": "default" - }, - { - "name": "webui_api_explorer_url ", - "value": " https://apiexplorer.openbankproject.com", - "web_ui_props_id": "default" - }, - { - "name": "webui_sofi_url ", - "value": " https://sofi.openbankproject.com", - "web_ui_props_id": "default" - }, - { - "name": "webui_api_manager_url ", - "value": " https://apimanager.openbankproject.com", - "web_ui_props_id": "default" - }, - { - "name": "webui_api_manager_url ", - "value": " https://apitester.openbankproject.com", - "web_ui_props_id": "default" - }, - { - "name": "webui_api_documentation_url ", - "value": " https://github.com/OpenBankProject/OBP-API/wiki", - "web_ui_props_id": "default" - }, - { - "name": "webui_login_page_special_instructions", - "value": "", - "web_ui_props_id": "default" - } - ] -}""") + response = api.get(urlpath) except APIError as err: messages.error(self.request, Exception("OBP-API server is not running or do not response properly. " "Please check OBP-API server. "