Search in sources :

Example 1 with EntityMetadata

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;
}
Also used : EntityMetadata(com.google.cloud.teleport.v2.values.EntityMetadata) HashMap(java.util.HashMap) GoogleCloudDataplexV1Entity(com.google.api.services.dataplex.v1.model.GoogleCloudDataplexV1Entity) HashMap(java.util.HashMap) Collectors.toMap(java.util.stream.Collectors.toMap) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap)

Example 2 with EntityMetadata

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;
}
Also used : EntityMetadata(com.google.cloud.teleport.v2.values.EntityMetadata) HashMap(java.util.HashMap) GoogleCloudDataplexV1Entity(com.google.api.services.dataplex.v1.model.GoogleCloudDataplexV1Entity)

Aggregations

GoogleCloudDataplexV1Entity (com.google.api.services.dataplex.v1.model.GoogleCloudDataplexV1Entity)2 EntityMetadata (com.google.cloud.teleport.v2.values.EntityMetadata)2 HashMap (java.util.HashMap)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 Map (java.util.Map)1 Collectors.toMap (java.util.stream.Collectors.toMap)1