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

Function main

parametermanager/getParamVersion.js:25–68  ·  view source on GitHub ↗

* Retrieves the details of a specific version of an existing parameter in the specified * project using the Google Cloud Parameter Manager SDK. * * @param {string} projectId - The Google Cloud project ID where the parameter is located. * @param {string} parameterId - The ID of the parameter for

(projectId, parameterId, versionId)

Source from the content-addressed store, hash-verified

23 * @param {string} versionId - The version ID of the parameter to retrieve.
24 */
25async function main(projectId, parameterId, versionId) {
26 // [START parametermanager_get_param_version]
27 /**
28 * TODO(developer): Uncomment these variables before running the sample.
29 */
30 // const projectId = 'my-project';
31 // const parameterId = 'my-parameter';
32 // const versionId = 'v1';
33
34 // Imports the Parameter Manager library
35 const {ParameterManagerClient} = require('@google-cloud/parametermanager');
36
37 // Instantiates a client
38 const client = new ParameterManagerClient();
39
40 async function getParamVersion() {
41 // Construct the fully qualified parameter version name
42 const name = client.parameterVersionPath(
43 projectId,
44 'global',
45 parameterId,
46 versionId
47 );
48
49 // Get the parameter version
50 const [parameterVersion] = await client.getParameterVersion({
51 name: name,
52 });
53 // Find more details for the Parameter Version object here:
54 // https://cloud.google.com/secret-manager/parameter-manager/docs/reference/rest/v1/projects.locations.parameters.versions#ParameterVersion
55 console.log(
56 `Found parameter version ${parameterVersion.name} with state ${parameterVersion.disabled ? 'disabled' : 'enabled'}`
57 );
58 if (!parameterVersion.disabled) {
59 console.log(
60 `Payload: ${parameterVersion.payload.data.toString('utf-8')}`
61 );
62 }
63 return parameterVersion;
64 }
65
66 return await getParamVersion();
67 // [END parametermanager_get_param_version]
68}
69module.exports.main = main;
70
71/* c8 ignore next 10 */

Callers 1

getParamVersion.jsFile · 0.70

Calls 1

getParamVersionFunction · 0.85

Tested by

no test coverage detected