Search in sources :

Example 1 with CreateFeedRequest

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

the class AsyncCreateFeed method asyncCreateFeed.

public static void asyncCreateFeed() throws Exception {
    // It may require modifications to work in your environment.
    try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
        CreateFeedRequest request = CreateFeedRequest.newBuilder().setParent("parent-995424086").setFeedId("feedId-1278410919").setFeed(Feed.newBuilder().build()).build();
        ApiFuture<Feed> future = assetServiceClient.createFeedCallable().futureCall(request);
        // Do something.
        Feed response = future.get();
    }
}
Also used : AssetServiceClient(com.google.cloud.asset.v1.AssetServiceClient) CreateFeedRequest(com.google.cloud.asset.v1.CreateFeedRequest) Feed(com.google.cloud.asset.v1.Feed)

Example 2 with CreateFeedRequest

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

the class SyncCreateFeed method syncCreateFeed.

public static void syncCreateFeed() throws Exception {
    // It may require modifications to work in your environment.
    try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
        CreateFeedRequest request = CreateFeedRequest.newBuilder().setParent("parent-995424086").setFeedId("feedId-1278410919").setFeed(Feed.newBuilder().build()).build();
        Feed response = assetServiceClient.createFeed(request);
    }
}
Also used : AssetServiceClient(com.google.cloud.asset.v1.AssetServiceClient) CreateFeedRequest(com.google.cloud.asset.v1.CreateFeedRequest) Feed(com.google.cloud.asset.v1.Feed)

Example 3 with CreateFeedRequest

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

Aggregations

AssetServiceClient (com.google.cloud.asset.v1.AssetServiceClient)3 CreateFeedRequest (com.google.cloud.asset.v1.CreateFeedRequest)3 Feed (com.google.cloud.asset.v1.Feed)3 IOException (java.io.IOException)1