Skip to content

Commit 24a8ba0

Browse files
suryaguthikondagcf-owl-bot[bot]junkourata
authored andcommitted
feat(samples): add remaining featurestore api samples (#338)
* added create-featurestore-sample.js and create-featurestore-sample.test.js * feat(samples): added createFeaturestore sample (#313) * feat(samples): added remaining featurestore samples (#313) * removed the extraneous files * feat(samples): add remaining featurestore api samples (#313) * feat(samples): add remaining featurestore apis samples (#313) * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * feat(samples): changed timeout of featurestore apis samples (#313) * feat(samples): update featurestore-samples.test.js (#313) Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: junkourata <[email protected]>
1 parent 1b6c1ab commit 24a8ba0

8 files changed

+727
-0
lines changed
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+
* Deletes a single 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+
force = false,
29+
location = 'us-central1',
30+
apiEndpoint = 'us-central1-aiplatform.googleapis.com',
31+
timeout = 60000
32+
) {
33+
// [START aiplatform_delete_featurestore_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 force = <BOOLEAN>;
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 deleteFeaturestore() {
60+
// Configure the name resource
61+
const name = `projects/${project}/locations/${location}/featurestores/${featurestoreId}`;
62+
63+
const request = {
64+
name: name,
65+
force: Boolean(force),
66+
};
67+
68+
// Delete Featurestore request
69+
const [operation] = await featurestoreServiceClient.deleteFeaturestore(
70+
request,
71+
{timeout: Number(timeout)}
72+
);
73+
const [response] = await operation.promise();
74+
75+
console.log('Delete featurestore response');
76+
console.log('Raw response:');
77+
console.log(JSON.stringify(response, null, 2));
78+
}
79+
deleteFeaturestore();
80+
// [END aiplatform_delete_featurestore_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));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
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 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_get_featurestore_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 getFeaturestore() {
58+
// Configure the parent resource
59+
const name = `projects/${project}/locations/${location}/featurestores/${featurestoreId}`;
60+
61+
const request = {
62+
name: name,
63+
};
64+
65+
// Get Featurestore request
66+
const [response] = await featurestoreServiceClient.getFeaturestore(
67+
request,
68+
{timeout: Number(timeout)}
69+
);
70+
71+
console.log('Get featurestore response');
72+
console.log(`Name : ${response.name}`);
73+
console.log('Raw response:');
74+
console.log(JSON.stringify(response, null, 2));
75+
}
76+
getFeaturestore();
77+
// [END aiplatform_get_featurestore_sample]
78+
}
79+
80+
process.on('unhandledRejection', err => {
81+
console.error(err.message);
82+
process.exitCode = 1;
83+
});
84+
85+
main(...process.argv.slice(2));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
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 Featurestores asynchronously in a given project and location.
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+
location = 'us-central1',
28+
apiEndpoint = 'us-central1-aiplatform.googleapis.com',
29+
timeout = 5000
30+
) {
31+
// [START aiplatform_list_featurestores_async_sample]
32+
/**
33+
* TODO(developer): Uncomment these variables before running the sample.\
34+
* (Not necessary if passing values as arguments)
35+
*/
36+
37+
// const project = 'YOUR_PROJECT_ID';
38+
// const location = 'YOUR_PROJECT_LOCATION';
39+
// const apiEndpoint = 'YOUR_API_ENDPOINT';
40+
// const timeout = <TIMEOUT_IN_MILLI_SECONDS>;
41+
42+
// Imports the Google Cloud Featurestore Service Client library
43+
const {FeaturestoreServiceClient} = require('@google-cloud/aiplatform').v1;
44+
45+
// Specifies the location of the api endpoint
46+
const clientOptions = {
47+
apiEndpoint: apiEndpoint,
48+
};
49+
50+
// Instantiates a client
51+
const featurestoreServiceClient = new FeaturestoreServiceClient(
52+
clientOptions
53+
);
54+
55+
async function listFeaturestoresAsync() {
56+
// Configure the parent resource
57+
const parent = `projects/${project}/locations/${location}`;
58+
59+
const request = {
60+
parent: parent,
61+
};
62+
63+
// List featurestores async request
64+
const iterable = await featurestoreServiceClient.listFeaturestoresAsync(
65+
request,
66+
{timeout: Number(timeout)}
67+
);
68+
69+
console.log('List featurestores async response');
70+
console.log('Raw response:');
71+
for await (const response of iterable) {
72+
console.log(JSON.stringify(response, null, 2));
73+
}
74+
}
75+
listFeaturestoresAsync();
76+
// [END aiplatform_list_featurestores_async_sample]
77+
}
78+
79+
process.on('unhandledRejection', err => {
80+
console.error(err.message);
81+
process.exitCode = 1;
82+
});
83+
84+
main(...process.argv.slice(2));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
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 Featurestores in a given project and location.
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+
location = 'us-central1',
28+
apiEndpoint = 'us-central1-aiplatform.googleapis.com',
29+
timeout = 5000
30+
) {
31+
// [START aiplatform_list_featurestores_sample]
32+
/**
33+
* TODO(developer): Uncomment these variables before running the sample.\
34+
* (Not necessary if passing values as arguments)
35+
*/
36+
37+
// const project = 'YOUR_PROJECT_ID';
38+
// const location = 'YOUR_PROJECT_LOCATION';
39+
// const apiEndpoint = 'YOUR_API_ENDPOINT';
40+
// const timeout = <TIMEOUT_IN_MILLI_SECONDS>;
41+
42+
// Imports the Google Cloud Featurestore Service Client library
43+
const {FeaturestoreServiceClient} = require('@google-cloud/aiplatform').v1;
44+
45+
// Specifies the location of the api endpoint
46+
const clientOptions = {
47+
apiEndpoint: apiEndpoint,
48+
};
49+
50+
// Instantiates a client
51+
const featurestoreServiceClient = new FeaturestoreServiceClient(
52+
clientOptions
53+
);
54+
55+
async function listFeaturestores() {
56+
// Configure the parent resource
57+
const parent = `projects/${project}/locations/${location}`;
58+
59+
const request = {
60+
parent: parent,
61+
};
62+
63+
// List featurestores request
64+
const [response] = await featurestoreServiceClient.listFeaturestores(
65+
request,
66+
{timeout: Number(timeout)}
67+
);
68+
69+
console.log('List featurestores response');
70+
console.log('Raw response:');
71+
console.log(JSON.stringify(response, null, 2));
72+
}
73+
listFeaturestores();
74+
// [END aiplatform_list_featurestores_sample]
75+
}
76+
77+
process.on('unhandledRejection', err => {
78+
console.error(err.message);
79+
process.exitCode = 1;
80+
});
81+
82+
main(...process.argv.slice(2));

0 commit comments

Comments
 (0)