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

Function main

kms/updateKeyUpdateLabels.js:17–61  ·  view source on GitHub ↗
(
  projectId = 'my-project',
  locationId = 'us-east1',
  keyRingId = 'my-key-ring',
  keyId = 'my-key'
)

Source from the content-addressed store, hash-verified

15'use strict';
16
17async function main(
18 projectId = 'my-project',
19 locationId = 'us-east1',
20 keyRingId = 'my-key-ring',
21 keyId = 'my-key'
22) {
23 // [START kms_update_key_update_labels]
24 //
25 // TODO(developer): Uncomment these variables before running the sample.
26 //
27 // const projectId = 'my-project';
28 // const locationId = 'us-east1';
29 // const keyRingId = 'my-key-ring';
30 // const keyId = 'my-key';
31 // const versionId = '123';
32
33 // Imports the Cloud KMS library
34 const {KeyManagementServiceClient} = require('@google-cloud/kms');
35
36 // Instantiates a client
37 const client = new KeyManagementServiceClient();
38
39 // Build the key name
40 const keyName = client.cryptoKeyPath(projectId, locationId, keyRingId, keyId);
41
42 async function updateKeyUpdateLabels() {
43 const [key] = await client.updateCryptoKey({
44 cryptoKey: {
45 name: keyName,
46 labels: {
47 new_label: 'new_value',
48 },
49 },
50 updateMask: {
51 paths: ['labels'],
52 },
53 });
54
55 console.log(`Updated labels for: ${key.name}`);
56 return key;
57 }
58
59 return updateKeyUpdateLabels();
60 // [END kms_update_key_update_labels]
61}
62module.exports.main = main;
63
64/* c8 ignore next 10 */

Callers 1

Calls 1

updateKeyUpdateLabelsFunction · 0.85

Tested by

no test coverage detected