Skip to content

Commit

Permalink
[Feature][Connector2] Add DingTalk Source apache#2684
Browse files Browse the repository at this point in the history
  • Loading branch information
MRYOG committed Sep 9, 2022
1 parent 3613fc1 commit 84c0680
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
26 changes: 24 additions & 2 deletions docs/en/connector-v2/source/dingtalk.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,16 @@
## Description

A source plugin which use DingTalk
A source plugin which use DingTalk API

## Key features

- [x] [batch](../../concept/connector-v2-features.md)
- [ ] [stream](../../concept/connector-v2-features.md)
- [x] [exactly-once](../../concept/connector-v2-features.md)
- [ ] [schema projection](../../concept/connector-v2-features.md)
- [ ] [parallelism](../../concept/connector-v2-features.md)
- [ ] [support user-defined split](../../concept/connector-v2-features.md)

## Options

Expand All @@ -22,7 +31,9 @@ DingTalk API address like : https://oapi.dingtalk.com/topapi/v2/department/lists

### access_token [string]

DingTalk access token [DingTalk Doc](https://open.dingtalk.com/document/orgapp-server/obtain-the-access_token-of-an-internal-app) , the valid period of access token is 7200 seconds , if access token expired , can use app_key and app_secret get new message (string)
DingTalk access_token [DingTalk Doc](https://open.dingtalk.com/document/orgapp-server/obtain-the-access_token-of-an-internal-app) <br>
The valid period of access token is 7200 seconds , if access token expired , can use app_key and app_secret get new message (string)<br>
access_token is the source voucher , can direct use of access_token or use app_key and app_secret get it

### app_key [string]

Expand Down Expand Up @@ -51,4 +62,15 @@ source {
app_secret="qv5pLes-M9JvHXjaBqkPFdAyk9WKEjDjEZOpLZKHi"
}
}
result :
row=1 : {"auto_add_user":false,"create_dept_group":false,"dept_id":101254282,"ext":"{\"faceCount\":\"1\"}","name":"技术部","parent_id":1}
row=2 : {"auto_add_user":true,"create_dept_group":true,"dept_id":101279294,"name":"财务部","parent_id":1}
row=3 : {"auto_add_user":false,"create_dept_group":false,"dept_id":101316242,"ext":"{\"faceCount\":\"2\"}","name":"渠道部","parent_id":1}
row=4 : {"auto_add_user":false,"create_dept_group":false,"dept_id":101340237,"name":"运营部","parent_id":1}
row=5 : {"auto_add_user":false,"create_dept_group":false,"dept_id":101467231,"ext":"{\"faceCount\":\"1\"}","name":"客服部","parent_id":1}
row=6 : {"auto_add_user":true,"create_dept_group":true,"dept_id":101532253,"name":"人力部","parent_id":1}
row=7 : {"auto_add_user":true,"create_dept_group":true,"dept_id":101532254,"name":"直销部","parent_id":1}
```


Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import org.apache.seatunnel.connectors.seatunnel.common.DingTalkConstant;
import org.apache.seatunnel.connectors.seatunnel.common.DingTalkParameter;
import org.apache.seatunnel.connectors.seatunnel.common.DingTalkUtil;
import org.apache.seatunnel.connectors.seatunnel.common.schema.SeatunnelSchema;
import org.apache.seatunnel.connectors.seatunnel.common.schema.SeaTunnelSchema;
import org.apache.seatunnel.connectors.seatunnel.common.source.AbstractSingleSplitReader;
import org.apache.seatunnel.connectors.seatunnel.common.source.AbstractSingleSplitSource;
import org.apache.seatunnel.connectors.seatunnel.common.source.SingleSplitReaderContext;
Expand Down Expand Up @@ -85,9 +85,9 @@ public void prepare(Config pluginConfig) throws PrepareFailException {

if (pluginConfig.hasPath(DingTalkConstant.SCHEMA)) {
Config schema = pluginConfig.getConfig(DingTalkConstant.SCHEMA);
this.rowType = SeatunnelSchema.buildWithConfig(schema).getSeaTunnelRowType();
this.rowType = SeaTunnelSchema.buildWithConfig(schema).getSeaTunnelRowType();
} else {
this.rowType = SeatunnelSchema.buildSimpleTextSchema();
this.rowType = SeaTunnelSchema.buildSimpleTextSchema();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ source {
# This is a example source plugin **only for test and demonstrate the feature source plugin**
DingTalk {
api_client="https://oapi.dingtalk.com/topapi/v2/department/listsub"
access_token="07c0cb8af8cc3c7f9927fbd3f53b886e"
access_token="02b3b3338c5d34df9197c6adf02e39fb"
}

# If you would like to get more information about how to configure seatunnel and see full list of source plugins,
Expand Down

0 comments on commit 84c0680

Please sign in to comment.