All Security Command Center code samples

This page contains code samples for Security Command Center. To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser.

Add security marks to assets

Demonstrates adding security marks to assets

Add security marks to findings

Demonstrates adding security marks to findings

Adding and deleting security marks

Demonstrates adding and deleting security marks in the same request

Create a finding

Demonstrates how to create a new finding

Create a finding with source properties

Demonstrates how to create a new security finding that includes additional metadata via sourceProperties

Create a NotificationConfig

Demonstrates how to create a NotificationConfig

Create a security source

Demonstrates how to create a security source

Delete a NotificationConfig

Demonstrates how to delete a NotificationConfig

Delete security marks

Demonstrates how to delete security marks

Enable asset discovery

Demonstrates how to enable or disable asset discovery

Get a NotificationConfig

Demonstrates how to retrieve NotificationConfigs

Get a source

Demonstrates how to retrieve a specific source

Get IAM policies

Demonstrates how to retrieve IAM policies for a source

Get organization settings

Demonstrates how to retrieve organization settings configurations

Group assets

Demonstrates how to group assets by attributes

Group assets by state

Demonstrates how to group assets by state change

Group assets by state

Demonstrates how to group assets by state change

Group assets with filter

Demonstrates how to filter and group assets by type

Group findings

Demonstrates how to group findings by properties

Group findings

Demonstrates how to group active findings by source

Group findings by source

Demonstrates how to group findings by security source

Group findings by state

Demonstrates how to group findings by state change

Group findings by state change

Demonstrates how to group active findings by state change

Group findings by time

Demonstrates how to group findings for specific points in time

Group findings by time

Demonstrates how to group active findings for specific points in time

Group findings with filter

Demonstrates how to filter and group findings by properties

List assets

Demonstrates how to list all assets in an organization

List assets by time

Demonstrates how to list assets for specific points in time

List assets with filter

Demonstrates how to filter and list assets by project

List assets with security marks

Demonstrates how to filter and list assets by security mark

List assets with state change

Demonstrates how to list assets with state changes

List findings

Demonstrates how to list all findings in an organization

List findings by time

Demonstrates how to list findings for specific points in time

List findings with filter

Demonstrates how to filter and list findings by category

List findings with security marks

Demonstrates how to filter and list findings by security mark

List NotificationConfigs

Demonstrates how to list NotificationConfigs

List security sources

Demonstrates how to list all security sources in an organization

Receive notifications

Demonstrates how to convert a Pub/Sub message into a notification message

Run asset discovery

Demonstrates how to start an asset discovery scan

Set IAM policies

Demonstrates how to set IAM policies on a source

Test IAM permissions

Demonstrates how to verify IAM permissions to create findings

Update a NotificationConfig

Demonstrates how to update a NotificationConfig

Update a source

Demonstrates how to update a source

Update finding source properties

Demonstrates how to update source properties for a finding

Update finding state

Demonstrates how to update a finding's state