import random


def getinsight(arn, action, count):
    """
    Calculates insight for CloudTrail tuple <<UserIdentity -> arn, eventName, Count of EventName>
    
    :param arn: CloudTrail UserIdentity -> arn
    :param action: CloudTrail eventName
    :param count: Count of eventName aggregated by ProactiveExploration-ReadCloudTrail.py
    :return: insight - index calculated by model
    """
    # CODE TO INVOKE ENDPOINT AND GENERATE A SCORE
    # For a full production system, in order to be most accurate, 
    #   we need to rescale the inputs to fit the model training.
    # We'll skip today for our demo.  The python for doing the scaling
    #   can be found in the modeling notebook, and we will update this lambda
    #   function in the github repo after re:Invent
    
    # Our simpfile.csv is just a file with two numbers - invoke_endpoing for this model
    #    likes file objects to read
    # payload = pd.read_csv('simpfile.csv')
    # payload_file = io.StringIO()
    # payload.to_csv(payload_file, header = None, index = None)
    # client = boto3.client('sagemaker-runtime')
    # response = client.invoke_endpoint(
    # EndpointName = 'XXXXXX <<FILL IN ENDPOINT NAME>> XXXXXXXXXXXXXX', 
        # ContentType = 'text/csv',
        # Body = payload_file.getvalue())
    # result = json.loads(response['Body'].read().decode())
    
    # FOR demo purposes, we'll just generate a float [0..1]
    result = random.random()
    return result