-
Notifications
You must be signed in to change notification settings - Fork 0
/
show.py
34 lines (26 loc) · 916 Bytes
/
show.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import logging
from db.driver import Connection
from db.query import get_quote
from db.consts import get_response_object
log = logging.getLogger()
log.setLevel(logging.DEBUG)
def handler(event, context):
conn = Connection()
if not event:
return get_response_object(
400,
{"error": "Missing path parameter"}, {})
path_parameters = event.get("pathParameters")
id = path_parameters.get("id")
if not id:
return get_response_object(
400,
{"error": "Id Cannot be left empty"}, {})
quote, err = get_quote(id, conn.get_connection())
if err:
return get_response_object(
400,
{"error":
f"Could not fetch pet information for pet id {id}"},
{})
return get_response_object(200, {}, {"result": quote})