emqx_web_hook.schema 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. %%-*- mode: erlang -*-
  2. %% EMQ X R3.0 config mapping
  3. {mapping, "web.hook.api.url", "emqx_web_hook.url", [
  4. {datatype, string}
  5. ]}.
  6. {mapping, "web.hook.ssl", "emqx_web.hook.ssl", [
  7. {default, off},
  8. {datatype, flag}
  9. ]}.
  10. {mapping, "web.hook.ssl.cafile", "emqx_web_hook.ssloptions", [
  11. {default, ""},
  12. {datatype, string}
  13. ]}.
  14. {mapping, "web.hook.ssl.certfile", "emqx_web_hook.ssloptions", [
  15. {default, ""},
  16. {datatype, string}
  17. ]}.
  18. {mapping, "web.hook.ssl.keyfile", "emqx_web_hook.ssloptions", [
  19. {default, ""},
  20. {datatype, string}
  21. ]}.
  22. {mapping, "web.hook.encode_payload", "emqx_web_hook.encode_payload", [
  23. {default, undefined},
  24. {datatype, {enum, [base62, base64]}}
  25. ]}.
  26. {mapping, "web.hook.rule.client.connect.$name", "emqx_web_hook.rules", [
  27. {datatype, string}
  28. ]}.
  29. {mapping, "web.hook.rule.client.connack.$name", "emqx_web_hook.rules", [
  30. {datatype, string}
  31. ]}.
  32. {mapping, "web.hook.rule.client.connected.$name", "emqx_web_hook.rules", [
  33. {datatype, string}
  34. ]}.
  35. {mapping, "web.hook.rule.client.disconnected.$name", "emqx_web_hook.rules", [
  36. {datatype, string}
  37. ]}.
  38. {mapping, "web.hook.rule.client.subscribe.$name", "emqx_web_hook.rules", [
  39. {datatype, string}
  40. ]}.
  41. {mapping, "web.hook.rule.client.unsubscribe.$name", "emqx_web_hook.rules", [
  42. {datatype, string}
  43. ]}.
  44. {mapping, "web.hook.rule.session.subscribed.$name", "emqx_web_hook.rules", [
  45. {datatype, string}
  46. ]}.
  47. {mapping, "web.hook.rule.session.unsubscribed.$name", "emqx_web_hook.rules", [
  48. {datatype, string}
  49. ]}.
  50. {mapping, "web.hook.rule.session.terminated.$name", "emqx_web_hook.rules", [
  51. {datatype, string}
  52. ]}.
  53. {mapping, "web.hook.rule.message.publish.$name", "emqx_web_hook.rules", [
  54. {datatype, string}
  55. ]}.
  56. {mapping, "web.hook.rule.message.acked.$name", "emqx_web_hook.rules", [
  57. {datatype, string}
  58. ]}.
  59. {mapping, "web.hook.rule.message.delivered.$name", "emqx_web_hook.rules", [
  60. {datatype, string}
  61. ]}.
  62. {mapping, "web.hook.headers.$name", "emqx_web_hook.headers", [
  63. {datatype, string}
  64. ]}.
  65. {translation, "emqx_web_hook.headers", fun(Conf) ->
  66. Headers = cuttlefish_variable:filter_by_prefix("web.hook.headers", Conf),
  67. [{K, V} || {[_, _, _, K], V} <- Headers]
  68. end}.
  69. {translation, "emqx_web_hook.rules", fun(Conf) ->
  70. Hooks = cuttlefish_variable:filter_by_prefix("web.hook.rule", Conf),
  71. lists:map(
  72. fun({[_, _, _,Name1,Name2, _], Val}) ->
  73. {lists:concat([Name1,".",Name2]), Val}
  74. end, Hooks)
  75. end}.
  76. {translation, "emqx_web_hook.ssloptions", fun(Conf) ->
  77. CA = cuttlefish:conf_get("web.hook.ssl.cafile", Conf),
  78. Cert = cuttlefish:conf_get("web.hook.ssl.certfile", Conf),
  79. Key = cuttlefish:conf_get("web.hook.ssl.keyfile", Conf),
  80. case ((Cert == "") or (Key == "")) of
  81. true -> [{cacertfile, CA}];
  82. _ -> [{cacertfile, CA}, {certfile, Cert}, {keyfile, Key}]
  83. end
  84. end}.