def source_info(req, service_name): service = Service(name=service_name) input_dict = { 'cluster_id': req.zato.cluster_id, 'name': service_name } response = req.zato.client.invoke('zato.service.get-source-info', input_dict) if response.has_data: service.id = response.data.service_id source = response.data.source.decode('base64').decode('utf-8') if response.data.source else '' if source: source_html = highlight(source, PythonLexer(stripnl=False), HtmlFormatter(linenos='table')) service.source_info = SourceInfo() service.source_info.source = source service.source_info.source_html = source_html service.source_info.path = response.data.source_path service.source_info.hash = response.data.source_hash service.source_info.hash_method = response.data.source_hash_method service.source_info.server_name = response.data.server_name return_data = { 'cluster_id':req.zato.cluster_id, 'service':service, } return TemplateResponse(req, 'zato/service/source-info.html', return_data)
def test_response(self): request = {'cluster_id': rand_int(), 'name': rand_string()} expected_id = rand_int() expected_name = rand_string() expected_is_active = rand_bool() expected_impl_name = rand_string() expected_is_internal = rand_bool() service = Service() service.id = expected_id service.name = expected_name service.is_active = expected_is_active service.impl_name = expected_impl_name service.is_internal = expected_is_internal expected = Expected() expected.add(service) instance = self.invoke(GetByName, request, expected) response = Bunch( loads(instance.response.payload.getvalue()) ['zato_service_get_by_name_response']) eq_(response.id, expected_id) eq_(response.name, expected_name) eq_(response.is_active, expected_is_active) eq_(response.impl_name, expected_impl_name) eq_(response.is_internal, expected_is_internal) eq_(response.usage, 0)
def source_info(req, service_name): service = Service(name=service_name) input_dict = { 'cluster_id': req.zato.cluster_id, 'name': service_name } zato_message, soap_response = invoke_admin_service(req.zato.cluster, 'zato:service.get-source-info', input_dict) if zato_path('response.item').get_from(zato_message) is not None: msg_item = zato_message.response.item service.id = msg_item.service_id.text source = msg_item.source.text.decode('base64') if msg_item.source else '' if source: source_html = highlight(source, PythonLexer(stripnl=False), HtmlFormatter(linenos='table')) service.source_info = SourceInfo() service.source_info.source = source service.source_info.source_html = source_html service.source_info.path = msg_item.source_path.text service.source_info.hash = msg_item.source_hash.text service.source_info.hash_method = msg_item.source_hash_method.text service.source_info.server_name = msg_item.server_name.text return_data = { 'cluster_id':req.zato.cluster_id, 'service':service, } return TemplateResponse(req, 'zato/service/source-info.html', return_data)
def source_info(req, service_name): service = Service(name=service_name) input_dict = {'cluster_id': req.zato.cluster_id, 'name': service_name} response = req.zato.client.invoke('zato.service.get-source-info', input_dict) if response.has_data: service.id = response.data.service_id source = b64decode( response.data.source) if response.data.source else '' if source: source_html = highlight(source, PythonLexer(stripnl=False), HtmlFormatter(linenos='table')) service.source_info = SourceCodeInfo() service.source_info.source = source service.source_info.source_html = source_html service.source_info.path = response.data.source_path service.source_info.hash = response.data.source_hash service.source_info.hash_method = response.data.source_hash_method service.source_info.server_name = response.data.server_name return_data = { 'cluster_id': req.zato.cluster_id, 'service': service, } return TemplateResponse(req, 'zato/service/source-info.html', return_data)
def test_response(self): request = {'cluster_id':rand_int(), 'name':rand_string()} expected_id = rand_int() expected_name = rand_string() expected_is_active = rand_bool() expected_impl_name = rand_string() expected_is_internal = rand_bool() service = Service() service.id = expected_id service.name = expected_name service.is_active = expected_is_active service.impl_name = expected_impl_name service.is_internal = expected_is_internal expected = Expected() expected.add(service) instance = self.invoke(GetByName, request, expected) response = Bunch(loads(instance.response.payload.getvalue())['response']) eq_(response.id, expected_id) eq_(response.name, expected_name) eq_(response.is_active, expected_is_active) eq_(response.impl_name, expected_impl_name) eq_(response.is_internal, expected_is_internal) eq_(response.usage, 0)
def source_info(req, service_name): service = Service(name=service_name) input_dict = {"cluster_id": req.zato.cluster_id, "name": service_name} response = req.zato.client.invoke("zato.service.get-source-info", input_dict) if response.has_data: service.id = response.data.service_id source = response.data.source.decode("base64") if response.data.source else "" if source: source_html = highlight(source, PythonLexer(stripnl=False), HtmlFormatter(linenos="table")) service.source_info = SourceInfo() service.source_info.source = source service.source_info.source_html = source_html service.source_info.path = response.data.source_path service.source_info.hash = response.data.source_hash service.source_info.hash_method = response.data.source_hash_method service.source_info.server_name = response.data.server_name return_data = {"cluster_id": req.zato.cluster_id, "service": service} return TemplateResponse(req, "zato/service/source-info.html", return_data)
def request_response(req, service_name): service = Service(name=service_name) pretty_print = asbool(req.GET.get('pretty_print')) input_dict = {'name': service_name, 'cluster_id': req.zato.cluster_id} service_response = req.zato.client.invoke( 'zato.service.get-request-response', input_dict) if service_response.ok: request = b64decode(service_response.data.sample_req if service_response.data.sample_req else '') request = request.decode('utf8') request_data_format = known_data_format(request) if request_data_format: if pretty_print: request = get_pretty_print(request, request_data_format) service.sample_req_html = highlight( request, data_format_lexer[request_data_format](), HtmlFormatter(linenos='table')) response = b64decode(service_response.data.sample_resp if service_response.data.sample_resp else '') response = response.decode('utf8') response_data_format = known_data_format(response) if response_data_format: if pretty_print: response = get_pretty_print(response, response_data_format) service.sample_resp_html = highlight( response, data_format_lexer[response_data_format](), HtmlFormatter(linenos='table')) service.sample_req = request service.sample_resp = response ts = {} for name in ('req', 'resp'): full_name = 'sample_{}_ts'.format(name) value = getattr(service_response.data, full_name, '') if value: value = from_utc_to_user(value + '+00:00', req.zato.user_profile) ts[full_name] = value service.id = service_response.data.service_id service.sample_cid = service_response.data.sample_cid service.sample_req_ts = ts['sample_req_ts'] service.sample_resp_ts = ts['sample_resp_ts'] service.sample_req_resp_freq = service_response.data.sample_req_resp_freq return_data = { 'cluster_id': req.zato.cluster_id, 'service': service, 'pretty_print': not pretty_print, } return TemplateResponse(req, 'zato/service/request-response.html', return_data)
def request_response(req, service_name): service = Service(name=service_name) pretty_print = asbool(req.GET.get('pretty_print')) input_dict = { 'name': service_name, 'cluster_id': req.zato.cluster_id } zato_message, soap_response = invoke_admin_service(req.zato.cluster, 'zato:service.get-request-response', input_dict) if zato_path('response.item').get_from(zato_message) is not None: item = zato_message.response.item request = (item.sample_req.text if item.sample_req.text else '').decode('base64') request_data_format = known_data_format(request) if request_data_format: if pretty_print: request = get_pretty_print(request, request_data_format) service.sample_req_html = highlight(request, data_format_lexer[request_data_format](), HtmlFormatter(linenos='table')) response = (item.sample_resp.text if item.sample_resp.text else '').decode('base64') response_data_format = known_data_format(response) if response_data_format: if pretty_print: response = get_pretty_print(response, response_data_format) service.sample_resp_html = highlight(response, data_format_lexer[response_data_format](), HtmlFormatter(linenos='table')) service.sample_req = request service.sample_resp = response ts = {} for name in('req', 'resp'): full_name = 'sample_{}_ts'.format(name) value = getattr(item, full_name).text or '' if value: value = from_utc_to_user(value+'+00:00', req.zato.user_profile) ts[full_name] = value service.id = item.service_id.text service.sample_cid = item.sample_cid.text service.sample_req_ts = ts['sample_req_ts'] service.sample_resp_ts = ts['sample_resp_ts'] service.sample_req_resp_freq = item.sample_req_resp_freq.text return_data = { 'cluster_id': req.zato.cluster_id, 'service': service, 'pretty_print': not pretty_print, } return TemplateResponse(req, 'zato/service/request-response.html', return_data)
def request_response(req, service_name): service = Service(name=service_name) pretty_print = asbool(req.GET.get('pretty_print')) input_dict = { 'name': service_name, 'cluster_id': req.zato.cluster_id } service_response = req.zato.client.invoke('zato.service.get-request-response', input_dict) if service_response.ok: request = (service_response.data.sample_req if service_response.data.sample_req else '').decode('base64') request_data_format = known_data_format(request) if request_data_format: if pretty_print: request = get_pretty_print(request, request_data_format) service.sample_req_html = highlight(request, data_format_lexer[request_data_format](), HtmlFormatter(linenos='table')) response = (service_response.data.sample_resp if service_response.data.sample_resp else '').decode('base64') response_data_format = known_data_format(response) if response_data_format: if pretty_print: response = get_pretty_print(response, response_data_format) service.sample_resp_html = highlight(response, data_format_lexer[response_data_format](), HtmlFormatter(linenos='table')) service.sample_req = request service.sample_resp = response ts = {} for name in('req', 'resp'): full_name = 'sample_{}_ts'.format(name) value = getattr(service_response.data, full_name, '') if value: value = from_utc_to_user(value+'+00:00', req.zato.user_profile) ts[full_name] = value service.id = service_response.data.service_id service.sample_cid = service_response.data.sample_cid service.sample_req_ts = ts['sample_req_ts'] service.sample_resp_ts = ts['sample_resp_ts'] service.sample_req_resp_freq = service_response.data.sample_req_resp_freq return_data = { 'cluster_id': req.zato.cluster_id, 'service': service, 'pretty_print': not pretty_print, } return TemplateResponse(req, 'zato/service/request-response.html', return_data)
def request_response(req, service_name): service = Service(name=service_name) pretty_print = asbool(req.GET.get("pretty_print")) input_dict = {"name": service_name, "cluster_id": req.zato.cluster_id} service_response = req.zato.client.invoke("zato.service.get-request-response", input_dict) if service_response.ok: request = (service_response.data.sample_req if service_response.data.sample_req else "").decode("base64") request_data_format = known_data_format(request) if request_data_format: if pretty_print: request = get_pretty_print(request, request_data_format) service.sample_req_html = highlight( request, data_format_lexer[request_data_format](), HtmlFormatter(linenos="table") ) response = (service_response.data.sample_resp if service_response.data.sample_resp else "").decode("base64") response_data_format = known_data_format(response) if response_data_format: if pretty_print: response = get_pretty_print(response, response_data_format) service.sample_resp_html = highlight( response, data_format_lexer[response_data_format](), HtmlFormatter(linenos="table") ) service.sample_req = request service.sample_resp = response ts = {} for name in ("req", "resp"): full_name = "sample_{}_ts".format(name) value = getattr(service_response.data, full_name, "") if value: value = from_utc_to_user(value + "+00:00", req.zato.user_profile) ts[full_name] = value service.id = service_response.data.service_id service.sample_cid = service_response.data.sample_cid service.sample_req_ts = ts["sample_req_ts"] service.sample_resp_ts = ts["sample_resp_ts"] service.sample_req_resp_freq = service_response.data.sample_req_resp_freq return_data = {"cluster_id": req.zato.cluster_id, "service": service, "pretty_print": not pretty_print} return TemplateResponse(req, "zato/service/request-response.html", return_data)
def wsdl(req, service_name): service = Service(name=service_name) has_wsdl = False wsdl_public_url = get_public_wsdl_url(req.zato.cluster, service_name) input_dict = {'name': service_name, 'cluster_id': req.zato.cluster_id} response = req.zato.client.invoke('zato.service.has-wsdl', input_dict) if response.has_data: service.id = response.data.service_id has_wsdl = response.data.has_wsdl return_data = { 'cluster_id': req.zato.cluster_id, 'service': service, 'has_wsdl': has_wsdl, 'wsdl_public_url': wsdl_public_url, } return TemplateResponse(req, 'zato/service/wsdl.html', return_data)
def wsdl(req, service_name): service = Service(name=service_name) has_wsdl = False wsdl_public_url = get_public_wsdl_url(req.zato.cluster, service_name) input_dict = {"name": service_name, "cluster_id": req.zato.cluster_id} response = req.zato.client.invoke("zato.service.has-wsdl", input_dict) if response.has_data: service.id = response.data.service_id has_wsdl = response.data.has_wsdl return_data = { "cluster_id": req.zato.cluster_id, "service": service, "has_wsdl": has_wsdl, "wsdl_public_url": wsdl_public_url, } return TemplateResponse(req, "zato/service/wsdl.html", return_data)
def wsdl(req, service_name): service = Service(name=service_name) has_wsdl = False wsdl_public_url = get_public_wsdl_url(req.zato.cluster, service_name) input_dict = { 'name': service_name, 'cluster_id': req.zato.cluster_id } response = req.zato.client.invoke('zato.service.has-wsdl', input_dict) if response.has_data: service.id = response.data.service_id has_wsdl = response.data.has_wsdl return_data = { 'cluster_id':req.zato.cluster_id, 'service':service, 'has_wsdl':has_wsdl, 'wsdl_public_url':wsdl_public_url, } return TemplateResponse(req, 'zato/service/wsdl.html', return_data)
def wsdl(req, service_name): service = Service(name=service_name) has_wsdl = False wsdl_public_url = get_public_wsdl_url(req.zato.cluster, service_name) input_dict = { 'name': service_name, 'cluster_id': req.zato.cluster_id } zato_message, soap_response = invoke_admin_service(req.zato.cluster, 'zato:service.has-wsdl', input_dict) if zato_path('response.item').get_from(zato_message) is not None: service.id = zato_message.response.item.service_id.text has_wsdl = is_boolean(zato_message.response.item.has_wsdl.text) return_data = { 'cluster_id':req.zato.cluster_id, 'service':service, 'has_wsdl':has_wsdl, 'wsdl_public_url':wsdl_public_url, } return TemplateResponse(req, 'zato/service/wsdl.html', return_data)