mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Add request/parser for DescribeOperableDBInstanceOptions
This commit is contained in:
parent
a5d39f73d8
commit
eef7a3fa72
3 changed files with 110 additions and 0 deletions
|
@ -0,0 +1,47 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module AWS
|
||||
module RDS
|
||||
|
||||
class DescribeOrderableDBInstanceOptions < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@response = { 'DescribeOrderableDBInstanceOptionsResult' => {'OrderableDBInstanceOptions' => []}, 'ResponseMetadata' => {} }
|
||||
@db_instance_option = {}
|
||||
@db_instance_options = []
|
||||
end
|
||||
|
||||
def start_element(name, attrs = [])
|
||||
case name
|
||||
when 'AvailabilityZones' then @availability_zones = []
|
||||
when 'AvailabilityZone' then @availability_zone = {}
|
||||
end
|
||||
super
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
when 'MultiAZCapable', 'ReadReplicaCapable' then @db_instance_option[name] = to_boolean(value)
|
||||
when 'Engine', 'LicenseModel', 'EngineVersion', 'DBInstanceClass' then @db_instance_option[name] = value
|
||||
when 'AvailabilityZones' then @db_instance_option[name] = @availability_zones
|
||||
when 'AvailabilityZone' then @availability_zones << @availability_zone unless @availability_zone.empty?
|
||||
when 'Name' then @availability_zone[name] = value
|
||||
when 'ProvisionedIopsCapable' then @availability_zone[name] = to_boolean(value)
|
||||
when 'OrderableDBInstanceOption'
|
||||
@db_instance_options << @db_instance_option
|
||||
@db_instance_option = {}
|
||||
when 'OrderableDBInstanceOptions'
|
||||
@response['DescribeOrderableDBInstanceOptionsResult']['OrderableDBInstanceOptions'] = @db_instance_options
|
||||
when 'Marker' then @response['DescribeOrderableDBInstanceOptionsResult'][name] = value
|
||||
when 'RequestId' then @response['ResponseMetadata'][name] = value
|
||||
end
|
||||
end
|
||||
|
||||
def to_boolean(v)
|
||||
v =~ /\A\s*(true|yes|1|y)\s*$/i
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -51,6 +51,8 @@ module Fog
|
|||
request :describe_db_subnet_groups
|
||||
# TODO: :delete_db_subnet_group, :modify_db_subnet_group
|
||||
|
||||
request :describe_orderable_db_instance_options
|
||||
|
||||
model_path 'fog/aws/models/rds'
|
||||
model :server
|
||||
collection :servers
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class RDS
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/rds/describe_orderable_db_instance_options'
|
||||
|
||||
# Describe all or specified load db instances
|
||||
# http://docs.amazonwebservices.com/AmazonRDS/latest/APIReference/API_DescribeDBInstances.html
|
||||
# ==== Parameters
|
||||
# * Engine <~String> - The name of the engine to retrieve DB Instance options for. Required.
|
||||
# * Options <~Hash> - Hash of options. Optional. The following keys are used:
|
||||
# * :db_instance_class <~String> - Filter available offerings matching the specified DB Instance class. Optional.
|
||||
# * :engine_version <~String> - Filters available offerings matching the specified engine version. Optional.
|
||||
# * :license_model <~String> - Filters available offerings matching the specified license model. Optional.
|
||||
# * :marker <~String> - The pagination token provided in the previous request. If this parameter is specified the response includes only records beyond the marker, up to MaxRecords. Optional.
|
||||
# * :max_records <~Integer> - The maximum number of records to include in the response. If more records exist, a pagination token is included in the response. Optional.
|
||||
# * :vpc <~Boolean> - Filter to show only the available VPC or non-VPC offerings. Optional.
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Hash>:
|
||||
def describe_orderable_db_instance_options(engine=nil, opts={})
|
||||
params = {}
|
||||
params['Engine'] = engine if engine
|
||||
params['DBInstanceClass'] = opts[:db_instance_class] if opts[:db_instance_class]
|
||||
params['EngineVersion'] = opts[:engine_version] if opts[:engine_version]
|
||||
params['LicenseModel'] = opts[:license_model] if opts[:license_model]
|
||||
params['Marker'] = opts[:marker] if opts[:marker]
|
||||
params['MaxRecords'] = opts[:max_records] if opts[:max_records]
|
||||
params['Vpc'] = opts[:vpc] if opts[:vpc]
|
||||
|
||||
request({
|
||||
'Action' => 'DescribeOrderableDBInstanceOptions',
|
||||
:parser => Fog::Parsers::AWS::RDS::DescribeOrderableDBInstanceOptions.new
|
||||
}.merge(params))
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def describe_orderable_db_instance_options(engine=nil, opts={})
|
||||
response = Excon::Response.new
|
||||
if engine
|
||||
# set up some mock data here...
|
||||
else
|
||||
raise Fog::AWS::RDS::NotFound.new('An engine must be specified to retrieve orderable instance options')
|
||||
end
|
||||
|
||||
response.status = 200
|
||||
response.body = {
|
||||
'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id },
|
||||
'DescribeOrderableDBInstanceOptionsResult' => { 'OrderableDBInstanceOptions' => [] }
|
||||
}
|
||||
response
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue