(queryId, description)
| 19 | // description: Create SavedQuery. |
| 20 | |
| 21 | async function main(queryId, description) { |
| 22 | // [START asset_quickstart_create_saved_query] |
| 23 | const {AssetServiceClient} = require('@google-cloud/asset'); |
| 24 | |
| 25 | const client = new AssetServiceClient(); |
| 26 | |
| 27 | // example inputs: |
| 28 | // const queryId = 'my-query-id'; |
| 29 | // const description = 'description'; |
| 30 | async function createSavedQuery() { |
| 31 | const projectId = await client.getProjectId(); |
| 32 | const parent = `projects/${projectId}`; |
| 33 | const request = { |
| 34 | parent: parent, |
| 35 | savedQueryId: queryId, |
| 36 | savedQuery: { |
| 37 | content: { |
| 38 | iamPolicyAnalysisQuery: { |
| 39 | scope: parent, |
| 40 | accessSelector: { |
| 41 | permissions: ['iam.serviceAccounts.actAs'], |
| 42 | }, |
| 43 | }, |
| 44 | }, |
| 45 | description: description, |
| 46 | }, |
| 47 | }; |
| 48 | const [query] = await client.createSavedQuery(request); |
| 49 | // Handle the operation using the promise pattern. |
| 50 | console.log('Query name:', query.name); |
| 51 | console.log('Query description:', query.description); |
| 52 | console.log('Created time:', query.createTime); |
| 53 | console.log('Updated time:', query.lastUpdateTime); |
| 54 | console.log('Query type:', query.content.queryContent); |
| 55 | console.log('Query content:', JSON.stringify(query.content, null, 4)); |
| 56 | // [END asset_quickstart_create_saved_query] |
| 57 | } |
| 58 | await createSavedQuery(); |
| 59 | } |
| 60 | |
| 61 | exports.createSavedQuery = main; |
nothing calls this directly
no test coverage detected