use of com.google.cloud.teleport.v2.values.EntityMetadata in project DataflowTemplates by GoogleCloudPlatform.
the class DefaultDataplexClient method updateEntitiesUnderAsset.
/**
* Handles just updating of entities. Each entity is logged after updating.
*/
private Map<EntityMetadata, GoogleCloudDataplexV1Entity> updateEntitiesUnderAsset(String assetName, Map<EntityMetadata, GoogleCloudDataplexV1Entity> metadataToEntity) throws IOException {
Map<EntityMetadata, GoogleCloudDataplexV1Entity> updatedMetadataToEntity = new HashMap<>();
for (Map.Entry<EntityMetadata, GoogleCloudDataplexV1Entity> entry : metadataToEntity.entrySet()) {
EntityMetadata metadata = entry.getKey();
GoogleCloudDataplexV1Entity existing = entry.getValue();
metadata.updateDataplexEntity(existing);
GoogleCloudDataplexV1Entity updated = client.projects().locations().lakes().zones().entities().update(existing.getName(), existing.setAsset(assetName)).execute();
LOG.info("Updated entity with name '{}' that points to data path '{}'", updated.getName(), metadata.dataPath());
updatedMetadataToEntity.put(metadata, updated);
}
return updatedMetadataToEntity;
}
use of com.google.cloud.teleport.v2.values.EntityMetadata in project DataflowTemplates by GoogleCloudPlatform.
the class DefaultDataplexClient method createEntitiesUnderAsset.
/**
* Handles just the creation of entities. Each entity is logged after creation.
*/
private Map<EntityMetadata, GoogleCloudDataplexV1Entity> createEntitiesUnderAsset(String assetName, List<EntityMetadata> metadata) throws IOException {
Map<EntityMetadata, GoogleCloudDataplexV1Entity> metadataToEntity = new HashMap<>();
for (EntityMetadata m : metadata) {
GoogleCloudDataplexV1Entity entity = client.projects().locations().lakes().zones().entities().create(assetName, m.toDataplexEntity().setAsset(assetName)).execute();
LOG.info("Created entity with name '{}' pointing to '{}'", entity.getName(), m.dataPath());
metadataToEntity.put(m, entity);
}
return metadataToEntity;
}
Aggregations