Пример #1
0
        public AddTagsToStreamResponse AddTagsToStream(Dictionary <string, string> tags, string streamName = null)
        {
            if (string.IsNullOrEmpty(streamName) && string.IsNullOrEmpty(_streamName))
            {
                throw new Exception("Please specify a stream name to add tags");
            }

            if (tags == null || tags.Count == 0 || tags.Count > 10)
            {
                throw new Exception("Please create a tag dictionary that's between 0 and 10 in size");
            }

            var addTagsRequest = new AddTagsToStreamRequest()
            {
                StreamName = streamName ?? _streamName,
                Tags       = tags
            };

            var response = AsyncHelper.RunSync(() => _client.AddTagsToStreamAsync(addTagsRequest));

            return(response);
        }
Пример #2
0
        /// <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);
        }
 private Amazon.Kinesis.Model.AddTagsToStreamResponse CallAWSServiceOperation(IAmazonKinesis client, Amazon.Kinesis.Model.AddTagsToStreamRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Kinesis", "AddTagsToStream");
     try
     {
         #if DESKTOP
         return(client.AddTagsToStream(request));
         #elif CORECLR
         return(client.AddTagsToStreamAsync(request).GetAwaiter().GetResult());
         #else
                 #error "Unknown build edition"
         #endif
     }
     catch (AmazonServiceException exc)
     {
         var webException = exc.InnerException as System.Net.WebException;
         if (webException != null)
         {
             throw new Exception(Utils.Common.FormatNameResolutionFailureMessage(client.Config, webException.Message), webException);
         }
         throw;
     }
 }