in src/createChimeSMAResources/createChimeSMAResources.py [0:0]
def get_phone_number():
search_response = chime.search_available_phone_numbers(
# AreaCode='string',
# City='string',
# Country='string',
State="AZ",
# TollFreePrefix='string',
MaxResults=1,
)
phone_number_to_order = search_response["E164PhoneNumbers"][0]
print("Phone Number: " + phone_number_to_order)
phone_order = chime.create_phone_number_order(
ProductType="SipMediaApplicationDialIn",
E164PhoneNumbers=[
phone_number_to_order,
],
)
print("Phone Order: " + str(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: " + str(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)
return phone_number_to_order