mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[aws|elasticache] implement DescribeEvents
This commit is contained in:
parent
bb21207fa8
commit
199693733b
5 changed files with 111 additions and 3 deletions
|
@ -21,6 +21,7 @@ module Fog
|
||||||
#request :describe_cache_parameter_groups
|
#request :describe_cache_parameter_groups
|
||||||
#request :modify_cache_parameter_group
|
#request :modify_cache_parameter_group
|
||||||
#request :reset_cache_parameter_group
|
#request :reset_cache_parameter_group
|
||||||
|
#request :describe_engine_default_parameters
|
||||||
|
|
||||||
request :create_cache_security_group
|
request :create_cache_security_group
|
||||||
request :delete_cache_security_group
|
request :delete_cache_security_group
|
||||||
|
@ -28,9 +29,7 @@ module Fog
|
||||||
request :authorize_cache_security_group_ingress
|
request :authorize_cache_security_group_ingress
|
||||||
request :revoke_cache_security_group_ingress
|
request :revoke_cache_security_group_ingress
|
||||||
|
|
||||||
#request :describe_engine_default_parameters
|
request :describe_events
|
||||||
|
|
||||||
#request :describe_events
|
|
||||||
|
|
||||||
model_path 'fog/aws/models/elasticache'
|
model_path 'fog/aws/models/elasticache'
|
||||||
model :cluster
|
model :cluster
|
||||||
|
|
38
lib/fog/aws/parsers/elasticache/event_list.rb
Normal file
38
lib/fog/aws/parsers/elasticache/event_list.rb
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
module Fog
|
||||||
|
module Parsers
|
||||||
|
module AWS
|
||||||
|
module Elasticache
|
||||||
|
require 'fog/aws/parsers/elasticache/base'
|
||||||
|
|
||||||
|
class EventListParser < Base
|
||||||
|
|
||||||
|
def reset
|
||||||
|
super
|
||||||
|
@response['Events'] = []
|
||||||
|
end
|
||||||
|
|
||||||
|
def start_element(name, attrs = [])
|
||||||
|
super
|
||||||
|
case name
|
||||||
|
when 'Event'; then @event = {}
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def end_element(name)
|
||||||
|
case name
|
||||||
|
when 'Date'
|
||||||
|
@event[name] = DateTime.parse(value.strip)
|
||||||
|
when 'Message', 'SourceIdentifier', 'SourceType'
|
||||||
|
@event[name] = value ? value.strip : name
|
||||||
|
when 'Event'
|
||||||
|
@response['Events'] << @event unless @event.empty?
|
||||||
|
else
|
||||||
|
super
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
46
lib/fog/aws/requests/elasticache/describe_events.rb
Normal file
46
lib/fog/aws/requests/elasticache/describe_events.rb
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
module Fog
|
||||||
|
module AWS
|
||||||
|
class Elasticache
|
||||||
|
class Real
|
||||||
|
|
||||||
|
require 'fog/aws/parsers/elasticache/event_list'
|
||||||
|
|
||||||
|
# Returns a list of service events
|
||||||
|
#
|
||||||
|
# === Parameters (optional)
|
||||||
|
# * options <~Hash> (optional):
|
||||||
|
# * :start_time <~DateTime> - starting time for event records
|
||||||
|
# * :end_time <~DateTime> - ending time for event records
|
||||||
|
# * :duration <~DateTime> - time span for event records
|
||||||
|
# * :marker <~String> - marker provided in the previous request
|
||||||
|
# * :max_records <~Integer> - the maximum number of records to include
|
||||||
|
# * :source_identifier <~DateTime> - identifier of the event source
|
||||||
|
# * :source_type <~DateTime> - event type, one of:
|
||||||
|
# (cache-cluster | cache-parameter-group | cache-security-group)
|
||||||
|
# === Returns
|
||||||
|
# * response <~Excon::Response>:
|
||||||
|
# * body <~Hash>
|
||||||
|
def describe_events(options = {})
|
||||||
|
request(
|
||||||
|
'Action' => 'DescribeEvents',
|
||||||
|
'StartTime' => options[:sart_time],
|
||||||
|
'EndTime' => options[:end_time],
|
||||||
|
'Duration' => options[:duration],
|
||||||
|
'Marker' => options[:marker],
|
||||||
|
'MaxRecords' => options[:max_records],
|
||||||
|
'SourceIdentifier' => options[:source_identifier],
|
||||||
|
'SourceType' => options[:source_type],
|
||||||
|
:parser => Fog::Parsers::AWS::Elasticache::EventListParser.new
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
class Mock
|
||||||
|
def describe_events
|
||||||
|
Fog::Mock.not_implemented
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
17
tests/aws/requests/elasticache/describe_events.rb
Normal file
17
tests/aws/requests/elasticache/describe_events.rb
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
Shindo.tests('AWS::Elasticache | describe cache cluster events',
|
||||||
|
['aws', 'elasticache']) do
|
||||||
|
|
||||||
|
tests('success') do
|
||||||
|
pending if Fog.mocking?
|
||||||
|
|
||||||
|
tests(
|
||||||
|
'#describe_events'
|
||||||
|
).formats(AWS::Elasticache::Formats::EVENT_LIST) do
|
||||||
|
AWS[:elasticache].describe_events().body['Events']
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
tests('failure') do
|
||||||
|
# TODO:
|
||||||
|
end
|
||||||
|
end
|
|
@ -41,6 +41,14 @@ class AWS
|
||||||
})
|
})
|
||||||
SINGLE_CACHE_CLUSTER = BASIC.merge('CacheCluster' => CACHE_CLUSTER)
|
SINGLE_CACHE_CLUSTER = BASIC.merge('CacheCluster' => CACHE_CLUSTER)
|
||||||
DESCRIBE_CACHE_CLUSTERS = BASIC.merge('CacheClusters' => [CACHE_CLUSTER])
|
DESCRIBE_CACHE_CLUSTERS = BASIC.merge('CacheClusters' => [CACHE_CLUSTER])
|
||||||
|
|
||||||
|
EVENT = {
|
||||||
|
'Date' => DateTime,
|
||||||
|
'Message' => String,
|
||||||
|
'SourceIdentifier' => String,
|
||||||
|
'SourceType' => String,
|
||||||
|
}
|
||||||
|
EVENT_LIST = [EVENT]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue