MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/nodejs-docs-samples / main

Function main

container-analysis/snippets/createNote.js:21–57  ·  view source on GitHub ↗
(
  projectId = 'your-project-id', // Your GCP Project ID
  noteId = 'my-note-id' // Id of the note
)

Source from the content-addressed store, hash-verified

19// description: Creates a Note with specified ID
20// usage: node createNote.js "project-id" "note-id"
21async function main(
22 projectId = 'your-project-id', // Your GCP Project ID
23 noteId = 'my-note-id' // Id of the note
24) {
25 // [START containeranalysis_create_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 // Construct request
37 // Associate the Note with a metadata type
38 // https://cloud.google.com/container-registry/docs/container-analysis#supported_metadata_types
39 // Here, we use the type "vulnerabiltity"
40 const formattedParent = client.getGrafeasClient().projectPath(projectId);
41
42 // Creates and returns a new Note
43 const [note] = await client.getGrafeasClient().createNote({
44 parent: formattedParent,
45 noteId: noteId,
46 note: {
47 attestation: {
48 hint: {
49 humanReadableName: 'my-attestation-authority',
50 },
51 },
52 },
53 });
54
55 console.log(`Note ${note.name} created.`);
56 // [END containeranalysis_create_note]
57}
58
59main(...process.argv.slice(2));

Callers 1

createNote.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected