/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License 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.
 */
package org.apache.auron.flink.connector.kafka;

import java.util.Arrays;
import java.util.List;

/**
 * Utilities for Kafka.
 */
public class KafkaConstants {

    /**
     * The list of Kafka properties that are allowed to be passed to the consumer.
     * rdkafka will validate properties. To prevent Auron from reporting errors, we will filter kafka properties.
     */
    public static final List<String> KAFKA_PROPERTIES_WHITE_LIST = Arrays.asList(
            "builtin.features",
            "client.id",
            "metadata.broker.list",
            "bootstrap.servers",
            "message.max.bytes",
            "message.copy.max.bytes",
            "receive.message.max.bytes",
            "max.in.flight.requests.per.connection",
            "max.in.flight",
            "metadata.recovery.strategy",
            "metadata.recovery.rebootstrap.trigger.ms",
            "topic.metadata.refresh.interval.ms",
            "metadata.max.age.ms",
            "topic.metadata.refresh.fast.interval.ms",
            "topic.metadata.refresh.fast.cnt",
            "topic.metadata.refresh.sparse",
            "topic.metadata.propagation.max.ms",
            "topic.blacklist",
            "debug",
            "socket.timeout.ms",
            "socket.blocking.max.ms",
            "socket.send.buffer.bytes",
            "socket.receive.buffer.bytes",
            "socket.keepalive.enable",
            "socket.nagle.disable",
            "socket.max.fails",
            "broker.address.ttl",
            "broker.address.family",
            "socket.connection.setup.timeout.ms",
            "connections.max.idle.ms",
            "reconnect.backoff.jitter.ms",
            "reconnect.backoff.ms",
            "reconnect.backoff.max.ms",
            "statistics.interval.ms",
            "enabled_events",
            "error_cb",
            "throttle_cb",
            "stats_cb",
            "log_cb",
            "log_level",
            "log.queue",
            "log.thread.name",
            "enable.random.seed",
            "log.connection.close",
            "background_event_cb",
            "socket_cb",
            "connect_cb",
            "closesocket_cb",
            "open_cb",
            "resolve_cb",
            "opaque",
            "default_topic_conf",
            "internal.termination.signal",
            "api.version.request",
            "api.version.request.timeout.ms",
            "api.version.fallback.ms",
            "broker.version.fallback",
            "allow.auto.create.topics",
            "security.protocol",
            "ssl.cipher.suites",
            "ssl.curves.list",
            "ssl.sigalgs.list",
            "ssl.key.location",
            "ssl.key.password",
            "ssl.key.pem",
            "ssl_key",
            "ssl.certificate.location",
            "ssl.certificate.pem",
            "ssl_certificate",
            "ssl.ca.location",
            "https.ca.location",
            "https.ca.pem",
            "ssl.ca.pem",
            "ssl_ca",
            "ssl.ca.certificate.stores",
            "ssl.crl.location",
            "ssl.keystore.location",
            "ssl.keystore.password",
            "ssl.providers",
            "ssl.engine.location",
            "ssl.engine.id",
            "ssl_engine_callback_data",
            "enable.ssl.certificate.verification",
            "ssl.endpoint.identification.algorithm",
            "ssl.certificate.verify_cb",
            "sasl.mechanisms",
            "sasl.mechanism",
            "sasl.kerberos.service.name",
            "sasl.kerberos.principal",
            "sasl.kerberos.kinit.cmd",
            "sasl.kerberos.keytab",
            "sasl.kerberos.min.time.before.relogin",
            "sasl.username",
            "sasl.password",
            "sasl.oauthbearer.config",
            "enable.sasl.oauthbearer.unsecure.jwt",
            "oauthbearer_token_refresh_cb",
            "sasl.oauthbearer.method",
            "sasl.oauthbearer.client.id",
            "sasl.oauthbearer.client.credentials.client.id",
            "sasl.oauthbearer.client.credentials.client.secret",
            "sasl.oauthbearer.client.secret",
            "sasl.oauthbearer.scope",
            "sasl.oauthbearer.extensions",
            "sasl.oauthbearer.token.endpoint.url",
            "sasl.oauthbearer.grant.type",
            "sasl.oauthbearer.assertion.algorithm",
            "sasl.oauthbearer.assertion.private.key.file",
            "sasl.oauthbearer.assertion.private.key.passphrase",
            "sasl.oauthbearer.assertion.private.key.pem",
            "sasl.oauthbearer.assertion.file",
            "sasl.oauthbearer.assertion.claim.aud",
            "sasl.oauthbearer.assertion.claim.exp.seconds",
            "sasl.oauthbearer.assertion.claim.iss",
            "sasl.oauthbearer.assertion.claim.jti.include",
            "sasl.oauthbearer.assertion.claim.nbf.seconds",
            "sasl.oauthbearer.assertion.claim.sub",
            "sasl.oauthbearer.assertion.jwt.template.file",
            "sasl.oauthbearer.metadata.authentication.type",
            "plugin.library.paths",
            "interceptors",
            "group.id",
            "group.instance.id",
            "partition.assignment.strategy",
            "session.timeout.ms",
            "heartbeat.interval.ms",
            "group.protocol.type",
            "group.protocol",
            "group.remote.assignor",
            "coordinator.query.interval.ms",
            "max.poll.interval.ms",
            "auto.commit.interval.ms",
            "enable.auto.offset.store",
            "queued.min.messages",
            "queued.max.messages.kbytes",
            "fetch.wait.max.ms",
            "fetch.queue.backoff.ms",
            "fetch.message.max.bytes",
            "max.partition.fetch.bytes",
            "fetch.max.bytes",
            "fetch.min.bytes",
            "fetch.error.backoff.ms",
            "offset.store.method",
            "isolation.level",
            "consume_cb",
            "rebalance_cb",
            "offset_commit_cb",
            "enable.partition.eof",
            "check.crcs",
            "client.rack",
            "transactional.id",
            "transaction.timeout.ms",
            "enable.idempotence",
            "enable.gapless.guarantee",
            "queue.buffering.max.messages",
            "queue.buffering.max.kbytes",
            "queue.buffering.max.ms",
            "linger.ms",
            "message.send.max.retries",
            "retries",
            "retry.backoff.ms",
            "retry.backoff.max.ms",
            "queue.buffering.backpressure.threshold",
            "compression.codec",
            "compression.type",
            "batch.num.messages",
            "batch.size",
            "delivery.report.only.error",
            "dr_cb",
            "dr_msg_cb",
            "sticky.partitioning.linger.ms",
            "client.dns.lookup",
            "enable.metrics.push",
            "request.required.acks",
            "acks",
            "request.timeout.ms",
            "message.timeout.ms",
            "delivery.timeout.ms",
            "queuing.strategy",
            "produce.offset.report",
            "partitioner",
            "partitioner_cb",
            "msg_order_cmp",
            "opaque",
            "compression.codec",
            "compression.type",
            "compression.level",
            "auto.commit.enable",
            "enable.auto.commit",
            "auto.commit.interval.ms",
            "auto.offset.reset",
            "offset.store.path",
            "offset.store.sync.interval.ms",
            "offset.store.method",
            "consume.callback.max.messages");

    public static final String KAFKA_FORMAT_PROTOBUF = "Protobuf";
    public static final String KAFKA_FORMAT_JSON = "Json";

    public static final String KAFKA_PB_FORMAT_PB_DESC_FILE_FIELD = "pb_desc_file";
    public static final String KAFKA_PB_FORMAT_ROOT_MESSAGE_NAME_FIELD = "root_message_name";
    public static final String KAFKA_PB_FORMAT_SKIP_FIELDS_FIELD = "skip_fields";
    public static final String KAFKA_PB_FORMAT_NESTED_COL_MAPPING_FIELD = "nested_col_mapping";

    public static final String KAFKA_AURON_META_PARTITION_ID = "serialized_kafka_records_partition";
    public static final String KAFKA_AURON_META_OFFSET = "serialized_kafka_records_offset";
    public static final String KAFKA_AURON_META_TIMESTAMP = "serialized_kafka_records_timestamp";

    public static final String FLINK_SQL_PROC_TIME_KEY_WORD = "proctime";
}
