createUser method
Creates a user.
May throw ResourceInUseException. May throw LimitExceededException. May throw ConcurrentModificationException.
Parameter userId
:
The ARN for the user.
Parameter clientRequestToken
:
A unique, user-specified identifier for this request that ensures
idempotency.
Parameter email
:
The email address for the user.
Parameter firstName
:
The first name for the user.
Parameter lastName
:
The last name for the user.
Parameter tags
:
The tags for the user.
Implementation
Future<CreateUserResponse> createUser({
required String userId,
String? clientRequestToken,
String? email,
String? firstName,
String? lastName,
List<Tag>? tags,
}) async {
ArgumentError.checkNotNull(userId, 'userId');
_s.validateStringLength(
'userId',
userId,
1,
128,
isRequired: true,
);
_s.validateStringLength(
'clientRequestToken',
clientRequestToken,
10,
150,
);
_s.validateStringLength(
'email',
email,
1,
128,
);
_s.validateStringLength(
'firstName',
firstName,
0,
30,
);
_s.validateStringLength(
'lastName',
lastName,
0,
30,
);
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'AlexaForBusiness.CreateUser'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'UserId': userId,
'ClientRequestToken':
clientRequestToken ?? _s.generateIdempotencyToken(),
if (email != null) 'Email': email,
if (firstName != null) 'FirstName': firstName,
if (lastName != null) 'LastName': lastName,
if (tags != null) 'Tags': tags,
},
);
return CreateUserResponse.fromJson(jsonResponse.body);
}