Group findings by state

Stay organized with collections Save and categorize content based on your preferences.

Demonstrates how to group findings by state change

Code sample


from datetime import timedelta

from import securitycenter

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

# source_name is the resource path for a source that has been
# created previously (you can use list_sources to find a specific one).
# Its format is:
# source_name = "organizations/{organization_id}/sources/{source_id}"
# e.g.:
# source_name = "organizations/111122222444/sources/1234"

# List assets and their state change the last 30 days
compare_delta = timedelta(days=30)

group_result_iterator = client.group_findings(
        "parent": source_name,
        "group_by": "state_change",
        "compare_duration": compare_delta,
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.