将 ListStreams 与 AWS SDK 或 CLI 配合使用 - AWS SDK 代码示例

AWS 文档 SDK 示例 GitHub 存储库中还有更多 AWS SDK 示例。

ListStreams 与 AWS SDK 或 CLI 配合使用

以下代码示例演示如何使用 ListStreams

.NET
适用于 .NET 的 SDK
注意

查看 GitHub,了解更多信息。在 AWS 代码示例存储库中查找完整示例,了解如何进行设置和运行。

using System; using System.Collections.Generic; using System.Threading.Tasks; using Amazon.Kinesis; using Amazon.Kinesis.Model; /// <summary> /// Retrieves and displays a list of existing Amazon Kinesis streams. /// </summary> public class ListStreams { public static async Task Main(string[] args) { IAmazonKinesis client = new AmazonKinesisClient(); var response = await client.ListStreamsAsync(new ListStreamsRequest()); List<string> streamNames = response.StreamNames; if (streamNames.Count > 0) { streamNames .ForEach(s => Console.WriteLine($"Stream name: {s}")); } else { Console.WriteLine("No streams were found."); } } }
  • 有关 API 的详细信息,请参阅《适用于 .NET 的 AWS SDK API Reference》中的 ListStreams

CLI
AWS CLI

列出数据流

以下 list-streams 示例列出了当前账户和区域中的所有活动数据流。

aws kinesis list-streams

输出:

{ "StreamNames": [ "samplestream", "samplestream1" ] }

有关更多信息,请参阅《Amazon Kinesis Data Streams 开发人员指南》中的列出流

  • 有关 API 详细信息,请参阅《AWS CLI 命令参考》中的 ListStreams

Rust
适用于 Rust 的 SDK
注意

查看 GitHub,了解更多信息。在 AWS 代码示例存储库中查找完整示例,了解如何进行设置和运行。

async fn show_streams(client: &Client) -> Result<(), Error> { let resp = client.list_streams().send().await?; println!("Stream names:"); let streams = resp.stream_names; for stream in &streams { println!(" {}", stream); } println!("Found {} stream(s)", streams.len()); Ok(()) }
  • 有关 API 详细信息,请参阅《AWS SDK for Rust API Reference》中的 ListStreams

SAP ABAP
适用于 SAP ABAP 的 SDK
注意

查看 GitHub,了解更多信息。在 AWS 代码示例存储库中查找完整示例,了解如何进行设置和运行。

TRY. oo_result = lo_kns->liststreams( " oo_result is returned for testing purposes. " "Set Limit to specify that a maximum of streams should be returned." iv_limit = iv_limit ). DATA(lt_streams) = oo_result->get_streamnames( ). MESSAGE 'Streams listed.' TYPE 'I'. CATCH /aws1/cx_knslimitexceededex. MESSAGE 'The request processing has failed because of a limit exceed exception.' TYPE 'E'. ENDTRY.
  • 有关 API 详细信息,请参阅《AWS SDK for SAP ABAP API Reference》中的 ListStreams