My Hours
My Hours 源连接器
支持这些引擎
Spark
Flink
SeaTunnel Zeta
关键特性
描述
用于通过 My Hours REST API 读取数据。连接器会先使用配置的 email 和 password 登录获取访问令牌,
然后在后续请求中自动携带该令牌。
支持的数据源信息
为了使用 My Hours 连接器,需要以下依赖项。 可以通过 install-plugin.sh 或从 Maven 中央存储库下载。
| 数据源 | 支持的版本 | 依赖 |
|---|---|---|
| My Hours | universal | 下载 |
源选项
| 参数名 | 类型 | 必须 | 默认值 | 描述 |
|---|---|---|---|---|
| url | String | 是 | - | My Hours API 请求 URL。 |
| String | 是 | - | My Hours 登录邮箱。 | |
| password | String | 是 | - | My Hours 登录密码。 |
| schema | Config | 否 | - | 当 format 为 json 时需要配置。更多详情请参考 Schema 特性。 |
| schema.fields | Config | 否 | - | 上游数据字段。 |
| json_field | Config | 否 | - | 通过 JSONPath 从响应中抽取字段,需要与 schema 一起使用。 |
| content_field | String | 否 | - | 在解析 schema 前抽取 JSON 响应中的一部分,例如 $.store.book.*。 |
| format | String | 否 | text | 响应格式,支持 json 和 text。使用 schema、json_field 或 content_field 时请设置为 json。 |
| method | String | 否 | GET | HTTP 请求方法,支持 GET 和 POST。 |
| headers | Map | 否 | - | 额外 HTTP 请求头。连接器登录后会自动添加 My Hours Authorization 请求头。 |
| params | Map | 否 | - | HTTP 查询参数。 |
| body | String | 否 | - | HTTP 请求体。 |
| poll_interval_millis | Int | 否 | - | 流模式下请求 HTTP API 的间隔,单位毫秒。 |
| retry | Int | 否 | - | 请求抛出 IOException 时的最大重试次数。 |
| retry_backoff_multiplier_ms | Int | 否 | 100 | 重试退避倍数,单位毫秒。 |
| retry_backoff_max_ms | Int | 否 | 10000 | 最大重试退避时间,单位毫秒。 |
| json_filed_missed_return_null | Boolean | 否 | false | 配置的 JSON 字段缺失时返回 null。 |
| common-options | 否 | - | 源插件通用参数。 |
如何创建 My Hours 数据同步作业
env {
parallelism = 1
job.mode = "BATCH"
}
source {
MyHours {
url = "https://api2.myhours.com/api/Projects/getAll"
email = "seatunnel@test.com"
password = "********"
method = "GET"
format = "json"
schema {
fields {
name = string
archived = boolean
dateArchived = string
dateCreated = string
clientName = string
budgetAlertPercent = string
budgetType = int
totalTimeLogged = double
budgetValue = double
totalAmount = double
totalExpense = double
laborCost = double
totalCost = double
billableTimeLogged = double
totalBillableAmount = double
billable = boolean
roundType = int
roundInterval = int
budgetSpentPercentage = double
budgetTarget = int
budgetPeriodType = string
budgetSpent = string
id = string
}
}
}
}
# 控制台打印读取的数据
sink {
Console {
parallelism = 1
}
}
参数解释
format
当您指定格式为 json 时,您还应该指定 schema 选项。
content_field
此参数可以获取响应中的一部分 JSON 数据。如果只需要 book 部分,可配置 content_field = "$.store.book.*"。
json_field
此参数帮助您配置模式,因此此参数必须与 schema 一起使用。
变更日志
Change Log
| Change | Commit | Version |
|---|---|---|
| [Feature][connector-http] Parameters support placeholder replacement (#9184) | https://github.com/apache/seatunnel/commit/8617014edc | 2.3.11 |
| [improve] http connector options (#8969) | https://github.com/apache/seatunnel/commit/63ff9f910a | 2.3.10 |
| [Fix][connector-http] fix when post have param (#8434) | https://github.com/apache/seatunnel/commit/c1b2675ab0 | 2.3.10 |
| [Improve][dist]add shade check rule (#8136) | https://github.com/apache/seatunnel/commit/51ef800016 | 2.3.9 |
| [Feature][Connector-V2] Support TableSourceFactory/TableSinkFactory on http (#5816) | https://github.com/apache/seatunnel/commit/6f49ec6ead | 2.3.4 |
| [Improve][build] Give the maven module a human readable name (#4114) | https://github.com/apache/seatunnel/commit/d7cd601051 | 2.3.1 |
| [Improve][Project] Code format with spotless plugin. (#4101) | https://github.com/apache/seatunnel/commit/a2ab166561 | 2.3.1 |
| [Improve][Connector-V2][Http]Improve json parse option rule for all http connector (#3627) | https://github.com/apache/seatunnel/commit/589e4161ec | 2.3.0 |
| [Feature][Connector-V2][HTTP] Use json-path parsing (#3510) | https://github.com/apache/seatunnel/commit/1807eb6c95 | 2.3.0 |
| [Hotfix][OptionRule] Fix option rule about all connectors (#3592) | https://github.com/apache/seatunnel/commit/226dc6a119 | 2.3.0 |
| [Improve][Connector-V2][MyHours]Unified exception for MyHours connector (#3538) | https://github.com/apache/seatunnel/commit/48ab7c97d5 | 2.3.0 |
| [HotFix][Core][API] Fix OptionValidation error code (#3439) | https://github.com/apache/seatunnel/commit/ace219f376 | 2.3.0 |
| [Improve][Connector-V2][My Hours]Add http method enum && Improve My Hours connector option rule (#3390) | https://github.com/apache/seatunnel/commit/a86c9d90f7 | 2.3.0 |
| [Feature][Connector-V2][Http] Add option rules && Improve Myhours sink connector (#3351) | https://github.com/apache/seatunnel/commit/cc8bb60c83 | 2.3.0 |
| [Feature][Connector-V2][My Hours] Add My Hours Source Connector (#3228) | https://github.com/apache/seatunnel/commit/4104a3e30e | 2.3.0 |