com.amazonaws.services.identitymanagement.model.CreateUserResult Java Examples

The following examples show how to use com.amazonaws.services.identitymanagement.model.CreateUserResult. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CreateUser.java    From aws-doc-sdk-examples with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {

        final String USAGE =
            "To run this example, supply a username\n" +
            "Ex: CreateUser <username>\n";

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

        String username = args[0];

        final AmazonIdentityManagement iam =
            AmazonIdentityManagementClientBuilder.defaultClient();

        CreateUserRequest request = new CreateUserRequest()
            .withUserName(username);

        CreateUserResult response = iam.createUser(request);

        System.out.println("Successfully created user: " +
                response.getUser().getUserName());
    }
 
Example #2
Source File: IAMService.java    From Serverless-Programming-Cookbook with MIT License 5 votes vote down vote up
/**
 * Create user.
 * @param userName - user name.
 * @return IAMOperationResponse
 */
public final IAMOperationResponse createUser(final String userName) {

    CreateUserRequest request =
            new CreateUserRequest().withUserName(userName);

    CreateUserResult response = iamClient.createUser(request);

    return new IAMOperationResponse(
            "Created user " + response.getUser().getUserName(),
            null);
}
 
Example #3
Source File: IAMServiceImpl.java    From Serverless-Programming-Cookbook with MIT License 5 votes vote down vote up
@Override
public final IAMOperationResponse createUser(final String userName) {

    CreateUserRequest request =
            new CreateUserRequest().withUserName(userName);

    CreateUserResult response = iamClient.createUser(request);

    return new IAMOperationResponse(
            "Created user " + response.getUser().getUserName(),
            null);
}
 
Example #4
Source File: IAMServiceImplTest.java    From Serverless-Programming-Cookbook with MIT License 5 votes vote down vote up
@Test
public void testCreateUser() {
    IAMOperationResponse expectedResponse = new IAMOperationResponse(
            "Created user test_user", null);
    when(iamClient.createUser(any()))
            .thenReturn(new CreateUserResult()
                    .withUser(new User().withUserName("test_user")));
    IAMOperationResponse actualResponse
            = service.createUser("test_user");
    Assert.assertEquals(expectedResponse, actualResponse);
}
 
Example #5
Source File: IdentityManagementImpl.java    From aws-sdk-java-resources with Apache License 2.0 5 votes vote down vote up
@Override
public User createUser(CreateUserRequest request,
        ResultCapture<CreateUserResult> extractor) {

    ActionResult result = service.performAction("CreateUser", request,
            extractor);

    if (result == null) return null;
    return new UserImpl(result.getResource());
}
 
Example #6
Source File: IdentityManagementImpl.java    From aws-sdk-java-resources with Apache License 2.0 5 votes vote down vote up
@Override
public User createUser(String userName, ResultCapture<CreateUserResult>
        extractor) {

    CreateUserRequest request = new CreateUserRequest()
        .withUserName(userName);
    return createUser(request, extractor);
}
 
Example #7
Source File: IdentityManagementImpl.java    From aws-sdk-java-resources with Apache License 2.0 4 votes vote down vote up
@Override
public User createUser(String userName) {
    return createUser(userName, (ResultCapture<CreateUserResult>)null);
}
 
Example #8
Source File: IdentityManagement.java    From aws-sdk-java-resources with Apache License 2.0 2 votes vote down vote up
/**
 * Performs the <code>CreateUser</code> action and use a ResultCapture to
 * retrieve the low-level client response.
 *
 * <p>
 *
 * @return The <code>User</code> resource object associated with the result
 *         of this action.
 * @see CreateUserRequest
 */
com.amazonaws.resources.identitymanagement.User createUser(CreateUserRequest
        request, ResultCapture<CreateUserResult> extractor);
 
Example #9
Source File: IdentityManagement.java    From aws-sdk-java-resources with Apache License 2.0 2 votes vote down vote up
/**
 * The convenient method form for the <code>CreateUser</code> action.
 *
 * @see #createUser(CreateUserRequest, ResultCapture)
 */
com.amazonaws.resources.identitymanagement.User createUser(String userName,
        ResultCapture<CreateUserResult> extractor);