Search in sources :

Example 1 with FeedName

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

the class SyncDeleteFeedFeedname method syncDeleteFeedFeedname.

public static void syncDeleteFeedFeedname() throws Exception {
    // It may require modifications to work in your environment.
    try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
        FeedName name = FeedName.ofProjectFeedName("[PROJECT]", "[FEED]");
        assetServiceClient.deleteFeed(name);
    }
}
Also used : AssetServiceClient(com.google.cloud.asset.v1.AssetServiceClient) FeedName(com.google.cloud.asset.v1.FeedName)

Example 2 with FeedName

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

the class SyncGetFeedFeedname method syncGetFeedFeedname.

public static void syncGetFeedFeedname() throws Exception {
    // It may require modifications to work in your environment.
    try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
        FeedName name = FeedName.ofProjectFeedName("[PROJECT]", "[FEED]");
        Feed response = assetServiceClient.getFeed(name);
    }
}
Also used : AssetServiceClient(com.google.cloud.asset.v1.AssetServiceClient) FeedName(com.google.cloud.asset.v1.FeedName) Feed(com.google.cloud.asset.v1.Feed)

Example 3 with FeedName

use of com.google.cloud.asset.v1.FeedName 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 4 with FeedName

use of com.google.cloud.asset.v1.FeedName 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 5 with FeedName

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

the class UpdateFeedExample method updateFeed.

// Update a feed
public static void updateFeed(String feedName, String topic) throws Exception {
    // String feedName = "MY_FEED_NAME"
    // String topic = "projects/[PROJECT_ID]/topics/[TOPIC_NAME]"
    Feed feed = Feed.newBuilder().setName(feedName).setFeedOutputConfig(FeedOutputConfig.newBuilder().setPubsubDestination(PubsubDestination.newBuilder().setTopic(topic).build()).build()).build();
    UpdateFeedRequest request = UpdateFeedRequest.newBuilder().setFeed(feed).setUpdateMask(FieldMask.newBuilder().addPaths("feed_output_config.pubsub_destination.topic").build()).build();
    // the "close" method on the client to safely clean up any remaining background resources.
    try (AssetServiceClient client = AssetServiceClient.create()) {
        Feed response = client.updateFeed(request);
        System.out.println("Feed updated successfully: " + response.getName());
    } catch (Exception e) {
        System.out.println("Error during UpdateFeed: \n" + e.toString());
    }
}
Also used : UpdateFeedRequest(com.google.cloud.asset.v1.UpdateFeedRequest) AssetServiceClient(com.google.cloud.asset.v1.AssetServiceClient) Feed(com.google.cloud.asset.v1.Feed)

Aggregations

AssetServiceClient (com.google.cloud.asset.v1.AssetServiceClient)5 Feed (com.google.cloud.asset.v1.Feed)3 FeedName (com.google.cloud.asset.v1.FeedName)2 UpdateFeedRequest (com.google.cloud.asset.v1.UpdateFeedRequest)1