mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[aws|rds] add request definitions for RDS tagging and increment RDS API version
This commit is contained in:
parent
41a277a9bd
commit
3ba4af532f
4 changed files with 138 additions and 1 deletions
|
@ -23,6 +23,10 @@ module Fog
|
|||
request :describe_db_engine_versions
|
||||
request :describe_db_reserved_instances
|
||||
|
||||
request :add_tags_to_resource
|
||||
request :list_tags_for_resource
|
||||
request :remove_tags_from_resource
|
||||
|
||||
request :describe_db_snapshots
|
||||
request :create_db_snapshot
|
||||
request :delete_db_snapshot
|
||||
|
@ -187,7 +191,7 @@ module Fog
|
|||
:host => @host,
|
||||
:path => @path,
|
||||
:port => @port,
|
||||
:version => '2012-01-15' #'2011-04-01'
|
||||
:version => '2012-09-17' #'2011-04-01'
|
||||
}
|
||||
)
|
||||
|
||||
|
|
46
lib/fog/aws/requests/rds/add_tags_to_resource.rb
Normal file
46
lib/fog/aws/requests/rds/add_tags_to_resource.rb
Normal file
|
@ -0,0 +1,46 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class RDS
|
||||
class Real
|
||||
|
||||
# adds tags to a database instance
|
||||
# http://docs.amazonwebservices.com/AmazonRDS/latest/APIReference/API_AddTagsToResource.html
|
||||
# ==== Parameters
|
||||
# * rds_id <~String> - name of the RDS instance whose tags are to be retrieved
|
||||
# * tags <~Hash> A Hash of (String) key-value pairs
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Hash>:
|
||||
def add_tags_to_resource(rds_id, tags)
|
||||
keys = tags.keys.sort
|
||||
values = keys.map {|key| tags[key]}
|
||||
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)))
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def add_tags_to_resource(rds_id, tags)
|
||||
response = Excon::Response.new
|
||||
if server = self.data[:servers][rds_id]
|
||||
server['Tags'].merge! tags
|
||||
response.status = 200
|
||||
response.body = {
|
||||
"ResponseMetadata"=>{ "RequestId"=> Fog::AWS::Mock.request_id }
|
||||
}
|
||||
response
|
||||
else
|
||||
raise Fog::AWS::RDS::NotFound.new("DBInstance #{rds_id} not found")
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
43
lib/fog/aws/requests/rds/list_tags_for_resource.rb
Normal file
43
lib/fog/aws/requests/rds/list_tags_for_resource.rb
Normal file
|
@ -0,0 +1,43 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class RDS
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/rds/tag_list_parser'
|
||||
|
||||
# returns a Hash of tags for a database instance
|
||||
# http://docs.amazonwebservices.com/AmazonRDS/latest/APIReference/API_ListTagsForResource.html
|
||||
# ==== Parameters
|
||||
# * rds_id <~String> - name of the RDS instance whose tags are to be retrieved
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Hash>:
|
||||
def list_tags_for_resource(rds_id)
|
||||
request(
|
||||
'Action' => 'ListTagsForResource',
|
||||
'ResourceName' => "arn:aws:rds:#{@region}:#{owner_id}:db:#{rds_id}",
|
||||
:parser => Fog::Parsers::AWS::RDS::TagListParser.new,
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def list_tags_for_resource(rds_id)
|
||||
response = Excon::Response.new
|
||||
if server = self.data[:servers][rds_id]
|
||||
response.status = 200
|
||||
response.body = {
|
||||
"ListTagsForResourceResult" => { "TagList" => server['Tags'] }
|
||||
}
|
||||
response
|
||||
else
|
||||
raise Fog::AWS::RDS::NotFound.new("DBInstance #{rds_id} not found")
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
44
lib/fog/aws/requests/rds/remove_tags_from_resource.rb
Normal file
44
lib/fog/aws/requests/rds/remove_tags_from_resource.rb
Normal file
|
@ -0,0 +1,44 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class RDS
|
||||
class Real
|
||||
|
||||
# removes tags from a database instance
|
||||
# http://docs.amazonwebservices.com/AmazonRDS/latest/APIReference/API_RemoveTagsFromResource.html
|
||||
# ==== Parameters
|
||||
# * rds_id <~String> - name of the RDS instance whose tags are to be retrieved
|
||||
# * keys <~Array> A list of String keys for the tags to remove
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Hash>:
|
||||
def remove_tags_from_resource(rds_id, keys)
|
||||
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))
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def remove_tags_from_resource(rds_id, keys)
|
||||
response = Excon::Response.new
|
||||
if server = self.data[:servers][rds_id]
|
||||
keys.each {|key| server['Tags'].delete key}
|
||||
response.status = 200
|
||||
response.body = {
|
||||
"ResponseMetadata"=>{ "RequestId"=> Fog::AWS::Mock.request_id }
|
||||
}
|
||||
response
|
||||
else
|
||||
raise Fog::AWS::RDS::NotFound.new("DBInstance #{rds_id} not found")
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Reference in a new issue