feat(bridge): add is_template flag to bridge config fields
This commit is contained in:
parent
df458b98d7
commit
51c8173174
|
@ -61,6 +61,7 @@
|
||||||
}.
|
}.
|
||||||
-type url() :: binary().
|
-type url() :: binary().
|
||||||
-type json_binary() :: binary().
|
-type json_binary() :: binary().
|
||||||
|
-type template() :: binary().
|
||||||
|
|
||||||
-typerefl_from_string({duration/0, emqx_schema, to_duration}).
|
-typerefl_from_string({duration/0, emqx_schema, to_duration}).
|
||||||
-typerefl_from_string({duration_s/0, emqx_schema, to_duration_s}).
|
-typerefl_from_string({duration_s/0, emqx_schema, to_duration_s}).
|
||||||
|
@ -78,6 +79,7 @@
|
||||||
-typerefl_from_string({comma_separated_atoms/0, emqx_schema, to_comma_separated_atoms}).
|
-typerefl_from_string({comma_separated_atoms/0, emqx_schema, to_comma_separated_atoms}).
|
||||||
-typerefl_from_string({url/0, emqx_schema, to_url}).
|
-typerefl_from_string({url/0, emqx_schema, to_url}).
|
||||||
-typerefl_from_string({json_binary/0, emqx_schema, to_json_binary}).
|
-typerefl_from_string({json_binary/0, emqx_schema, to_json_binary}).
|
||||||
|
-typerefl_from_string({template/0, emqx_schema, to_template}).
|
||||||
|
|
||||||
-type parsed_server() :: #{
|
-type parsed_server() :: #{
|
||||||
hostname := string(),
|
hostname := string(),
|
||||||
|
@ -120,7 +122,8 @@
|
||||||
to_erl_cipher_suite/1,
|
to_erl_cipher_suite/1,
|
||||||
to_comma_separated_atoms/1,
|
to_comma_separated_atoms/1,
|
||||||
to_url/1,
|
to_url/1,
|
||||||
to_json_binary/1
|
to_json_binary/1,
|
||||||
|
to_template/1
|
||||||
]).
|
]).
|
||||||
|
|
||||||
-export([
|
-export([
|
||||||
|
@ -160,7 +163,8 @@
|
||||||
comma_separated_atoms/0,
|
comma_separated_atoms/0,
|
||||||
url/0,
|
url/0,
|
||||||
json_binary/0,
|
json_binary/0,
|
||||||
port_number/0
|
port_number/0,
|
||||||
|
template/0
|
||||||
]).
|
]).
|
||||||
|
|
||||||
-export([namespace/0, roots/0, roots/1, fields/1, desc/1, tags/0]).
|
-export([namespace/0, roots/0, roots/1, fields/1, desc/1, tags/0]).
|
||||||
|
@ -2594,6 +2598,9 @@ to_json_binary(Str) ->
|
||||||
Error
|
Error
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
to_template(Str) ->
|
||||||
|
{ok, iolist_to_binary(Str)}.
|
||||||
|
|
||||||
%% @doc support the following format:
|
%% @doc support the following format:
|
||||||
%% - 127.0.0.1:1883
|
%% - 127.0.0.1:1883
|
||||||
%% - ::1:1883
|
%% - ::1:1883
|
||||||
|
|
|
@ -181,7 +181,7 @@ fields("post", Type) ->
|
||||||
cql_field() ->
|
cql_field() ->
|
||||||
{cql,
|
{cql,
|
||||||
mk(
|
mk(
|
||||||
binary(),
|
emqx_schema:template(),
|
||||||
#{desc => ?DESC("cql_template"), default => ?DEFAULT_CQL, format => <<"sql">>}
|
#{desc => ?DESC("cql_template"), default => ?DEFAULT_CQL, format => <<"sql">>}
|
||||||
)}.
|
)}.
|
||||||
|
|
||||||
|
|
|
@ -184,8 +184,12 @@ fields("post", Type) ->
|
||||||
sql_field() ->
|
sql_field() ->
|
||||||
{sql,
|
{sql,
|
||||||
mk(
|
mk(
|
||||||
binary(),
|
emqx_schema:template(),
|
||||||
#{desc => ?DESC("sql_template"), default => ?DEFAULT_SQL, format => <<"sql">>}
|
#{
|
||||||
|
desc => ?DESC("sql_template"),
|
||||||
|
default => ?DEFAULT_SQL,
|
||||||
|
format => <<"sql">>
|
||||||
|
}
|
||||||
)}.
|
)}.
|
||||||
|
|
||||||
batch_value_separator_field() ->
|
batch_value_separator_field() ->
|
||||||
|
|
|
@ -160,13 +160,7 @@ fields(dynamo_action) ->
|
||||||
);
|
);
|
||||||
fields(action_parameters) ->
|
fields(action_parameters) ->
|
||||||
Parameters =
|
Parameters =
|
||||||
[
|
[{template, template_field_schema()}] ++ emqx_bridge_dynamo_connector:fields(config),
|
||||||
{template,
|
|
||||||
mk(
|
|
||||||
binary(),
|
|
||||||
#{desc => ?DESC("template"), default => ?DEFAULT_TEMPLATE}
|
|
||||||
)}
|
|
||||||
] ++ emqx_bridge_dynamo_connector:fields(config),
|
|
||||||
lists:foldl(
|
lists:foldl(
|
||||||
fun(Key, Acc) ->
|
fun(Key, Acc) ->
|
||||||
proplists:delete(Key, Acc)
|
proplists:delete(Key, Acc)
|
||||||
|
@ -199,11 +193,7 @@ fields(connector_resource_opts) ->
|
||||||
fields("config") ->
|
fields("config") ->
|
||||||
[
|
[
|
||||||
{enable, mk(boolean(), #{desc => ?DESC("config_enable"), default => true})},
|
{enable, mk(boolean(), #{desc => ?DESC("config_enable"), default => true})},
|
||||||
{template,
|
{template, template_field_schema()},
|
||||||
mk(
|
|
||||||
binary(),
|
|
||||||
#{desc => ?DESC("template"), default => ?DEFAULT_TEMPLATE}
|
|
||||||
)},
|
|
||||||
{local_topic,
|
{local_topic,
|
||||||
mk(
|
mk(
|
||||||
binary(),
|
binary(),
|
||||||
|
@ -230,6 +220,15 @@ fields("put") ->
|
||||||
fields("get") ->
|
fields("get") ->
|
||||||
emqx_bridge_schema:status_fields() ++ fields("post").
|
emqx_bridge_schema:status_fields() ++ fields("post").
|
||||||
|
|
||||||
|
template_field_schema() ->
|
||||||
|
mk(
|
||||||
|
emqx_schema:template(),
|
||||||
|
#{
|
||||||
|
desc => ?DESC("template"),
|
||||||
|
default => ?DEFAULT_TEMPLATE
|
||||||
|
}
|
||||||
|
).
|
||||||
|
|
||||||
desc("config") ->
|
desc("config") ->
|
||||||
?DESC("desc_config");
|
?DESC("desc_config");
|
||||||
desc(Method) when Method =:= "get"; Method =:= "put"; Method =:= "post" ->
|
desc(Method) when Method =:= "get"; Method =:= "put"; Method =:= "post" ->
|
||||||
|
|
|
@ -135,7 +135,7 @@ overwrite() ->
|
||||||
index() ->
|
index() ->
|
||||||
{index,
|
{index,
|
||||||
?HOCON(
|
?HOCON(
|
||||||
binary(),
|
emqx_schema:template(),
|
||||||
#{
|
#{
|
||||||
required => true,
|
required => true,
|
||||||
example => <<"${payload.index}">>,
|
example => <<"${payload.index}">>,
|
||||||
|
@ -146,7 +146,7 @@ index() ->
|
||||||
id(Required) ->
|
id(Required) ->
|
||||||
{id,
|
{id,
|
||||||
?HOCON(
|
?HOCON(
|
||||||
binary(),
|
emqx_schema:template(),
|
||||||
#{
|
#{
|
||||||
required => Required,
|
required => Required,
|
||||||
example => <<"${payload.id}">>,
|
example => <<"${payload.id}">>,
|
||||||
|
@ -157,7 +157,7 @@ id(Required) ->
|
||||||
doc() ->
|
doc() ->
|
||||||
{doc,
|
{doc,
|
||||||
?HOCON(
|
?HOCON(
|
||||||
binary(),
|
emqx_schema:template(),
|
||||||
#{
|
#{
|
||||||
required => false,
|
required => false,
|
||||||
example => <<"${payload.doc}">>,
|
example => <<"${payload.doc}">>,
|
||||||
|
@ -187,7 +187,7 @@ doc_as_upsert() ->
|
||||||
routing() ->
|
routing() ->
|
||||||
{routing,
|
{routing,
|
||||||
?HOCON(
|
?HOCON(
|
||||||
binary(),
|
emqx_schema:template(),
|
||||||
#{
|
#{
|
||||||
required => false,
|
required => false,
|
||||||
example => <<"${payload.routing}">>,
|
example => <<"${payload.routing}">>,
|
||||||
|
|
|
@ -122,7 +122,7 @@ fields(producer) ->
|
||||||
)},
|
)},
|
||||||
{ordering_key_template,
|
{ordering_key_template,
|
||||||
sc(
|
sc(
|
||||||
binary(),
|
emqx_schema:template(),
|
||||||
#{
|
#{
|
||||||
default => <<>>,
|
default => <<>>,
|
||||||
desc => ?DESC("ordering_key_template")
|
desc => ?DESC("ordering_key_template")
|
||||||
|
@ -130,7 +130,7 @@ fields(producer) ->
|
||||||
)},
|
)},
|
||||||
{payload_template,
|
{payload_template,
|
||||||
sc(
|
sc(
|
||||||
binary(),
|
emqx_schema:template(),
|
||||||
#{
|
#{
|
||||||
default => <<>>,
|
default => <<>>,
|
||||||
desc => ?DESC("payload_template")
|
desc => ?DESC("payload_template")
|
||||||
|
@ -201,8 +201,11 @@ fields(consumer_topic_mapping) ->
|
||||||
{qos, mk(emqx_schema:qos(), #{default => 0, desc => ?DESC(consumer_mqtt_qos)})},
|
{qos, mk(emqx_schema:qos(), #{default => 0, desc => ?DESC(consumer_mqtt_qos)})},
|
||||||
{payload_template,
|
{payload_template,
|
||||||
mk(
|
mk(
|
||||||
string(),
|
emqx_schema:template(),
|
||||||
#{default => <<"${.}">>, desc => ?DESC(consumer_mqtt_payload)}
|
#{
|
||||||
|
default => <<"${.}">>,
|
||||||
|
desc => ?DESC(consumer_mqtt_payload)
|
||||||
|
}
|
||||||
)}
|
)}
|
||||||
];
|
];
|
||||||
fields("consumer_resource_opts") ->
|
fields("consumer_resource_opts") ->
|
||||||
|
@ -221,14 +224,18 @@ fields("consumer_resource_opts") ->
|
||||||
fields(key_value_pair) ->
|
fields(key_value_pair) ->
|
||||||
[
|
[
|
||||||
{key,
|
{key,
|
||||||
mk(binary(), #{
|
mk(emqx_schema:template(), #{
|
||||||
required => true,
|
required => true,
|
||||||
validator => [
|
validator => [
|
||||||
emqx_resource_validator:not_empty("Key templates must not be empty")
|
emqx_resource_validator:not_empty("Key templates must not be empty")
|
||||||
],
|
],
|
||||||
desc => ?DESC(kv_pair_key)
|
desc => ?DESC(kv_pair_key)
|
||||||
})},
|
})},
|
||||||
{value, mk(binary(), #{required => true, desc => ?DESC(kv_pair_value)})}
|
{value,
|
||||||
|
mk(emqx_schema:template(), #{
|
||||||
|
required => true,
|
||||||
|
desc => ?DESC(kv_pair_value)
|
||||||
|
})}
|
||||||
];
|
];
|
||||||
fields("get_producer") ->
|
fields("get_producer") ->
|
||||||
emqx_bridge_schema:status_fields() ++ fields("post_producer");
|
emqx_bridge_schema:status_fields() ++ fields("post_producer");
|
||||||
|
|
|
@ -167,13 +167,13 @@ fields(action_parameters) ->
|
||||||
})},
|
})},
|
||||||
|
|
||||||
{partition_key,
|
{partition_key,
|
||||||
mk(binary(), #{
|
mk(emqx_schema:template(), #{
|
||||||
required => false, desc => ?DESC(emqx_bridge_hstreamdb_connector, "partition_key")
|
required => false,
|
||||||
|
desc => ?DESC(emqx_bridge_hstreamdb_connector, "partition_key")
|
||||||
})},
|
})},
|
||||||
|
|
||||||
{grpc_flush_timeout, fun grpc_flush_timeout/1},
|
{grpc_flush_timeout, fun grpc_flush_timeout/1},
|
||||||
{record_template,
|
{record_template, record_template_schema()},
|
||||||
mk(binary(), #{default => <<"${payload}">>, desc => ?DESC("record_template")})},
|
|
||||||
{aggregation_pool_size,
|
{aggregation_pool_size,
|
||||||
mk(pos_integer(), #{
|
mk(pos_integer(), #{
|
||||||
default => ?DEFAULT_AGG_POOL_SIZE, desc => ?DESC("aggregation_pool_size")
|
default => ?DEFAULT_AGG_POOL_SIZE, desc => ?DESC("aggregation_pool_size")
|
||||||
|
@ -222,6 +222,12 @@ fields("put") ->
|
||||||
hstream_bridge_common_fields() ++
|
hstream_bridge_common_fields() ++
|
||||||
connector_fields().
|
connector_fields().
|
||||||
|
|
||||||
|
record_template_schema() ->
|
||||||
|
mk(emqx_schema:template(), #{
|
||||||
|
default => <<"${payload}">>,
|
||||||
|
desc => ?DESC("record_template")
|
||||||
|
}).
|
||||||
|
|
||||||
grpc_timeout(type) -> emqx_schema:timeout_duration_ms();
|
grpc_timeout(type) -> emqx_schema:timeout_duration_ms();
|
||||||
grpc_timeout(desc) -> ?DESC(emqx_bridge_hstreamdb_connector, "grpc_timeout");
|
grpc_timeout(desc) -> ?DESC(emqx_bridge_hstreamdb_connector, "grpc_timeout");
|
||||||
grpc_timeout(default) -> ?DEFAULT_GRPC_TIMEOUT_RAW;
|
grpc_timeout(default) -> ?DEFAULT_GRPC_TIMEOUT_RAW;
|
||||||
|
@ -239,8 +245,7 @@ hstream_bridge_common_fields() ->
|
||||||
[
|
[
|
||||||
{direction, mk(egress, #{desc => ?DESC("config_direction"), default => egress})},
|
{direction, mk(egress, #{desc => ?DESC("config_direction"), default => egress})},
|
||||||
{local_topic, mk(binary(), #{desc => ?DESC("local_topic")})},
|
{local_topic, mk(binary(), #{desc => ?DESC("local_topic")})},
|
||||||
{record_template,
|
{record_template, record_template_schema()}
|
||||||
mk(binary(), #{default => <<"${payload}">>, desc => ?DESC("record_template")})}
|
|
||||||
] ++
|
] ++
|
||||||
emqx_resource_schema:fields("resource_opts").
|
emqx_resource_schema:fields("resource_opts").
|
||||||
|
|
||||||
|
|
|
@ -287,7 +287,7 @@ method_field() ->
|
||||||
body_field() ->
|
body_field() ->
|
||||||
{body,
|
{body,
|
||||||
mk(
|
mk(
|
||||||
binary(),
|
emqx_schema:template(),
|
||||||
#{
|
#{
|
||||||
default => undefined,
|
default => undefined,
|
||||||
desc => ?DESC("config_body")
|
desc => ?DESC("config_body")
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
%% api
|
%% api
|
||||||
|
|
||||||
write_syntax_type() ->
|
write_syntax_type() ->
|
||||||
typerefl:alias("string", write_syntax()).
|
typerefl:alias("template", write_syntax()).
|
||||||
|
|
||||||
%% Examples
|
%% Examples
|
||||||
conn_bridge_examples(Method) ->
|
conn_bridge_examples(Method) ->
|
||||||
|
|
|
@ -84,7 +84,7 @@ fields(action_parameters) ->
|
||||||
)},
|
)},
|
||||||
{device_id,
|
{device_id,
|
||||||
mk(
|
mk(
|
||||||
binary(),
|
emqx_schema:template(),
|
||||||
#{
|
#{
|
||||||
desc => ?DESC("config_device_id")
|
desc => ?DESC("config_device_id")
|
||||||
}
|
}
|
||||||
|
@ -114,7 +114,7 @@ fields(action_parameters_data) ->
|
||||||
)},
|
)},
|
||||||
{measurement,
|
{measurement,
|
||||||
mk(
|
mk(
|
||||||
binary(),
|
emqx_schema:template(),
|
||||||
#{
|
#{
|
||||||
required => true,
|
required => true,
|
||||||
desc => ?DESC("config_parameters_measurement")
|
desc => ?DESC("config_parameters_measurement")
|
||||||
|
@ -122,7 +122,9 @@ fields(action_parameters_data) ->
|
||||||
)},
|
)},
|
||||||
{data_type,
|
{data_type,
|
||||||
mk(
|
mk(
|
||||||
hoconsc:union([enum([text, boolean, int32, int64, float, double]), binary()]),
|
hoconsc:union([
|
||||||
|
enum([text, boolean, int32, int64, float, double]), emqx_schema:template()
|
||||||
|
]),
|
||||||
#{
|
#{
|
||||||
required => true,
|
required => true,
|
||||||
desc => ?DESC("config_parameters_data_type")
|
desc => ?DESC("config_parameters_data_type")
|
||||||
|
@ -130,7 +132,7 @@ fields(action_parameters_data) ->
|
||||||
)},
|
)},
|
||||||
{value,
|
{value,
|
||||||
mk(
|
mk(
|
||||||
binary(),
|
emqx_schema:template(),
|
||||||
#{
|
#{
|
||||||
required => true,
|
required => true,
|
||||||
desc => ?DESC("config_parameters_value")
|
desc => ?DESC("config_parameters_value")
|
||||||
|
|
|
@ -477,11 +477,20 @@ fields(producer_kafka_ext_headers) ->
|
||||||
];
|
];
|
||||||
fields(kafka_message) ->
|
fields(kafka_message) ->
|
||||||
[
|
[
|
||||||
{key, mk(string(), #{default => <<"${.clientid}">>, desc => ?DESC(kafka_message_key)})},
|
{key,
|
||||||
{value, mk(string(), #{default => <<"${.}">>, desc => ?DESC(kafka_message_value)})},
|
mk(emqx_schema:template(), #{
|
||||||
|
default => <<"${.clientid}">>,
|
||||||
|
desc => ?DESC(kafka_message_key)
|
||||||
|
})},
|
||||||
|
{value,
|
||||||
|
mk(emqx_schema:template(), #{
|
||||||
|
default => <<"${.}">>,
|
||||||
|
desc => ?DESC(kafka_message_value)
|
||||||
|
})},
|
||||||
{timestamp,
|
{timestamp,
|
||||||
mk(string(), #{
|
mk(emqx_schema:template(), #{
|
||||||
default => <<"${.timestamp}">>, desc => ?DESC(kafka_message_timestamp)
|
default => <<"${.timestamp}">>,
|
||||||
|
desc => ?DESC(kafka_message_timestamp)
|
||||||
})}
|
})}
|
||||||
];
|
];
|
||||||
fields(producer_buffer) ->
|
fields(producer_buffer) ->
|
||||||
|
@ -536,8 +545,11 @@ fields(consumer_topic_mapping) ->
|
||||||
{qos, mk(emqx_schema:qos(), #{default => 0, desc => ?DESC(consumer_mqtt_qos)})},
|
{qos, mk(emqx_schema:qos(), #{default => 0, desc => ?DESC(consumer_mqtt_qos)})},
|
||||||
{payload_template,
|
{payload_template,
|
||||||
mk(
|
mk(
|
||||||
string(),
|
emqx_schema:template(),
|
||||||
#{default => <<"${.}">>, desc => ?DESC(consumer_mqtt_payload)}
|
#{
|
||||||
|
default => <<"${.}">>,
|
||||||
|
desc => ?DESC(consumer_mqtt_payload)
|
||||||
|
}
|
||||||
)}
|
)}
|
||||||
];
|
];
|
||||||
fields(consumer_kafka_opts) ->
|
fields(consumer_kafka_opts) ->
|
||||||
|
|
|
@ -150,7 +150,7 @@ fields(producer) ->
|
||||||
[
|
[
|
||||||
{payload_template,
|
{payload_template,
|
||||||
sc(
|
sc(
|
||||||
binary(),
|
emqx_schema:template(),
|
||||||
#{
|
#{
|
||||||
default => <<"${.}">>,
|
default => <<"${.}">>,
|
||||||
desc => ?DESC("payload_template")
|
desc => ?DESC("payload_template")
|
||||||
|
|
|
@ -44,8 +44,10 @@ roots() -> [].
|
||||||
fields("config") ->
|
fields("config") ->
|
||||||
[
|
[
|
||||||
{enable, mk(boolean(), #{desc => ?DESC("enable"), default => true})},
|
{enable, mk(boolean(), #{desc => ?DESC("enable"), default => true})},
|
||||||
{collection, mk(binary(), #{desc => ?DESC("collection"), default => <<"mqtt">>})},
|
{collection,
|
||||||
{payload_template, mk(binary(), #{required => false, desc => ?DESC("payload_template")})},
|
mk(emqx_schema:template(), #{desc => ?DESC("collection"), default => <<"mqtt">>})},
|
||||||
|
{payload_template,
|
||||||
|
mk(emqx_schema:template(), #{required => false, desc => ?DESC("payload_template")})},
|
||||||
{resource_opts,
|
{resource_opts,
|
||||||
mk(
|
mk(
|
||||||
ref(?MODULE, "creation_opts"),
|
ref(?MODULE, "creation_opts"),
|
||||||
|
|
|
@ -200,7 +200,7 @@ fields("ingress_local") ->
|
||||||
[
|
[
|
||||||
{topic,
|
{topic,
|
||||||
mk(
|
mk(
|
||||||
binary(),
|
emqx_schema:template(),
|
||||||
#{
|
#{
|
||||||
validator => fun emqx_schema:non_empty_string/1,
|
validator => fun emqx_schema:non_empty_string/1,
|
||||||
desc => ?DESC("ingress_local_topic"),
|
desc => ?DESC("ingress_local_topic"),
|
||||||
|
@ -217,7 +217,7 @@ fields("ingress_local") ->
|
||||||
)},
|
)},
|
||||||
{retain,
|
{retain,
|
||||||
mk(
|
mk(
|
||||||
hoconsc:union([boolean(), binary()]),
|
hoconsc:union([boolean(), emqx_schema:template()]),
|
||||||
#{
|
#{
|
||||||
default => <<"${retain}">>,
|
default => <<"${retain}">>,
|
||||||
desc => ?DESC("retain")
|
desc => ?DESC("retain")
|
||||||
|
@ -225,7 +225,7 @@ fields("ingress_local") ->
|
||||||
)},
|
)},
|
||||||
{payload,
|
{payload,
|
||||||
mk(
|
mk(
|
||||||
binary(),
|
emqx_schema:template(),
|
||||||
#{
|
#{
|
||||||
default => undefined,
|
default => undefined,
|
||||||
desc => ?DESC("payload")
|
desc => ?DESC("payload")
|
||||||
|
@ -268,7 +268,7 @@ fields("egress_remote") ->
|
||||||
[
|
[
|
||||||
{topic,
|
{topic,
|
||||||
mk(
|
mk(
|
||||||
binary(),
|
emqx_schema:template(),
|
||||||
#{
|
#{
|
||||||
required => true,
|
required => true,
|
||||||
validator => fun emqx_schema:non_empty_string/1,
|
validator => fun emqx_schema:non_empty_string/1,
|
||||||
|
@ -286,7 +286,7 @@ fields("egress_remote") ->
|
||||||
)},
|
)},
|
||||||
{retain,
|
{retain,
|
||||||
mk(
|
mk(
|
||||||
hoconsc:union([boolean(), binary()]),
|
hoconsc:union([boolean(), emqx_schema:template()]),
|
||||||
#{
|
#{
|
||||||
required => false,
|
required => false,
|
||||||
default => false,
|
default => false,
|
||||||
|
@ -295,7 +295,7 @@ fields("egress_remote") ->
|
||||||
)},
|
)},
|
||||||
{payload,
|
{payload,
|
||||||
mk(
|
mk(
|
||||||
binary(),
|
emqx_schema:template(),
|
||||||
#{
|
#{
|
||||||
default => undefined,
|
default => undefined,
|
||||||
desc => ?DESC("payload")
|
desc => ?DESC("payload")
|
||||||
|
@ -344,7 +344,7 @@ desc(_) ->
|
||||||
undefined.
|
undefined.
|
||||||
|
|
||||||
qos() ->
|
qos() ->
|
||||||
hoconsc:union([emqx_schema:qos(), binary()]).
|
hoconsc:union([emqx_schema:qos(), emqx_schema:template()]).
|
||||||
|
|
||||||
parse_server(Str) ->
|
parse_server(Str) ->
|
||||||
#{hostname := Host, port := Port} = emqx_schema:parse_server(Str, ?MQTT_HOST_OPTS),
|
#{hostname := Host, port := Port} = emqx_schema:parse_server(Str, ?MQTT_HOST_OPTS),
|
||||||
|
|
|
@ -117,7 +117,7 @@ fields("config") ->
|
||||||
{enable, mk(boolean(), #{desc => ?DESC("config_enable"), default => true})},
|
{enable, mk(boolean(), #{desc => ?DESC("config_enable"), default => true})},
|
||||||
{sql,
|
{sql,
|
||||||
mk(
|
mk(
|
||||||
binary(),
|
emqx_schema:template(),
|
||||||
#{desc => ?DESC("sql_template"), default => ?DEFAULT_SQL, format => <<"sql">>}
|
#{desc => ?DESC("sql_template"), default => ?DEFAULT_SQL, format => <<"sql">>}
|
||||||
)},
|
)},
|
||||||
{local_topic,
|
{local_topic,
|
||||||
|
|
|
@ -146,7 +146,7 @@ fields(action_parameters_data) ->
|
||||||
[
|
[
|
||||||
{timestamp,
|
{timestamp,
|
||||||
mk(
|
mk(
|
||||||
binary(),
|
emqx_schema:template(),
|
||||||
#{
|
#{
|
||||||
desc => ?DESC("config_parameters_timestamp"),
|
desc => ?DESC("config_parameters_timestamp"),
|
||||||
required => false
|
required => false
|
||||||
|
@ -154,7 +154,7 @@ fields(action_parameters_data) ->
|
||||||
)},
|
)},
|
||||||
{metric,
|
{metric,
|
||||||
mk(
|
mk(
|
||||||
binary(),
|
emqx_schema:template(),
|
||||||
#{
|
#{
|
||||||
required => true,
|
required => true,
|
||||||
desc => ?DESC("config_parameters_metric")
|
desc => ?DESC("config_parameters_metric")
|
||||||
|
@ -162,7 +162,7 @@ fields(action_parameters_data) ->
|
||||||
)},
|
)},
|
||||||
{tags,
|
{tags,
|
||||||
mk(
|
mk(
|
||||||
hoconsc:union([map(), binary()]),
|
hoconsc:union([map(), emqx_schema:template()]),
|
||||||
#{
|
#{
|
||||||
required => true,
|
required => true,
|
||||||
desc => ?DESC("config_parameters_tags"),
|
desc => ?DESC("config_parameters_tags"),
|
||||||
|
@ -188,7 +188,7 @@ fields(action_parameters_data) ->
|
||||||
)},
|
)},
|
||||||
{value,
|
{value,
|
||||||
mk(
|
mk(
|
||||||
hoconsc:union([integer(), float(), binary()]),
|
hoconsc:union([integer(), float(), emqx_schema:template()]),
|
||||||
#{
|
#{
|
||||||
required => true,
|
required => true,
|
||||||
desc => ?DESC("config_parameters_value")
|
desc => ?DESC("config_parameters_value")
|
||||||
|
|
|
@ -158,7 +158,7 @@ fields(action_parameters) ->
|
||||||
[
|
[
|
||||||
{sql,
|
{sql,
|
||||||
hoconsc:mk(
|
hoconsc:mk(
|
||||||
binary(),
|
emqx_schema:template(),
|
||||||
#{desc => ?DESC("sql_template"), default => ?DEFAULT_SQL, format => <<"sql">>}
|
#{desc => ?DESC("sql_template"), default => ?DEFAULT_SQL, format => <<"sql">>}
|
||||||
)}
|
)}
|
||||||
];
|
];
|
||||||
|
@ -177,7 +177,7 @@ fields("config") ->
|
||||||
)},
|
)},
|
||||||
{sql,
|
{sql,
|
||||||
hoconsc:mk(
|
hoconsc:mk(
|
||||||
binary(),
|
emqx_schema:template(),
|
||||||
#{desc => ?DESC("sql_template"), default => ?DEFAULT_SQL, format => <<"sql">>}
|
#{desc => ?DESC("sql_template"), default => ?DEFAULT_SQL, format => <<"sql">>}
|
||||||
)},
|
)},
|
||||||
{local_topic,
|
{local_topic,
|
||||||
|
|
|
@ -61,7 +61,7 @@ fields(action_parameters) ->
|
||||||
[
|
[
|
||||||
{sql,
|
{sql,
|
||||||
hoconsc:mk(
|
hoconsc:mk(
|
||||||
binary(),
|
emqx_schema:template(),
|
||||||
#{desc => ?DESC("sql_template"), default => default_sql(), format => <<"sql">>}
|
#{desc => ?DESC("sql_template"), default => default_sql(), format => <<"sql">>}
|
||||||
)}
|
)}
|
||||||
];
|
];
|
||||||
|
|
|
@ -51,12 +51,12 @@ fields(action_parameters) ->
|
||||||
fields(producer_pulsar_message) ->
|
fields(producer_pulsar_message) ->
|
||||||
[
|
[
|
||||||
{key,
|
{key,
|
||||||
?HOCON(string(), #{
|
?HOCON(emqx_schema:template(), #{
|
||||||
default => <<"${.clientid}">>,
|
default => <<"${.clientid}">>,
|
||||||
desc => ?DESC("producer_key_template")
|
desc => ?DESC("producer_key_template")
|
||||||
})},
|
})},
|
||||||
{value,
|
{value,
|
||||||
?HOCON(string(), #{
|
?HOCON(emqx_schema:template(), #{
|
||||||
default => <<"${.}">>,
|
default => <<"${.}">>,
|
||||||
desc => ?DESC("producer_value_template")
|
desc => ?DESC("producer_value_template")
|
||||||
})}
|
})}
|
||||||
|
|
|
@ -99,7 +99,7 @@ fields(action_parameters) ->
|
||||||
)},
|
)},
|
||||||
{payload_template,
|
{payload_template,
|
||||||
hoconsc:mk(
|
hoconsc:mk(
|
||||||
binary(),
|
emqx_schema:template(),
|
||||||
#{
|
#{
|
||||||
default => <<"">>,
|
default => <<"">>,
|
||||||
desc => ?DESC(?CONNECTOR_SCHEMA, "payload_template")
|
desc => ?DESC(?CONNECTOR_SCHEMA, "payload_template")
|
||||||
|
|
|
@ -211,7 +211,7 @@ desc(_) ->
|
||||||
undefined.
|
undefined.
|
||||||
|
|
||||||
command_template(type) ->
|
command_template(type) ->
|
||||||
list(binary());
|
hoconsc:array(emqx_schema:template());
|
||||||
command_template(required) ->
|
command_template(required) ->
|
||||||
true;
|
true;
|
||||||
command_template(validator) ->
|
command_template(validator) ->
|
||||||
|
|
|
@ -162,8 +162,11 @@ fields(action_parameters) ->
|
||||||
[
|
[
|
||||||
{template,
|
{template,
|
||||||
mk(
|
mk(
|
||||||
binary(),
|
emqx_schema:template(),
|
||||||
#{desc => ?DESC("template"), default => ?DEFAULT_TEMPLATE}
|
#{
|
||||||
|
desc => ?DESC("template"),
|
||||||
|
default => ?DEFAULT_TEMPLATE
|
||||||
|
}
|
||||||
)}
|
)}
|
||||||
] ++ emqx_bridge_rocketmq_connector:fields(config),
|
] ++ emqx_bridge_rocketmq_connector:fields(config),
|
||||||
lists:foldl(
|
lists:foldl(
|
||||||
|
@ -205,7 +208,7 @@ fields("config") ->
|
||||||
{enable, mk(boolean(), #{desc => ?DESC("config_enable"), default => true})},
|
{enable, mk(boolean(), #{desc => ?DESC("config_enable"), default => true})},
|
||||||
{template,
|
{template,
|
||||||
mk(
|
mk(
|
||||||
binary(),
|
emqx_schema:template(),
|
||||||
#{desc => ?DESC("template"), default => ?DEFAULT_TEMPLATE}
|
#{desc => ?DESC("template"), default => ?DEFAULT_TEMPLATE}
|
||||||
)},
|
)},
|
||||||
{local_topic,
|
{local_topic,
|
||||||
|
@ -214,8 +217,7 @@ fields("config") ->
|
||||||
#{desc => ?DESC("local_topic"), required => false}
|
#{desc => ?DESC("local_topic"), required => false}
|
||||||
)}
|
)}
|
||||||
] ++ emqx_resource_schema:fields("resource_opts") ++
|
] ++ emqx_resource_schema:fields("resource_opts") ++
|
||||||
(emqx_bridge_rocketmq_connector:fields(config) --
|
emqx_bridge_rocketmq_connector:fields(config);
|
||||||
emqx_connector_schema_lib:prepare_statement_fields());
|
|
||||||
fields("post") ->
|
fields("post") ->
|
||||||
[type_field(), name_field() | fields("config")];
|
[type_field(), name_field() | fields("config")];
|
||||||
fields("put") ->
|
fields("put") ->
|
||||||
|
|
|
@ -47,7 +47,7 @@ fields(config) ->
|
||||||
{servers, servers()},
|
{servers, servers()},
|
||||||
{topic,
|
{topic,
|
||||||
mk(
|
mk(
|
||||||
binary(),
|
emqx_schema:template(),
|
||||||
#{default => <<"TopicTest">>, desc => ?DESC(topic)}
|
#{default => <<"TopicTest">>, desc => ?DESC(topic)}
|
||||||
)},
|
)},
|
||||||
{access_key,
|
{access_key,
|
||||||
|
|
|
@ -77,7 +77,7 @@ fields(s3_upload_parameters) ->
|
||||||
[
|
[
|
||||||
{content,
|
{content,
|
||||||
hoconsc:mk(
|
hoconsc:mk(
|
||||||
string(),
|
emqx_schema:template(),
|
||||||
#{
|
#{
|
||||||
required => false,
|
required => false,
|
||||||
default => <<"${.}">>,
|
default => <<"${.}">>,
|
||||||
|
|
|
@ -192,7 +192,7 @@ fields(action_parameters) ->
|
||||||
[
|
[
|
||||||
{sql,
|
{sql,
|
||||||
mk(
|
mk(
|
||||||
binary(),
|
emqx_schema:template(),
|
||||||
#{desc => ?DESC("sql_template"), default => ?DEFAULT_SQL, format => <<"sql">>}
|
#{desc => ?DESC("sql_template"), default => ?DEFAULT_SQL, format => <<"sql">>}
|
||||||
)}
|
)}
|
||||||
];
|
];
|
||||||
|
|
|
@ -112,7 +112,7 @@ fields("parameters") ->
|
||||||
[
|
[
|
||||||
{target_topic,
|
{target_topic,
|
||||||
mk(
|
mk(
|
||||||
binary(),
|
emqx_schema:template(),
|
||||||
#{desc => ?DESC("target_topic"), default => <<"${topic}">>}
|
#{desc => ?DESC("target_topic"), default => <<"${topic}">>}
|
||||||
)},
|
)},
|
||||||
{target_qos,
|
{target_qos,
|
||||||
|
@ -122,7 +122,7 @@ fields("parameters") ->
|
||||||
)},
|
)},
|
||||||
{template,
|
{template,
|
||||||
mk(
|
mk(
|
||||||
binary(),
|
emqx_schema:template(),
|
||||||
#{desc => ?DESC("template"), default => <<"${payload}">>}
|
#{desc => ?DESC("template"), default => <<"${payload}">>}
|
||||||
)}
|
)}
|
||||||
];
|
];
|
||||||
|
|
|
@ -83,7 +83,7 @@ fields("config") ->
|
||||||
{enable, mk(boolean(), #{desc => ?DESC("config_enable"), default => true})},
|
{enable, mk(boolean(), #{desc => ?DESC("config_enable"), default => true})},
|
||||||
{sql,
|
{sql,
|
||||||
mk(
|
mk(
|
||||||
binary(),
|
emqx_schema:template(),
|
||||||
#{
|
#{
|
||||||
desc => ?DESC("sql_template"),
|
desc => ?DESC("sql_template"),
|
||||||
default => ?DEFAULT_SQL,
|
default => ?DEFAULT_SQL,
|
||||||
|
@ -125,7 +125,7 @@ fields(action_parameters) ->
|
||||||
{database, fun emqx_connector_schema_lib:database/1},
|
{database, fun emqx_connector_schema_lib:database/1},
|
||||||
{sql,
|
{sql,
|
||||||
mk(
|
mk(
|
||||||
binary(),
|
emqx_schema:template(),
|
||||||
#{
|
#{
|
||||||
desc => ?DESC("sql_template"),
|
desc => ?DESC("sql_template"),
|
||||||
default => ?DEFAULT_SQL,
|
default => ?DEFAULT_SQL,
|
||||||
|
|
|
@ -65,6 +65,12 @@ readable("boolean()") ->
|
||||||
dashboard => #{type => boolean},
|
dashboard => #{type => boolean},
|
||||||
docgen => #{type => "Boolean"}
|
docgen => #{type => "Boolean"}
|
||||||
};
|
};
|
||||||
|
readable("template()") ->
|
||||||
|
#{
|
||||||
|
swagger => #{type => string},
|
||||||
|
dashboard => #{type => string, is_template => true},
|
||||||
|
docgen => #{type => "String", desc => ?DESC(template)}
|
||||||
|
};
|
||||||
readable("binary()") ->
|
readable("binary()") ->
|
||||||
#{
|
#{
|
||||||
swagger => #{type => string},
|
swagger => #{type => string},
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{application, emqx_s3, [
|
{application, emqx_s3, [
|
||||||
{description, "EMQX S3"},
|
{description, "EMQX S3"},
|
||||||
{vsn, "5.0.14"},
|
{vsn, "5.1.0"},
|
||||||
{modules, []},
|
{modules, []},
|
||||||
{registered, [emqx_s3_sup]},
|
{registered, [emqx_s3_sup]},
|
||||||
{applications, [
|
{applications, [
|
||||||
|
|
|
@ -103,7 +103,7 @@ put_object(Client, Key, Value) ->
|
||||||
|
|
||||||
-spec put_object(client(), key(), upload_options(), iodata()) -> ok_or_error(term()).
|
-spec put_object(client(), key(), upload_options(), iodata()) -> ok_or_error(term()).
|
||||||
put_object(
|
put_object(
|
||||||
#{bucket := Bucket, headers := BaseHeaders, aws_config := AwsConfig = #aws_config{}},
|
#{bucket := Bucket0, headers := BaseHeaders, aws_config := AwsConfig = #aws_config{}},
|
||||||
Key,
|
Key,
|
||||||
UploadOpts,
|
UploadOpts,
|
||||||
Content
|
Content
|
||||||
|
@ -111,6 +111,7 @@ put_object(
|
||||||
ECKey = erlcloud_key(Key),
|
ECKey = erlcloud_key(Key),
|
||||||
ECOpts = erlcloud_upload_options(UploadOpts),
|
ECOpts = erlcloud_upload_options(UploadOpts),
|
||||||
Headers = join_headers(BaseHeaders, maps:get(headers, UploadOpts, undefined)),
|
Headers = join_headers(BaseHeaders, maps:get(headers, UploadOpts, undefined)),
|
||||||
|
Bucket = to_list_string(Bucket0),
|
||||||
try erlcloud_s3:put_object(Bucket, ECKey, Content, ECOpts, Headers, AwsConfig) of
|
try erlcloud_s3:put_object(Bucket, ECKey, Content, ECOpts, Headers, AwsConfig) of
|
||||||
Props when is_list(Props) ->
|
Props when is_list(Props) ->
|
||||||
ok
|
ok
|
||||||
|
|
|
@ -74,7 +74,7 @@ fields(s3_upload) ->
|
||||||
[
|
[
|
||||||
{bucket,
|
{bucket,
|
||||||
mk(
|
mk(
|
||||||
string(),
|
emqx_schema:template(),
|
||||||
#{
|
#{
|
||||||
desc => ?DESC("bucket"),
|
desc => ?DESC("bucket"),
|
||||||
required => true
|
required => true
|
||||||
|
@ -82,7 +82,7 @@ fields(s3_upload) ->
|
||||||
)},
|
)},
|
||||||
{key,
|
{key,
|
||||||
mk(
|
mk(
|
||||||
string(),
|
emqx_schema:template(),
|
||||||
#{
|
#{
|
||||||
desc => ?DESC("key"),
|
desc => ?DESC("key"),
|
||||||
required => true
|
required => true
|
||||||
|
|
|
@ -9,4 +9,7 @@ emqx_conf_schema_types {
|
||||||
secret.desc:
|
secret.desc:
|
||||||
"""A string holding some sensitive information, such as a password. When secret starts with <code>file://</code>, the rest of the string is interpreted as a path to a file containing the secret itself: whole content of the file except any trailing whitespace characters is considered a secret value. Note: when clustered, all EMQX nodes should have the same file present before using <code>file://</code> secrets."""
|
"""A string holding some sensitive information, such as a password. When secret starts with <code>file://</code>, the rest of the string is interpreted as a path to a file containing the secret itself: whole content of the file except any trailing whitespace characters is considered a secret value. Note: when clustered, all EMQX nodes should have the same file present before using <code>file://</code> secrets."""
|
||||||
|
|
||||||
|
template.desc: """~
|
||||||
|
A string for `${.path.to.var}` style value interpolation,
|
||||||
|
where the leading dot is optional, and `${.}` represents all values as an object."""
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue