(endpointDisplayName, project, location = 'us-central1')
| 17 | 'use strict'; |
| 18 | |
| 19 | async function main(endpointDisplayName, project, location = 'us-central1') { |
| 20 | // [START aiplatform_create_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 endpointDisplayName = 'YOUR_ENDPOINT_DISPLAY_NAME'; |
| 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 createEndpoint() { |
| 42 | // Configure the parent resource |
| 43 | const parent = `projects/${project}/locations/${location}`; |
| 44 | const endpoint = { |
| 45 | displayName: endpointDisplayName, |
| 46 | }; |
| 47 | const request = { |
| 48 | parent, |
| 49 | endpoint, |
| 50 | }; |
| 51 | |
| 52 | // Get and print out a list of all the endpoints for this resource |
| 53 | const [response] = await endpointServiceClient.createEndpoint(request); |
| 54 | console.log(`Long running operation : ${response.name}`); |
| 55 | |
| 56 | // Wait for operation to complete |
| 57 | await response.promise(); |
| 58 | const result = response.result; |
| 59 | |
| 60 | console.log('Create endpoint response'); |
| 61 | console.log(`\tName : ${result.name}`); |
| 62 | console.log(`\tDisplay name : ${result.displayName}`); |
| 63 | console.log(`\tDescription : ${result.description}`); |
| 64 | console.log(`\tLabels : ${JSON.stringify(result.labels)}`); |
| 65 | console.log(`\tCreate time : ${JSON.stringify(result.createTime)}`); |
| 66 | console.log(`\tUpdate time : ${JSON.stringify(result.updateTime)}`); |
| 67 | } |
| 68 | createEndpoint(); |
| 69 | // [END aiplatform_create_endpoint_sample] |
| 70 | } |
| 71 | |
| 72 | process.on('unhandledRejection', err => { |
| 73 | console.error(err.message); |
no test coverage detected