List Collections
Overview
Returns the Purview collections.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
only_names |
bool
|
If True, will return only the actual, friendly, and parent collection names. |
False
|
pprint |
bool
|
If True, will pretty print the collections. If only_names is also True, will pretty print only the names listed in only_names. |
False
|
api_version |
Optional[str]
|
If None, default is "2019-11-01-preview". |
None
|
Returns:
Type | Description |
---|---|
List of dictionaries containing the collection info. If only_names is True, will return a dictionary of only_names items. If pprint is True, will print the values to the screen and nothing is returned. |
Source code in purviewautomation/collections.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
|
Examples
The simpliest code is to print the collections (will provide the most detail)
print(client.list_collections())
Use the pprint (pretty print) parameter to print a cleaner output (print function is not needed)
client.list_collections(pprint=True)
To print only the real name, friendly name, and parent collection names (print function is not needed):
client.list_collections(only_names=True, pprint=True)
To return a list of the collections:
collections = client.list_collections()
for coll in collections:
print(coll)
To return a dictionary of the real, friendly, and parent collection names (real name is the key and friendly/parent collections are the values):
collection_names = client.list_collections(only_names=True)
for name, value in collection_names.items():
print(name, value)
# Return just the keys (real names)
for name in collection_names:
print(name)
# Return just the friendly names or just the parent collection names
for name in collection_names.values():
friendly_name = name["friendlyName"]
parent_name = name["parentCollection"]