use of com.google.api.services.dataplex.v1.model.GoogleCloudDataplexV1ListPartitionsResponse in project DataflowTemplates by GoogleCloudPlatform.
the class DefaultDataplexClient method getPartitions.
@Override
public ImmutableList<GoogleCloudDataplexV1Partition> getPartitions(String entityName) throws IOException {
ImmutableList.Builder<GoogleCloudDataplexV1Partition> result = ImmutableList.builder();
Partitions partitions = client.projects().locations().lakes().zones().entities().partitions();
GoogleCloudDataplexV1ListPartitionsResponse response = partitions.list(entityName).execute();
if (response.getPartitions() == null) {
return ImmutableList.of();
}
result.addAll(response.getPartitions());
// the result of the list is paginated with the default page size being 10
while (response.getNextPageToken() != null) {
response = partitions.list(entityName).setPageToken(response.getNextPageToken()).execute();
result.addAll(response.getPartitions());
}
return result.build();
}
use of com.google.api.services.dataplex.v1.model.GoogleCloudDataplexV1ListPartitionsResponse in project DataflowTemplates by GoogleCloudPlatform.
the class DefaultDataplexClientTest method testGetPartitionsByEntityName.
@Test
public void testGetPartitionsByEntityName() throws IOException {
CloudDataplex cloudDataplexClient = mock(CloudDataplex.class, Answers.RETURNS_DEEP_STUBS);
Partitions partitions = mock(Partitions.class, Answers.RETURNS_DEEP_STUBS);
when(cloudDataplexClient.projects().locations().lakes().zones().entities().partitions()).thenReturn(partitions);
GoogleCloudDataplexV1Partition partition1 = new GoogleCloudDataplexV1Partition().setName("partition1");
GoogleCloudDataplexV1Partition partition2 = new GoogleCloudDataplexV1Partition().setName("partition2");
GoogleCloudDataplexV1Partition partition3 = new GoogleCloudDataplexV1Partition().setName("partition2");
GoogleCloudDataplexV1ListPartitionsResponse response1 = new GoogleCloudDataplexV1ListPartitionsResponse().setPartitions(ImmutableList.of(partition1, partition2)).setNextPageToken(PAGE_TOKEN);
GoogleCloudDataplexV1ListPartitionsResponse response2 = new GoogleCloudDataplexV1ListPartitionsResponse().setPartitions(ImmutableList.of(partition3));
when(partitions.list("entity0").execute()).thenReturn(response1);
when(partitions.list("entity0").setPageToken(eq(PAGE_TOKEN)).execute()).thenReturn(response2);
assertEquals(ImmutableList.of(partition1, partition2, partition3), DefaultDataplexClient.withClient(cloudDataplexClient).getPartitions("entity0"));
}
Aggregations