Search in sources :

Example 11 with Feed

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

the class SyncUpdateFeedFeed method syncUpdateFeedFeed.

public static void syncUpdateFeedFeed() throws Exception {
    // It may require modifications to work in your environment.
    try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
        Feed feed = Feed.newBuilder().build();
        Feed response = assetServiceClient.updateFeed(feed);
    }
}
Also used : AssetServiceClient(com.google.cloud.asset.v1.AssetServiceClient) Feed(com.google.cloud.asset.v1.Feed)

Example 12 with Feed

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

the class CreateFeedExample method createFeed.

// Create a feed
public static void createFeed(String[] assetNames, String feedId, String topic, String projectId, ContentType contentType) throws IOException, IllegalArgumentException {
    // String[] assetNames = {"MY_ASSET_NAME"}
    // ContentType contentType = contentType
    // String FeedId = "MY_FEED_ID"
    // String topic = "projects/[PROJECT_ID]/topics/[TOPIC_NAME]"
    // String projectID = "MY_PROJECT_ID"
    Feed feed = Feed.newBuilder().addAllAssetNames(Arrays.asList(assetNames)).setContentType(contentType).setFeedOutputConfig(FeedOutputConfig.newBuilder().setPubsubDestination(PubsubDestination.newBuilder().setTopic(topic).build()).build()).build();
    CreateFeedRequest request = CreateFeedRequest.newBuilder().setParent(String.format(ProjectName.of(projectId).toString())).setFeedId(feedId).setFeed(feed).build();
    // the "close" method on the client to safely clean up any remaining background resources.
    try (AssetServiceClient client = AssetServiceClient.create()) {
        Feed response = client.createFeed(request);
        System.out.println("Feed created successfully: " + response.getName());
    } catch (IOException | IllegalArgumentException e) {
        System.out.println("Error during CreateFeed: \n" + e.toString());
    }
}
Also used : AssetServiceClient(com.google.cloud.asset.v1.AssetServiceClient) IOException(java.io.IOException) CreateFeedRequest(com.google.cloud.asset.v1.CreateFeedRequest) Feed(com.google.cloud.asset.v1.Feed)

Example 13 with Feed

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

the class GetFeedExample method getFeed.

// Get a feed with full feed name
public static void getFeed(String feedName) throws Exception {
    // the "close" method on the client to safely clean up any remaining background resources.
    try (AssetServiceClient client = AssetServiceClient.create()) {
        Feed feed = client.getFeed(feedName);
        System.out.println("Get a feed: " + feedName);
    } catch (Exception e) {
        System.out.println("Error during GetFeed: \n" + e.toString());
    }
}
Also used : AssetServiceClient(com.google.cloud.asset.v1.AssetServiceClient) Feed(com.google.cloud.asset.v1.Feed)

Example 14 with Feed

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

the class DeleteFeedExample method deleteFeed.

// Delete a feed with full feed name
public static void deleteFeed(String feedName) throws Exception {
    // the "close" method on the client to safely clean up any remaining background resources.
    try (AssetServiceClient client = AssetServiceClient.create()) {
        client.deleteFeed(feedName);
        System.out.println("Feed deleted");
    } catch (Exception e) {
        System.out.println("Error during DeleteFeed: \n" + e.toString());
    }
}
Also used : AssetServiceClient(com.google.cloud.asset.v1.AssetServiceClient)

Example 15 with Feed

use of com.google.cloud.asset.v1.Feed 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)

Aggregations

AssetServiceClient (com.google.cloud.asset.v1.AssetServiceClient)24 Feed (com.google.cloud.asset.v1.Feed)13 ArrayList (java.util.ArrayList)6 CreateFeedRequest (com.google.cloud.asset.v1.CreateFeedRequest)3 ExportAssetsRequest (com.google.cloud.asset.v1.ExportAssetsRequest)3 UpdateFeedRequest (com.google.cloud.asset.v1.UpdateFeedRequest)3 Asset (com.google.cloud.asset.v1.Asset)2 DeleteFeedRequest (com.google.cloud.asset.v1.DeleteFeedRequest)2 ExportAssetsResponse (com.google.cloud.asset.v1.ExportAssetsResponse)2 FeedName (com.google.cloud.asset.v1.FeedName)2 GetFeedRequest (com.google.cloud.asset.v1.GetFeedRequest)2 ListAssetsRequest (com.google.cloud.asset.v1.ListAssetsRequest)2 ResourceName (com.google.api.resourcenames.ResourceName)1 ListAssetsPagedResponse (com.google.cloud.asset.v1.AssetServiceClient.ListAssetsPagedResponse)1 BatchGetAssetsHistoryRequest (com.google.cloud.asset.v1.BatchGetAssetsHistoryRequest)1 BatchGetAssetsHistoryResponse (com.google.cloud.asset.v1.BatchGetAssetsHistoryResponse)1 ListAssetsResponse (com.google.cloud.asset.v1.ListAssetsResponse)1 Operation (com.google.longrunning.Operation)1 AbstractMessage (com.google.protobuf.AbstractMessage)1 Empty (com.google.protobuf.Empty)1