createThreatIntelSet method

Future<CreateThreatIntelSetResponse> createThreatIntelSet({
  1. required bool activate,
  2. required String detectorId,
  3. required ThreatIntelSetFormat format,
  4. required String location,
  5. required String name,
  6. String? clientToken,
  7. Map<String, String>? tags,
})

Creates a new ThreatIntelSet. ThreatIntelSets consist of known malicious IP addresses. GuardDuty generates findings based on ThreatIntelSets. Only users of the administrator account can use this operation.

May throw BadRequestException. May throw InternalServerErrorException.

Parameter activate : A Boolean value that indicates whether GuardDuty is to start using the uploaded ThreatIntelSet.

Parameter detectorId : The unique ID of the detector of the GuardDuty account that you want to create a threatIntelSet for.

Parameter format : The format of the file that contains the ThreatIntelSet.

Parameter location : The URI of the file that contains the ThreatIntelSet. For example: https://s3.us-west-2.amazonaws.com/my-bucket/my-object-key.

Parameter name : A user-friendly ThreatIntelSet name displayed in all findings that are generated by activity that involves IP addresses included in this ThreatIntelSet.

Parameter clientToken : The idempotency token for the create request.

Parameter tags : The tags to be added to a new threat list resource.

Implementation

Future<CreateThreatIntelSetResponse> createThreatIntelSet({
  required bool activate,
  required String detectorId,
  required ThreatIntelSetFormat format,
  required String location,
  required String name,
  String? clientToken,
  Map<String, String>? tags,
}) async {
  ArgumentError.checkNotNull(activate, 'activate');
  ArgumentError.checkNotNull(detectorId, 'detectorId');
  _s.validateStringLength(
    'detectorId',
    detectorId,
    1,
    300,
    isRequired: true,
  );
  ArgumentError.checkNotNull(format, 'format');
  ArgumentError.checkNotNull(location, 'location');
  _s.validateStringLength(
    'location',
    location,
    1,
    300,
    isRequired: true,
  );
  ArgumentError.checkNotNull(name, 'name');
  _s.validateStringLength(
    'name',
    name,
    1,
    300,
    isRequired: true,
  );
  _s.validateStringLength(
    'clientToken',
    clientToken,
    0,
    64,
  );
  final $payload = <String, dynamic>{
    'activate': activate,
    'format': format.toValue(),
    'location': location,
    'name': name,
    'clientToken': clientToken ?? _s.generateIdempotencyToken(),
    if (tags != null) 'tags': tags,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/detector/${Uri.encodeComponent(detectorId)}/threatintelset',
    exceptionFnMap: _exceptionFns,
  );
  return CreateThreatIntelSetResponse.fromJson(response);
}