本文整理汇总了Golang中github.com/aws/aws-sdk-go/service/sns.SNS.ListSubscriptionsByTopic方法的典型用法代码示例。如果您正苦于以下问题:Golang SNS.ListSubscriptionsByTopic方法的具体用法?Golang SNS.ListSubscriptionsByTopic怎么用?Golang SNS.ListSubscriptionsByTopic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/aws/aws-sdk-go/service/sns.SNS
的用法示例。
在下文中一共展示了SNS.ListSubscriptionsByTopic方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: findSubscriptionByNonID
// finds a subscription using protocol, endpoint and topic_arn (which is a key in sns subscription)
func findSubscriptionByNonID(d *schema.ResourceData, snsconn *sns.SNS) (*sns.Subscription, error) {
protocol := d.Get("protocol").(string)
endpoint := d.Get("endpoint").(string)
topic_arn := d.Get("topic_arn").(string)
req := &sns.ListSubscriptionsByTopicInput{
TopicArn: aws.String(topic_arn),
}
for {
res, err := snsconn.ListSubscriptionsByTopic(req)
if err != nil {
return nil, fmt.Errorf("Error fetching subscripitions for topic %s : %s", topic_arn, err)
}
for _, subscription := range res.Subscriptions {
log.Printf("[DEBUG] check subscription with EndPoint %s, Protocol %s, topicARN %s and SubscriptionARN %s", *subscription.Endpoint, *subscription.Protocol, *subscription.TopicArn, *subscription.SubscriptionArn)
if *subscription.Endpoint == endpoint && *subscription.Protocol == protocol && *subscription.TopicArn == topic_arn && !subscriptionHasPendingConfirmation(subscription.SubscriptionArn) {
return subscription, nil
}
}
// if there are more than 100 subscriptions then go to the next 100 otherwise return nil
if res.NextToken != nil {
req.NextToken = res.NextToken
} else {
return nil, nil
}
}
}