跳到主要内容
版本:Next

Persistiq

Persistiq 源连接器

描述​

用于从 Persistiq 读取数据。

关键特性​

选项​

参数名类型必须默认值描述
urlString是-HTTP 请求 URL
passwordString是-API 密钥用于登录
methodString否getHTTP 请求方法,仅支持 GET、POST 方法
schemaConfig否-HTTP 和 SeaTunnel 数据结构映射。更多详情请参考 Schema 特性。
schema.fieldsConfig否-上游数据的模式字段
formatString否json上游数据的格式,现在仅支持 json text,默认 json。
paramsMap否-HTTP 参数
bodyString否-HTTP 请求体
json_fieldConfig否-JSON 字段配置
content_fieldString否-内容 JSON 配置
poll_interval_millisint否-流模式下请求 HTTP API 的间隔(毫秒)
retryint否-如果 HTTP 请求返回 IOException 的最大重试次数
retry_backoff_multiplier_msint否100HTTP 请求失败时的重试退避倍数(毫秒)
retry_backoff_max_msint否10000HTTP 请求失败时的最大重试退避时间(毫秒)
enable_multi_linesboolean否false是否启用多行模式
common-optionsconfig否-源插件通用参数

url [String]​

HTTP 请求 URL

password [String]​

API 密钥用于登录,您可以在 Persistiq 网站获取

method [String]​

HTTP 请求方法,仅支持 GET、POST 方法

params [Map]​

HTTP 参数

body [String]​

HTTP 请求体

poll_interval_millis [int]​

流模式下请求 HTTP API 的间隔(毫秒)

retry [int]​

如果 HTTP 请求返回 IOException 的最大重试次数

retry_backoff_multiplier_ms [int]​

HTTP 请求失败时的重试退避倍数(毫秒)

retry_backoff_max_ms [int]​

HTTP 请求失败时的最大重试退避时间(毫秒)

format [String]​

上游数据的格式,现在仅支持 json text,默认 json。

当您指定 format 为 json 时,您还应该指定 schema 选项,例如:

上游数据如下:

{
"code": 200,
"data": "get success",
"success": true
}

您应该指定 schema 如下:


schema {
fields {
code = int
data = string
success = boolean
}
}

连接器将生成如下数据:

codedatasuccess
200get successtrue

当您指定 format 为 text 时,连接器不会对上游数据做任何处理,例如:

上游数据如下:

{
"code": 200,
"data": "get success",
"success": true
}

连接器将生成如下数据:

content
{"code": 200, "data": "get success", "success": true}

schema [Config]​

fields [Config]​

上游数据的模式字段。更多详情请参考 Schema 特性。

content_field [String]​

此参数可以获取一些 JSON 数据。如果只需要 book 部分的数据,请配置 content_field = "$.store.book.*"。

如果您的返回数据看起来像这样。

{
"store": {
"book": [
{
"category": "reference",
"author": "Nigel Rees",
"title": "Sayings of the Century",
"price": 8.95
},
{
"category": "fiction",
"author": "Evelyn Waugh",
"title": "Sword of Honour",
"price": 12.99
}
],
"bicycle": {
"color": "red",
"price": 19.95
}
},
"expensive": 10
}

您可以配置 content_field = "$.store.book.*" 并且返回的结果看起来像这样:

[
{
"category": "reference",
"author": "Nigel Rees",
"title": "Sayings of the Century",
"price": 8.95
},
{
"category": "fiction",
"author": "Evelyn Waugh",
"title": "Sword of Honour",
"price": 12.99
}
]

然后您可以使用更简单的 schema 获取所需的结果,如

Http {
url = "http://example.com/xyz"
method = "GET"
format = "json"
content_field = "$.store.book.*"
schema = {
fields {
category = string
author = string
title = string
price = string
}
}
}

这里是一个示例:

json_field [Config]​

此参数帮助您配置模式,因此此参数必须与 schema 一起使用。

如果您的数据看起来像这样:

{
"store": {
"book": [
{
"category": "reference",
"author": "Nigel Rees",
"title": "Sayings of the Century",
"price": 8.95
},
{
"category": "fiction",
"author": "Evelyn Waugh",
"title": "Sword of Honour",
"price": 12.99
}
],
"bicycle": {
"color": "red",
"price": 19.95
}
},
"expensive": 10
}

您可以通过如下配置任务来获取 'book' 的内容:

source {
Http {
url = "http://example.com/xyz"
method = "GET"
format = "json"
json_field = {
category = "$.store.book[*].category"
author = "$.store.book[*].author"
title = "$.store.book[*].title"
price = "$.store.book[*].price"
}
schema = {
fields {
category = string
author = string
title = string
price = string
}
}
}
}

通用选项​

源插件通用参数,请参考 源通用选项 详见。

示例​

source {
Persistiq{
url = "https://api.persistiq.com/v1/users"
password = "Your password"
content_field = "$.users.*"
schema = {
fields {
id = string
name = string
email = string
activated = boolean
default_mailbox_id = string
salesforce_id = string
}
}
}
}

变更日志​