2014-12-30 17:25:09 -05:00
|
|
|
module Fog
|
|
|
|
module AWS
|
|
|
|
class RDS
|
|
|
|
class Real
|
|
|
|
require 'fog/aws/parsers/rds/delete_db_instance'
|
|
|
|
|
|
|
|
# delete a database instance
|
|
|
|
# http://docs.amazonwebservices.com/AmazonRDS/latest/APIReference/API_DeleteDBInstance.html
|
|
|
|
# ==== Parameters
|
|
|
|
# * DBInstanceIdentifier <~String> - The DB Instance identifier for the DB Instance to be deleted.
|
|
|
|
# * FinalDBSnapshotIdentifier <~String> - The DBSnapshotIdentifier of the new DBSnapshot created when SkipFinalSnapshot is set to false
|
|
|
|
# * SkipFinalSnapshot <~Boolean> - Determines whether a final DB Snapshot is created before the DB Instance is deleted
|
|
|
|
#
|
|
|
|
# ==== Returns
|
|
|
|
# * response<~Excon::Response>:
|
|
|
|
# * body<~Hash>:
|
|
|
|
def delete_db_instance(identifier, snapshot_identifier, skip_snapshot = false)
|
|
|
|
params = {}
|
|
|
|
params['FinalDBSnapshotIdentifier'] = snapshot_identifier if snapshot_identifier
|
|
|
|
request({
|
2015-03-19 15:50:35 -04:00
|
|
|
'Action' => 'DeleteDBInstance',
|
2014-12-30 17:25:09 -05:00
|
|
|
'DBInstanceIdentifier' => identifier,
|
2015-03-19 15:50:35 -04:00
|
|
|
'SkipFinalSnapshot' => skip_snapshot,
|
|
|
|
:parser => Fog::Parsers::AWS::RDS::DeleteDBInstance.new
|
2014-12-30 17:25:09 -05:00
|
|
|
}.merge(params))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class Mock
|
|
|
|
def delete_db_instance(identifier, snapshot_identifier, skip_snapshot = false)
|
|
|
|
response = Excon::Response.new
|
|
|
|
|
2015-03-19 15:50:35 -04:00
|
|
|
|
|
|
|
server_set = self.data[:servers][identifier] ||
|
|
|
|
raise(Fog::AWS::RDS::NotFound.new("DBInstance #{identifier} not found"))
|
|
|
|
|
2014-12-30 17:25:09 -05:00
|
|
|
unless skip_snapshot
|
2015-03-19 15:50:35 -04:00
|
|
|
if server_set["ReadReplicaSourceDBInstanceIdentifier"]
|
|
|
|
raise Fog::AWS::RDS::Error.new("InvalidParameterCombination => FinalDBSnapshotIdentifier can not be specified when deleting a replica instance")
|
|
|
|
else
|
|
|
|
create_db_snapshot(identifier, snapshot_identifier)
|
|
|
|
end
|
2014-12-30 17:25:09 -05:00
|
|
|
end
|
|
|
|
|
2015-03-19 15:50:35 -04:00
|
|
|
self.data[:servers].delete(identifier)
|
|
|
|
|
|
|
|
response.status = 200
|
|
|
|
response.body = {
|
|
|
|
"ResponseMetadata" => { "RequestId" => Fog::AWS::Mock.request_id },
|
|
|
|
"DeleteDBInstanceResult" => { "DBInstance" => server_set }
|
|
|
|
}
|
|
|
|
response
|
2014-12-30 17:25:09 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|