//snippet-sourcedescription:[ListSubscriptions.java demonstrates how to list existing Amazon SNS subscriptions.]
//snippet-keyword:[Java]
//snippet-sourcesyntax:[java]
//snippet-keyword:[Code Sample]
//snippet-keyword:[Amazon Simple Notification Service]
//snippet-service:[sns]
//snippet-sourcetype:[full-example]
//snippet-sourcedate:[2019-07-20]
//snippet-sourceauthor:[jschwarzwalder AWS]
/*
 * Copyright 2010-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License").
 * You may not use this file except in compliance with the License.
 * A copy of the License is located at
 *
 *  http://aws.amazon.com/apache2.0
 *
 * or in the "license" file accompanying this file. This file is distributed
 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
 * express or implied. See the License for the specific language governing
 * permissions and limitations under the License.
 */
//snippet-start:[sns.java2.ListSubscriptions.complete]
package com.example.sns;

//snippet-start:[sns.java2.ListSubscriptions.import]

import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.sns.SnsClient;
import software.amazon.awssdk.services.sns.model.ListSubscriptionsRequest;
import software.amazon.awssdk.services.sns.model.ListSubscriptionsResponse;
//snippet-end:[sns.java2.ListSubscriptions.import]

public class ListSubscriptions {
    public static void main(String[] args) {
        final String USAGE = "\n" +
                "ListSubscriptions - returns a list of Amazon SNS subscriptions.\n" +
                "Usage: ListSubscriptions \n\n";


        //snippet-start:[sns.java2.ListSubscriptions.main]

        SnsClient snsClient = SnsClient.builder().region(Region.US_EAST_1).build();

        ListSubscriptionsRequest request = ListSubscriptionsRequest.builder().build();

        ListSubscriptionsResponse result = snsClient.listSubscriptions(request);

        System.out.println(result.subscriptions());
        //snippet-end:[sns.java2.ListSubscriptions.main]
    }
}
//snippet-end:[sns.java2.ListSubscriptions.complete]


@@ -370,28 +370,23 @@
 or:%5B
-j
 sc
-hwarzwalder
+macdon
  AWS%5D%0A
+%0A
 /*%0A 
@@ -404,18 +404,18 @@
  2010-20
-19
+20
  Amazon.
@@ -1100,17 +1100,16 @@
 import%5D%0A
-%0A
 import s
@@ -1351,16 +1351,79 @@
 sponse;%0A
+import software.amazon.awssdk.services.sns.model.SnsException;%0A
 //snippe
@@ -1716,17 +1716,16 @@
 %5Cn%5Cn%22;%0A%0A
-%0A
         
@@ -1775,25 +1775,40 @@
 s.main%5D%0A
-%0A
+        try %7B%0A%0A 
         
 SnsClien
@@ -1799,16 +1799,19 @@
         
+   
 SnsClien
@@ -1843,16 +1843,37 @@
 uilder()
+%0A                    
 .region(
@@ -1886,15 +1886,36 @@
 .US_
+W
 E
-A
 ST_
-1)
+2)%0A                    
 .bui
@@ -1913,32 +1913,36 @@
      .build();%0A%0A
+    
         ListSubs
@@ -2002,16 +2002,37 @@
 uilder()
+%0A                    
 .build()
@@ -2034,32 +2034,36 @@
 ild();%0A%0A        
+ 
+   
 ListSubscription
@@ -2119,17 +2119,20 @@
 quest);%0A
-%0A
+    
         
@@ -2174,16 +2174,159 @@
 ions());
+%0A%0A        %7D catch (SnsException e) %7B%0A%0A            System.err.println(e.awsErrorDetails().errorMessage());%0A            System.exit(1);%0A        %7D
 %0A       
@@ -2436,9 +2436,8 @@
 mplete%5D%0A
-%0A

Update ListSubscriptions.java