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

Function main

ai-platform/snippets/get-feature-sample.js:25–81  ·  view source on GitHub ↗
(
  project,
  featurestoreId,
  entityTypeId,
  featureId,
  location = 'us-central1',
  apiEndpoint = 'us-central1-aiplatform.googleapis.com',
  timeout = 300000
)

Source from the content-addressed store, hash-verified

23'use strict';
24
25async function main(
26 project,
27 featurestoreId,
28 entityTypeId,
29 featureId,
30 location = 'us-central1',
31 apiEndpoint = 'us-central1-aiplatform.googleapis.com',
32 timeout = 300000
33) {
34 // [START aiplatform_get_feature_sample]
35 /**
36 * TODO(developer): Uncomment these variables before running the sample.\
37 * (Not necessary if passing values as arguments)
38 */
39
40 // const project = 'YOUR_PROJECT_ID';
41 // const featurestoreId = 'YOUR_FEATURESTORE_ID';
42 // const entityTypeId = 'YOUR_ENTITY_TYPE_ID';
43 // const featureId = 'YOUR_FEATURE_ID';
44 // const location = 'YOUR_PROJECT_LOCATION';
45 // const apiEndpoint = 'YOUR_API_ENDPOINT';
46 // const timeout = <TIMEOUT_IN_MILLI_SECONDS>;
47
48 // Imports the Google Cloud Featurestore Service Client library
49 const {FeaturestoreServiceClient} = require('@google-cloud/aiplatform').v1;
50
51 // Specifies the location of the api endpoint
52 const clientOptions = {
53 apiEndpoint: apiEndpoint,
54 };
55
56 // Instantiates a client
57 const featurestoreServiceClient = new FeaturestoreServiceClient(
58 clientOptions
59 );
60
61 async function getFeature() {
62 // Configure the name resource
63 const name = `projects/${project}/locations/${location}/featurestores/${featurestoreId}/entityTypes/${entityTypeId}/features/${featureId}`;
64
65 const request = {
66 name: name,
67 };
68
69 // Get Feature request
70 const [response] = await featurestoreServiceClient.getFeature(request, {
71 timeout: Number(timeout),
72 });
73
74 console.log('Get feature response');
75 console.log(`Name : ${response.name}`);
76 console.log('Raw response:');
77 console.log(JSON.stringify(response, null, 2));
78 }
79 getFeature();
80 // [END aiplatform_get_feature_sample]
81}
82

Callers 1

Calls 1

getFeatureFunction · 0.85

Tested by

no test coverage detected