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

Function main

parametermanager/createParam.js:23–51  ·  view source on GitHub ↗

* Creates a global parameter using the Parameter Manager SDK. * * @param {string} projectId - The Google Cloud project ID where the parameter is to be created. * @param {string} parameterId - The ID of the parameter to create. This ID must be unique within the project.

(projectId, parameterId)

Source from the content-addressed store, hash-verified

21 * @param {string} parameterId - The ID of the parameter to create. This ID must be unique within the project.
22 */
23async function main(projectId, parameterId) {
24 // [START parametermanager_create_param]
25 /**
26 * TODO(developer): Uncomment these variables before running the sample.
27 */
28 // const projectId = 'YOUR_PROJECT_ID';
29 // const parameterId = 'YOUR_PARAMETER_ID';
30
31 // Imports the Parameter Manager library
32 const {ParameterManagerClient} = require('@google-cloud/parametermanager');
33
34 // Instantiates a client
35 const client = new ParameterManagerClient();
36
37 async function createParam() {
38 const parent = client.locationPath(projectId, 'global');
39 const request = {
40 parent: parent,
41 parameterId: parameterId,
42 };
43
44 const [parameter] = await client.createParameter(request);
45 console.log(`Created parameter: ${parameter.name}`);
46 return parameter;
47 }
48
49 return await createParam();
50 // [END parametermanager_create_param]
51}
52module.exports.main = main;
53
54/* c8 ignore next 10 */

Callers 1

createParam.jsFile · 0.70

Calls 1

createParamFunction · 0.85

Tested by

no test coverage detected