MCPcopy Create free account
hub / github.com/aws-samples/aws-cdk-examples / handler

Function handler

python/image-content-search/src/imageData/main.py:12–38  ·  view source on GitHub ↗
(event, context)

Source from the content-addressed store, hash-verified

10# return the suitable data
11
12def handler(event, context):
13 # logger.info(event)
14
15 if "ResourceProperties" in event:
16 body = event["ResourceProperties"]
17 for k in body: event[k] = body[k]
18
19 if "body" in event:
20 body = get_http_params(event["body"])
21 for k in body: event[k] = body[k]
22
23 source = event["source"]
24
25 if source == "Cloudformation": # Cloudformation => create schema
26 return create_schema()
27 elif source == "EventBridge": # Event Bridge => image labels
28 image_id = event["detail"]["image_id"]
29 labels = event["detail"]["labels"]
30 response = insert_new_image(image_id, labels)
31 return response
32 elif source == "API": #API Gateway => search
33 if "language" in event:
34 response = search_label(event["label"], event["country"], event["language"])
35 else:
36 response = search_label(event["label"])
37
38 return response

Callers

nothing calls this directly

Calls 4

get_http_paramsFunction · 0.90
create_schemaFunction · 0.90
insert_new_imageFunction · 0.90
search_labelFunction · 0.90

Tested by

no test coverage detected