OneSignal source connector

Description

Used to read data from OneSignal.

Key features

Options

name type required default value
url String Yes -
password String Yes -
method String No get
schema Config No -
schema.fields Config No -
format String No json
params Map No -
body String No -
json_field Config No -
content_json String No -
poll_interval_millis int No -
retry int No -
retry_backoff_multiplier_ms int No 100
retry_backoff_max_ms int No 10000
enable_multi_lines boolean No false
common-options config No -

url [String]

http request url

password [String]

Auth key for login, you can get more detail at this link:

https://documentation.onesignal.com/docs/accounts-and-keys#user-auth-key

method [String]

http request method, only supports GET, POST method

params [Map]

http params

body [String]

http body

poll_interval_millis [int]

request http api interval(millis) in stream mode

retry [int]

The max retry times if request http return to IOException

retry_backoff_multiplier_ms [int]

The retry-backoff times(millis) multiplier if request http failed

retry_backoff_max_ms [int]

The maximum retry-backoff times(millis) if request http failed

format [String]

the format of upstream data, now only support json text, default json.

when you assign format is json, you should also assign schema option, for example:

upstream data is the following:

  1. {
  2. "code": 200,
  3. "data": "get success",
  4. "success": true
  5. }

you should assign schema as the following:

  1. schema {
  2. fields {
  3. code = int
  4. data = string
  5. success = boolean
  6. }
  7. }

connector will generate data as the following:

code data success
200 get success true

when you assign format is text, connector will do nothing for upstream data, for example:

upstream data is the following:

  1. {
  2. "code": 200,
  3. "data": "get success",
  4. "success": true
  5. }

connector will generate data as the following:

content
{“code”: 200, “data”: “get success”, “success”: true}

schema [Config]

fields [Config]

the schema fields of upstream data

content_json [String]

This parameter can get some json data.If you only need the data in the ‘book’ section, configure content_field = "$.store.book.*".

If your return data looks something like this.

  1. {
  2. "store": {
  3. "book": [
  4. {
  5. "category": "reference",
  6. "author": "Nigel Rees",
  7. "title": "Sayings of the Century",
  8. "price": 8.95
  9. },
  10. {
  11. "category": "fiction",
  12. "author": "Evelyn Waugh",
  13. "title": "Sword of Honour",
  14. "price": 12.99
  15. }
  16. ],
  17. "bicycle": {
  18. "color": "red",
  19. "price": 19.95
  20. }
  21. },
  22. "expensive": 10
  23. }

You can configure content_field = "$.store.book.*" and the result returned looks like this:

  1. [
  2. {
  3. "category": "reference",
  4. "author": "Nigel Rees",
  5. "title": "Sayings of the Century",
  6. "price": 8.95
  7. },
  8. {
  9. "category": "fiction",
  10. "author": "Evelyn Waugh",
  11. "title": "Sword of Honour",
  12. "price": 12.99
  13. }
  14. ]

Then you can get the desired result with a simpler schema,like

  1. Http {
  2. url = "http://mockserver:1080/contentjson/mock"
  3. method = "GET"
  4. format = "json"
  5. content_field = "$.store.book.*"
  6. schema = {
  7. fields {
  8. category = string
  9. author = string
  10. title = string
  11. price = string
  12. }
  13. }
  14. }

Here is an example:

json_field [Config]

This parameter helps you configure the schema,so this parameter must be used with schema.

If your data looks something like this:

  1. {
  2. "store": {
  3. "book": [
  4. {
  5. "category": "reference",
  6. "author": "Nigel Rees",
  7. "title": "Sayings of the Century",
  8. "price": 8.95
  9. },
  10. {
  11. "category": "fiction",
  12. "author": "Evelyn Waugh",
  13. "title": "Sword of Honour",
  14. "price": 12.99
  15. }
  16. ],
  17. "bicycle": {
  18. "color": "red",
  19. "price": 19.95
  20. }
  21. },
  22. "expensive": 10
  23. }

You can get the contents of ‘book’ by configuring the task as follows:

  1. source {
  2. Http {
  3. url = "http://mockserver:1080/jsonpath/mock"
  4. method = "GET"
  5. format = "json"
  6. json_field = {
  7. category = "$.store.book[*].category"
  8. author = "$.store.book[*].author"
  9. title = "$.store.book[*].title"
  10. price = "$.store.book[*].price"
  11. }
  12. schema = {
  13. fields {
  14. category = string
  15. author = string
  16. title = string
  17. price = string
  18. }
  19. }
  20. }
  21. }

common options

Source plugin common parameters, please refer to Source Common Options for details

Example

  1. OneSignal {
  2. url = "https://onesignal.com/api/v1/apps"
  3. password = "SeaTunnel-test"
  4. schema = {
  5. fields {
  6. id = string
  7. name = string
  8. gcm_key = string
  9. chrome_key = string
  10. chrome_web_key = string
  11. chrome_web_origin = string
  12. chrome_web_gcm_sender_id = string
  13. chrome_web_default_notification_icon = string
  14. chrome_web_sub_domain = string
  15. apns_env = string
  16. apns_certificates = string
  17. apns_p8 = string
  18. apns_team_id = string
  19. apns_key_id = string
  20. apns_bundle_id = string
  21. safari_apns_certificate = string
  22. safari_site_origin = string
  23. safari_push_id = string
  24. safari_icon_16_16 = string
  25. safari_icon_32_32 = string
  26. safari_icon_64_64 = string
  27. safari_icon_128_128 = string
  28. safari_icon_256_256 = string
  29. site_name = string
  30. created_at = string
  31. updated_at = string
  32. players = int
  33. messageable_players = int
  34. basic_auth_key = string
  35. additional_data_is_root_payload = string
  36. }
  37. }
  38. }

Changelog

next version

  • Add OneSignal Source Connector
  • [Feature][Connector-V2][HTTP] Use json-path parsing (3510)