Exemple #1
0
def get_recommendations(demoGuid):
    """
    Get recommendations
    """

    try:
        payload = dict()
        payload['demoGuid'] = demoGuid
        response = call_openwhisk('retrieve', payload)
    except Exception as e:
        raise APIException('KO', internal_details=str(e))

    return response
Exemple #2
0
def get_observations(latitude, longitude):
    """
    Return observations for the given location
    """

    try:
        payload = dict()
        payload['latitude'] = latitude
        payload['longitude'] = longitude
        response = call_openwhisk('observations', payload)
    except Exception as e:
        raise APIException('KO', internal_details=str(e))

    return response
Exemple #3
0
def acknowledge_recommendation(demoGuid, recommendationId):
    """
    Acknowledge the given recommendation
    """

    try:
        payload = dict()
        payload['demoGuid'] = demoGuid
        payload['recommendationId'] = recommendationId
        response = call_openwhisk('acknowledge', payload)
    except Exception as e:
        raise APIException('KO', internal_details=str(e))

    return response
Exemple #4
0
def trigger_simulation(demoGuid):
    """
    Trigger a simulation in the given demo
    Creates a Snow Storm in the DC area
    """

    try:
        payload = dict()
        payload['demoGuid'] = demoGuid
        event = dict()
        event = json.loads(open('./sample_event.json').read())
        payload['event'] = event
        response = call_openwhisk('recommend', payload)
    except Exception as e:
        raise APIException('KO', internal_details=str(e))

    return response