* Retrieves a parameter from 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} parameterId - The ID of the parameter to retrieve.
(projectId, parameterId)
| 22 | * @param {string} parameterId - The ID of the parameter to retrieve. |
| 23 | */ |
| 24 | async function main(projectId, parameterId) { |
| 25 | // [START parametermanager_get_param] |
| 26 | /** |
| 27 | * TODO(developer): Uncomment these variables before running the sample. |
| 28 | */ |
| 29 | // const projectId = 'my-project'; |
| 30 | // const parameterId = 'my-parameter'; |
| 31 | |
| 32 | // Imports the Parameter Manager library |
| 33 | const {ParameterManagerClient} = require('@google-cloud/parametermanager'); |
| 34 | |
| 35 | // Instantiates a client |
| 36 | const client = new ParameterManagerClient(); |
| 37 | |
| 38 | async function getParam() { |
| 39 | // Construct the fully qualified parameter name |
| 40 | const name = client.parameterPath(projectId, 'global', parameterId); |
| 41 | |
| 42 | // Get the parameter |
| 43 | const [parameter] = await client.getParameter({ |
| 44 | name: name, |
| 45 | }); |
| 46 | |
| 47 | // Find more details for the Parameter object here: |
| 48 | // https://cloud.google.com/secret-manager/parameter-manager/docs/reference/rest/v1/projects.locations.parameters#Parameter |
| 49 | console.log( |
| 50 | `Found parameter ${parameter.name} with format ${parameter.format}` |
| 51 | ); |
| 52 | return parameter; |
| 53 | } |
| 54 | |
| 55 | return await getParam(); |
| 56 | // [END parametermanager_get_param] |
| 57 | } |
| 58 | module.exports.main = main; |
| 59 | |
| 60 | /* c8 ignore next 10 */ |