mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Created describe events for RDS
This commit is contained in:
parent
c343d42a1b
commit
0c536a543e
3 changed files with 118 additions and 0 deletions
34
lib/fog/aws/parsers/rds/base.rb
Normal file
34
lib/fog/aws/parsers/rds/base.rb
Normal file
|
@ -0,0 +1,34 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module AWS
|
||||
module RDS
|
||||
|
||||
require 'fog/aws/parsers/rds/base'
|
||||
|
||||
# Base parser for ResponseMetadata, RequestId
|
||||
class Base < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
super
|
||||
@response = { 'ResponseMetadata' => {} }
|
||||
end
|
||||
|
||||
def start_element(name, attrs = [])
|
||||
super
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
when 'RequestId'
|
||||
@response['ResponseMetadata'][name] = value
|
||||
else
|
||||
super
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
38
lib/fog/aws/parsers/rds/event_list.rb
Normal file
38
lib/fog/aws/parsers/rds/event_list.rb
Normal file
|
@ -0,0 +1,38 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module AWS
|
||||
module RDS
|
||||
require 'fog/aws/parsers/rds/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/rds/describe_events.rb
Normal file
46
lib/fog/aws/requests/rds/describe_events.rb
Normal file
|
@ -0,0 +1,46 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class RDS
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/rds/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::RDS::EventListParser.new
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
def describe_events
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue