PPA Tools: Dictionaries
Summary
This module contains actions used to process dictionaries.
Actions
ppa_tools.dictionaries.
create
Create a new dictionary using any number of keys & values.
Minimum Plugin Version: 3.4.0
Input
This action accepts any keys & values the new dictionary should contain.
Validation
Given this action accepts any inputs you supply, PPA cannot perform accurate validation in the Playbook editor.
Output
A dictionary containing the supplied keys & values.
Example
Creating a new dictionary called connection_info
using both static values & variables:
1 2 3 4 5 6 7 8 |
|
ppa_tools.dictionaries.
filter_from_list
Remove dictionaries from a list by testing the values of one or more keys.
A dictionary will be filtered if any of its keys match any filter.
Minimum Plugin Version: 3.1.0
Input
-
dictionaries: a list of dictionaries to filter
-
filters: a list of Filter dictionaries
Output
A list of dictionaries from dictionaries
whose keys matched no filters.
Case Sensitivity
As of plugin version 5.1.0 all text filters will be case-insensitive.
Example
-
Getting all users from Active Directory & saving them as
all_users
-
Filtering out users whose mail attribute is
null
or sAMAccountName containsadmin
-
Saving the filtered users as
filtered_users
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
ppa_tools.dictionaries.
find_in_list
Extract dictionaries from a list by testing the values of one or more keys.
A dictionary will be found if any of its keys match any filter.
Minimum Plugin Version: 6.1.0
Input
-
dictionaries: a list of dictionaries to filter
-
filters: a list of Filter dictionaries
Output
A list of dictionaries from dictionaries
whose keys matched at least one filter.
Case Sensitivity
As of plugin version 5.1.0 all text filters will be case-insensitive.
Example
-
Getting all users from Active Directory & saving them as
all_users
-
Finding users whose mail attribute is
null
-
Saving the found users as
users_without_email
1 2 3 4 5 6 7 8 9 10 11 |
|
ppa_tools.dictionaries.
get
Get the value of the supplied key from a dictionary.
If the key is missing from the dictionary this action will fail.
Minimum Plugin Version: 5.5.0
Input
-
dictionary: a dictionary to get the value from
-
key: the key to get from the dictionary
-
display_error: denotes whether an error mesage is shown when key does not exist (defaults to
true
)
Output
The value of the key inside the dictionary.
Example
1 2 3 4 5 6 7 8 9 10 |
|
ppa_tools.dictionaries.
get_key_values
Get the value of the supplied key from each supplied dictionary.
If the key is missing from any dictionaries its value will be null.
Minimum Plugin Version: 3.7.0
Input
-
dictionaries: a list of dictionaries to get the values from
-
key: the key to get from each dictionary
Output
A list of values retrieved from each dictionary using the supplied key.
Ordering
The order of the dictionaries is honoured when getting the values.
This means the first value in the outputted list will be from the first dictionary, etc.
Example
Extracting the sAMAccountName from each Active Directory user in a list:
1 2 3 4 5 6 7 8 9 10 |
|
ppa_tools.dictionaries.
insert
Add a new key & value to a dictionary.
Minimum Plugin Version: 3.0.0
Input
-
name: the name of the new key
-
value: the value of the new key
-
dictionary: the dictionary to add the key to
Output
The original dictionary with the new key & value inserted.
Example
Adding a value supplied by the Task Operator to a secrets dictionary:
1 2 3 4 5 6 |
|
ppa_tools.dictionaries.
keys
Get a list of all keys present in the supplied dictionary.
Minimum Plugin Version: 8.3.0
Input
- dictionary: a dictionary to get the keys from
Output
A list of keys from the dictionary.
Example
1 2 3 4 5 6 |
|
The new keys
variable will contain:
1 2 3 |
|
ppa_tools.dictionaries.
merge
Merge two dictionaries into a new dictionary.
Minimum Plugin Version: 3.0.0
Input
-
first: a dictionary to merge with
second
-
second: a dictionary to merge with
first
Output
A new dictionary containing the keys & values of from first
& second
.
Duplicate Keys
This action will fail if any keys appear in both first
& second
.
Example
Merging two dictionaries to create a single dictionary containing connection details:
1 2 3 4 5 6 7 8 |
|
The new connection_details
variable will contain:
1 2 3 4 |
|
ppa_tools.dictionaries.
remove_duplicates
Remove all duplicate dictionaries from a list.
Rather than checking each key in every dictionary, the value of the supplied key is used.
Minimum Plugin Version: 5.2.0
Input
-
items: a list of dictionaries
-
key: a key present in every dictionary whose value should be used to check for uniqueness
Output
A new copy of items
with any duplicate values removed.
Example
-
Auditing users from 2 Security Groups in Active Directory & combining them into a single list
-
Using the sAMAcccountName key to remove duplicate users from the combined list
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
|
ppa_tools.dictionaries.
values
Get a list of all values present in the supplied dictionary.
Minimum Plugin Version: 8.3.0
Input
- dictionary: a dictionary to get the keys from
Output
A list of values from the dictionary.
Example
1 2 3 4 5 6 |
|
The new values
variable will contain:
1 2 3 |
|