示例#1
0
def get_by_id(req, id_, cluster_id):
    try:
        response = req.zato.client.invoke(
            'zato.security.tech-account.get-by-id', {'id': id_})
    except Exception, e:
        msg = 'Could not fetch the technical account, e:[{e}]'.format(
            e=format_exc(e))
        logger.error(msg)
        return HttpResponseServerError(msg)
    else:
        tech_account = TechnicalAccount()
        tech_account.id = response.data.id
        tech_account.name = response.data.name
        tech_account.is_active = response.data.is_active

        return HttpResponse(tech_account.to_json(),
                            mimetype='application/javascript')


class Index(_Index):
    method_allowed = 'GET'
    url_name = 'security-tech-account'
    template = 'zato/security/tech-account.html'

    service_name = 'zato.security.tech-account.get-list'
    output_class = TechnicalAccount

    class SimpleIO(_Index.SimpleIO):
        input_required = ('cluster_id', )
        output_required = ('id', 'name', 'is_active')
        output_repeated = True
示例#2
0
    
@method_allowed('GET')
def get_by_id(req, id_, cluster_id):
    try:
        response = req.zato.client.invoke('zato.security.tech-account.get-by-id', {'id':id_})
    except Exception, e:
        msg = 'Could not fetch the technical account, e:[{e}]'.format(e=format_exc(e))
        logger.error(msg)
        return HttpResponseServerError(msg)
    else:
        tech_account = TechnicalAccount()
        tech_account.id = response.data.id
        tech_account.name = response.data.name
        tech_account.is_active = response.data.is_active

        return HttpResponse(tech_account.to_json(), mimetype='application/javascript')
    
class Index(_Index):
    method_allowed = 'GET'
    url_name = 'security-tech-account'
    template = 'zato/security/tech-account.html'
    
    service_name = 'zato.security.tech-account.get-list'
    output_class = TechnicalAccount
    
    class SimpleIO(_Index.SimpleIO):
        input_required = ('cluster_id',)
        output_required = ('id', 'name', 'is_active')
        output_repeated = True

    def handle(self):