* Retrieves a Model Armor template by its ID. * * @param {string} projectId - Google Cloud project ID where the template exists. * @param {string} locationId - Google Cloud location (region) of the template. * @param {string} templateId - Identifier of the template to retrieve.
(projectId, locationId, templateId)
| 22 | * @param {string} templateId - Identifier of the template to retrieve. |
| 23 | */ |
| 24 | async function getTemplate(projectId, locationId, templateId) { |
| 25 | // [START modelarmor_get_template] |
| 26 | /** |
| 27 | * TODO(developer): Uncomment these variables before running the sample. |
| 28 | */ |
| 29 | // const projectId = 'my-project'; |
| 30 | // const locationId = 'my-location'; |
| 31 | // const templateId = 'my-template'; |
| 32 | |
| 33 | const name = `projects/${projectId}/locations/${locationId}/templates/${templateId}`; |
| 34 | |
| 35 | // Imports the Model Armor library |
| 36 | const {ModelArmorClient} = require('@google-cloud/modelarmor').v1; |
| 37 | |
| 38 | // Instantiates a client |
| 39 | const client = new ModelArmorClient({ |
| 40 | apiEndpoint: `modelarmor.${locationId}.rep.googleapis.com`, |
| 41 | }); |
| 42 | |
| 43 | const request = { |
| 44 | name: name, |
| 45 | }; |
| 46 | |
| 47 | // Run request |
| 48 | const [response] = await client.getTemplate(request); |
| 49 | return response; |
| 50 | // [END modelarmor_get_template] |
| 51 | } |
| 52 | |
| 53 | module.exports = getTemplate; |