-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add parse_ion processor Signed-off-by: Emma Becar <[email protected]> Co-authored-by: Emma Becar <[email protected]>
- Loading branch information
Showing
14 changed files
with
551 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
...r/src/main/java/org/opensearch/dataprepper/plugins/processor/parse/CommonParseConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.dataprepper.plugins.processor.parse; | ||
|
||
import java.util.List; | ||
|
||
public interface CommonParseConfig { | ||
/** | ||
* The field of the Event that contains the JSON data. | ||
* | ||
* @return The name of the source field. | ||
*/ | ||
String getSource(); | ||
|
||
/** | ||
* The destination that the parsed JSON is written to. Defaults to the root of the Event. | ||
* If the destination field already exists, it will be overwritten. | ||
* | ||
* @return The name of the destination field. | ||
*/ | ||
String getDestination(); | ||
|
||
/** | ||
* An optional setting used to specify a JSON Pointer. Pointer points to the JSON key that will be parsed into the destination. | ||
* There is no pointer by default, meaning that the entirety of source will be parsed. If the target key would overwrite an existing | ||
* key in the Event then the absolute path of the target key will be placed into destination | ||
* | ||
* Note: (should this be configurable/what about double conflicts?) | ||
* @return String representing JSON Pointer | ||
*/ | ||
String getPointer(); | ||
|
||
/** | ||
* A `List` of `String`s that specifies the tags to be set in the event the processor fails to parse or an unknown | ||
* exception occurs while parsing. This tag may be used in conditional expressions in other parts of the configuration. | ||
* | ||
* @return List of tags to be set on failure | ||
*/ | ||
List<String> getTagsOnFailure(); | ||
|
||
/** | ||
* An optional setting used to specify a conditional expression. | ||
* If the expression evaluates to true, the processor will parse the source field. | ||
* | ||
* @return String representing conditional expression | ||
*/ | ||
String getParseWhen(); | ||
|
||
/** | ||
* An optional setting used to specify whether the destination field should be overwritten if it already exists. | ||
* Defaults to true. | ||
*/ | ||
boolean getOverwriteIfDestinationExists(); | ||
} |
25 changes: 25 additions & 0 deletions
25
...a/org/opensearch/dataprepper/plugins/processor/parse/ion/IonTimestampConverterModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.dataprepper.plugins.processor.parse.ion; | ||
|
||
import com.amazon.ion.Timestamp; | ||
import com.fasterxml.jackson.core.JsonGenerator; | ||
import com.fasterxml.jackson.databind.SerializerProvider; | ||
import com.fasterxml.jackson.databind.module.SimpleModule; | ||
import com.fasterxml.jackson.databind.ser.std.StdSerializer; | ||
|
||
import java.io.IOException; | ||
|
||
public class IonTimestampConverterModule extends SimpleModule { | ||
public IonTimestampConverterModule() { | ||
addSerializer(Timestamp.class, new StdSerializer<>(Timestamp.class) { | ||
@Override | ||
public void serialize(Timestamp value, JsonGenerator gen, SerializerProvider provider) throws IOException { | ||
gen.writeString(value.toZString()); | ||
} | ||
}); | ||
} | ||
} |
Oops, something went wrong.