Demonstrates how to group assets by state change

## Code sample

### Python


To authenticate to Security Command Center, set up Application Default Credentials.
For more information, see

[Set up authentication for a local development environment](https://docs.cloud.google.com/docs/authentication/set-up-adc-local-dev-environment.md.txt).

```python
from datetime import timedelta

from google.cloud import securitycenter

client = securitycenter.SecurityCenterClient()

duration = timedelta(days=5)

# 'parent' must be in one of the following formats:
#   "organizations/{organization_id}"
#   "projects/{project_id}"
#   "folders/{folder_id}"
parent = f"organizations/{organization_id}"
result_iterator = client.group_assets(
    request={
        "parent": parent,
        "group_by": "state_change",
        "compare_duration": duration,
    }
)
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](https://docs.cloud.google.com/docs/samples.md.txt?product=securitycommandcenter).