createDetector method
Creates a single GuardDuty detector. A detector is a resource that represents the GuardDuty service. To start using GuardDuty, you must create a detector in each Region where you enable the service. You can have only one detector per account per Region. All data sources are enabled in a new detector by default.
-
When you don't specify any
features, with an exception toRUNTIME_MONITORING, all the optional features are enabled by default. -
When you specify some of the
features, any feature that is not specified in the API call gets enabled by default, with an exception toRUNTIME_MONITORING.
EKS_RUNTIME_MONITORING) and Runtime Monitoring
(RUNTIME_MONITORING) will cause an error. You can add only
one of these two features because Runtime Monitoring already includes the
threat detection for Amazon EKS resources. For more information, see Runtime
Monitoring.
There might be regional differences because some data sources might not be available in all the Amazon Web Services Regions where GuardDuty is presently supported. For more information, see Regions and endpoints.
May throw BadRequestException.
May throw InternalServerErrorException.
Parameter enable :
A Boolean value that specifies whether the detector is to be enabled.
Parameter clientToken :
The idempotency token for the create request.
Parameter dataSources :
Describes which data sources will be enabled for the detector.
There might be regional differences because some data sources might not be available in all the Amazon Web Services Regions where GuardDuty is presently supported. For more information, see Regions and endpoints.
Parameter features :
A list of features that will be configured for the detector.
Parameter findingPublishingFrequency :
A value that specifies how frequently updated findings are exported.
Parameter tags :
The tags to be added to a new detector resource.
Implementation
Future<CreateDetectorResponse> createDetector({
required bool enable,
String? clientToken,
DataSourceConfigurations? dataSources,
List<DetectorFeatureConfiguration>? features,
FindingPublishingFrequency? findingPublishingFrequency,
Map<String, String>? tags,
}) async {
final $payload = <String, dynamic>{
'enable': enable,
'clientToken': clientToken ?? _s.generateIdempotencyToken(),
if (dataSources != null) 'dataSources': dataSources,
if (features != null) 'features': features,
if (findingPublishingFrequency != null)
'findingPublishingFrequency': findingPublishingFrequency.value,
if (tags != null) 'tags': tags,
};
final response = await _protocol.send(
payload: $payload,
method: 'POST',
requestUri: '/detector',
exceptionFnMap: _exceptionFns,
);
return CreateDetectorResponse.fromJson(response);
}