mirror of
https://github.com/fog/fog-aws.git
synced 2022-11-09 13:50:52 -05:00
Implement list_tags_for_stream
This commit is contained in:
parent
4bfa355e86
commit
0ec563f778
4 changed files with 78 additions and 3 deletions
|
@ -25,7 +25,7 @@ module Fog
|
||||||
request :split_shard
|
request :split_shard
|
||||||
request :merge_shards
|
request :merge_shards
|
||||||
request :add_tags_to_stream
|
request :add_tags_to_stream
|
||||||
# request :list_tags_for_stream
|
request :list_tags_for_stream
|
||||||
# request :remove_tags_from_stream
|
# request :remove_tags_from_stream
|
||||||
|
|
||||||
class Real
|
class Real
|
||||||
|
|
|
@ -6,7 +6,7 @@ module Fog
|
||||||
#
|
#
|
||||||
# ==== Options
|
# ==== Options
|
||||||
# * StreamName<~String>: The name of the stream.
|
# * StreamName<~String>: The name of the stream.
|
||||||
# * Tags<~Hash>: The name of the stream.
|
# * Tags<~Hash>: The set of key-value pairs to use to create the tags.
|
||||||
# ==== Returns
|
# ==== Returns
|
||||||
# * response<~Excon::Response>:
|
# * response<~Excon::Response>:
|
||||||
#
|
#
|
||||||
|
@ -16,7 +16,7 @@ module Fog
|
||||||
def add_tags_to_stream(options={})
|
def add_tags_to_stream(options={})
|
||||||
body = {
|
body = {
|
||||||
"StreamName" => options.delete("StreamName"),
|
"StreamName" => options.delete("StreamName"),
|
||||||
"Tags" => Fog::JSON.encode(options.delete("Tags"))
|
"Tags" => options.delete("Tags")
|
||||||
}.reject{ |_,v| v.nil? }
|
}.reject{ |_,v| v.nil? }
|
||||||
|
|
||||||
request({
|
request({
|
||||||
|
|
57
lib/fog/aws/requests/kinesis/list_tags_for_stream.rb
Normal file
57
lib/fog/aws/requests/kinesis/list_tags_for_stream.rb
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
module Fog
|
||||||
|
module AWS
|
||||||
|
class Kinesis
|
||||||
|
class Real
|
||||||
|
# Lists the tags for the specified Amazon Kinesis stream.
|
||||||
|
#
|
||||||
|
# ==== Options
|
||||||
|
# * ExclusiveStartTagKey<~String>: The key to use as the starting point for the list of tags.
|
||||||
|
# * Limit<~Number>: The number of tags to return.
|
||||||
|
# * StreamName<~String>: The name of the stream.
|
||||||
|
# ==== Returns
|
||||||
|
# * response<~Excon::Response>:
|
||||||
|
#
|
||||||
|
# ==== See Also
|
||||||
|
# https://docs.aws.amazon.com/kinesis/latest/APIReference/API_ListTagsForStream.html
|
||||||
|
#
|
||||||
|
def list_tags_for_stream(options={})
|
||||||
|
body = {
|
||||||
|
"ExclusiveStartTagKey" => options.delete("ExclusiveStartTagKey"),
|
||||||
|
"Limit" => options.delete("Limit"),
|
||||||
|
"StreamName" => options.delete("StreamName")
|
||||||
|
}.reject{ |_,v| v.nil? }
|
||||||
|
|
||||||
|
response = request({
|
||||||
|
:idempotent => true,
|
||||||
|
'X-Amz-Target' => "Kinesis_#{@version}.ListTagsForStream",
|
||||||
|
:body => body,
|
||||||
|
}.merge(options))
|
||||||
|
response.body = Fog::JSON.decode(response.body) unless response.body.nil?
|
||||||
|
response.body
|
||||||
|
response
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class Mock
|
||||||
|
def list_tags_for_stream(options={})
|
||||||
|
stream_name = options.delete("StreamName")
|
||||||
|
|
||||||
|
unless stream = data[:kinesis_streams].detect{ |s| s["StreamName"] == stream_name }
|
||||||
|
raise 'unknown stream'
|
||||||
|
end
|
||||||
|
|
||||||
|
response = Excon::Response.new
|
||||||
|
response.status = 200
|
||||||
|
response.body = {
|
||||||
|
"HasMoreTags" => false,
|
||||||
|
"Tags" => stream["Tags"].map{ |k,v|
|
||||||
|
{"Key" => k, "Value" => v}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
response
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -85,6 +85,16 @@ Shindo.tests('AWS::Kinesis | stream requests', ['aws', 'kinesis']) do
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@list_tags_for_stream_format = {
|
||||||
|
"HasMoreTags" => Fog::Boolean,
|
||||||
|
"Tags" => [
|
||||||
|
{
|
||||||
|
"Key" => String,
|
||||||
|
"Value" => String
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
tests("#create_stream").returns("") do
|
tests("#create_stream").returns("") do
|
||||||
Fog::AWS[:kinesis].create_stream("StreamName" => @stream_id).body.tap do
|
Fog::AWS[:kinesis].create_stream("StreamName" => @stream_id).body.tap do
|
||||||
wait_for_status.call("ACTIVE")
|
wait_for_status.call("ACTIVE")
|
||||||
|
@ -209,6 +219,14 @@ Shindo.tests('AWS::Kinesis | stream requests', ['aws', 'kinesis']) do
|
||||||
Fog::AWS[:kinesis].add_tags_to_stream("StreamName" => @stream_id, "Tags" => {"a" => "1", "b" => "2"}).body
|
Fog::AWS[:kinesis].add_tags_to_stream("StreamName" => @stream_id, "Tags" => {"a" => "1", "b" => "2"}).body
|
||||||
end
|
end
|
||||||
|
|
||||||
|
tests("#list_tags_for_stream").formats(@list_tags_for_stream_format) do
|
||||||
|
Fog::AWS[:kinesis].list_tags_for_stream("StreamName" => @stream_id).body.tap do |body|
|
||||||
|
returns({"a" => "1", "b" => "2"}) {
|
||||||
|
body["Tags"].inject({}){ |m, tag| m.merge(tag["Key"] => tag["Value"]) }
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
tests("#delete_stream").returns("") do
|
tests("#delete_stream").returns("") do
|
||||||
Fog::AWS[:kinesis].delete_stream("StreamName" => @stream_id).body
|
Fog::AWS[:kinesis].delete_stream("StreamName" => @stream_id).body
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue