There are more AWS SDK examples available in the AWS Doc SDK Examples
Use ListDashboards
with an AWS SDK or CLI
The following code examples show how to use ListDashboards
.
- .NET
-
- AWS SDK for .NET
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository
. /// <summary> /// Get a list of dashboards. /// </summary> /// <returns>A list of DashboardEntry objects.</returns> public async Task<List<DashboardEntry>> ListDashboards() { var results = new List<DashboardEntry>(); var paginateDashboards = _amazonCloudWatch.Paginators.ListDashboards( new ListDashboardsRequest()); // Get the entire list using the paginator. await foreach (var data in paginateDashboards.DashboardEntries) { results.Add(data); } return results; }
-
For API details, see ListDashboards in AWS SDK for .NET API Reference.
-
- Java
-
- SDK for Java 2.x
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository
. public static void listDashboards(CloudWatchClient cw) { try { ListDashboardsIterable listRes = cw.listDashboardsPaginator(); listRes.stream() .flatMap(r -> r.dashboardEntries().stream()) .forEach(entry -> { System.out.println("Dashboard name is: " + entry.dashboardName()); System.out.println("Dashboard ARN is: " + entry.dashboardArn()); }); } catch (CloudWatchException e) { System.err.println(e.awsErrorDetails().errorMessage()); System.exit(1); } }
-
For API details, see ListDashboards in AWS SDK for Java 2.x API Reference.
-
- Kotlin
-
- SDK for Kotlin
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository
. suspend fun listDashboards() { CloudWatchClient { region = "us-east-1" }.use { cwClient -> cwClient .listDashboardsPaginated({}) .transform { it.dashboardEntries?.forEach { obj -> emit(obj) } } .collect { obj -> println("Name is ${obj.dashboardName}") println("Dashboard ARN is ${obj.dashboardArn}") } } }
-
For API details, see ListDashboards
in AWS SDK for Kotlin API reference.
-
- PowerShell
-
- Tools for PowerShell
-
Example 1: Returns the collection of dashboards for your account.
Get-CWDashboardList
Output:
DashboardArn DashboardName LastModified Size ------------ ------------- ------------ ---- arn:... Dashboard1 7/6/2017 8:14:15 PM 252
Example 2: Returns the collection of dashboards for your account whose names start with the prefix 'dev'.
Get-CWDashboardList -DashboardNamePrefix dev
-
For API details, see ListDashboards in AWS Tools for PowerShell Cmdlet Reference.
-