Exemplo n.º 1
0
        public static void SNSListSubscriptionsByTopic()
        {
            #region SNSListSubscriptionsByTopic
            var snsClient = new AmazonSimpleNotificationServiceClient();
            var request   = new ListSubscriptionsByTopicRequest();
            var response  = new ListSubscriptionsByTopicResponse();

            request.TopicArn = "arn:aws:sns:us-east-1:80398EXAMPLE:CodingTestResults";

            do
            {
                response = snsClient.ListSubscriptionsByTopic(request);

                foreach (var sub in response.Subscriptions)
                {
                    Console.WriteLine("Subscription: {0}", sub.SubscriptionArn);

                    var subAttrs = snsClient.GetSubscriptionAttributes(
                        new GetSubscriptionAttributesRequest
                    {
                        SubscriptionArn = sub.SubscriptionArn
                    }).Attributes;

                    if (subAttrs.Count > 0)
                    {
                        foreach (var subAttr in subAttrs)
                        {
                            Console.WriteLine(" -{0} : {1}", subAttr.Key, subAttr.Value);
                        }
                    }

                    Console.WriteLine();
                }

                request.NextToken = response.NextToken;
            } while (!string.IsNullOrEmpty(response.NextToken));
            #endregion

            Console.ReadLine();
        }