aws boto sns - получить endpoint_arn по токену устройства
В настоящее время, если мы хотим добавить устройство в приложение SNS, используя:
ep = SNSConnection.create_platform_endpoint(app_arn,device_token,user_data)
Существует вариант, что устройство уже было добавлено в прошлом. Чтобы убедиться, что устройство уже добавлено, мы используем:
def is_device_registered(device_token):
list_of_endpoints = SNSConnection.list_endpoints_by_platform_application(AC.INPLAY_CHAT_APPLICATION_SNS_ARN)
all_app_endpoints = list_of_endpoints['ListEndpointsByPlatformApplicationResponse']['ListEndpointsByPlatformApplicationResult']['Endpoints']
for ep in all_app_endpoints:
ep_device_token = ep['Attributes']['Token']
if device_token == ep_device_token:
endpoint_arn = ep['EndpointArn']
print 'Found an endpoint for device_token: %s, entry:%s' % (device_token,endpoint_arn)
return endpoint_arn
return None
что очень неэффективно и не может быть масштабировано.
есть ли функция boto sns, которая получает device_token и возвращает endpoint_arn, если существует? (Нет, если нет).