mirror of
https://github.com/fog/fog-aws.git
synced 2022-11-09 13:50:52 -05:00
Kinesis get_shard_iterator
This commit is contained in:
parent
16922f0f39
commit
d2b1d8623b
3 changed files with 58 additions and 1 deletions
|
@ -12,6 +12,7 @@ module Fog
|
|||
request :describe_stream
|
||||
request :create_stream
|
||||
request :delete_stream
|
||||
request :get_shard_iterator
|
||||
|
||||
class Real
|
||||
include Fog::AWS::CredentialFetcher::ConnectionMethods
|
||||
|
|
42
lib/fog/aws/requests/kinesis/get_shard_iterator.rb
Normal file
42
lib/fog/aws/requests/kinesis/get_shard_iterator.rb
Normal file
|
@ -0,0 +1,42 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class Kinesis
|
||||
class Real
|
||||
# Gets a shard iterator.
|
||||
#
|
||||
# ==== Options
|
||||
# * ShardId<~String>: The shard ID of the shard to get the iterator for.
|
||||
# * ShardIteratorType<~String>: Determines how the shard iterator is used to start reading data records from the shard.
|
||||
# * StartingSequenceNumber<~String>: The sequence number of the data record in the shard from which to start reading from.
|
||||
# * StreamName<~String>: A name to identify the stream.
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
#
|
||||
# ==== See Also
|
||||
# https://docs.aws.amazon.com/kinesis/latest/APIReference/API_GetShardIterator.html
|
||||
#
|
||||
def get_shard_iterator(options={})
|
||||
body = {
|
||||
"ShardId" => options.delete("ShardId"),
|
||||
"ShardIteratorType" => options.delete("ShardIteratorType"),
|
||||
"StartingSequenceNumber" => options.delete("StartingSequenceNumber"),
|
||||
"StreamName" => options.delete("StreamName")
|
||||
}.reject{ |_,v| v.nil? }
|
||||
|
||||
response = request({
|
||||
'X-Amz-Target' => 'Kinesis_20131202.GetShardIterator',
|
||||
:body => body,
|
||||
}.merge(options))
|
||||
response.body = Fog::JSON.decode(response.body) unless response.body.nil?
|
||||
response
|
||||
end
|
||||
end
|
||||
|
||||
class Mock
|
||||
def get_shard_iterator(options={})
|
||||
raise Fog::Mock::NotImplementedError
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -52,8 +52,17 @@ Shindo.tests('AWS::Kinesis | stream requests', ['aws', 'kinesis']) do
|
|||
}
|
||||
}
|
||||
|
||||
@get_shard_iterator_format = {
|
||||
"ShardIterator" => String
|
||||
}
|
||||
|
||||
tests("#create_stream").returns("") do
|
||||
Fog::AWS[:kinesis].create_stream("StreamName" => @stream_id).body
|
||||
result = Fog::AWS[:kinesis].create_stream("StreamName" => @stream_id).body
|
||||
while Fog::AWS[:kinesis].describe_stream("StreamName" => @stream_id).body["StreamDescription"]["StreamStatus"] != "ACTIVE"
|
||||
sleep 1
|
||||
print '.'
|
||||
end
|
||||
result
|
||||
end
|
||||
|
||||
tests("#list_streams").formats(@list_streams_format, false) do
|
||||
|
@ -64,6 +73,11 @@ Shindo.tests('AWS::Kinesis | stream requests', ['aws', 'kinesis']) do
|
|||
Fog::AWS[:kinesis].describe_stream("StreamName" => @stream_id).body
|
||||
end
|
||||
|
||||
tests("#get_shard_iterator").formats(@get_shard_iterator_format) do
|
||||
first_shard_id = Fog::AWS[:kinesis].describe_stream("StreamName" => @stream_id).body["StreamDescription"]["Shards"].first["ShardId"]
|
||||
Fog::AWS[:kinesis].get_shard_iterator("StreamName" => @stream_id, "ShardId" => first_shard_id, "ShardIteratorType" => "TRIM_HORIZON").body
|
||||
end
|
||||
|
||||
tests("#delete_stream").returns("") do
|
||||
Fog::AWS[:kinesis].delete_stream("StreamName" => @stream_id).body
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue