My Hours source connector

Support Those Engines

Spark
Flink
SeaTunnel Zeta

Key Features

Description

Used to read data from My Hours.

Key features

Supported DataSource Info

In order to use the My Hours connector, the following dependencies are required. They can be downloaded via install-plugin.sh or from the Maven central repository.

Datasource Supported Versions Dependency
My Hours universal Download

Source Options

Name Type Required Default Description
url String Yes - Http request url.
email String Yes - My hours login email address.
password String Yes - My hours login password.
schema Config No - Http and seatunnel data structure mapping
schema.fields Config No - The schema fields of upstream data
json_field Config No - This parameter helps you configure the schema,so this parameter must be used with schema.
content_json String No - This parameter can get some json data.If you only need the data in the ‘book’ section, configure content_field = "$.store.book.*".
format String No json The format of upstream data, now only support json text, default json.
method String No get Http request method, only supports GET, POST method.
headers Map No - Http headers.
params Map No - Http params.
body String No - Http body.
poll_interval_millis Int No - Request http api interval(millis) in stream mode.
retry Int No - The max retry times if request http return to IOException.
retry_backoff_multiplier_ms Int No 100 The retry-backoff times(millis) multiplier if request http failed.
retry_backoff_max_ms Int No 10000 The maximum retry-backoff times(millis) if request http failed
enable_multi_lines Boolean No false
common-options No - Source plugin common parameters, please refer to Source Common Options for details

How to Create a My Hours Data Synchronization Jobs

  1. env {
  2. parallelism = 1
  3. job.mode = "BATCH"
  4. }
  5. MyHours{
  6. url = "https://api2.myhours.com/api/Projects/getAll"
  7. email = "seatunnel@test.com"
  8. password = "seatunnel"
  9. schema {
  10. fields {
  11. name = string
  12. archived = boolean
  13. dateArchived = string
  14. dateCreated = string
  15. clientName = string
  16. budgetAlertPercent = string
  17. budgetType = int
  18. totalTimeLogged = double
  19. budgetValue = double
  20. totalAmount = double
  21. totalExpense = double
  22. laborCost = double
  23. totalCost = double
  24. billableTimeLogged = double
  25. totalBillableAmount = double
  26. billable = boolean
  27. roundType = int
  28. roundInterval = int
  29. budgetSpentPercentage = double
  30. budgetTarget = int
  31. budgetPeriodType = string
  32. budgetSpent = string
  33. id = string
  34. }
  35. }
  36. }
  37. # Console printing of the read data
  38. sink {
  39. Console {
  40. parallelism = 1
  41. }
  42. }

Parameter Interpretation

format

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}

content_json

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

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. }

Changelog

next version

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