Search in sources :

Example 1 with DescribeSubscriptionFiltersResponse

use of software.amazon.awssdk.services.cloudwatchlogs.model.DescribeSubscriptionFiltersResponse in project aws-doc-sdk-examples by awsdocs.

the class DescribeSubscriptionFilters method describeFilters.

// snippet-start:[cloudwatch.java2.describe_subscription_filters.main]
public static void describeFilters(CloudWatchLogsClient logs, String logGroup) {
    try {
        boolean done = false;
        String newToken = null;
        while (!done) {
            DescribeSubscriptionFiltersResponse response;
            if (newToken == null) {
                DescribeSubscriptionFiltersRequest request = DescribeSubscriptionFiltersRequest.builder().logGroupName(logGroup).limit(1).build();
                response = logs.describeSubscriptionFilters(request);
            } else {
                DescribeSubscriptionFiltersRequest request = DescribeSubscriptionFiltersRequest.builder().nextToken(newToken).logGroupName(logGroup).limit(1).build();
                response = logs.describeSubscriptionFilters(request);
            }
            for (SubscriptionFilter filter : response.subscriptionFilters()) {
                System.out.printf("Retrieved filter with name %s, " + "pattern %s " + "and destination arn %s", filter.filterName(), filter.filterPattern(), filter.destinationArn());
                System.out.println("");
            }
            if (response.nextToken() == null) {
                done = true;
            } else {
                newToken = response.nextToken();
            }
        }
    } catch (CloudWatchException e) {
        System.err.println(e.awsErrorDetails().errorMessage());
        System.exit(1);
    }
    System.out.printf("Done");
}
Also used : SubscriptionFilter(software.amazon.awssdk.services.cloudwatchlogs.model.SubscriptionFilter) CloudWatchException(software.amazon.awssdk.services.cloudwatch.model.CloudWatchException) DescribeSubscriptionFiltersResponse(software.amazon.awssdk.services.cloudwatchlogs.model.DescribeSubscriptionFiltersResponse) DescribeSubscriptionFiltersRequest(software.amazon.awssdk.services.cloudwatchlogs.model.DescribeSubscriptionFiltersRequest)

Aggregations

CloudWatchException (software.amazon.awssdk.services.cloudwatch.model.CloudWatchException)1 DescribeSubscriptionFiltersRequest (software.amazon.awssdk.services.cloudwatchlogs.model.DescribeSubscriptionFiltersRequest)1 DescribeSubscriptionFiltersResponse (software.amazon.awssdk.services.cloudwatchlogs.model.DescribeSubscriptionFiltersResponse)1 SubscriptionFilter (software.amazon.awssdk.services.cloudwatchlogs.model.SubscriptionFilter)1