Ejemplo n.º 1
0
    def POST(self):
        '''Executes a python client API call identified by its generic name'''

        # Get the call name from the HTTP header
        call_name = web.input().call_name

        # Load the local ontology into the SMART client
        smart_client = get_smart_client(ONTOLOGY)

        # Figure out the SMART model corresponding to the API call
        model = get_model(call_name)

        # Get a reference to the conveninence method in the SMART client and execute the call
        method_to_call = getattr(smart_client, call_name)
        r = method_to_call()

        # Run the API tests on the result of the call
        messages = getMessages(runTest(model, r.body, r.contentType))

        # Encode and return the call and tests result as JSON
        return json.dumps(
            {
                'body': r.body,
                'contentType': r.contentType,
                'messages': messages
            },
            sort_keys=True,
            indent=4)
Ejemplo n.º 2
0
    def POST(self):
        '''Executes the appropriate series of tests for a given data model'''

        # Get the input data from the HTTP header
        model = web.input().model
        data = web.input().data
        contentType = web.input().content_type

        # Run the tests and obtain the failure messages
        messages = getMessages(runTest(model, data, contentType))

        # Return the failure messages encoded as JSON
        return json.dumps(messages, sort_keys=True, indent=4)
Ejemplo n.º 3
0
    def POST(self):
        '''Executes the appropriate series of tests for a given data model'''

        # Get the input data from the HTTP header
        model = web.input().model
        data = web.input().data
        contentType = web.input().content_type

        # Run the tests and obtain the failure messages
        messages = getMessages(runTest(model, data, contentType))

        # Return the failure messages encoded as JSON
        return json.dumps(messages, sort_keys=True, indent=4)
Ejemplo n.º 4
0
    def POST(self):
        '''Executes a python client API call identified by its generic name'''
        global _smart

        # make sure the SMARTClient is init'd
        cookies = web.cookies()
        api_base = cookies.api_base
        record_id = cookies.record_id

        # reconstruct acc_token from cookies
        acc_token = {
            'oauth_token_secret': cookies.oauth_token_secret,
            'oauth_token': cookies.oauth_token,
            'record_id': record_id,
            'user_id': cookies.user_id
        }

        logging.debug('Cookies are: api_base: ' + api_base + ' record_id: ' +
                      record_id + ' acc_token: ' + str(acc_token))

        smart = _smart_client(api_base, record_id)
        if smart is None:
            return False

        smart.update_token(acc_token)

        call_name = web.input().call_name

        # Figure out the SMART model corresponding to the API call
        model = get_model(call_name)

        logging.debug('Calling ' + call_name)
        method_to_call = getattr(SMARTClient, call_name)
        r = method_to_call(_smart)

        # Run the API tests on the result of the call
        contentType = r.response.get('content-type', None)
        messages = getMessages(runTest(model, r.body, contentType))

        # Encode and return the call and tests result as JSON
        return json.dumps(
            {
                'body': r.body,
                'contentType': contentType,
                'messages': messages
            },
            sort_keys=True,
            indent=4)
Ejemplo n.º 5
0
    def POST(self):
        '''Executes a python client API call identified by its generic name'''
        global _smart

        # make sure the SMARTClient is init'd
        cookies = web.cookies()
        api_base = cookies.api_base
        record_id = cookies.record_id

        # reconstruct acc_token from cookies
        acc_token = {
            'oauth_token_secret': cookies.oauth_token_secret,
            'oauth_token': cookies.oauth_token,
            'record_id': record_id,
            'user_id': cookies.user_id
        }

        logging.debug('Cookies are: api_base: ' + api_base +
                ' record_id: ' + record_id +
                ' acc_token: ' + str(acc_token))

        smart = _smart_client(api_base, record_id)
        if smart is None:
            return False

        smart.update_token(acc_token)

        call_name = web.input().call_name

        # Figure out the SMART model corresponding to the API call
        model = get_model(call_name)

        logging.debug('Calling ' + call_name)
        method_to_call = getattr(SMARTClient, call_name)
        r = method_to_call(_smart)

        # Run the API tests on the result of the call
        contentType = r.response.get('content-type', None)
        messages = getMessages(runTest(model, r.body, contentType))

        # Encode and return the call and tests result as JSON
        return json.dumps({
            'body': r.body,
            'contentType': contentType,
            'messages': messages
        }, sort_keys=True, indent=4)
Ejemplo n.º 6
0
 def POST(self):
     '''Executes a python client API call identified by its generic name'''
     
     # Get the call name from the HTTP header
     call_name = web.input().call_name
     
     # Load the local ontology into the SMART client
     smart_client = get_smart_client(ONTOLOGY)
     
     # Figure out the SMART model corresponding to the API call
     model = get_model(call_name)
     
     # Get a reference to the conveninence method in the SMART client and execute the call
     method_to_call = getattr(smart_client, call_name)
     r = method_to_call()
     
     # Run the API tests on the result of the call
     messages = getMessages(runTest(model,r.body,r.contentType))
     
     # Encode and return the call and tests result as JSON
     return json.dumps({'body':r.body, 'contentType':r.contentType, 'messages':messages}, sort_keys=True, indent=4)