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

Function main

parametermanager/renderParamVersion.js:26–74  ·  view source on GitHub ↗

* Retrieves and renders the details of a specific version of an * existing parameter in the global location of 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} para

(projectId, parameterId, parameterVersionId)

Source from the content-addressed store, hash-verified

24 * @param {string} parameterVersionId - The ID of the parameter version to be rendered or an alias (e.g. 'latest').
25 */
26async function main(projectId, parameterId, parameterVersionId) {
27 // [START parametermanager_render_param_version]
28 /**
29 * TODO(developer): Uncomment these variables before running the sample.
30 */
31 // const projectId = 'YOUR_PROJECT_ID';
32 // const parameterId = 'YOUR_PARAMETER_ID';
33 // const parameterVersionId = 'YOUR_PARAMETER_VERSION_ID';
34 // const parameterVersionId = 'latest';
35
36 // Imports the Parameter Manager library
37 const {ParameterManagerClient} = require('@google-cloud/parametermanager');
38
39 // Instantiates a client
40 const client = new ParameterManagerClient();
41
42 async function renderParamVersion() {
43 // Construct the parameter version name
44 const name = client.parameterVersionPath(
45 projectId,
46 'global',
47 parameterId,
48 parameterVersionId
49 );
50
51 // Construct the request
52 const request = {
53 name: name,
54 };
55
56 // Render the parameter version
57 const [parameterVersion] = await client.renderParameterVersion(request);
58 console.log(
59 `Rendered parameter version: ${parameterVersion.parameterVersion}`
60 );
61
62 // If the parameter contains secret references, they will be resolved
63 // and the actual secret values will be included in the rendered output.
64 // Be cautious with logging or displaying this information.
65 console.log(
66 'Rendered payload: ',
67 parameterVersion.renderedPayload.toString('utf-8')
68 );
69 return parameterVersion;
70 }
71
72 return await renderParamVersion();
73 // [END parametermanager_render_param_version]
74}
75module.exports.main = main;
76
77/* c8 ignore next 10 */

Callers 1

Calls 1

renderParamVersionFunction · 0.85

Tested by

no test coverage detected