createDetector method

Future<CreateDetectorResponse> createDetector({
  1. required bool enable,
  2. String? clientToken,
  3. DataSourceConfigurations? dataSources,
  4. FindingPublishingFrequency? findingPublishingFrequency,
  5. Map<String, String>? tags,
})

Creates a single Amazon 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.

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.

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,
  FindingPublishingFrequency? findingPublishingFrequency,
  Map<String, String>? tags,
}) async {
  ArgumentError.checkNotNull(enable, 'enable');
  _s.validateStringLength(
    'clientToken',
    clientToken,
    0,
    64,
  );
  final $payload = <String, dynamic>{
    'enable': enable,
    'clientToken': clientToken ?? _s.generateIdempotencyToken(),
    if (dataSources != null) 'dataSources': dataSources,
    if (findingPublishingFrequency != null)
      'findingPublishingFrequency': findingPublishingFrequency.toValue(),
    if (tags != null) 'tags': tags,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/detector',
    exceptionFnMap: _exceptionFns,
  );
  return CreateDetectorResponse.fromJson(response);
}