updateUserPool method

Future<void> updateUserPool({
  1. required String userPoolId,
  2. AccountRecoverySettingType? accountRecoverySetting,
  3. AdminCreateUserConfigType? adminCreateUserConfig,
  4. List<VerifiedAttributeType>? autoVerifiedAttributes,
  5. DeviceConfigurationType? deviceConfiguration,
  6. EmailConfigurationType? emailConfiguration,
  7. String? emailVerificationMessage,
  8. String? emailVerificationSubject,
  9. LambdaConfigType? lambdaConfig,
  10. UserPoolMfaType? mfaConfiguration,
  11. UserPoolPolicyType? policies,
  12. String? smsAuthenticationMessage,
  13. SmsConfigurationType? smsConfiguration,
  14. String? smsVerificationMessage,
  15. UserPoolAddOnsType? userPoolAddOns,
  16. Map<String, String>? userPoolTags,
  17. VerificationMessageTemplateType? verificationMessageTemplate,
})

Updates the specified user pool with the specified attributes. You can get a list of the current user pool settings using DescribeUserPool.

May throw ResourceNotFoundException. May throw InvalidParameterException. May throw ConcurrentModificationException. May throw TooManyRequestsException. May throw NotAuthorizedException. May throw UserImportInProgressException. May throw InternalErrorException. May throw InvalidSmsRoleAccessPolicyException. May throw InvalidSmsRoleTrustRelationshipException. May throw UserPoolTaggingException. May throw InvalidEmailRoleAccessPolicyException.

Parameter userPoolId : The user pool ID for the user pool you want to update.

Parameter accountRecoverySetting : Use this setting to define which verified available method a user can use to recover their password when they call ForgotPassword. It allows you to define a preferred method when a user has more than one method available. With this setting, SMS does not qualify for a valid password recovery mechanism if the user also has SMS MFA enabled. In the absence of this setting, Cognito uses the legacy behavior to determine the recovery method where SMS is preferred over email.

Parameter adminCreateUserConfig : The configuration for AdminCreateUser requests.

Parameter autoVerifiedAttributes : The attributes that are automatically verified when the Amazon Cognito service makes a request to update user pools.

Parameter deviceConfiguration : Device configuration.

Parameter emailConfiguration : Email configuration.

Parameter emailVerificationMessage : The contents of the email verification message.

Parameter emailVerificationSubject : The subject of the email verification message.

Parameter lambdaConfig : The AWS Lambda configuration information from the request to update the user pool.

Parameter mfaConfiguration : Can be one of the following values:

  • OFF - MFA tokens are not required and cannot be specified during user registration.
  • ON - MFA tokens are required for all user registrations. You can only specify required when you are initially creating a user pool.
  • OPTIONAL - Users have the option when registering to create an MFA token.

Parameter policies : A container with the policies you wish to update in a user pool.

Parameter smsAuthenticationMessage : The contents of the SMS authentication message.

Parameter smsConfiguration : SMS configuration.

Parameter smsVerificationMessage : A container with information about the SMS verification message.

Parameter userPoolAddOns : Used to enable advanced security risk detection. Set the key AdvancedSecurityMode to the value "AUDIT".

Parameter userPoolTags : The tag keys and values to assign to the user pool. A tag is a label that you can use to categorize and manage user pools in different ways, such as by purpose, owner, environment, or other criteria.

Parameter verificationMessageTemplate : The template for verification messages.

Implementation

Future<void> updateUserPool({
  required String userPoolId,
  AccountRecoverySettingType? accountRecoverySetting,
  AdminCreateUserConfigType? adminCreateUserConfig,
  List<VerifiedAttributeType>? autoVerifiedAttributes,
  DeviceConfigurationType? deviceConfiguration,
  EmailConfigurationType? emailConfiguration,
  String? emailVerificationMessage,
  String? emailVerificationSubject,
  LambdaConfigType? lambdaConfig,
  UserPoolMfaType? mfaConfiguration,
  UserPoolPolicyType? policies,
  String? smsAuthenticationMessage,
  SmsConfigurationType? smsConfiguration,
  String? smsVerificationMessage,
  UserPoolAddOnsType? userPoolAddOns,
  Map<String, String>? userPoolTags,
  VerificationMessageTemplateType? verificationMessageTemplate,
}) async {
  ArgumentError.checkNotNull(userPoolId, 'userPoolId');
  _s.validateStringLength(
    'userPoolId',
    userPoolId,
    1,
    55,
    isRequired: true,
  );
  _s.validateStringLength(
    'emailVerificationMessage',
    emailVerificationMessage,
    6,
    20000,
  );
  _s.validateStringLength(
    'emailVerificationSubject',
    emailVerificationSubject,
    1,
    140,
  );
  _s.validateStringLength(
    'smsAuthenticationMessage',
    smsAuthenticationMessage,
    6,
    140,
  );
  _s.validateStringLength(
    'smsVerificationMessage',
    smsVerificationMessage,
    6,
    140,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AWSCognitoIdentityProviderService.UpdateUserPool'
  };
  await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'UserPoolId': userPoolId,
      if (accountRecoverySetting != null)
        'AccountRecoverySetting': accountRecoverySetting,
      if (adminCreateUserConfig != null)
        'AdminCreateUserConfig': adminCreateUserConfig,
      if (autoVerifiedAttributes != null)
        'AutoVerifiedAttributes':
            autoVerifiedAttributes.map((e) => e.toValue()).toList(),
      if (deviceConfiguration != null)
        'DeviceConfiguration': deviceConfiguration,
      if (emailConfiguration != null)
        'EmailConfiguration': emailConfiguration,
      if (emailVerificationMessage != null)
        'EmailVerificationMessage': emailVerificationMessage,
      if (emailVerificationSubject != null)
        'EmailVerificationSubject': emailVerificationSubject,
      if (lambdaConfig != null) 'LambdaConfig': lambdaConfig,
      if (mfaConfiguration != null)
        'MfaConfiguration': mfaConfiguration.toValue(),
      if (policies != null) 'Policies': policies,
      if (smsAuthenticationMessage != null)
        'SmsAuthenticationMessage': smsAuthenticationMessage,
      if (smsConfiguration != null) 'SmsConfiguration': smsConfiguration,
      if (smsVerificationMessage != null)
        'SmsVerificationMessage': smsVerificationMessage,
      if (userPoolAddOns != null) 'UserPoolAddOns': userPoolAddOns,
      if (userPoolTags != null) 'UserPoolTags': userPoolTags,
      if (verificationMessageTemplate != null)
        'VerificationMessageTemplate': verificationMessageTemplate,
    },
  );
}