forked from strands-agents/samples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdelete_booking.py
More file actions
29 lines (27 loc) · 1.02 KB
/
delete_booking.py
File metadata and controls
29 lines (27 loc) · 1.02 KB
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
from strands import tool
import boto3
@tool
def delete_booking(booking_id: str, restaurant_name:str) -> str:
"""delete an existing booking_id at restaurant_name
Args:
booking_id: the id of the reservation
restaurant_name: name of the restaurant handling the reservation
Returns:
confirmation_message: confirmation message
"""
kb_name = 'restaurant-assistant'
dynamodb = boto3.resource('dynamodb')
smm_client = boto3.client('ssm')
table_name = smm_client.get_parameter(
Name=f'{kb_name}-table-name',
WithDecryption=False
)
table = dynamodb.Table(table_name["Parameter"]["Value"])
try:
response = table.delete_item(Key={'booking_id': booking_id, 'restaurant_name': restaurant_name})
if response['ResponseMetadata']['HTTPStatusCode'] == 200:
return f'Booking with ID {booking_id} deleted successfully'
else:
return f'Failed to delete booking with ID {booking_id}'
except Exception as e:
return str(e)