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

Function main

parametermanager/removeParamKmsKey.js:23–55  ·  view source on GitHub ↗

* Removes a kms_key for global parameter using the Parameter Manager SDK. * * @param {string} projectId - The Google Cloud project ID where the parameter is to be updated. * @param {string} parameterId - The ID of the parameter to update. This ID must be unique within the project.

(projectId, parameterId)

Source from the content-addressed store, hash-verified

21 * @param {string} parameterId - The ID of the parameter to update. This ID must be unique within the project.
22 */
23async function main(projectId, parameterId) {
24 // [START parametermanager_remove_param_kms_key]
25 /**
26 * TODO(developer): Uncomment these variables before running the sample.
27 */
28 // const projectId = 'YOUR_PROJECT_ID';
29 // const parameterId = 'YOUR_PARAMETER_ID';
30
31 // Imports the Parameter Manager library
32 const {ParameterManagerClient} = require('@google-cloud/parametermanager');
33
34 // Instantiates a client
35 const client = new ParameterManagerClient();
36
37 async function removeParamKmsKey() {
38 const name = client.parameterPath(projectId, 'global', parameterId);
39 const request = {
40 parameter: {
41 name: name,
42 },
43 updateMask: {
44 paths: ['kms_key'],
45 },
46 };
47
48 const [parameter] = await client.updateParameter(request);
49 console.log(`Removed kms_key for parameter ${parameter.name}`);
50 return parameter;
51 }
52
53 return await removeParamKmsKey();
54 // [END parametermanager_remove_param_kms_key]
55}
56module.exports.main = main;
57
58/* c8 ignore next 10 */

Callers 1

Calls 1

removeParamKmsKeyFunction · 0.85

Tested by

no test coverage detected