moveAccount method

Future<void> moveAccount({
  1. required String accountId,
  2. required String destinationParentId,
  3. required String sourceParentId,
})

Moves an account from its current source parent root or organizational unit (OU) to the specified destination parent root or OU.

You can only call this operation from the management account.

May throw AccessDeniedException. May throw AccountNotFoundException. May throw AWSOrganizationsNotInUseException. May throw ConcurrentModificationException. May throw DestinationParentNotFoundException. May throw DuplicateAccountException. May throw InvalidInputException. May throw ServiceException. May throw SourceParentNotFoundException. May throw TooManyRequestsException.

Parameter accountId : ID for the account that you want to move.

The regex pattern for an account ID string requires exactly 12 digits.

Parameter destinationParentId : ID for the root or organizational unit that you want to move the account to.

The regex pattern for a parent ID string requires one of the following:

  • Root - A string that begins with "r-" followed by from 4 to 32 lowercase letters or digits.
  • Organizational unit (OU) - A string that begins with "ou-" followed by from 4 to 32 lowercase letters or digits (the ID of the root that the OU is in). This string is followed by a second "-" dash and from 8 to 32 additional lowercase letters or digits.

Parameter sourceParentId : ID for the root or organizational unit that you want to move the account from.

The regex pattern for a parent ID string requires one of the following:

  • Root - A string that begins with "r-" followed by from 4 to 32 lowercase letters or digits.
  • Organizational unit (OU) - A string that begins with "ou-" followed by from 4 to 32 lowercase letters or digits (the ID of the root that the OU is in). This string is followed by a second "-" dash and from 8 to 32 additional lowercase letters or digits.

Implementation

Future<void> moveAccount({
  required String accountId,
  required String destinationParentId,
  required String sourceParentId,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AWSOrganizationsV20161128.MoveAccount'
  };
  await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'AccountId': accountId,
      'DestinationParentId': destinationParentId,
      'SourceParentId': sourceParentId,
    },
  );
}