本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
与 Amazon SDK或AddTagsToStream
一起使用 CLI
以下代码示例演示如何使用 AddTagsToStream
。
- .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> /// This example shows how to apply key/value pairs to an Amazon Kinesis /// stream. /// </summary> public class TagStream { public static async Task Main() { IAmazonKinesis client = new AmazonKinesisClient(); string streamName = "AmazonKinesisStream"; var tags = new Dictionary<string, string> { { "Project", "Sample Kinesis Project" }, { "Application", "Sample Kinesis App" }, }; var success = await ApplyTagsToStreamAsync(client, streamName, tags); if (success) { Console.WriteLine($"Taggs successfully added to {streamName}."); } else { Console.WriteLine("Tags were not added to the stream."); } } /// <summary> /// Applies the set of tags to the named Kinesis stream. /// </summary> /// <param name="client">The initialized Kinesis client.</param> /// <param name="streamName">The name of the Kinesis stream to which /// the tags will be attached.</param> /// <param name="tags">A sictionary containing key/value pairs which /// will be used to create the Kinesis tags.</param> /// <returns>A Boolean value which represents the success or failure /// of AddTagsToStreamAsync.</returns> public static async Task<bool> ApplyTagsToStreamAsync( IAmazonKinesis client, string streamName, Dictionary<string, string> tags) { var request = new AddTagsToStreamRequest { StreamName = streamName, Tags = tags, }; var response = await client.AddTagsToStreamAsync(request); return response.HttpStatusCode == System.Net.HttpStatusCode.OK; } }
-
有关API详细信息,请参阅 “Amazon SDK for .NET API参考 AddTagsToStream” 中的。
-
- CLI
-
- Amazon CLI
-
向数据流添加标签
以下
add-tags-to-stream
示例会将带有键samplekey
和值example
的标签分配给指定流。aws kinesis add-tags-to-stream \ --stream-name
samplestream
\ --tagssamplekey=example
此命令不生成任何输出。
有关更多信息,请参阅《Amazon Kinesis Data Streams 开发人员指南》中的标记流。
-
有关API详细信息,请参阅 “AddTagsToStream Amazon CLI
命令参考”。
-
有关 Amazon SDK开发者指南和代码示例的完整列表,请参阅将此服务与 Amazon SDK。本主题还包括有关入门的信息以及有关先前SDK版本的详细信息。
操作
CreateStream