1
0
Fork 0
mirror of https://github.com/fog/fog-aws.git synced 2022-11-09 13:50:52 -05:00
fog--fog-aws/lib/fog/aws/requests/rds/delete_db_cluster.rb

43 lines
1.4 KiB
Ruby
Raw Normal View History

module Fog
module AWS
class RDS
class Real
require 'fog/aws/parsers/rds/delete_db_cluster'
def delete_db_cluster(identifier, snapshot_identifier, skip_snapshot = false)
params = {}
params["FinalDBSnapshotIdentifier"] = snapshot_identifier if snapshot_identifier
request({
'Action' => 'DeleteDBCluster',
'DBClusterIdentifier' => identifier,
'SkipFinalSnapshot' => skip_snapshot,
}.merge(params))
end
end
class Mock
def delete_db_cluster(identifier, snapshot_identifier, skip_snapshot = false)
response = Excon::Response.new
cluster = self.data[:clusters][identifier] || raise(Fog::AWS::RDS::NotFound.new("DBCluster #{identifier} not found"))
raise Fog::AWS::RDS::Error.new("InvalidDBClusterStateFault => Cluster cannot be deleted, it still contains DB instances in non-deleting state.") if cluster["DBClusterMembers"].any?
unless skip_snapshot
create_db_cluster_snapshot(identifier, snapshot_identifier)
end
self.data[:clusters].delete(identifier)
response.status = 200
response.body = {
"ResponseMetadata" => { "RequestId" => Fog::AWS::Mock.request_id },
"DeleteDBClusterResult" => { "DBCluster" => cluster}
}
response
end
end
end
end
end