AWS 文檔 AWS SDK示例 GitHub 回購中有更多SDK示例
本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
搭ListTagsForStream
配 AWS SDK或使用 CLI
下列程式碼範例會示範如何使用ListTagsForStream
。
- .NET
-
- AWS SDK for .NET
-
注意
還有更多關於 GitHub。尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫
中設定和執行。 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細資訊,請參閱AWS SDK for .NET API參考ListTagsForStream中的。
-
- CLI
-
- AWS CLI
-
若要列出資料串流的標籤
下列
list-tags-for-stream
範例會列出附加至指定資料串流的標籤。aws kinesis list-tags-for-stream \ --stream-name
samplestream
輸出:
{ "Tags": [ { "Key": "samplekey", "Value": "example" } ], "HasMoreTags": false }
如需詳細資訊,請參閱 Amazon Kinesis 資料串流開發人員指南中的標記串流。
-
如需詳API細資訊,請參閱AWS CLI 指令參考ListTagsForStream
中的。
-
ListStreams
PutRecord