EventJsonFormatOptions.java

package org.wikimedia.eventutilities.flink.formats.json;

import java.util.List;
import java.util.Map;

import org.apache.flink.configuration.ConfigOption;
import org.apache.flink.configuration.ConfigOptions;
import org.apache.flink.formats.json.JsonFormatOptions;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;

public final class EventJsonFormatOptions {

    public static final ConfigOption<List<String>> EVENT_SCHEMAS_BASE_URIS =
        ConfigOptions.key("event-schema-base-uris")
            .stringType()
            .asList()
            .noDefaultValue()
            .withDescription(
                "URIs from which to fetch event JSONSchemas.");

    public static final ConfigOption<String> EVENT_STREAM_CONFIG_URI =
        ConfigOptions.key("event-stream-config-uri")
            .stringType()
            .noDefaultValue()
            .withDescription(
                "URI from which to fetch event stream config."
            );

    public static final ConfigOption<String> STREAM_NAME =
        ConfigOptions.key("event-stream-name")
            .stringType()
            .noDefaultValue()
            .withDescription(
                "The event stream to fetch the schema for."
            );

    public static final ConfigOption<String> SCHEMA_VERSION =
        ConfigOptions.key("event-schema-version")
            .stringType()
            .noDefaultValue()
            .withDescription(
                "Filled on a per-table basis either automatically through the catalog or manually using CREATE."
            );

    public static final ConfigOption<Map<String, String>> HTTP_ROUTES =
        ConfigOptions.key("http-routes")
            .mapType()
            .noDefaultValue()
            .withDescription(
                "Sets http routing for EventStreamFactory"
            );

    public static final ImmutableList<ConfigOption<?>> FORWARD_OPTIONS = ImmutableList.of(
        EVENT_SCHEMAS_BASE_URIS,
        EVENT_STREAM_CONFIG_URI,
        STREAM_NAME,
        SCHEMA_VERSION,
        HTTP_ROUTES
    );

    /**
     * Default options that are applied to every table with event-json format that is created.
     */
    public static final ImmutableMap<String, String> DEFAULT_FORMAT_OPTIONS = ImmutableMap.<String, String>builder()
        .put(EventJsonFormatFactory.IDENTIFIER + "." + JsonFormatOptions.TIMESTAMP_FORMAT.key(), "ISO-8601")
        .build();

    private EventJsonFormatOptions() {
    }
}