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

Function main

parametermanager/listParams.js:23–57  ·  view source on GitHub ↗

* Lists all parameters in the global location for the specified * project using the Google Cloud Parameter Manager SDK. * * @param {string} projectId - The Google Cloud project ID where the parameters are located.

(projectId)

Source from the content-addressed store, hash-verified

21 * @param {string} projectId - The Google Cloud project ID where the parameters are located.
22 */
23async function main(projectId) {
24 // [START parametermanager_list_params]
25 /**
26 * TODO(developer): Uncomment these variables before running the sample.
27 */
28 // const projectId = 'my-project';
29
30 // Imports the Parameter Manager library
31 const {ParameterManagerClient} = require('@google-cloud/parametermanager');
32
33 // Instantiates a client
34 const client = new ParameterManagerClient();
35
36 async function listParams() {
37 // Construct the parent string for listing parameters globally
38 const parent = client.locationPath(projectId, 'global');
39
40 const request = {
41 parent: parent,
42 };
43
44 // Use listParametersAsync to handle pagination automatically
45 const parameters = await client.listParametersAsync(request);
46
47 for await (const parameter of parameters) {
48 console.log(
49 `Found parameter ${parameter.name} with format ${parameter.format}`
50 );
51 }
52 return parameters;
53 }
54
55 return await listParams();
56 // [END parametermanager_list_params]
57}
58module.exports.main = main;
59
60/* c8 ignore next 10 */

Callers 1

listParams.jsFile · 0.70

Calls 1

listParamsFunction · 0.85

Tested by

no test coverage detected