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

Function main

kms/quickstart.js:17–48  ·  view source on GitHub ↗
(projectId = 'my-project', locationId = 'us-east1')

Source from the content-addressed store, hash-verified

15'use strict';
16
17async function main(projectId = 'my-project', locationId = 'us-east1') {
18 // [START kms_quickstart]
19 //
20 // TODO(developer): Uncomment these variables before running the sample.
21 //
22 // const projectId = 'my-project';
23 // const locationId = 'us-east1';
24
25 // Imports the Cloud KMS library
26 const {KeyManagementServiceClient} = require('@google-cloud/kms');
27
28 // Instantiates a client
29 const client = new KeyManagementServiceClient();
30
31 // Build the location name
32 const locationName = client.locationPath(projectId, locationId);
33
34 async function listKeyRings() {
35 const [keyRings] = await client.listKeyRings({
36 parent: locationName,
37 });
38
39 for (const keyRing of keyRings) {
40 console.log(keyRing.name);
41 }
42
43 return keyRings;
44 }
45
46 return listKeyRings();
47 // [END kms_quickstart]
48}
49module.exports.main = main;
50
51/* c8 ignore next 10 */

Callers 1

quickstart.jsFile · 0.70

Calls 1

listKeyRingsFunction · 0.85

Tested by

no test coverage detected