List EventBridge rules using an Amazon SDK - Amazon EventBridge
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

List EventBridge rules using an Amazon SDK

The following code example shows how to list Amazon EventBridge rules.

.NET
Amazon SDK for .NET
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the Amazon Code Examples Repository.

List all of the rules for an event bus.

/// <summary> /// List the rules on an event bus. /// </summary> /// <param name="eventBusArn">The optional ARN of the event bus. If empty, uses the default event bus.</param> /// <returns>The list of rules.</returns> public async Task<List<Rule>> ListAllRulesForEventBus(string? eventBusArn = null) { var results = new List<Rule>(); var request = new ListRulesRequest() { EventBusName = eventBusArn }; // Get all of the pages of rules. ListRulesResponse response; do { response = await _amazonEventBridge.ListRulesAsync(request); results.AddRange(response.Rules); request.NextToken = response.NextToken; } while (response.NextToken is not null); return results; }
  • For API details, see ListRules in Amazon SDK for .NET API Reference.

For a complete list of Amazon SDK developer guides and code examples, see Using EventBridge with an Amazon SDK. This topic also includes information about getting started and details about previous SDK versions.