-
Notifications
You must be signed in to change notification settings - Fork 202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds example annotations to a handful of processors #5140
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,8 @@ | |
import com.fasterxml.jackson.annotation.JsonPropertyOrder; | ||
import jakarta.validation.constraints.AssertTrue; | ||
import jakarta.validation.constraints.NotBlank; | ||
import org.opensearch.dataprepper.model.annotations.ExampleValues; | ||
import org.opensearch.dataprepper.model.annotations.ExampleValues.Example; | ||
|
||
import java.util.List; | ||
|
||
|
@@ -61,11 +63,17 @@ public class CsvProcessorConfig { | |
"the header in <code>column_names_source_key</code> generates the event fields. If too few columns are specified " + | ||
"in this field, the remaining column names are automatically generated. " + | ||
"If too many column names are specified in this field, the CSV processor omits the extra column names.") | ||
@ExampleValues({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This fits in the category of source examples which I don't see as adding a whole lot of value. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think for the list values like this, the example is helpful. This makes it clear what to input even though the resulting config is a list and the description shows a full List |
||
@Example(value = "column_one", description = "Specifies column_one as one of the column names to create") | ||
}) | ||
private List<String> columnNames; | ||
|
||
@JsonProperty("csv_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>csv</code> processor will only run on events when the expression evaluates to true. ") | ||
@ExampleValues({ | ||
@Example(value = "/some_key == null", description = "Only runs the csv processor if the key some_key is null or does not exist.") | ||
}) | ||
private String csvWhen; | ||
|
||
@JsonPropertyDescription("If true, the configured source field will be deleted after the CSV data is parsed into separate fields.") | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,8 @@ | |
import org.opensearch.dataprepper.model.annotations.ConditionalRequired; | ||
import org.opensearch.dataprepper.model.annotations.ConditionalRequired.IfThenElse; | ||
import org.opensearch.dataprepper.model.annotations.ConditionalRequired.SchemaProperty; | ||
import org.opensearch.dataprepper.model.annotations.ExampleValues; | ||
import org.opensearch.dataprepper.model.annotations.ExampleValues.Example; | ||
|
||
import java.util.List; | ||
import java.util.stream.Stream; | ||
|
@@ -68,6 +70,11 @@ public static class Entry { | |
@AlsoRequired(values = { | ||
@AlsoRequired.Required(name=METADATA_KEY_KEY, allowedValues = {"null"}) | ||
}) | ||
@ExampleValues({ | ||
@Example(value = "my_key", description = "Adds 'my_key' to the Event"), | ||
@Example(value = "${/key_one}-${/key_two}", description = "Evaluates existing Event keys key_one and key_two and adds the result to the Event"), | ||
@Example(value = "/nested/key", description = "Adds a nested key of { \"nested\": { \"key\": \"some_value\" }"), | ||
}) | ||
private String key; | ||
|
||
@JsonProperty(METADATA_KEY_KEY) | ||
|
@@ -76,6 +83,9 @@ public static class Entry { | |
@AlsoRequired(values = { | ||
@AlsoRequired.Required(name="key", allowedValues = {"null"}) | ||
}) | ||
@ExampleValues({ | ||
@Example(value = "some_metadata", description = "The Event will contain a metadata key called 'some_metadata' that can be used in expressions with sending the key to the sinks.") | ||
}) | ||
private String metadataKey; | ||
|
||
@JsonPropertyDescription("The value of the new entry to be added, which can be used with any of the " + | ||
|
@@ -84,6 +94,12 @@ public static class Entry { | |
@AlsoRequired.Required(name="format", allowedValues = {"null"}), | ||
@AlsoRequired.Required(name=VALUE_EXPRESSION_KEY, allowedValues = {"null"}) | ||
}) | ||
@ExampleValues({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps include a number as well. |
||
@Example(value = "my_string_value", description = "Adds a value of 'my_string_value' to the key or metadata_key"), | ||
@Example(value = "false", description = "Adds a value of false to the key or metadata_key"), | ||
@Example(value = "10", description = "Adds a value of 10 to the key or metadata_key"), | ||
@Example(value = "[ \"element_one\", \"element_two\" ]", description = "Adds an array value with two elements to the key or metadata_key"), | ||
}) | ||
private Object value; | ||
|
||
@JsonPropertyDescription("A format string to use as the value of the new entry, for example, " + | ||
|
@@ -93,6 +109,9 @@ public static class Entry { | |
@AlsoRequired.Required(name="value", allowedValues = {"null"}), | ||
@AlsoRequired.Required(name=VALUE_EXPRESSION_KEY, allowedValues = {"null"}) | ||
}) | ||
@ExampleValues({ | ||
@Example(value = "${/key_one}-${/key_two}", description = "Adds a value as a combination of the existing key_one and key_two values to the key or metadata_key"), | ||
}) | ||
private String format; | ||
|
||
@JsonProperty(VALUE_EXPRESSION_KEY) | ||
|
@@ -105,6 +124,10 @@ public static class Entry { | |
@AlsoRequired.Required(name="value", allowedValues = {"null"}), | ||
@AlsoRequired.Required(name="format", allowedValues = {"null"}) | ||
}) | ||
@ExampleValues({ | ||
@Example(value = "length(/my_key)", description = "Adds an integer value based on the length of the existing key 'my_key' to the new key or metadata_key"), | ||
@Example(value = "/my_key", description = "Adds a value based on the existing value of my_key to the new key or metadata_key"), | ||
}) | ||
private String valueExpression; | ||
|
||
@JsonProperty(OVERWRITE_IF_KEY_EXISTS_KEY) | ||
|
@@ -126,6 +149,9 @@ public static class Entry { | |
@JsonProperty("add_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>, that will be evaluated to determine whether the processor will be run on the event.") | ||
@ExampleValues({ | ||
@Example(value = "/some_key == null", description = "Only runs the add_entries processor if the key some_key is null or does not exist.") | ||
}) | ||
private String addWhen; | ||
|
||
public String getKey() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we don't need an example here since this is just a key.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here. I think for lists it doesn't hurt to have a placeholder value