createPublishingDestination method

Future<CreatePublishingDestinationResponse> createPublishingDestination({
  1. required DestinationProperties destinationProperties,
  2. required DestinationType destinationType,
  3. required String detectorId,
  4. String? clientToken,
})

Creates a publishing destination to export findings to. The resource to export findings to must exist before you use this operation.

May throw BadRequestException. May throw InternalServerErrorException.

Parameter destinationProperties : The properties of the publishing destination, including the ARNs for the destination and the KMS key used for encryption.

Parameter destinationType : The type of resource for the publishing destination. Currently only Amazon S3 buckets are supported.

Parameter detectorId : The ID of the GuardDuty detector associated with the publishing destination.

Parameter clientToken : The idempotency token for the request.

Implementation

Future<CreatePublishingDestinationResponse> createPublishingDestination({
  required DestinationProperties destinationProperties,
  required DestinationType destinationType,
  required String detectorId,
  String? clientToken,
}) async {
  ArgumentError.checkNotNull(destinationProperties, 'destinationProperties');
  ArgumentError.checkNotNull(destinationType, 'destinationType');
  ArgumentError.checkNotNull(detectorId, 'detectorId');
  _s.validateStringLength(
    'detectorId',
    detectorId,
    1,
    300,
    isRequired: true,
  );
  _s.validateStringLength(
    'clientToken',
    clientToken,
    0,
    64,
  );
  final $payload = <String, dynamic>{
    'destinationProperties': destinationProperties,
    'destinationType': destinationType.toValue(),
    'clientToken': clientToken ?? _s.generateIdempotencyToken(),
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri:
        '/detector/${Uri.encodeComponent(detectorId)}/publishingDestination',
    exceptionFnMap: _exceptionFns,
  );
  return CreatePublishingDestinationResponse.fromJson(response);
}