createUser method
Creates a user in a Simple AD or Microsoft AD directory. The status of a newly created user is "ACTIVE". New users can access Amazon WorkDocs.
May throw EntityAlreadyExistsException. May throw UnauthorizedOperationException. May throw UnauthorizedResourceAccessException. May throw FailedDependencyException. May throw ServiceUnavailableException.
Parameter givenName
:
The given name of the user.
Parameter password
:
The password of the user.
Parameter surname
:
The surname of the user.
Parameter username
:
The login name of the user.
Parameter authenticationToken
:
Amazon WorkDocs authentication token. Not required when using AWS
administrator credentials to access the API.
Parameter emailAddress
:
The email address of the user.
Parameter organizationId
:
The ID of the organization.
Parameter storageRule
:
The amount of storage for the user.
Parameter timeZoneId
:
The time zone ID of the user.
Implementation
Future<CreateUserResponse> createUser({
required String givenName,
required String password,
required String surname,
required String username,
String? authenticationToken,
String? emailAddress,
String? organizationId,
StorageRuleType? storageRule,
String? timeZoneId,
}) async {
ArgumentError.checkNotNull(givenName, 'givenName');
_s.validateStringLength(
'givenName',
givenName,
1,
64,
isRequired: true,
);
ArgumentError.checkNotNull(password, 'password');
_s.validateStringLength(
'password',
password,
4,
32,
isRequired: true,
);
ArgumentError.checkNotNull(surname, 'surname');
_s.validateStringLength(
'surname',
surname,
1,
64,
isRequired: true,
);
ArgumentError.checkNotNull(username, 'username');
_s.validateStringLength(
'username',
username,
1,
256,
isRequired: true,
);
_s.validateStringLength(
'authenticationToken',
authenticationToken,
1,
8199,
);
_s.validateStringLength(
'emailAddress',
emailAddress,
1,
256,
);
_s.validateStringLength(
'organizationId',
organizationId,
1,
256,
);
_s.validateStringLength(
'timeZoneId',
timeZoneId,
1,
256,
);
final headers = <String, String>{
if (authenticationToken != null)
'Authentication': authenticationToken.toString(),
};
final $payload = <String, dynamic>{
'GivenName': givenName,
'Password': password,
'Surname': surname,
'Username': username,
if (emailAddress != null) 'EmailAddress': emailAddress,
if (organizationId != null) 'OrganizationId': organizationId,
if (storageRule != null) 'StorageRule': storageRule,
if (timeZoneId != null) 'TimeZoneId': timeZoneId,
};
final response = await _protocol.send(
payload: $payload,
method: 'POST',
requestUri: '/api/v1/users',
headers: headers,
exceptionFnMap: _exceptionFns,
);
return CreateUserResponse.fromJson(response);
}