pick
pick is a DTL operation that keeps only specific keys in a mapping and removes
the rest.
Use it when a mapping should be reduced to an allowlist.
YOp
- pick:
path: user
keys: [name, email]
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
path | string | yes | Path to the mapping to filter. |
keys | sequence of strings | yes | Keys to keep. Missing keys are ignored. |
Behavior
- Requires the target path to exist.
- Requires the target to be a mapping.
- Removes keys that are not listed.
- Ignores listed keys that do not exist.
Errors
| Error | Meaning |
|---|---|
PATH_NOT_FOUND | Target path does not exist. |
NOT_A_MAPPING | Target is not a mapping. |
Example
yops:
- pick:
path: config
keys: [host, port]
Input:
config:
host: localhost
port: 5432
secret: abc
Output:
config:
host: localhost
port: 5432