-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add select_fields_from_objects_in_list action, use in kandji_de…
…vice_information workflow
- Loading branch information
1 parent
bfa2adb
commit 2ee0d58
Showing
4 changed files
with
79 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -545,3 +545,42 @@ employee_departments = join_lists( | |
# } | ||
# ] | ||
``` | ||
|
||
## Select Fields from Objects in List | ||
|
||
Extract specific fields from each object in a list. For each object in the input list, create a new object containing only the specified fields. If a field doesn't exist in an object, | ||
that entry will raise a KeyError. The field names must exactly match the keys in the objects. | ||
|
||
Example field selections: | ||
|
||
``` | ||
["name", "email"] - extracts just the name and email fields | ||
["id", "created_at", "status"] - extracts multiple top-level fields | ||
``` | ||
| Parameter | Type | Description | Required/Optional | | ||
| ------------ | ---- | ------------------------------------------------ | ----------------- | | ||
| `input_list` | list | The list of JSON objects to extract fields from. | Required | | ||
| `fields` | list | The field names to select from each object. | Required | | ||
Usage Examples: | ||
```python | ||
# Given a list of user objects with multiple fields | ||
users = [ | ||
{"id": 1, "name": "John", "email": "[email protected]", "role": "admin"}, | ||
{"id": 2, "name": "Jane", "email": "[email protected]", "role": "user"} | ||
] | ||
# Extract just the name and email fields | ||
simplified_users = select_fields_from_objects_in_list( | ||
input_list=users, | ||
fields=["name", "email"] | ||
) | ||
# Result: | ||
# [ | ||
# {"name": "John", "email": "[email protected]"}, | ||
# {"name": "Jane", "email": "[email protected]"} | ||
# ] | ||
``` |
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