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

Function main

vision/productSearch/createProductSet.js:17–52  ·  view source on GitHub ↗
(projectId, location, productSetId, productSetDisplayName)

Source from the content-addressed store, hash-verified

15'use strict';
16
17function main(projectId, location, productSetId, productSetDisplayName) {
18 // [START vision_product_search_create_product_set]
19 // Imports the Google Cloud client library
20 const vision = require('@google-cloud/vision');
21
22 // Creates a client
23 const client = new vision.ProductSearchClient();
24
25 async function createProductSet() {
26 /**
27 * TODO(developer): Uncomment the following line before running the sample.
28 */
29 // const projectId = 'Your Google Cloud project Id';
30 // const location = 'A compute region name';
31 // const productSetId = 'Id of the product set';
32 // const productSetDisplayName = 'Display name of the product set';
33
34 // Resource path that represents Google Cloud Platform location.
35 const locationPath = client.locationPath(projectId, location);
36
37 const productSet = {
38 displayName: productSetDisplayName,
39 };
40
41 const request = {
42 parent: locationPath,
43 productSet: productSet,
44 productSetId: productSetId,
45 };
46
47 const [createdProductSet] = await client.createProductSet(request);
48 console.log(`Product Set name: ${createdProductSet.name}`);
49 }
50 createProductSet();
51 // [END vision_product_search_create_product_set]
52}
53
54process.on('unhandledRejection', err => {
55 console.error(err.message);

Callers 1

Calls 1

createProductSetFunction · 0.85

Tested by

no test coverage detected