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

Function getTemplate

model-armor/snippets/getTemplate.js:24–51  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

22 * @param {string} templateId - Identifier of the template to retrieve.
23 */
24async 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
53module.exports = getTemplate;

Callers 1

modelarmor.test.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected