Group findings

Demonstrates how to group findings by properties

Code sample


from import securitycenter

# Create a client.
client = securitycenter.SecurityCenterClient()

# organization_id is the numeric ID of the organization. e.g.:
# organization_id = "111122222444"
org_name = "organizations/{org_id}".format(org_id=organization_id)
# The "sources/-" suffix lists findings across all sources.  You
# also use a specific source_name instead.
all_sources = "{org_name}/sources/-".format(org_name=org_name)
group_result_iterator = client.group_findings(
    request={"parent": all_sources, "group_by": "category"}
for i, group_result in enumerate(group_result_iterator):
    print((i + 1), group_result)

What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser.