Search in sources :

Example 1 with BatchGetAssetsHistoryResponse

use of com.google.cloud.asset.v1.BatchGetAssetsHistoryResponse in project gapic-generator-java by googleapis.

the class AsyncBatchGetAssetsHistory method asyncBatchGetAssetsHistory.

public static void asyncBatchGetAssetsHistory() throws Exception {
    // It may require modifications to work in your environment.
    try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
        BatchGetAssetsHistoryRequest request = BatchGetAssetsHistoryRequest.newBuilder().setParent(FeedName.ofProjectFeedName("[PROJECT]", "[FEED]").toString()).addAllAssetNames(new ArrayList<String>()).setContentType(ContentType.forNumber(0)).setReadTimeWindow(TimeWindow.newBuilder().build()).addAllRelationshipTypes(new ArrayList<String>()).build();
        ApiFuture<BatchGetAssetsHistoryResponse> future = assetServiceClient.batchGetAssetsHistoryCallable().futureCall(request);
        // Do something.
        BatchGetAssetsHistoryResponse response = future.get();
    }
}
Also used : AssetServiceClient(com.google.cloud.asset.v1.AssetServiceClient) ArrayList(java.util.ArrayList) BatchGetAssetsHistoryRequest(com.google.cloud.asset.v1.BatchGetAssetsHistoryRequest) BatchGetAssetsHistoryResponse(com.google.cloud.asset.v1.BatchGetAssetsHistoryResponse)

Example 2 with BatchGetAssetsHistoryResponse

use of com.google.cloud.asset.v1.BatchGetAssetsHistoryResponse in project java-asset by googleapis.

the class BatchGetAssetsHistoryExample method main.

// Export assets for a project.
// @param args path where the results will be exported to.
public static void main(String... args) throws Exception {
    // Asset names, e.g.: "//storage.googleapis.com/[BUCKET_NAME]"
    String[] assetNames = args[0].split(",");
    try (AssetServiceClient client = AssetServiceClient.create()) {
        ProjectName parent = ProjectName.of(projectId);
        ContentType contentType = ContentType.CONTENT_TYPE_UNSPECIFIED;
        TimeWindow readTimeWindow = TimeWindow.newBuilder().build();
        BatchGetAssetsHistoryRequest request = BatchGetAssetsHistoryRequest.newBuilder().setParent(parent.toString()).addAllAssetNames(Arrays.asList(assetNames)).setContentType(contentType).setReadTimeWindow(readTimeWindow).build();
        BatchGetAssetsHistoryResponse response = client.batchGetAssetsHistory(request);
        System.out.println(response);
    }
}
Also used : ContentType(com.google.cloud.asset.v1.ContentType) ProjectName(com.google.cloud.asset.v1.ProjectName) AssetServiceClient(com.google.cloud.asset.v1.AssetServiceClient) BatchGetAssetsHistoryRequest(com.google.cloud.asset.v1.BatchGetAssetsHistoryRequest) BatchGetAssetsHistoryResponse(com.google.cloud.asset.v1.BatchGetAssetsHistoryResponse) TimeWindow(com.google.cloud.asset.v1.TimeWindow)

Aggregations

AssetServiceClient (com.google.cloud.asset.v1.AssetServiceClient)2 BatchGetAssetsHistoryRequest (com.google.cloud.asset.v1.BatchGetAssetsHistoryRequest)2 BatchGetAssetsHistoryResponse (com.google.cloud.asset.v1.BatchGetAssetsHistoryResponse)2 ContentType (com.google.cloud.asset.v1.ContentType)1 ProjectName (com.google.cloud.asset.v1.ProjectName)1 TimeWindow (com.google.cloud.asset.v1.TimeWindow)1 ArrayList (java.util.ArrayList)1