我的帐户中有700个SNS主题。我正在使用boto删除所有这些。代码正在删除它们,但是我每次都只会删除100个主题。我已经运行了7次代码,以删除所有700个主题。我希望一次删除所有
也尝试过GUI,但同样存在问题
def delete_topic(self, topic):
params = {'ContentType' : 'JSON',
'TopicArn' : topic}
response = self.make_request('DeleteTopic', params, '/', 'GET')
body = response.read()
if response.status == 200:
return json.loads(body)
else:
boto.log.error('%s %s' % (response.status, response.reason))
boto.log.error('%s' % body)
raise self.ResponseError(response.status, response.reason, body)
endpoint = boto.sqs.regioninfo.RegionInfo(name=region,endpoint='sns.'+str(region)+'.amazonaws.com')
sns = boto.connect_sns(aws_access_key_id=aKey, aws_secret_access_key=aSecret,region=endpoint)
topics = sns.get_all_topics()
dict_topic = topics[u'ListTopicsResponse']['ListTopicsResult']['Topics']
i=0
for key in dict_topic:
topic=topics[u'ListTopicsResponse']['ListTopicsResult']['Topics'][i]['TopicArn']
delete_topic(sns,topic)
print "Deleted the topic"+str(topic)
i = i + 1
答案 0 :(得分:0)
您应该使用next_token参数,因为它是嵌套的字典分页:
get_all_topics(next_token=None)
Parameters: next_token (string) – Token returned by the previous call to this method.
您还可以查看该帖子: