goutamadwant commented on code in PR #12281:
URL: https://github.com/apache/seatunnel/pull/12281#discussion_r3997361463


##########
seatunnel-connectors-v2/connector-http/connector-http-splunk/src/main/java/org/apache/seatunnel/connectors/seatunnel/splunk/config/SplunkSourceParameter.java:
##########
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.splunk.config;
+
+import org.apache.seatunnel.api.configuration.ReadonlyConfig;
+import org.apache.seatunnel.connectors.seatunnel.http.config.HttpParameter;
+
+import java.util.HashMap;
+
+public class SplunkSourceParameter extends HttpParameter {
+    /**
+     * Overrides buildWithConfig to accept an explicit apiKey parameter. 
Splunk's REST API requires
+     * the API key to be passed specifically as an Authorization header, so 
this method ensures the
+     * key is properly extracted and configured.
+     */
+    public void buildWithConfig(ReadonlyConfig pluginConfig, String apiKey) {
+        super.buildWithConfig(pluginConfig);

Review Comment:
   The documented POST request is not encoded correctly. 
super.buildWithConfig() leaves the configured body as a plain string, and 
HttpClientProvider consequently sends search=...&output_mode=json with 
Content-Type: application/json. Splunk expects these values as URL-encoded form 
parameters. Please construct the request with POST/form semantics and model 
search and output_mode as form fields. A request-capture test should assert the 
method, content type, and decoded parameter values.



##########
docs/en/connector-v2/source/Http-Splunk.md:
##########
@@ -0,0 +1,34 @@
+# Http-Splunk
+
+> Http-Splunk source connector
+
+## Description
+
+Read data from the Splunk API via HTTP.
+
+## Key Features
+
+- [x] batch
+- [ ] stream
+- [ ] exactly-once
+
+## Options
+
+| Name | Type | Required | Default Value | Description |
+| --- | --- | --- | --- | --- |
+| url | String | Yes | - | Splunk REST API Endpoint URL |
+| api_key | String | Yes | - | Splunk Authorization Token or API Key |
+| plugin_output | String | No | - | The result table name when generating data 
|
+
+## Example
+
+```hocon
+source {
+  Http-Splunk {
+    url = "https://your-splunk-instance:8089/services/search/jobs/export";

Review Comment:
   The /services/search/jobs/export endpoint is deprecated and disabled in 
current Splunk releases. Please update the example and tests to use 
/services/search/v2/jobs/export. This page should also be moved under 
docs/en/connectors/source/, which is the directory included in the connector 
sidebar, and a matching docs/zh/connectors/source/ page should be added.



##########
seatunnel-connectors-v2/connector-http/connector-http-splunk/src/main/java/org/apache/seatunnel/connectors/seatunnel/splunk/SplunkSource.java:
##########
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.splunk;
+
+import org.apache.seatunnel.api.configuration.ReadonlyConfig;
+import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import 
org.apache.seatunnel.connectors.seatunnel.common.source.AbstractSingleSplitReader;
+import 
org.apache.seatunnel.connectors.seatunnel.common.source.SingleSplitReaderContext;
+import org.apache.seatunnel.connectors.seatunnel.http.source.HttpSource;
+import org.apache.seatunnel.connectors.seatunnel.http.source.HttpSourceReader;
+import 
org.apache.seatunnel.connectors.seatunnel.splunk.config.SplunkSourceOptions;
+import 
org.apache.seatunnel.connectors.seatunnel.splunk.config.SplunkSourceParameter;
+
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+public class SplunkSource extends HttpSource {
+    private final SplunkSourceParameter splunkSourceParameter = new 
SplunkSourceParameter();
+
+    public SplunkSource(ReadonlyConfig pluginConfig) {
+        super(pluginConfig);
+        String apiKey = pluginConfig.get(SplunkSourceOptions.API_KEY);
+        splunkSourceParameter.buildWithConfig(pluginConfig, apiKey);
+    }
+
+    @Override
+    public String getPluginName() {
+        return "splunk";
+    }
+
+    @Override
+    public AbstractSingleSplitReader<SeaTunnelRow> createReader(
+            SingleSplitReaderContext readerContext) throws Exception {
+        return new HttpSourceReader(

Review Comment:
   HttpSourceReader does not preserve Splunk export semantics here. The 
underlying HTTP client buffers the complete response with 
EntityUtils.toString(), and with the default enable_multi_lines = false, the 
entire newline-delimited export is emitted as one content row. Splunk returns 
separate JSON objects for result rows and can include preview and final result 
sets. Please consume the response incrementally, emit individual result rows, 
and prevent preview/final duplicates. A regression containing two result lines 
should produce exactly two SeaTunnel rows.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to