deleteOrganizationalUnit method

Future<void> deleteOrganizationalUnit({
  1. required String organizationalUnitId,
})

Deletes an organizational unit (OU) from a root or another OU. You must first remove all accounts and child OUs from the OU that you want to delete.

You can only call this operation from the management account.

May throw AccessDeniedException. May throw AWSOrganizationsNotInUseException. May throw ConcurrentModificationException. May throw InvalidInputException. May throw OrganizationalUnitNotEmptyException. May throw OrganizationalUnitNotFoundException. May throw ServiceException. May throw TooManyRequestsException.

Parameter organizationalUnitId : ID for the organizational unit that you want to delete. You can get the ID from the ListOrganizationalUnitsForParent operation.

The regex pattern for an organizational unit ID string requires "ou-" followed by from 4 to 32 lowercase letters or digits (the ID of the root that contains the OU). This string is followed by a second "-" dash and from 8 to 32 additional lowercase letters or digits.

Implementation

Future<void> deleteOrganizationalUnit({
  required String organizationalUnitId,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AWSOrganizationsV20161128.DeleteOrganizationalUnit'
  };
  await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'OrganizationalUnitId': organizationalUnitId,
    },
  );
}