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

Function main

parametermanager/enableParamVersion.js:26–72  ·  view source on GitHub ↗

* Enables a specific version of a parameter in Google Cloud Parameter Manager. * This function demonstrates how to enable a parameter version by setting * its 'disabled' field to false using the Parameter Manager client library. * * @param {string} projectId - The Google Cloud project ID where t

(projectId, parameterId, versionId)

Source from the content-addressed store, hash-verified

24 * @param {string} versionId - The version ID of the parameter to be enabled.
25 */
26async function main(projectId, parameterId, versionId) {
27 // [START parametermanager_enable_param_version]
28 /**
29 * TODO(developer): Uncomment these variables before running the sample.
30 */
31 // const projectId = 'my-project';
32 // const parameterId = 'my-parameter';
33 // const versionId = 'v1';
34
35 // Imports the Parameter Manager library
36 const {ParameterManagerClient} = require('@google-cloud/parametermanager');
37
38 // Instantiates a client
39 const client = new ParameterManagerClient();
40
41 async function enableParamVersion() {
42 // Construct the full resource name
43 const name = client.parameterVersionPath(
44 projectId,
45 'global',
46 parameterId,
47 versionId
48 );
49
50 // Construct the request
51 const request = {
52 parameterVersion: {
53 name: name,
54 disabled: false,
55 },
56 updateMask: {
57 paths: ['disabled'],
58 },
59 };
60
61 // Make the API call to update the parameter version
62 const [parameterVersion] = await client.updateParameterVersion(request);
63
64 console.log(
65 `Enabled parameter version ${parameterVersion.name} for parameter ${parameterId}`
66 );
67 return parameterVersion;
68 }
69
70 return await enableParamVersion();
71 // [END parametermanager_enable_param_version]
72}
73module.exports.main = main;
74
75/* c8 ignore next 10 */

Callers 1

Calls 1

enableParamVersionFunction · 0.85

Tested by

no test coverage detected