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

Function main

ai-platform/snippets/undeploy-model.js:19–67  ·  view source on GitHub ↗
(
  deployedModelId,
  endpointId,
  project,
  location = 'us-central1'
)

Source from the content-addressed store, hash-verified

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

Callers 1

undeploy-model.jsFile · 0.70

Calls 1

undeployModelFunction · 0.70

Tested by

no test coverage detected