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

Function main

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

* Creates a parameter in the global location of the specified * project with specified format using the Google Cloud 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

(projectId, parameterId, formatType)

Source from the content-addressed store, hash-verified

23 * @param {string} formatType - The format type of the parameter (UNFORMATTED, YAML, JSON).
24 */
25async function main(projectId, parameterId, formatType) {
26 // [START parametermanager_create_structured_param]
27 /**
28 * TODO(developer): Uncomment these variables before running the sample.
29 */
30 // const {protos} = require('@google-cloud/parametermanager');
31 // const projectId = 'YOUR_PROJECT_ID';
32 // const parameterId = 'YOUR_PARAMETER_ID';
33 // const formatType = protos.google.cloud.parametermanager.v1.ParameterFormat.JSON;
34
35 // Imports the Parameter Manager library
36 const {ParameterManagerClient} = require('@google-cloud/parametermanager');
37
38 // Instantiates a client
39 const client = new ParameterManagerClient();
40
41 async function createStructuredParam() {
42 const parent = client.locationPath(projectId, 'global');
43 const request = {
44 parent: parent,
45 parameterId: parameterId,
46 parameter: {
47 format: formatType,
48 },
49 };
50
51 const [parameter] = await client.createParameter(request);
52 console.log(
53 `Created parameter ${parameter.name} with format ${parameter.format}`
54 );
55 return parameter;
56 }
57
58 return await createStructuredParam();
59 // [END parametermanager_create_structured_param]
60}
61module.exports.main = main;
62
63/* c8 ignore next 10 */

Callers 1

Calls 1

createStructuredParamFunction · 0.85

Tested by

no test coverage detected