Skip to content

Commit

Permalink
Merge pull request fog#4 from KevinLoiseau/enhance/add_attribute_db_s…
Browse files Browse the repository at this point in the history
…ubnet_group_for_db_instance

Enhance/add attribute db subnet group for db instance
  • Loading branch information
ybart authored Mar 25, 2019
2 parents 39ade53 + c2942b4 commit a228369
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/fog/aws/models/rds/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class Server < Fog::Model
attribute :storage_type, :aliases => 'StorageType'
attribute :tde_credential_arn, :aliases => 'TdeCredentialArn'
attribute :vpc_security_groups, :aliases => 'VpcSecurityGroups', :type => :array
attribute :db_subnet_group, :aliases => 'DBSubnetGroup'

attr_accessor :password, :parameter_group_name, :security_group_names, :port, :source_snapshot_id

Expand Down
40 changes: 39 additions & 1 deletion lib/fog/aws/parsers/rds/db_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def reset
end

def fresh_instance
{'PendingModifiedValues' => [], 'DBSecurityGroups' => [], 'ReadReplicaDBInstanceIdentifiers' => [], 'Endpoint' => {}}
{'PendingModifiedValues' => [], 'DBSecurityGroups' => [], 'ReadReplicaDBInstanceIdentifiers' => [], 'Endpoint' => {}, 'DBSubnetGroup' => {}}
end

def start_element(name, attrs = [])
Expand All @@ -35,6 +35,17 @@ def start_element(name, attrs = [])
when 'VpcSecurityGroups'
@in_vpc_security_groups = true
@vpc_security_groups = []
when 'DBSubnetGroup'
@in_db_subnet_group = true
@db_subnet_group = {}
when 'Subnets'
@in_subnets = true
@subnets = []
when 'Subnet'
@subnet = {}
when 'SubnetAvailabilityZone'
@in_subnet_availability_zone = true
@subnet_availability_zone = {}
end
end

Expand Down Expand Up @@ -122,6 +133,33 @@ def end_element(name)
@db_instance['ReadReplicaSourceDBInstanceIdentifier'] = value
when 'DBInstance'
@db_instance = fresh_instance
when 'DBSubnetGroup'
@in_db_subnet_group = false
@db_instance['DBSubnetGroup'] = @db_subnet_group
when 'VpcId'
if @in_db_subnet_group
@db_subnet_group[name] = value
end
when 'Subnets'
@in_subnets = false
if @in_db_subnet_group
@db_subnet_group['Subnets'] = @subnets
end
when 'Subnet'
if @in_subnets
@subnets << @subnet
end
when 'SubnetIdentifier', 'SubnetStatus'
if @in_subnets
@subnet[name] = value
end
when 'SubnetAvailabilityZone'
@in_subnet_availability_zone = false
@subnet['SubnetAvailabilityZone'] = @subnet_availability_zone
when 'Name'
if @in_subnet_availability_zone
@subnet_availability_zone[name] = value
end
end
end
end
Expand Down

0 comments on commit a228369

Please sign in to comment.