use of com.google.cloud.redis.v1beta1.LocationName in project gapic-generator-java by googleapis.
the class CloudRedisClientTest method listInstancesTest.
@Test
public void listInstancesTest() throws Exception {
Instance responsesElement = Instance.newBuilder().build();
ListInstancesResponse expectedResponse = ListInstancesResponse.newBuilder().setNextPageToken("").addAllInstances(Arrays.asList(responsesElement)).build();
mockCloudRedis.addResponse(expectedResponse);
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
ListInstancesPagedResponse pagedListResponse = client.listInstances(parent);
List<Instance> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getInstancesList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockCloudRedis.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListInstancesRequest actualRequest = ((ListInstancesRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.redis.v1beta1.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.
}
}
use of com.google.cloud.redis.v1beta1.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];
}
}
use of com.google.cloud.redis.v1beta1.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];
}
}
use of com.google.cloud.redis.v1beta1.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());
}
}
Aggregations