Skip to content

Commit 8fee3d5

Browse files
committed
fix: restore more deleted files
1 parent 67b5c93 commit 8fee3d5

File tree

7 files changed

+617
-0
lines changed

7 files changed

+617
-0
lines changed
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/*
2+
* Copyright 2022 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
/*
18+
* Gets details of a single EntityType.
19+
* See https://cloud.google.com/vertex-ai/docs/featurestore/setup before running
20+
* the code snippet
21+
*/
22+
23+
'use strict';
24+
25+
async function main(
26+
project,
27+
featurestoreId,
28+
entityTypeId,
29+
location = 'us-central1',
30+
apiEndpoint = 'us-central1-aiplatform.googleapis.com',
31+
timeout = 5000
32+
) {
33+
// [START aiplatform_get_entity_type_sample]
34+
/**
35+
* TODO(developer): Uncomment these variables before running the sample.\
36+
* (Not necessary if passing values as arguments)
37+
*/
38+
39+
// const project = 'YOUR_PROJECT_ID';
40+
// const featurestoreId = 'YOUR_FEATURESTORE_ID';
41+
// const entityTypeId = 'YOUR_ENTITY_TYPE_ID';
42+
// const location = 'YOUR_PROJECT_LOCATION';
43+
// const apiEndpoint = 'YOUR_API_ENDPOINT';
44+
// const timeout = <TIMEOUT_IN_MILLI_SECONDS>;
45+
46+
// Imports the Google Cloud Featurestore Service Client library
47+
const {FeaturestoreServiceClient} = require('@google-cloud/aiplatform').v1;
48+
49+
// Specifies the location of the api endpoint
50+
const clientOptions = {
51+
apiEndpoint: apiEndpoint,
52+
};
53+
54+
// Instantiates a client
55+
const featurestoreServiceClient = new FeaturestoreServiceClient(
56+
clientOptions
57+
);
58+
59+
async function getEntityType() {
60+
// Configure the name resource
61+
const name = `projects/${project}/locations/${location}/featurestores/${featurestoreId}/entityTypes/${entityTypeId}`;
62+
63+
const request = {
64+
name: name,
65+
};
66+
67+
// Get EntityType request
68+
const [response] = await featurestoreServiceClient.getEntityType(request, {
69+
timeout: Number(timeout),
70+
});
71+
72+
console.log('Get entity type response');
73+
console.log(`Name : ${response.name}`);
74+
console.log('Raw response:');
75+
console.log(JSON.stringify(response, null, 2));
76+
}
77+
getEntityType();
78+
// [END aiplatform_get_entity_type_sample]
79+
}
80+
81+
process.on('unhandledRejection', err => {
82+
console.error(err.message);
83+
process.exitCode = 1;
84+
});
85+
86+
main(...process.argv.slice(2));
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/*
2+
* Copyright 2022 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
/*
18+
* Lists EntityTypes Asynchronously in a given Featurestore.
19+
* See https://cloud.google.com/vertex-ai/docs/featurestore/setup before running
20+
* the code snippet
21+
*/
22+
23+
'use strict';
24+
25+
async function main(
26+
project,
27+
featurestoreId,
28+
location = 'us-central1',
29+
apiEndpoint = 'us-central1-aiplatform.googleapis.com',
30+
timeout = 5000
31+
) {
32+
// [START aiplatform_list_entity_types_async_sample]
33+
/**
34+
* TODO(developer): Uncomment these variables before running the sample.\
35+
* (Not necessary if passing values as arguments)
36+
*/
37+
38+
// const project = 'YOUR_PROJECT_ID';
39+
// const featurestoreId = 'YOUR_FEATURESTORE_ID';
40+
// const location = 'YOUR_PROJECT_LOCATION';
41+
// const apiEndpoint = 'YOUR_API_ENDPOINT';
42+
// const timeout = <TIMEOUT_IN_MILLI_SECONDS>;
43+
44+
// Imports the Google Cloud Featurestore Service Client library
45+
const {FeaturestoreServiceClient} = require('@google-cloud/aiplatform').v1;
46+
47+
// Specifies the location of the api endpoint
48+
const clientOptions = {
49+
apiEndpoint: apiEndpoint,
50+
};
51+
52+
// Instantiates a client
53+
const featurestoreServiceClient = new FeaturestoreServiceClient(
54+
clientOptions
55+
);
56+
57+
async function listEntityTypesAsync() {
58+
// Configure the parent resource
59+
const parent = `projects/${project}/locations/${location}/featurestores/${featurestoreId}`;
60+
61+
const request = {
62+
parent: parent,
63+
};
64+
65+
// List EntityTypes Async request
66+
const iterable = await featurestoreServiceClient.listEntityTypesAsync(
67+
request,
68+
{timeout: Number(timeout)}
69+
);
70+
71+
console.log('List entity types async response');
72+
console.log('Raw response:');
73+
for await (const response of iterable) {
74+
console.log(JSON.stringify(response, null, 2));
75+
}
76+
}
77+
listEntityTypesAsync();
78+
// [END aiplatform_list_entity_types_async_sample]
79+
}
80+
81+
process.on('unhandledRejection', err => {
82+
console.error(err.message);
83+
process.exitCode = 1;
84+
});
85+
86+
main(...process.argv.slice(2));
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
/*
2+
* Copyright 2022 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
/*
18+
* Lists Features Asynchronously in a given EntityType.
19+
* See https://cloud.google.com/vertex-ai/docs/featurestore/setup before running
20+
* the code snippet
21+
*/
22+
23+
'use strict';
24+
25+
async function main(
26+
project,
27+
featurestoreId,
28+
entityTypeId,
29+
location = 'us-central1',
30+
apiEndpoint = 'us-central1-aiplatform.googleapis.com',
31+
timeout = 300000
32+
) {
33+
// [START aiplatform_list_features_async_sample]
34+
/**
35+
* TODO(developer): Uncomment these variables before running the sample.\
36+
* (Not necessary if passing values as arguments)
37+
*/
38+
39+
// const project = 'YOUR_PROJECT_ID';
40+
// const featurestoreId = 'YOUR_FEATURESTORE_ID';
41+
// const entityTypeId = 'YOUR_ENTITY_TYPE_ID';
42+
// const location = 'YOUR_PROJECT_LOCATION';
43+
// const apiEndpoint = 'YOUR_API_ENDPOINT';
44+
// const timeout = <TIMEOUT_IN_MILLI_SECONDS>;
45+
46+
// Imports the Google Cloud Featurestore Service Client library
47+
const {FeaturestoreServiceClient} = require('@google-cloud/aiplatform').v1;
48+
49+
// Specifies the location of the api endpoint
50+
const clientOptions = {
51+
apiEndpoint: apiEndpoint,
52+
};
53+
54+
// Instantiates a client
55+
const featurestoreServiceClient = new FeaturestoreServiceClient(
56+
clientOptions
57+
);
58+
59+
async function listFeaturesAsync() {
60+
// Configure the parent resource
61+
const parent = `projects/${project}/locations/${location}/featurestores/${featurestoreId}/entityTypes/${entityTypeId}`;
62+
63+
const request = {
64+
parent: parent,
65+
};
66+
67+
// List Features async request
68+
const iterable = await featurestoreServiceClient.listFeaturesAsync(
69+
request,
70+
{
71+
timeout: Number(timeout),
72+
}
73+
);
74+
75+
console.log('List features async response');
76+
console.log('Raw response:');
77+
for await (const response of iterable) {
78+
console.log(JSON.stringify(response, null, 2));
79+
}
80+
}
81+
listFeaturesAsync();
82+
// [END aiplatform_list_features_async_sample]
83+
}
84+
85+
process.on('unhandledRejection', err => {
86+
console.error(err.message);
87+
process.exitCode = 1;
88+
});
89+
90+
main(...process.argv.slice(2));
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/*
2+
* Copyright 2022 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
/*
18+
* Searches Features matching a query in a given project Asyncronously.
19+
* See https://cloud.google.com/vertex-ai/docs/featurestore/setup before running
20+
* the code snippet
21+
*/
22+
23+
'use strict';
24+
25+
async function main(
26+
project,
27+
query,
28+
location = 'us-central1',
29+
apiEndpoint = 'us-central1-aiplatform.googleapis.com',
30+
timeout = 300000
31+
) {
32+
// [START aiplatform_search_features_async_sample]
33+
/**
34+
* TODO(developer): Uncomment these variables before running the sample.\
35+
* (Not necessary if passing values as arguments)
36+
*/
37+
38+
// const project = 'YOUR_PROJECT_ID';
39+
// const location = 'YOUR_PROJECT_LOCATION';
40+
// const apiEndpoint = 'YOUR_API_ENDPOINT';
41+
// const timeout = <TIMEOUT_IN_MILLI_SECONDS>;
42+
43+
// Imports the Google Cloud Featurestore Service Client library
44+
const {FeaturestoreServiceClient} = require('@google-cloud/aiplatform').v1;
45+
46+
// Specifies the location of the api endpoint
47+
const clientOptions = {
48+
apiEndpoint: apiEndpoint,
49+
};
50+
51+
// Instantiates a client
52+
const featurestoreServiceClient = new FeaturestoreServiceClient(
53+
clientOptions
54+
);
55+
56+
async function searchFeaturesAsync() {
57+
// Configure the locationResource resource
58+
const locationResource = `projects/${project}/locations/${location}`;
59+
60+
const request = {
61+
location: locationResource,
62+
query: query,
63+
};
64+
65+
// Search Features async request
66+
const iterable = await featurestoreServiceClient.searchFeaturesAsync(
67+
request,
68+
{
69+
timeout: Number(timeout),
70+
}
71+
);
72+
73+
console.log('Search features async response');
74+
console.log('Raw response:');
75+
for await (const response of iterable) {
76+
console.log(JSON.stringify(response, null, 2));
77+
}
78+
}
79+
searchFeaturesAsync();
80+
// [END aiplatform_search_features_async_sample]
81+
}
82+
83+
process.on('unhandledRejection', err => {
84+
console.error(err.message);
85+
process.exitCode = 1;
86+
});
87+
88+
main(...process.argv.slice(2));

0 commit comments

Comments
 (0)