use of com.google.cloud.asset.v1.ExportAssetsResponse in project java-asset by googleapis.
the class ExportAssetsExample method exportAssets.
// Export assets for a project.
// @param exportPath where the results will be exported to.
public static void exportAssets(String exportPath, ContentType contentType) throws IOException, IllegalArgumentException, InterruptedException, ExecutionException {
try (AssetServiceClient client = AssetServiceClient.create()) {
ProjectName parent = ProjectName.of(projectId);
OutputConfig outputConfig = OutputConfig.newBuilder().setGcsDestination(GcsDestination.newBuilder().setUri(exportPath).build()).build();
ExportAssetsRequest request = ExportAssetsRequest.newBuilder().setParent(parent.toString()).setOutputConfig(outputConfig).setContentType(contentType).build();
ExportAssetsResponse response = client.exportAssetsAsync(request).get();
System.out.println(response);
}
}
use of com.google.cloud.asset.v1.ExportAssetsResponse in project gapic-generator-java by googleapis.
the class AsyncExportAssetsLRO method asyncExportAssetsLRO.
public static void asyncExportAssetsLRO() throws Exception {
// It may require modifications to work in your environment.
try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
ExportAssetsRequest request = ExportAssetsRequest.newBuilder().setParent(FeedName.ofProjectFeedName("[PROJECT]", "[FEED]").toString()).setReadTime(Timestamp.newBuilder().build()).addAllAssetTypes(new ArrayList<String>()).setContentType(ContentType.forNumber(0)).setOutputConfig(OutputConfig.newBuilder().build()).addAllRelationshipTypes(new ArrayList<String>()).build();
OperationFuture<ExportAssetsResponse, ExportAssetsRequest> future = assetServiceClient.exportAssetsOperationCallable().futureCall(request);
// Do something.
ExportAssetsResponse response = future.get();
}
}
use of com.google.cloud.asset.v1.ExportAssetsResponse in project gapic-generator-java by googleapis.
the class SyncExportAssets method syncExportAssets.
public static void syncExportAssets() throws Exception {
// It may require modifications to work in your environment.
try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
ExportAssetsRequest request = ExportAssetsRequest.newBuilder().setParent(FeedName.ofProjectFeedName("[PROJECT]", "[FEED]").toString()).setReadTime(Timestamp.newBuilder().build()).addAllAssetTypes(new ArrayList<String>()).setContentType(ContentType.forNumber(0)).setOutputConfig(OutputConfig.newBuilder().build()).addAllRelationshipTypes(new ArrayList<String>()).build();
ExportAssetsResponse response = assetServiceClient.exportAssetsAsync(request).get();
}
}
use of com.google.cloud.asset.v1.ExportAssetsResponse in project java-asset by googleapis.
the class ExportAssetsBigqueryExample method exportBigQuery.
// Export assets to BigQuery for a project.
public static void exportBigQuery(String bigqueryDataset, String bigqueryTable, ContentType contentType, boolean isPerType) throws IOException, IllegalArgumentException, InterruptedException, ExecutionException {
try (AssetServiceClient client = AssetServiceClient.create()) {
ProjectName parent = ProjectName.of(projectId);
OutputConfig outputConfig;
// Outputs to per-type BigQuery table.
if (isPerType) {
outputConfig = OutputConfig.newBuilder().setBigqueryDestination(BigQueryDestination.newBuilder().setDataset(bigqueryDataset).setTable(bigqueryTable).setForce(true).setSeparateTablesPerAssetType(true).setPartitionSpec(PartitionSpec.newBuilder().setPartitionKey(PartitionSpec.PartitionKey.READ_TIME).build()).build()).build();
} else {
outputConfig = OutputConfig.newBuilder().setBigqueryDestination(BigQueryDestination.newBuilder().setDataset(bigqueryDataset).setTable(bigqueryTable).setForce(true).build()).build();
}
ExportAssetsRequest request = ExportAssetsRequest.newBuilder().setParent(parent.toString()).setContentType(contentType).setOutputConfig(outputConfig).build();
ExportAssetsResponse response = client.exportAssetsAsync(request).get();
System.out.println(response);
}
}
Aggregations