enablePolicyType method

Future<EnablePolicyTypeResponse> enablePolicyType({
  1. required PolicyType policyType,
  2. required String rootId,
})

Enables a policy type in a root. After you enable a policy type in a root, you can attach policies of that type to the root, any organizational unit (OU), or account in that root. You can undo this by using the DisablePolicyType operation.

This is an asynchronous request that AWS performs in the background. AWS recommends that you first use ListRoots to see the status of policy types for a specified root, and then use this operation.

This operation can be called only from the organization's management account.

You can enable a policy type in a root only if that policy type is available in the organization. To view the status of available policy types in the organization, use DescribeOrganization.

May throw AccessDeniedException. May throw AWSOrganizationsNotInUseException. May throw ConcurrentModificationException. May throw ConstraintViolationException. May throw InvalidInputException. May throw PolicyTypeAlreadyEnabledException. May throw RootNotFoundException. May throw ServiceException. May throw TooManyRequestsException. May throw PolicyTypeNotAvailableForOrganizationException. May throw UnsupportedAPIEndpointException. May throw PolicyChangesInProgressException.

Parameter policyType : The policy type that you want to enable. You can specify one of the following values:

Parameter rootId : The unique identifier (ID) of the root in which you want to enable a policy type. You can get the ID from the ListRoots operation.

The regex pattern for a root ID string requires "r-" followed by from 4 to 32 lowercase letters or digits.

Implementation

Future<EnablePolicyTypeResponse> enablePolicyType({
  required PolicyType policyType,
  required String rootId,
}) async {
  ArgumentError.checkNotNull(policyType, 'policyType');
  ArgumentError.checkNotNull(rootId, 'rootId');
  _s.validateStringLength(
    'rootId',
    rootId,
    0,
    34,
    isRequired: true,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AWSOrganizationsV20161128.EnablePolicyType'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'PolicyType': policyType.toValue(),
      'RootId': rootId,
    },
  );

  return EnablePolicyTypeResponse.fromJson(jsonResponse.body);
}