// Imports the Google Cloud client library.
const {SecurityCenterClient} = require('@google-cloud/security-center');
// Creates a new client.
const client = new SecurityCenterClient();
// organizationId is the numeric ID of the organization.
/*
* TODO(developer): Uncomment the following lines
*/
// const organizationId = "1234567777";
const orgName = client.organizationPath(organizationId);
// Call the API with automatic pagination.
async function listAssetsWithSecurityMarks() {
const [response] = await client.listAssets({
parent: orgName,
filter: 'security_marks.marks.key_a="value_a"',
});
let count = 0;
Array.from(response).forEach(result =>
console.log(
`${++count} ${result.asset.name} ${
result.asset.securityCenterProperties.resourceName
}`
)
);
}
listAssetsWithSecurityMarks();
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)
marks_filter = 'security_marks.marks.key_a = "value_a"'
# Call the API and print results.
asset_iterator = client.list_assets(
request={"parent": org_name, "filter": marks_filter}
)
# Call the API and print results.
asset_iterator = client.list_assets(
request={"parent": org_name, "filter": marks_filter}
)
for i, asset_result in enumerate(asset_iterator):
print(i, asset_result)