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;
}
Aggregations