()
| 16 | |
| 17 | // Demonstrates how to create a security source. |
| 18 | async function main() { |
| 19 | // [START securitycenter_create_source_v2] |
| 20 | // Import the Google Cloud client library. |
| 21 | const {SecurityCenterClient} = require('@google-cloud/security-center').v2; |
| 22 | |
| 23 | // Create a new Security Center client |
| 24 | const client = new SecurityCenterClient(); |
| 25 | |
| 26 | // TODO(developer): Update for your own environment. |
| 27 | const organizationId = '1081635000895'; |
| 28 | |
| 29 | // Resource name of the new source's parent. Format is: |
| 30 | // "organizations/[organization_id]". |
| 31 | const parent = client.organizationPath(organizationId); |
| 32 | |
| 33 | // The source object. |
| 34 | const source = { |
| 35 | displayName: 'Customized Display Name V2', |
| 36 | description: 'A new custom source that does X', |
| 37 | }; |
| 38 | |
| 39 | // Build the create source request. |
| 40 | const createSourceRequest = { |
| 41 | parent, |
| 42 | source, |
| 43 | }; |
| 44 | |
| 45 | // The source is not visible in the Security Command Center dashboard |
| 46 | // until it generates findings. |
| 47 | // Call the API |
| 48 | async function createSource() { |
| 49 | const [source] = await client.createSource(createSourceRequest); |
| 50 | console.log('New Source created: %j', source); |
| 51 | } |
| 52 | |
| 53 | await createSource(); |
| 54 | // [END securitycenter_create_source_v2] |
| 55 | } |
| 56 | |
| 57 | main().catch(err => { |
| 58 | console.error(err); |
no test coverage detected