Search in sources :

Example 6 with GoogleCloudDataplexV1Asset

use of com.google.api.services.dataplex.v1.model.GoogleCloudDataplexV1Asset in project DataflowTemplates by GoogleCloudPlatform.

the class DataplexBigQueryToGcs method resolveAsset.

/**
 * Resolves a Dataplex asset name into the corresponding resource spec, verifying that the asset
 * is of the correct type.
 */
private static String resolveAsset(DataplexClient dataplex, String assetName, DataplexAssetResourceSpec expectedType) throws IOException {
    LOG.info("Resolving asset: {}", assetName);
    GoogleCloudDataplexV1Asset asset = dataplex.getAsset(assetName);
    checkNotNull(asset.getResourceSpec(), "Asset has no ResourceSpec.");
    String type = asset.getResourceSpec().getType();
    if (!expectedType.name().equals(type)) {
        throw new IllegalArgumentException(String.format("Asset %s is of type %s, expected: %s.", assetName, type, expectedType.name()));
    }
    String resourceName = asset.getResourceSpec().getName();
    checkNotNull(resourceName, "Asset has no resource name.");
    LOG.info("Resolved resource name: {}", resourceName);
    return resourceName;
}
Also used : GoogleCloudDataplexV1Asset(com.google.api.services.dataplex.v1.model.GoogleCloudDataplexV1Asset)

Aggregations

GoogleCloudDataplexV1Asset (com.google.api.services.dataplex.v1.model.GoogleCloudDataplexV1Asset)6 GoogleCloudDataplexV1AssetResourceSpec (com.google.api.services.dataplex.v1.model.GoogleCloudDataplexV1AssetResourceSpec)1 GoogleCloudDataplexV1Entity (com.google.api.services.dataplex.v1.model.GoogleCloudDataplexV1Entity)1 GoogleCloudDataplexV1Partition (com.google.api.services.dataplex.v1.model.GoogleCloudDataplexV1Partition)1 GoogleCloudDataplexV1Zone (com.google.api.services.dataplex.v1.model.GoogleCloudDataplexV1Zone)1 DataplexClient (com.google.cloud.teleport.v2.clients.DataplexClient)1 DefaultDataplexClient (com.google.cloud.teleport.v2.clients.DefaultDataplexClient)1 DynamicDataSourceConfiguration (com.google.cloud.teleport.v2.io.DynamicJdbcIO.DynamicDataSourceConfiguration)1 DataplexJdbcIngestionOptions (com.google.cloud.teleport.v2.options.DataplexJdbcIngestionOptions)1 NoopTransform (com.google.cloud.teleport.v2.transforms.NoopTransform)1 WriteDispositionException (com.google.cloud.teleport.v2.utils.WriteDisposition.WriteDispositionException)1 Pipeline (org.apache.beam.sdk.Pipeline)1 Before (org.junit.Before)1