putInsightSelectors method

Future<PutInsightSelectorsResponse> putInsightSelectors({
  1. required List<InsightSelector> insightSelectors,
  2. required String trailName,
})

Lets you enable Insights event logging by specifying the Insights selectors that you want to enable on an existing trail. You also use PutInsightSelectors to turn off Insights event logging, by passing an empty list of insight types. In this release, only ApiCallRateInsight is supported as an Insights selector.

May throw TrailNotFoundException. May throw InvalidTrailNameException. May throw InvalidHomeRegionException. May throw InvalidInsightSelectorsException. May throw InsufficientS3BucketPolicyException. May throw InsufficientEncryptionPolicyException. May throw UnsupportedOperationException. May throw OperationNotPermittedException. May throw NotOrganizationMasterAccountException.

Parameter insightSelectors : A JSON string that contains the insight types you want to log on a trail. In this release, only ApiCallRateInsight is supported as an insight type.

Parameter trailName : The name of the CloudTrail trail for which you want to change or add Insights selectors.

Implementation

Future<PutInsightSelectorsResponse> putInsightSelectors({
  required List<InsightSelector> insightSelectors,
  required String trailName,
}) async {
  ArgumentError.checkNotNull(insightSelectors, 'insightSelectors');
  ArgumentError.checkNotNull(trailName, 'trailName');
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target':
        'com.amazonaws.cloudtrail.v20131101.CloudTrail_20131101.PutInsightSelectors'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'InsightSelectors': insightSelectors,
      'TrailName': trailName,
    },
  );

  return PutInsightSelectorsResponse.fromJson(jsonResponse.body);
}