@@ -0,0 +1,2993 @@
+//snippet-sourcedescription:%5BListUsers.java demonstrates how to list the users for an organization.%5D%0A//snippet-keyword:%5BSDK for Java 2.0%5D%0A//snippet-keyword:%5BCode Sample%5D%0A//snippet-service:%5BAmazon WorkDocs%5D%0A//snippet-sourcetype:%5Bfull-example%5D%0A//snippet-sourcedate:%5B6/30/2020%5D%0A//snippet-sourceauthor:%5Bscmacdon - aws%5D%0A%0A// snippet-start:%5Bworkdocs.java2.list_users.complete%5D%0A// snippet-start:%5Bworkdocs.java2.list_users.import%5D%0Apackage com.example.workdocs;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0Aimport software.amazon.awssdk.regions.Region;%0Aimport software.amazon.awssdk.services.workdocs.WorkDocsClient;%0Aimport software.amazon.awssdk.services.workdocs.model.DescribeUsersRequest;%0Aimport software.amazon.awssdk.services.workdocs.model.DescribeUsersResponse;%0Aimport software.amazon.awssdk.services.workdocs.model.User;%0A// snippet-end:%5Bworkdocs.java2.list_users.import%5D%0A// snippet-start:%5Bworkdocs.java2.list_users.main%5D%0Apublic class ListUsers %7B%0A%0A    public static void main(String%5B%5D args) %7B%0A        // Based on WorkDocs dev guide code at http://docs.aws.amazon.com/workdocs/latest/developerguide/connect-workdocs-iam.html%0A%0A        final String USAGE = %22%5Cn%22 +%0A                %22To run this example, supply your organization ID%5Cn%22 +%0A                %22%5Cn%22 +%0A                %22Ex: list_users %3CorganizationId%3E%5Cn%22;%0A%0A       if (args.length %3C 1) %7B%0A            System.out.println(USAGE);%0A            System.exit(1);%0A        %7D%0A%0A        String orgId = args%5B0%5D;%0A%0A        // Create a service client%0A        Region region = Region.US_WEST_2;%0A        WorkDocsClient workDocs = WorkDocsClient.builder()%0A                .region(region)%0A                .build();%0A%0A        getAllUsers(workDocs, orgId);%0A    %7D%0A%0A    public static void getAllUsers(WorkDocsClient workDocs,String orgId) %7B%0A%0A        List%3CUser%3E wdUsers = new ArrayList%3C%3E();%0A%0A        String marker = null;%0A%0A        do %7B%0A            DescribeUsersResponse result;%0A%0A            if(marker == null) %7B%0A                DescribeUsersRequest request = DescribeUsersRequest.builder()%0A                        .organizationId(orgId)%0A                        .build();%0A                result = workDocs.describeUsers(request);%0A            %7D else %7B%0A                DescribeUsersRequest request = DescribeUsersRequest.builder()%0A                        .organizationId(orgId)%0A                        .marker(marker)%0A                        .build();%0A                result = workDocs.describeUsers(request);%0A            %7D%0A%0A            System.out.println(%22List of users:%22);%0A%0A            wdUsers.addAll(result.users());%0A            marker = result.marker();%0A        %7D while (marker != null);%0A%0A        for (User wdUser : wdUsers) %7B%0A            System.out.printf(%22Firstname:%25s %7C Lastname:%25s %7C Email:%25s %7C root-folder-id:%25s%5Cn%22,%0A                    wdUser.givenName(), wdUser.surname(), wdUser.emailAddress(),%0A                    wdUser.rootFolderId());%0A        %7D%0A    %7D%0A%7D%0A// snippet-end:%5Bworkdocs.java2.list_users.main%5D%0A// snippet-end:%5Bworkdocs.java2.list_users.complete%5D%0A

Create ListUsers.java