//snippet-sourcedescription:[CreateAccessPoint.java demonstrates how to create an access point for an Amazon S3 bucket.]
//snippet-keyword:[SDK for Java 2.0]
//snippet-keyword:[Code Sample]
//snippet-service:[Amazon S3]
//snippet-sourcetype:[full-example]
//snippet-sourcedate:[10/28/2020]
//snippet-sourceauthor:[scmacdon-aws]

/*
   Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
   This file is 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/
   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.
*/

package com.example.s3;

// snippet-start:[s3.java2.create_access_point.import]
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.s3control.S3ControlClient;
import software.amazon.awssdk.services.s3control.model.CreateAccessPointRequest;
import software.amazon.awssdk.services.s3control.model.S3ControlException;
// snippet-end:[s3.java2.create_access_point.import]

public class CreateAccessPoint {

    public static void main(String[] args) {

        final String USAGE = "\n" +
                "Usage:\n" +
                "    CreateAccessPoint <accountId><bucketName> <name>\n\n" +
                "Where:\n" +
                "    accountId - the account id that owns the S3 bucket \n\n" +
                "    bucketName - the bucket name \n" +
                "    name - the name of the access point \n";

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

        /* Read the name from command args*/
        String accountId = args[0];
        String bucketName = args[1];
        String name = args[2];

        //Create the S3Client object
        Region region = Region.US_EAST_1;

        S3ControlClient s3ControlClient = S3ControlClient.builder()
                .region(region)
                .build();

        createSpecificAccessPoint(s3ControlClient, accountId, bucketName, name );
    }

    // snippet-start:[s3.java2.create_access_point.main]
    public static void createSpecificAccessPoint(S3ControlClient s3ControlClient,
                                                 String accountId,
                                                 String bucketName,
                                                 String name ) {


        try {
            CreateAccessPointRequest accessPointRequest = CreateAccessPointRequest.builder()
                .accountId(accountId)
                .bucket(bucketName)
                .name(name)
                .build();

            s3ControlClient.createAccessPoint(accessPointRequest);
            System.out.println("The Access Point was created" );

        } catch (S3ControlException e) {
            System.err.println(e.awsErrorDetails().errorMessage());
            System.exit(1);
        }
    }
    // snippet-end:[s3.java2.create_access_point.main]
}

@@ -103,17 +103,42 @@
 Amazon S
-3
+imple Storage Service (S3)
  bucket.
@@ -158,16 +158,20 @@
 eyword:%5B
+AWS 
 SDK for 
@@ -175,19 +175,18 @@
 or Java 
+v
 2
-.0
 %5D%0A//snip
@@ -430,455 +430,43 @@
 %0A   
-This file is licensed under the Apache License, Version 2.0 (the %22License%22).%0A   You may not use this file except in compliance with the License. A copy of%0A   the License is located at%0A    http://aws.amazon.com/a
+SPDX-License-Identifier: A
 pache
+-
 2.0
-/%0A   This file is distributed on an %22AS IS%22 BASIS, WITHOUT WARRANTIES OR%0A   CONDITIONS OF ANY KIND, either express or implied. See the License for the%0A   specific language governing permissions and limitations under the License.
 %0A*/%0A
@@ -1181,16 +1181,23 @@
 wns the 
+Amazon 
 S3 bucke
@@ -1283,17 +1283,28 @@
    %22    
-n
+accessPointN
 ame - th
@@ -1469,18 +1469,8 @@
 the 
-name from 
 comm
@@ -1564,25 +1564,36 @@
      String 
-n
+accessPointN
 ame = args%5B2
@@ -1877,17 +1877,28 @@
 etName, 
-n
+accessPointN
 ame );%0A 
@@ -1960,16 +1960,90 @@
 t.main%5D%0A
+    // This method creates an access point for the given Amazon S3 bucket%0A
     publ
@@ -2307,17 +2307,28 @@
  String 
-n
+accessPointN
 ame ) %7B%0A
@@ -2328,17 +2328,16 @@
 me ) %7B%0A%0A
-%0A
         
@@ -2531,17 +2531,28 @@
   .name(
-n
+accessPointN
 ame)%0A   
@@ -2682,16 +2682,16 @@
 The 
-A
+a
 ccess 
-P
+p
 oint

Update CreateAccessPoint.java