in process-agent-event.py [0:0]
def lambda_handler(event, context):
global DDBTableName,Logger
logging.basicConfig()
Logger.setLevel(logging.INFO)
if os.environ.get("WallboardTable") is not None: DDBTableName = os.environ.get("WallboardTable")
for RawPayload in event["Records"]:
AgentEvent = json.loads(base64.b64decode(RawPayload["kinesis"]["data"]))
EventType = AgentEvent["EventType"]
AgentARN = AgentEvent["AgentARN"]
Logger.debug("Event type: "+EventType+" AgentARN: "+AgentARN)
if EventType == "LOGIN": # We don't really need to do this but just in case...
SaveStateUsingARN(AgentARN, "Login")
continue
if EventType == "LOGOUT":
SaveStateUsingARN(AgentARN, "Logout")
continue
if EventType == "STATE_CHANGE":
State = AgentEvent["CurrentAgentSnapshot"]["AgentStatus"]["Name"]
AgentName = AgentEvent["CurrentAgentSnapshot"]["Configuration"]["FirstName"]+" "+AgentEvent["CurrentAgentSnapshot"]["Configuration"]["LastName"]
Username = AgentEvent["CurrentAgentSnapshot"]["Configuration"]["Username"]
Logger.debug("Agent: "+AgentName+" ("+Username+") State: "+State)
if len(AgentName) == 1: Logger.warning("Expected first and last name of agent but didn't get it in the event.")
SaveStateToDDB(Username, AgentName, AgentARN, State)
continue
if EventType == "HEART_BEAT":
# Not sure what to do here yet
continue
Logger.warning("Unknown event type: "+EventType)
return