createUser method

Future<CreateUserResponse> createUser({
  1. required String displayName,
  2. required String name,
  3. required String organizationId,
  4. required String password,
})

Creates a user who can be used in Amazon WorkMail by calling the RegisterToWorkMail operation.

May throw DirectoryServiceAuthenticationFailedException. May throw DirectoryUnavailableException. May throw InvalidParameterException. May throw InvalidPasswordException. May throw NameAvailabilityException. May throw OrganizationNotFoundException. May throw OrganizationStateException. May throw ReservedNameException. May throw UnsupportedOperationException.

Parameter displayName : The display name for the new user.

Parameter name : The name for the new user. WorkMail directory user names have a maximum length of 64. All others have a maximum length of 20.

Parameter organizationId : The identifier of the organization for which the user is created.

Parameter password : The password for the new user.

Implementation

Future<CreateUserResponse> createUser({
  required String displayName,
  required String name,
  required String organizationId,
  required String password,
}) async {
  ArgumentError.checkNotNull(displayName, 'displayName');
  _s.validateStringLength(
    'displayName',
    displayName,
    0,
    256,
    isRequired: true,
  );
  ArgumentError.checkNotNull(name, 'name');
  _s.validateStringLength(
    'name',
    name,
    1,
    64,
    isRequired: true,
  );
  ArgumentError.checkNotNull(organizationId, 'organizationId');
  _s.validateStringLength(
    'organizationId',
    organizationId,
    34,
    34,
    isRequired: true,
  );
  ArgumentError.checkNotNull(password, 'password');
  _s.validateStringLength(
    'password',
    password,
    0,
    256,
    isRequired: true,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'WorkMailService.CreateUser'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'DisplayName': displayName,
      'Name': name,
      'OrganizationId': organizationId,
      'Password': password,
    },
  );

  return CreateUserResponse.fromJson(jsonResponse.body);
}