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

Function main

ai-platform/snippets/delete-endpoint.js:19–62  ·  view source on GitHub ↗
(endpointId, project, location = 'us-central1')

Source from the content-addressed store, hash-verified

17'use strict';
18
19async function main(endpointId, project, location = 'us-central1') {
20 // [START aiplatform_delete_endpoint_sample]
21 /**
22 * TODO(developer): Uncomment these variables before running the sample.\
23 * (Not necessary if passing values as arguments)
24 */
25
26 // const endpointId = 'YOUR_ENDPOINT_ID';
27 // const project = 'YOUR_PROJECT_ID';
28 // const location = 'YOUR_PROJECT_LOCATION';
29
30 // Imports the Google Cloud Endpoint Service Client library
31 const {EndpointServiceClient} = require('@google-cloud/aiplatform');
32
33 // Specifies the location of the api endpoint
34 const clientOptions = {
35 apiEndpoint: 'us-central1-aiplatform.googleapis.com',
36 };
37
38 // Instantiates a client
39 const endpointServiceClient = new EndpointServiceClient(clientOptions);
40
41 async function deleteEndpoint() {
42 // Configure the parent resource
43 const endpoint = {
44 name: `projects/${project}/locations/${location}/endpoints/${endpointId}`,
45 };
46
47 // NOTE: Be sure to undeploy any models deployed to the endpoint before
48 // attempting to delete the endpoint.
49
50 // Delete endpoint request
51 const [response] = await endpointServiceClient.deleteEndpoint(endpoint);
52 console.log(`Long running operation : ${response.name}`);
53
54 // Wait for operation to complete
55 await response.promise();
56 const result = response.result;
57
58 console.log('Delete endpoint response:\n', result);
59 }
60 deleteEndpoint();
61 // [END aiplatform_delete_endpoint_sample]
62}
63
64process.on('unhandledRejection', err => {
65 console.error(err.message);

Callers 1

delete-endpoint.jsFile · 0.70

Calls 1

deleteEndpointFunction · 0.70

Tested by

no test coverage detected