Search in sources :

Example 1 with LocationName

use of com.google.cloud.dialogflow.v2.LocationName in project gapic-generator-java by googleapis.

the class ConfigClientTest method listBucketsExceptionTest3.

@Test
public void listBucketsExceptionTest3() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockConfigServiceV2.addException(exception);
    try {
        LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
        client.listBuckets(parent);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) StatusRuntimeException(io.grpc.StatusRuntimeException) BillingAccountLocationName(com.google.logging.v2.BillingAccountLocationName) OrganizationLocationName(com.google.logging.v2.OrganizationLocationName) FolderLocationName(com.google.logging.v2.FolderLocationName) LocationName(com.google.logging.v2.LocationName) Test(org.junit.Test)

Example 2 with LocationName

use of com.google.cloud.dialogflow.v2.LocationName in project java-aiplatform by googleapis.

the class ImportDataVideoObjectTrackingSampleTest method setUp.

@Before
public void setUp() throws InterruptedException, ExecutionException, TimeoutException, IOException {
    bout = new ByteArrayOutputStream();
    out = new PrintStream(bout);
    originalPrintStream = System.out;
    System.setOut(out);
    // create a temp dataset for importing data
    DatasetServiceSettings datasetServiceSettings = DatasetServiceSettings.newBuilder().setEndpoint("us-central1-aiplatform.googleapis.com:443").build();
    try (DatasetServiceClient datasetServiceClient = DatasetServiceClient.create(datasetServiceSettings)) {
        String metadataSchemaUri = "gs://google-cloud-aiplatform/schema/dataset/metadata/video_1.0.0.yaml";
        LocationName locationName = LocationName.of(PROJECT, LOCATION);
        Dataset dataset = Dataset.newBuilder().setDisplayName("test_dataset_display_name").setMetadataSchemaUri(metadataSchemaUri).build();
        OperationFuture<Dataset, CreateDatasetOperationMetadata> datasetFuture = datasetServiceClient.createDatasetAsync(locationName, dataset);
        Dataset datasetResponse = datasetFuture.get(300, TimeUnit.SECONDS);
        String[] datasetValues = datasetResponse.getName().split("/");
        datasetId = datasetValues[datasetValues.length - 1];
    }
}
Also used : PrintStream(java.io.PrintStream) DatasetServiceSettings(com.google.cloud.aiplatform.v1beta1.DatasetServiceSettings) CreateDatasetOperationMetadata(com.google.cloud.aiplatform.v1beta1.CreateDatasetOperationMetadata) Dataset(com.google.cloud.aiplatform.v1beta1.Dataset) DatasetServiceClient(com.google.cloud.aiplatform.v1beta1.DatasetServiceClient) ByteArrayOutputStream(java.io.ByteArrayOutputStream) LocationName(com.google.cloud.aiplatform.v1beta1.LocationName) Before(org.junit.Before)

Example 3 with LocationName

use of com.google.cloud.dialogflow.v2.LocationName in project java-aiplatform by googleapis.

the class ImportDataImageObjectDetectionSampleTest method setUp.

@Before
public void setUp() throws InterruptedException, ExecutionException, TimeoutException, IOException {
    bout = new ByteArrayOutputStream();
    out = new PrintStream(bout);
    originalPrintStream = System.out;
    System.setOut(out);
    // create a temp dataset for importing data
    DatasetServiceSettings datasetServiceSettings = DatasetServiceSettings.newBuilder().setEndpoint("us-central1-aiplatform.googleapis.com:443").build();
    try (DatasetServiceClient datasetServiceClient = DatasetServiceClient.create(datasetServiceSettings)) {
        String metadataSchemaUri = "gs://google-cloud-aiplatform/schema/dataset/metadata/image_1.0.0.yaml";
        LocationName locationName = LocationName.of(PROJECT, LOCATION);
        Dataset dataset = Dataset.newBuilder().setDisplayName("test_dataset_display_name").setMetadataSchemaUri(metadataSchemaUri).build();
        OperationFuture<Dataset, CreateDatasetOperationMetadata> datasetFuture = datasetServiceClient.createDatasetAsync(locationName, dataset);
        Dataset datasetResponse = datasetFuture.get(120, TimeUnit.SECONDS);
        String[] datasetValues = datasetResponse.getName().split("/");
        datasetId = datasetValues[datasetValues.length - 1];
    }
}
Also used : PrintStream(java.io.PrintStream) DatasetServiceSettings(com.google.cloud.aiplatform.v1beta1.DatasetServiceSettings) CreateDatasetOperationMetadata(com.google.cloud.aiplatform.v1beta1.CreateDatasetOperationMetadata) Dataset(com.google.cloud.aiplatform.v1beta1.Dataset) DatasetServiceClient(com.google.cloud.aiplatform.v1beta1.DatasetServiceClient) ByteArrayOutputStream(java.io.ByteArrayOutputStream) LocationName(com.google.cloud.aiplatform.v1beta1.LocationName) Before(org.junit.Before)

Example 4 with LocationName

use of com.google.cloud.dialogflow.v2.LocationName in project java-aiplatform by googleapis.

the class CreateDatasetVideoSample method createDatasetSample.

static void createDatasetSample(String datasetVideoDisplayName, String project) throws IOException, InterruptedException, ExecutionException, TimeoutException {
    DatasetServiceSettings datasetServiceSettings = DatasetServiceSettings.newBuilder().setEndpoint("us-central1-aiplatform.googleapis.com:443").build();
    // the "close" method on the client to safely clean up any remaining background resources.
    try (DatasetServiceClient datasetServiceClient = DatasetServiceClient.create(datasetServiceSettings)) {
        String location = "us-central1";
        String metadataSchemaUri = "gs://google-cloud-aiplatform/schema/dataset/metadata/video_1.0.0.yaml";
        LocationName locationName = LocationName.of(project, location);
        Dataset dataset = Dataset.newBuilder().setDisplayName(datasetVideoDisplayName).setMetadataSchemaUri(metadataSchemaUri).build();
        OperationFuture<Dataset, CreateDatasetOperationMetadata> datasetFuture = datasetServiceClient.createDatasetAsync(locationName, dataset);
        System.out.format("Operation name: %s\n", datasetFuture.getInitialFuture().get().getName());
        System.out.println("Waiting for operation to finish...");
        Dataset datasetResponse = datasetFuture.get(300, TimeUnit.SECONDS);
        System.out.println("Create Dataset Video Response");
        System.out.format("Name: %s\n", datasetResponse.getName());
        System.out.format("Display Name: %s\n", datasetResponse.getDisplayName());
        System.out.format("Metadata Schema Uri: %s\n", datasetResponse.getMetadataSchemaUri());
        System.out.format("Metadata: %s\n", datasetResponse.getMetadata());
        System.out.format("Create Time: %s\n", datasetResponse.getCreateTime());
        System.out.format("Update Time: %s\n", datasetResponse.getUpdateTime());
        System.out.format("Labels: %s\n", datasetResponse.getLabelsMap());
    }
}
Also used : DatasetServiceSettings(com.google.cloud.aiplatform.v1.DatasetServiceSettings) CreateDatasetOperationMetadata(com.google.cloud.aiplatform.v1.CreateDatasetOperationMetadata) Dataset(com.google.cloud.aiplatform.v1.Dataset) DatasetServiceClient(com.google.cloud.aiplatform.v1.DatasetServiceClient) LocationName(com.google.cloud.aiplatform.v1.LocationName)

Example 5 with LocationName

use of com.google.cloud.dialogflow.v2.LocationName 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

Test (org.junit.Test)40 LocationName (com.google.cloud.aiplatform.v1.LocationName)36 AbstractMessage (com.google.protobuf.AbstractMessage)23 LocationName (com.google.privacy.dlp.v2.LocationName)22 OrganizationLocationName (com.google.privacy.dlp.v2.OrganizationLocationName)22 LocationName (com.google.cloud.translate.v3beta1.LocationName)18 TranslationServiceClient (com.google.cloud.translate.v3beta1.TranslationServiceClient)18 AutoMlClient (com.google.cloud.automl.v1.AutoMlClient)17 LocationName (com.google.cloud.automl.v1.LocationName)17 JobServiceClient (com.google.cloud.aiplatform.v1.JobServiceClient)15 JobServiceSettings (com.google.cloud.aiplatform.v1.JobServiceSettings)15 Value (com.google.protobuf.Value)15 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)14 Model (com.google.cloud.aiplatform.v1.Model)14 StatusRuntimeException (io.grpc.StatusRuntimeException)14 PipelineServiceClient (com.google.cloud.aiplatform.v1.PipelineServiceClient)13 PipelineServiceSettings (com.google.cloud.aiplatform.v1.PipelineServiceSettings)13 TrainingPipeline (com.google.cloud.aiplatform.v1.TrainingPipeline)13 LocationName (com.google.cloud.translate.v3.LocationName)13 TranslationServiceClient (com.google.cloud.translate.v3.TranslationServiceClient)13