本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
与 Amazon SDK或ListTagsForStream
一起使用 CLI
以下代码示例演示如何使用 ListTagsForStream
。
- .NET
-
- Amazon SDK for .NET
-
注意
还有更多相关信息 GitHub。查找完整示例,学习如何在 Amazon 代码示例存储库
中进行设置和运行。 using System; using System.Collections.Generic; using System.Threading.Tasks; using Amazon.Kinesis; using Amazon.Kinesis.Model; /// <summary> /// Shows how to list the tags that have been attached to an Amazon Kinesis /// stream. /// </summary> public class ListTags { public static async Task Main() { IAmazonKinesis client = new AmazonKinesisClient(); string streamName = "AmazonKinesisStream"; await ListTagsAsync(client, streamName); } /// <summary> /// List the tags attached to a Kinesis stream. /// </summary> /// <param name="client">An initialized Kinesis client object.</param> /// <param name="streamName">The name of the Kinesis stream for which you /// wish to display tags.</param> public static async Task ListTagsAsync(IAmazonKinesis client, string streamName) { var request = new ListTagsForStreamRequest { StreamName = streamName, Limit = 10, }; var response = await client.ListTagsForStreamAsync(request); DisplayTags(response.Tags); while (response.HasMoreTags) { request.ExclusiveStartTagKey = response.Tags[response.Tags.Count - 1].Key; response = await client.ListTagsForStreamAsync(request); } } /// <summary> /// Displays the items in a list of Kinesis tags. /// </summary> /// <param name="tags">A list of the Tag objects to be displayed.</param> public static void DisplayTags(List<Tag> tags) { tags .ForEach(t => Console.WriteLine($"Key: {t.Key} Value: {t.Value}")); } }
-
有关API详细信息,请参阅 “Amazon SDK for .NET API参考 ListTagsForStream” 中的。
-
- CLI
-
- Amazon CLI
-
列出数据流的标签
以下
list-tags-for-stream
示例列出了附加指定数据流的标签:aws kinesis list-tags-for-stream \ --stream-name
samplestream
输出:
{ "Tags": [ { "Key": "samplekey", "Value": "example" } ], "HasMoreTags": false }
有关更多信息,请参阅《Amazon Kinesis Data Streams 开发人员指南》中的标记流。
-
有关API详细信息,请参阅 “ListTagsForStream Amazon CLI
命令参考”。
-
有关 Amazon SDK开发者指南和代码示例的完整列表,请参阅将此服务与 Amazon SDK。本主题还包括有关入门的信息以及有关先前SDK版本的详细信息。
ListStreams
PutRecord