createTopic method

Future<CreateTopicResponse> createTopic({
  1. required String clusterArn,
  2. required int partitionCount,
  3. required int replicationFactor,
  4. required String topicName,
  5. String? configs,
})

Creates a topic in the specified MSK cluster.

May throw BadRequestException. May throw ClusterConnectivityException. May throw ConflictException. May throw ControllerMovedException. May throw ForbiddenException. May throw GroupSubscribedToTopicException. May throw InternalServerErrorException. May throw KafkaRequestException. May throw KafkaTimeoutException. May throw NotControllerException. May throw ReassignmentInProgressException. May throw ServiceUnavailableException. May throw TooManyRequestsException. May throw TopicExistsException. May throw UnauthorizedException. May throw UnknownTopicOrPartitionException.

Parameter clusterArn : The Amazon Resource Name (ARN) that uniquely identifies the cluster.

Parameter partitionCount : The number of partitions for the topic.

Parameter replicationFactor : The replication factor for the topic.

Parameter topicName : The name of the topic to create.

Parameter configs : Topic configurations encoded as a Base64 string.

Implementation

Future<CreateTopicResponse> createTopic({
  required String clusterArn,
  required int partitionCount,
  required int replicationFactor,
  required String topicName,
  String? configs,
}) async {
  _s.validateNumRange(
    'partitionCount',
    partitionCount,
    1,
    1152921504606846976,
    isRequired: true,
  );
  _s.validateNumRange(
    'replicationFactor',
    replicationFactor,
    1,
    1152921504606846976,
    isRequired: true,
  );
  final $payload = <String, dynamic>{
    'partitionCount': partitionCount,
    'replicationFactor': replicationFactor,
    'topicName': topicName,
    if (configs != null) 'configs': configs,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/v1/clusters/${Uri.encodeComponent(clusterArn)}/topics',
    exceptionFnMap: _exceptionFns,
  );
  return CreateTopicResponse.fromJson(response);
}