| 19 | // description: Retrieves and prints a specified note |
| 20 | // usage: node getNote.js "project-id" "note-id" |
| 21 | async function main( |
| 22 | projectId = 'your-project-id', // Your GCP Project ID |
| 23 | noteId = 'my-note-id' // Id of the note |
| 24 | ) { |
| 25 | // [START containeranalysis_get_note] |
| 26 | /** |
| 27 | * TODO(developer): Uncomment these variables before running the sample |
| 28 | */ |
| 29 | // const projectId = 'your-project-id', // Your GCP Project ID |
| 30 | // const noteId = 'my-note-id' // Id of the note |
| 31 | |
| 32 | // Import the library and create a client |
| 33 | const {ContainerAnalysisClient} = require('@google-cloud/containeranalysis'); |
| 34 | const client = new ContainerAnalysisClient(); |
| 35 | |
| 36 | // Get the full path to the note |
| 37 | const formattedName = client.notePath(projectId, noteId); |
| 38 | // Retrieve the specified note |
| 39 | const [note] = await client.getGrafeasClient().getNote({name: formattedName}); |
| 40 | |
| 41 | console.log(`Note name: ${note.name}`); |
| 42 | // [END containeranalysis_get_note] |
| 43 | } |
| 44 | |
| 45 | main(...process.argv.slice(2)); |