Group assets with filter

Demonstrates how to filter and group assets by type

Code sample


from 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"
only_projects = (
    + '""'
result_iterator = client.group_assets(
    request={"parent": org_name, "group_by": group_by_type, "filter": only_projects}
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.