describeEffectivePolicy method

Future<DescribeEffectivePolicyResponse> describeEffectivePolicy({
  1. required EffectivePolicyType policyType,
  2. String? targetId,
})

Returns the contents of the effective policy for specified policy type and account. The effective policy is the aggregation of any policies of the specified type that the account inherits, plus any policy of that type that is directly attached to the account.

This operation applies only to policy types other than service control policies (SCPs).

For more information about policy inheritance, see How Policy Inheritance Works in the AWS Organizations User Guide.

This operation can be called only from the organization's management account or by a member account that is a delegated administrator for an AWS service.

May throw AccessDeniedException. May throw AWSOrganizationsNotInUseException. May throw ConstraintViolationException. May throw ServiceException. May throw TooManyRequestsException. May throw TargetNotFoundException. May throw EffectivePolicyNotFoundException. May throw InvalidInputException. May throw UnsupportedAPIEndpointException.

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

Parameter targetId : When you're signed in as the management account, specify the ID of the account that you want details about. Specifying an organization root or organizational unit (OU) as the target is not supported.

Implementation

Future<DescribeEffectivePolicyResponse> describeEffectivePolicy({
  required EffectivePolicyType policyType,
  String? targetId,
}) async {
  ArgumentError.checkNotNull(policyType, 'policyType');
  _s.validateStringLength(
    'targetId',
    targetId,
    0,
    100,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AWSOrganizationsV20161128.DescribeEffectivePolicy'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'PolicyType': policyType.toValue(),
      if (targetId != null) 'TargetId': targetId,
    },
  );

  return DescribeEffectivePolicyResponse.fromJson(jsonResponse.body);
}