in src/createChimeVCResources/createChimeVCResources.py [0:0]
def get_phone_number():
print("Getting Phone Number")
search_response = chime.search_available_phone_numbers(
# AreaCode='string',
# City='string',
# Country='string',
# TollFreePrefix='string',
State="CA",
MaxResults=1,
)
phone_number_to_order = search_response["E164PhoneNumbers"][0]
print("Phone Number: {}".format(phone_number_to_order))
phone_order = chime.create_phone_number_order(
ProductType="VoiceConnector",
E164PhoneNumbers=[
phone_number_to_order,
],
)
print("Phone Order: {}".format(phone_order))
check_phone_order = chime.get_phone_number_order(
PhoneNumberOrderId=phone_order["PhoneNumberOrder"]["PhoneNumberOrderId"]
)
order_status = check_phone_order["PhoneNumberOrder"]["Status"]
timeout = 0
while not order_status == "Successful":
timeout += 1
print("Checking status: {}".format(order_status))
time.sleep(5)
check_phone_order = chime.get_phone_number_order(
PhoneNumberOrderId=phone_order["PhoneNumberOrder"]["PhoneNumberOrderId"]
)
order_status = check_phone_order["PhoneNumberOrder"]["Status"]
if order_status == "Failed":
raise Exception("Order number failed: {}".format(check_phone_order))
if timeout == 5:
return "Could not get phone number: {}".format(check_phone_order)
print("Phone Number Ordered: {}".format(phone_number_to_order))
return phone_number_to_order