//snippet-sourcedescription:[CreateApp.java demonstrates how to create an application in the Pinpoint dashboard.]
//snippet-keyword:[Java]
//snippet-sourcesyntax:[java]
//snippet-keyword:[Code Sample]
//snippet-keyword:[Amazon Pinpoint]
//snippet-service:[pinpoint]
//snippet-sourcetype:[full-example]
//snippet-sourcedate:[2019-06-01]
//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:[pinpoint.java2.CreateApp.complete]
package com.example.pinpoint;

//snippet-start:[pinpoint.java2.CreateApp.import]
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.pinpoint.PinpointClient;
import software.amazon.awssdk.services.pinpoint.model.CreateAppRequest;
import software.amazon.awssdk.services.pinpoint.model.CreateAppResponse;
import software.amazon.awssdk.services.pinpoint.model.CreateApplicationRequest;
//snippet-end:[pinpoint.java2.CreateApp.import]

public class CreateApp {
    public static void main(String[] args) {
        final String USAGE = "\n" +
                "CreateApp - create an application in pinpoint dashboard\n\n" +
                "Usage: CreateApp <appName>\n\n" +
                "Where:\n" +
                "  appName - the name of the application to create.\n\n";

        if (args.length < 1) {
            System.out.println(USAGE);
            System.exit(1);
        }

        //snippet-start:[pinpoint.java2.CreateApp.main]
        String appName = args[0];

        System.out.println("Creating an application with name: " + appName);

        PinpointClient pinpoint = PinpointClient.builder().region(Region.US_EAST_1).build();

        CreateApplicationRequest appRequest = CreateApplicationRequest.builder()
                .name(appName)
                .build();

        CreateAppRequest request = CreateAppRequest.builder()
                .createApplicationRequest(appRequest)
                .build();

        CreateAppResponse result = pinpoint.createApp(request);

        String appID = result.applicationResponse().id();
        System.out.println("Application " + appName + " has been created.");
        System.out.println("App ID is: " + appID);
        //snippet-end:[pinpoint.java2.CreateApp.main]
    }
}
//snippet-end:[pinpoint.java2.CreateApp.complete]

@@ -86,16 +86,23 @@
  in the 
+Amazon 
 Pinpoint
@@ -328,18 +328,18 @@
 te:%5B
-2019-06-01
+03/02/2020
 %5D%0A//
@@ -364,26 +364,20 @@
 or:%5B
-j
 sc
-hwarzwalder AWS
+macdon-aws
 %5D%0A/*
@@ -394,18 +394,8 @@
 ght 
-2010-2019 
 Amaz
@@ -953,60 +953,8 @@
  */%0A
-//snippet-start:%5Bpinpoint.java2.CreateApp.complete%5D%0A
 pack
@@ -1004,39 +1004,39 @@
 %5Bpinpoint.java2.
-C
+c
 reate
-A
+a
 pp.import%5D%0Aimpor
@@ -1365,16 +1365,89 @@
 equest;%0A
+import software.amazon.awssdk.services.pinpoint.model.PinpointException;%0A
 //snippe
@@ -1468,23 +1468,23 @@
 t.java2.
-C
+c
 reate
-A
+a
 pp.impor
@@ -1647,17 +1647,28 @@
 tion in 
-p
+the Amazon P
 inpoint 
@@ -1950,65 +1950,8 @@
    %7D
-%0A%0A        //snippet-start:%5Bpinpoint.java2.CreateApp.main%5D
 %0A   
@@ -1981,17 +1981,16 @@
 rgs%5B0%5D;%0A
-%0A
         
@@ -2117,16 +2117,33 @@
 uilder()
+%0A                
 .region(
@@ -2159,16 +2159,33 @@
 _EAST_1)
+%0A                
 .build()
@@ -2179,32 +2179,308 @@
      .build();%0A%0A
+        String appID = createApplication(pinpoint, appName);%0A        System.out.println(%22App ID is: %22 + appID);%0A    %7D%0A%0A    //snippet-start:%5Bpinpoint.java2.createapp.main%5D%0A    public static String createApplication(PinpointClient pinpoint, String appName) %7B%0A%0A        try %7B%0A    
         CreateAp
@@ -2560,16 +2560,20 @@
         
+    
 .name(ap
@@ -2587,32 +2587,36 @@
                 
+ 
+   
 .build();%0A%0A     
@@ -2602,32 +2602,36 @@
      .build();%0A%0A
+    
         CreateAp
@@ -2692,16 +2692,20 @@
         
+  
+  
 .createA
@@ -2742,32 +2742,36 @@
                 
+    
 .build();%0A%0A     
@@ -2765,32 +2765,36 @@
 ild();%0A%0A        
+   
+ 
 CreateAppRespons
@@ -2842,30 +2842,26 @@
         
-String appID =
+    return
  result.
@@ -2888,16 +2888,61 @@
 ).id();%0A
+%0A        %7D catch (PinpointException e) %7B%0A    
         
@@ -2940,35 +2940,35 @@
          System.
-out
+err
 .println(%22Applic
@@ -2964,107 +2964,100 @@
 tln(
-%22Application %22 + appName + %22 has been created.%22);%0A        System.out.println(%22App ID is: %22 + appID)
+e.awsErrorDetails().errorMessage());%0A            System.exit(1);%0A        %7D%0A        return %22%22
 ;%0A  
@@ -3092,23 +3092,23 @@
 t.java2.
-C
+c
 reate
-A
+a
 pp.main%5D
@@ -3120,54 +3120,4 @@
 %7D%0A%7D%0A
-//snippet-end:%5Bpinpoint.java2.CreateApp.complete%5D%0A

Update CreateApp.java