diff --git a/lib/fog/aws/requests/rds/add_tags_to_resource.rb b/lib/fog/aws/requests/rds/add_tags_to_resource.rb index 4ee57ddc9..0a28fef0b 100644 --- a/lib/fog/aws/requests/rds/add_tags_to_resource.rb +++ b/lib/fog/aws/requests/rds/add_tags_to_resource.rb @@ -12,28 +12,30 @@ module Fog # * body<~Hash>: def add_tags_to_resource(rds_id, tags) keys = tags.keys.sort - values = keys.map {|key| tags[key]} + values = keys.map { |key| tags[key] } + resource_name = "arn:aws:rds:#{@region}:#{owner_id}:db:#{rds_id}" + %w[us-gov-west-1 us-gov-east-1].include?(@region) ? resource_name.insert(7, '-us-gov') : resource_name request({ - 'Action' => 'AddTagsToResource', - 'ResourceName' => "arn:aws:rds:#{@region}:#{owner_id}:db:#{rds_id}", - :parser => Fog::Parsers::AWS::RDS::Base.new, - }.merge(Fog::AWS.indexed_param('Tags.member.%d.Key', keys)). - merge(Fog::AWS.indexed_param('Tags.member.%d.Value', values))) + 'Action' => 'AddTagsToResource', + 'ResourceName' => resource_name, + :parser => Fog::Parsers::AWS::RDS::Base.new + }.merge(Fog::AWS.indexed_param('Tags.member.%d.Key', keys)) + .merge(Fog::AWS.indexed_param('Tags.member.%d.Value', values))) end end class Mock def add_tags_to_resource(rds_id, tags) response = Excon::Response.new - if server = self.data[:servers][rds_id] - self.data[:tags][rds_id].merge! tags + if server = data[:servers][rds_id] + data[:tags][rds_id].merge! tags response.status = 200 response.body = { - "ResponseMetadata"=>{ "RequestId"=> Fog::AWS::Mock.request_id } + 'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id } } response else - raise Fog::AWS::RDS::NotFound.new("DBInstance #{rds_id} not found") + raise Fog::AWS::RDS::NotFound, "DBInstance #{rds_id} not found" end end end diff --git a/lib/fog/aws/requests/rds/list_tags_for_resource.rb b/lib/fog/aws/requests/rds/list_tags_for_resource.rb index c02d1e29c..f46541c46 100644 --- a/lib/fog/aws/requests/rds/list_tags_for_resource.rb +++ b/lib/fog/aws/requests/rds/list_tags_for_resource.rb @@ -11,11 +11,14 @@ module Fog # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: + def list_tags_for_resource(rds_id) + resource_name = "arn:aws:rds:#{@region}:#{owner_id}:db:#{rds_id}" + %w[us-gov-west-1 us-gov-east-1].include?(@region) ? resource_name.insert(7, '-us-gov') : resource_name request( - 'Action' => 'ListTagsForResource', - 'ResourceName' => "arn:aws:rds:#{@region}:#{owner_id}:db:#{rds_id}", - :parser => Fog::Parsers::AWS::RDS::TagListParser.new + 'Action' => 'ListTagsForResource', + 'ResourceName' => resource_name, + :parser => Fog::Parsers::AWS::RDS::TagListParser.new ) end end @@ -23,15 +26,15 @@ module Fog class Mock def list_tags_for_resource(rds_id) response = Excon::Response.new - if server = self.data[:servers][rds_id] + if server = data[:servers][rds_id] response.status = 200 response.body = { - "ListTagsForResourceResult" => - {"TagList" => self.data[:tags][rds_id]} + 'ListTagsForResourceResult' => + { 'TagList' => data[:tags][rds_id] } } response else - raise Fog::AWS::RDS::NotFound.new("DBInstance #{rds_id} not found") + raise Fog::AWS::RDS::NotFound, "DBInstance #{rds_id} not found" end end end diff --git a/lib/fog/aws/requests/rds/remove_tags_from_resource.rb b/lib/fog/aws/requests/rds/remove_tags_from_resource.rb index be84c17d9..9470367cf 100644 --- a/lib/fog/aws/requests/rds/remove_tags_from_resource.rb +++ b/lib/fog/aws/requests/rds/remove_tags_from_resource.rb @@ -11,11 +11,12 @@ module Fog # * response<~Excon::Response>: # * body<~Hash>: def remove_tags_from_resource(rds_id, keys) + resource_name = "arn:aws:rds:#{@region}:#{owner_id}:db:#{rds_id}" + %w[us-gov-west-1 us-gov-east-1].include?(@region) ? resource_name.insert(7, '-us-gov') : resource_name request( - { 'Action' => 'RemoveTagsFromResource', - 'ResourceName' => "arn:aws:rds:#{@region}:#{owner_id}:db:#{rds_id}", - :parser => Fog::Parsers::AWS::RDS::Base.new, - }.merge(Fog::AWS.indexed_param('TagKeys.member.%d', keys)) + { 'Action' => 'RemoveTagsFromResource', + 'ResourceName' => resource_name, + :parser => Fog::Parsers::AWS::RDS::Base.new }.merge(Fog::AWS.indexed_param('TagKeys.member.%d', keys)) ) end end @@ -23,15 +24,15 @@ module Fog class Mock def remove_tags_from_resource(rds_id, keys) response = Excon::Response.new - if server = self.data[:servers][rds_id] - keys.each {|key| self.data[:tags][rds_id].delete key} + if server = data[:servers][rds_id] + keys.each { |key| data[:tags][rds_id].delete key } response.status = 200 response.body = { - "ResponseMetadata"=>{ "RequestId"=> Fog::AWS::Mock.request_id } + 'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id } } response else - raise Fog::AWS::RDS::NotFound.new("DBInstance #{rds_id} not found") + raise Fog::AWS::RDS::NotFound, "DBInstance #{rds_id} not found" end end end