1
0
Fork 0
mirror of https://github.com/fog/fog-aws.git synced 2022-11-09 13:50:52 -05:00
fog--fog-aws/lib/fog/aws/requests/kinesis/describe_stream.rb

55 lines
1.9 KiB
Ruby
Raw Normal View History

2015-06-19 16:55:32 -04:00
module Fog
module AWS
class Kinesis
class Real
# Describes the specified stream.
#
# ==== Options
# * ExclusiveStartShardId<~String>: The shard ID of the shard to start with.
# * Limit<~Number>: The maximum number of shards to return.
# * StreamName<~String>: The name of the stream to describe.
# ==== Returns
# * response<~Excon::Response>:
#
# ==== See Also
# https://docs.aws.amazon.com/kinesis/latest/APIReference/API_DescribeStream.html
#
def describe_stream(options={})
body = {
"ExclusiveStartShardId" => options.delete("ExclusiveStartShardId"),
"Limit" => options.delete("Limit"),
"StreamName" => options.delete("StreamName")
}.reject{ |_,v| v.nil? }
response = request({
2015-06-24 16:41:21 -04:00
:idempotent => true,
2015-06-24 17:10:55 -04:00
'X-Amz-Target' => "Kinesis_#{@version}.DescribeStream",
2015-06-19 16:55:32 -04:00
:body => body,
}.merge(options))
response.body = Fog::JSON.decode(response.body) unless response.body.nil?
2015-06-30 18:15:14 -04:00
response.body
2015-06-19 16:55:32 -04:00
response
end
end
class Mock
2015-06-30 18:15:14 -04:00
def describe_stream(options={})
stream_name = options.delete("StreamName")
unless stream = data[:kinesis_streams].detect{ |s| s["StreamName"] == stream_name }
raise Fog::AWS::Kinesis::ResourceNotFound.new("Stream #{stream_name} under account #{@account_id} not found.")
2015-06-30 18:15:14 -04:00
end
# Strip Records key out of shards for response
shards = stream["Shards"].reject{ |k,_| k == "Records" }
response = Excon::Response.new
response.status = 200
response.body = { "StreamDescription" => stream.dup.merge("Shards" => shards) }
response
2015-06-19 16:55:32 -04:00
end
end
end
end
end