20
20
21
21
import lombok .Builder ;
22
22
import lombok .Getter ;
23
+ import lombok .Setter ;
23
24
24
25
/**
25
26
* ML batch ingestion data: index, field mapping and input and out files.
26
27
*/
28
+ @ Getter
27
29
public class MLBatchIngestionInput implements ToXContentObject , Writeable {
28
30
29
31
public static final String INDEX_NAME_FIELD = "index_name" ;
30
32
public static final String FIELD_MAP_FIELD = "field_map" ;
31
33
public static final String INGEST_FIELDS = "ingest_fields" ;
32
34
public static final String CONNECTOR_CREDENTIAL_FIELD = "credential" ;
33
35
public static final String DATA_SOURCE_FIELD = "data_source" ;
36
+ public static final String CONNECTOR_ID_FIELD = "connector_id" ;
34
37
35
- @ Getter
36
38
private String indexName ;
37
- @ Getter
38
39
private Map <String , Object > fieldMapping ;
39
- @ Getter
40
40
private String [] ingestFields ;
41
- @ Getter
42
41
private Map <String , Object > dataSources ;
43
- @ Getter
42
+ @ Setter
44
43
private Map <String , String > credential ;
44
+ private String connectorId ;
45
45
46
46
@ Builder (toBuilder = true )
47
47
public MLBatchIngestionInput (
48
48
String indexName ,
49
49
Map <String , Object > fieldMapping ,
50
50
String [] ingestFields ,
51
51
Map <String , Object > dataSources ,
52
- Map <String , String > credential
52
+ Map <String , String > credential ,
53
+ String connectorId
53
54
) {
54
55
if (indexName == null ) {
55
56
throw new IllegalArgumentException (
@@ -66,6 +67,7 @@ public MLBatchIngestionInput(
66
67
this .ingestFields = ingestFields ;
67
68
this .dataSources = dataSources ;
68
69
this .credential = credential ;
70
+ this .connectorId = connectorId ;
69
71
}
70
72
71
73
public static MLBatchIngestionInput parse (XContentParser parser ) throws IOException {
@@ -74,6 +76,7 @@ public static MLBatchIngestionInput parse(XContentParser parser) throws IOExcept
74
76
String [] ingestFields = null ;
75
77
Map <String , Object > dataSources = null ;
76
78
Map <String , String > credential = new HashMap <>();
79
+ String connectorId = null ;
77
80
78
81
ensureExpectedToken (XContentParser .Token .START_OBJECT , parser .currentToken (), parser );
79
82
while (parser .nextToken () != XContentParser .Token .END_OBJECT ) {
@@ -93,6 +96,9 @@ public static MLBatchIngestionInput parse(XContentParser parser) throws IOExcept
93
96
case CONNECTOR_CREDENTIAL_FIELD :
94
97
credential = parser .mapStrings ();
95
98
break ;
99
+ case CONNECTOR_ID_FIELD :
100
+ connectorId = parser .text ();
101
+ break ;
96
102
case DATA_SOURCE_FIELD :
97
103
dataSources = parser .map ();
98
104
break ;
@@ -101,7 +107,7 @@ public static MLBatchIngestionInput parse(XContentParser parser) throws IOExcept
101
107
break ;
102
108
}
103
109
}
104
- return new MLBatchIngestionInput (indexName , fieldMapping , ingestFields , dataSources , credential );
110
+ return new MLBatchIngestionInput (indexName , fieldMapping , ingestFields , dataSources , credential , connectorId );
105
111
}
106
112
107
113
@ Override
@@ -119,6 +125,9 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
119
125
if (credential != null ) {
120
126
builder .field (CONNECTOR_CREDENTIAL_FIELD , credential );
121
127
}
128
+ if (connectorId != null ) {
129
+ builder .field (CONNECTOR_ID_FIELD , connectorId );
130
+ }
122
131
if (dataSources != null ) {
123
132
builder .field (DATA_SOURCE_FIELD , dataSources );
124
133
}
@@ -147,6 +156,7 @@ public void writeTo(StreamOutput output) throws IOException {
147
156
} else {
148
157
output .writeBoolean (false );
149
158
}
159
+ output .writeOptionalString (connectorId );
150
160
if (dataSources != null ) {
151
161
output .writeBoolean (true );
152
162
output .writeMap (dataSources , StreamOutput ::writeString , StreamOutput ::writeGenericValue );
@@ -166,6 +176,7 @@ public MLBatchIngestionInput(StreamInput input) throws IOException {
166
176
if (input .readBoolean ()) {
167
177
credential = input .readMap (s -> s .readString (), s -> s .readString ());
168
178
}
179
+ this .connectorId = input .readOptionalString ();
169
180
if (input .readBoolean ()) {
170
181
dataSources = input .readMap (s -> s .readString (), s -> s .readGenericValue ());
171
182
}
0 commit comments