Group assets

Demonstrates how to group assets by attributes

Code sample

Python

from google.cloud import securitycenter

client = securitycenter.SecurityCenterClient()

# organization_id is the numeric ID of the organization.
# organization_id = "1234567777"
org_name = "organizations/{org_id}".format(org_id=organization_id)

group_by_type = "security_center_properties.resource_type"

result_iterator = client.group_assets(
    request={"parent": org_name, "group_by": group_by_type}
)
for i, result in enumerate(result_iterator):
    print((i + 1), result)

What's next

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