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

Function main

parametermanager/listParamVersions.js:25–60  ·  view source on GitHub ↗

* * Lists all versions 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 parameter is located. * @param {string} parameterId - The parameter ID for which vers

(projectId, parameterId)

Source from the content-addressed store, hash-verified

23 * @param {string} parameterId - The parameter ID for which versions are to be listed.
24 */
25async function main(projectId, parameterId) {
26 // [START parametermanager_list_param_versions]
27 /**
28 * TODO(developer): Uncomment these variables before running the sample.
29 */
30 // const projectId = 'my-project';
31 // const parameterId = 'my-parameter';
32
33 // Imports the Parameter Manager library
34 const {ParameterManagerClient} = require('@google-cloud/parametermanager');
35
36 // Instantiates a client
37 const client = new ParameterManagerClient();
38
39 async function listParamVersions() {
40 // Construct the parent string for listing parameter versions globally
41 const parent = client.parameterPath(projectId, 'global', parameterId);
42
43 const request = {
44 parent: parent,
45 };
46
47 // Use listParameterVersionsAsync to handle pagination automatically
48 const parameterVersions = await client.listParameterVersionsAsync(request);
49
50 for await (const version of parameterVersions) {
51 console.log(
52 `Found parameter version ${version.name} with state ${version.disabled ? 'disabled' : 'enabled'}`
53 );
54 }
55 return parameterVersions;
56 }
57
58 return await listParamVersions();
59 // [END parametermanager_list_param_versions]
60}
61module.exports.main = main;
62
63/* c8 ignore next 10 */

Callers 1

Calls 1

listParamVersionsFunction · 0.85

Tested by

no test coverage detected