use of com.google.cloud.datacatalog.v1beta1.ListEntriesRequest in project DataflowTemplates by GoogleCloudPlatform.
the class DataCatalogSchemaUtils method getSchemasForEntryGroup.
/**
* Retrieve all of the {@link Schema}s associated to {@link Entry}s in an {@link EntryGroup}.
*/
public static Map<String, Schema> getSchemasForEntryGroup(String gcpProject, String entryGroupId) {
DataCatalogClient client = null;
try {
client = DataCatalogClient.create();
} catch (IOException e) {
throw new RuntimeException("Unable to create a DataCatalogClient", e);
}
if (client == null) {
return null;
}
String formattedParent = DataCatalogClient.formatEntryGroupName(gcpProject, DEFAULT_LOCATION, entryGroupId);
List<Entry> entries = new ArrayList<>();
ListEntriesRequest request = ListEntriesRequest.newBuilder().setParent(formattedParent).build();
while (true) {
ListEntriesResponse response = client.listEntriesCallable().call(request);
entries.addAll(response.getEntriesList());
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
LOG.debug("Fetched entries: {}", entries);
return entries.stream().collect(Collectors.toMap(Entry::getDescription, e -> SchemaUtils.toBeamSchema(e.getSchema())));
}
Aggregations