You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: api.rb
    path of file: ./repos/aws-fluent-plugin-kinesis/lib/fluent/plugin/kinesis_helper
    
    the code of the file until where you have to start completion: #
# Copyright 2014-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License is located at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "license" file accompanying this file. This file is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.

require 'fluent_plugin_kinesis/version'
require 'fluent/configurable'
require 'benchmark'

module Fluent
  module Plugin
    module KinesisHelper
      module API
        MaxRecordSize = 1024 * 1024 # 1 MB

        module APIParams
          include Fluent::Configurable
          config_param :max_record_size, :integer, default: MaxRecordSize
        end

        def self.included(mod)
          mod.include APIParams
        end

        def configure(conf)
          super
          if @max_record_size > MaxRecordSize
            raise ConfigError, "max_record_size can't be grater than #{MaxRecordSize/1024} KB."
          end
        end

        module BatchRequest
          module BatchRequestParams
            include Fluent::Configurable
            config_param :retries_on_batch_request,                        :integer, default: 8
            config_param :reset_backoff_if_success,                        :bool,    default: true
            config_param :batch_request_max_count,                         :integer, default: nil
            config_param :batch_request_max_size,                          :integer, default: nil
            config_param :drop_failed_records_after_batch_request_retries, :bool,    default: true
            confi
    
          def give_up_retries(failed_records)
            failed_records.each {|record|
              log.error(truncate 'Could not put record, Error: %s/%s, Record: %s' % [
                record[:error_code],
                record[:error_message],
                record[:original]
              ])
            }

            if @drop_failed_records_after_batch_request_retries
              # Increment num_errors to monitor batch request failure from "monitor_agent" or "fluent-plugin-prometheus"
              increment_num_errors
            else
              # Raise error and return chunk to Fluentd for retrying
              case request_type
              # @see https://docs.aws.amazon.com/kinesis/latest/APIReference/API_PutRecords.html
              # @see https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/Kinesis/Client.html#put_records-instance_method
              # @see https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/Kinesis/Errors.html
              when :streams, :streams_aggregated
                provisioned_throughput_exceeded_records = failed_records.select { |record| record[:error_code] == 'ProvisionedThroughputExceededException' }
                target_failed_record = provisioned_throughput_exceeded_records.first || failed_records.first
                target_error = provisioned_throughput_exceeded_records.empty? ?
                  Aws::Kinesis::Errors::ServiceError :
                  Aws::Kinesis::Errors::ProvisionedThroughputExceededException
              # @see https://docs.aws.amazon.com/kinesis/latest/APIReference/API_PutRecords.html
              # @see https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/Firehose/Client.html#put_record_batch-instance_method
              # @see https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/Firehose/Errors.html
              when :firehose
                service_unavailable_exception_records = failed_records.select { |record| record[:error_code] == 'ServiceUnavailableException' }
                target_failed_record = service_unavailable_exception_records.first || failed_records.first
                target_error = service_unavailable_exception_records.empty? ?
                  Aws::Firehose::Errors::ServiceError :
                  Aws::Firehose::Errors::ServiceUnavailableException
              end