Search in sources :

Example 1 with CreateEndpointOperationMetadata

use of com.google.cloud.aiplatform.v1.CreateEndpointOperationMetadata in project java-aiplatform by googleapis.

the class CreateEndpointSample method createEndpointSample.

static void createEndpointSample(String project, String endpointDisplayName) throws IOException, InterruptedException, ExecutionException, TimeoutException {
    EndpointServiceSettings endpointServiceSettings = EndpointServiceSettings.newBuilder().setEndpoint("us-central1-aiplatform.googleapis.com:443").build();
    // the "close" method on the client to safely clean up any remaining background resources.
    try (EndpointServiceClient endpointServiceClient = EndpointServiceClient.create(endpointServiceSettings)) {
        String location = "us-central1";
        LocationName locationName = LocationName.of(project, location);
        Endpoint endpoint = Endpoint.newBuilder().setDisplayName(endpointDisplayName).build();
        OperationFuture<Endpoint, CreateEndpointOperationMetadata> endpointFuture = endpointServiceClient.createEndpointAsync(locationName, endpoint);
        System.out.format("Operation name: %s\n", endpointFuture.getInitialFuture().get().getName());
        System.out.println("Waiting for operation to finish...");
        Endpoint endpointResponse = endpointFuture.get(300, TimeUnit.SECONDS);
        System.out.println("Create Endpoint Response");
        System.out.format("Name: %s\n", endpointResponse.getName());
        System.out.format("Display Name: %s\n", endpointResponse.getDisplayName());
        System.out.format("Description: %s\n", endpointResponse.getDescription());
        System.out.format("Labels: %s\n", endpointResponse.getLabelsMap());
        System.out.format("Create Time: %s\n", endpointResponse.getCreateTime());
        System.out.format("Update Time: %s\n", endpointResponse.getUpdateTime());
    }
}
Also used : Endpoint(com.google.cloud.aiplatform.v1.Endpoint) EndpointServiceClient(com.google.cloud.aiplatform.v1.EndpointServiceClient) CreateEndpointOperationMetadata(com.google.cloud.aiplatform.v1.CreateEndpointOperationMetadata) EndpointServiceSettings(com.google.cloud.aiplatform.v1.EndpointServiceSettings) LocationName(com.google.cloud.aiplatform.v1.LocationName)

Aggregations

CreateEndpointOperationMetadata (com.google.cloud.aiplatform.v1.CreateEndpointOperationMetadata)1 Endpoint (com.google.cloud.aiplatform.v1.Endpoint)1 EndpointServiceClient (com.google.cloud.aiplatform.v1.EndpointServiceClient)1 EndpointServiceSettings (com.google.cloud.aiplatform.v1.EndpointServiceSettings)1 LocationName (com.google.cloud.aiplatform.v1.LocationName)1