ListEventBuses.java - AWS Code Sample

ListEventBuses.java

ListEventBuses.java demonstrates how to list your Amazon EventBridge buses.

Note

To run this Java (SDK V2) code example, ensure that you have set up your development environment, including your credentials. For more information, see AWS SDK for Java 2.x Developer Guide.

/* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0 */ package com.example.eventbridge; import software.amazon.awssdk.regions.Region; import software.amazon.awssdk.services.eventbridge.EventBridgeClient; import software.amazon.awssdk.services.eventbridge.model.EventBridgeException; import software.amazon.awssdk.services.eventbridge.model.EventBus; import software.amazon.awssdk.services.eventbridge.model.ListEventBusesRequest; import software.amazon.awssdk.services.eventbridge.model.ListEventBusesResponse; import java.util.List; /** * To run this Java V2 code example, ensure that you have setup your development environment, including your credentials. * * For information, see this documentation topic: * * https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html */ public class ListEventBuses { public static void main(String[] args) { Region region = Region.US_WEST_2; EventBridgeClient eventBrClient = EventBridgeClient.builder() .region(region) .build(); listBuses(eventBrClient) ; eventBrClient.close(); } public static void listBuses( EventBridgeClient eventBrClient) { try { ListEventBusesRequest busesRequest = ListEventBusesRequest.builder() .limit(10) .build(); ListEventBusesResponse response = eventBrClient.listEventBuses(busesRequest); List<EventBus> buses = response.eventBuses(); for (EventBus bus: buses) { System.out.println("The name of the event bus is: "+bus.name()); System.out.println("The ARN of the event bus is: "+bus.arn()); } } catch (EventBridgeException e) { System.err.println(e.awsErrorDetails().errorMessage()); System.exit(1); } } }

Sample Details

Service: Amazon EventBridge

Last tested: 09/28/2021

Author: scmacdon-aws

Type: full-example