Skip to content

Commit

Permalink
add example annotations
Browse files Browse the repository at this point in the history
Signed-off-by: Katherine Shen <[email protected]>
  • Loading branch information
shenkw1 committed Nov 5, 2024
1 parent 47cead1 commit 6869d7c
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import org.opensearch.dataprepper.model.annotations.ExampleValues;
import org.opensearch.dataprepper.model.annotations.ExampleValues.Example;

import java.util.List;

Expand All @@ -27,6 +29,9 @@ public class SelectEntriesProcessorConfig {
@JsonPropertyDescription("A <a href=\"https://opensearch.org/docs/latest/data-prepper/pipelines/expression-syntax/\">conditional expression</a>, " +
"such as <code>/some-key == \"test\"</code>, that will be evaluated to determine whether the processor will be " +
"run on the event. Default is <code>null</code>. All events will be processed unless otherwise stated.")
@ExampleValues({
@Example(value = "/some-key == test", description = "Only runs the select_entries processor on the Event if some_key is 'test'.")
})
private String selectWhen;

public List<String> getIncludeKeys() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import jakarta.validation.constraints.Max;
import org.opensearch.dataprepper.model.event.HandleFailedEventsOption;
import org.opensearch.dataprepper.plugins.processor.parse.CommonParseConfig;
import org.opensearch.dataprepper.model.annotations.ExampleValues;
import org.opensearch.dataprepper.model.annotations.ExampleValues.Example;

import java.util.List;
import java.util.Objects;
Expand All @@ -39,6 +41,9 @@ public class ParseIonProcessorConfig implements CommonParseConfig {
@JsonProperty("pointer")
@JsonPropertyDescription("A JSON pointer to the field to be parsed. There is no pointer by default, meaning the entire source is parsed. The pointer can access JSON array indexes as well. " +
"If the JSON pointer is invalid then the entire source data is parsed into the outgoing event. If the key that is pointed to already exists in the event and the destination is the root, then the pointer uses the entire path of the key.")
@ExampleValues({
@Example(value = "/example/pointer", description = "The field at '/example/pointer' in the input data will be parsed if the pointer is valid.")
})
private String pointer;

@JsonProperty(value = "overwrite_if_destination_exists", defaultValue = "true")
Expand All @@ -55,6 +60,9 @@ public class ParseIonProcessorConfig implements CommonParseConfig {

@JsonProperty("parse_when")
@JsonPropertyDescription("A Data Prepper [conditional expression](https://opensearch.org/docs/latest/data-prepper/pipelines/expression-syntax/), such as <code>/some-key == \"test\"</code>, that will be evaluated to determine whether the processor will be run on the event.")
@ExampleValues({
@Example(value = "/some_key == null", description = "Only runs parsing on the Event if some_key is null or doesn't exist.")
})
private String parseWhen;

@JsonProperty(value = "handle_failed_events", defaultValue = "skip")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import jakarta.validation.constraints.Max;
import org.opensearch.dataprepper.model.event.HandleFailedEventsOption;
import org.opensearch.dataprepper.plugins.processor.parse.CommonParseConfig;
import org.opensearch.dataprepper.model.annotations.ExampleValues;
import org.opensearch.dataprepper.model.annotations.ExampleValues.Example;

import java.util.Objects;
import java.util.List;
Expand Down Expand Up @@ -45,6 +47,9 @@ public class ParseJsonProcessorConfig implements CommonParseConfig {
@JsonProperty("pointer")
@JsonPropertyDescription("A JSON pointer to the field to be parsed. There is no pointer by default, meaning the entire source is parsed. The pointer can access JSON array indexes as well. " +
"If the JSON pointer is invalid then the entire source data is parsed into the outgoing event. If the key that is pointed to already exists in the event and the destination is the root, then the pointer uses the entire path of the key.")
@ExampleValues({
@Example(value = "/example/pointer", description = "The field at '/example/pointer' in the input data will be parsed if the pointer is valid.")
})
private String pointer;

@JsonProperty(value = "overwrite_if_destination_exists", defaultValue = "true")
Expand All @@ -62,6 +67,9 @@ public class ParseJsonProcessorConfig implements CommonParseConfig {
@JsonProperty("parse_when")
@JsonPropertyDescription("A <a href=\"https://opensearch.org/docs/latest/data-prepper/pipelines/expression-syntax/\">conditional expression</a> such as <code>/some_key == \"test\"</code>. " +
"If specified, the <code>parse_json</code> processor will only run on events when the expression evaluates to true. ")
@ExampleValues({
@Example(value = "/some_key == null", description = "Only runs parsing on the Event if some_key is null or doesn't exist.")
})
private String parseWhen;

@JsonProperty("handle_failed_events")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import jakarta.validation.constraints.Pattern;
import org.opensearch.dataprepper.model.event.HandleFailedEventsOption;
import org.opensearch.dataprepper.plugins.processor.parse.CommonParseConfig;
import org.opensearch.dataprepper.model.annotations.ExampleValues;
import org.opensearch.dataprepper.model.annotations.ExampleValues.Example;

import java.util.List;
import java.util.Objects;
Expand All @@ -32,6 +34,9 @@ public class ParseXmlProcessorConfig implements CommonParseConfig {
@JsonProperty("pointer")
@JsonPropertyDescription("A JSON pointer to the field to be parsed. There is no pointer by default, meaning the entire source is parsed. The pointer can access JSON array indexes as well. " +
"If the JSON pointer is invalid then the entire source data is parsed into the outgoing event. If the key that is pointed to already exists in the event and the destination is the root, then the pointer uses the entire path of the key.")
@ExampleValues({
@Example(value = "/example/pointer", description = "The field at '/example/pointer' in the input data will be parsed if the pointer is valid.")
})
private String pointer;

@JsonProperty(value = "overwrite_if_destination_exists", defaultValue = "true")
Expand All @@ -45,6 +50,9 @@ public class ParseXmlProcessorConfig implements CommonParseConfig {
@JsonProperty("parse_when")
@JsonPropertyDescription("A <a href=\"https://opensearch.org/docs/latest/data-prepper/pipelines/expression-syntax/\">conditional expression</a> such as <code>/some_key == \"test\"</code>. " +
"If specified, the <code>parse_xml</code> processor will only run on events when the expression evaluates to true. ")
@ExampleValues({
@Example(value = "/some_key == null", description = "Only runs parsing on the Event if some_key is null or doesn't exist.")
})
private String parseWhen;

@JsonProperty("tags_on_failure")
Expand Down

0 comments on commit 6869d7c

Please sign in to comment.