1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
module Fog
module AWS
class RDS
class Real
require 'fog/aws/parsers/rds/create_db_cluster_snapshot'
# create a snapshot of a db cluster
# http://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_CreateDBClusterSnapshot.html
#
# ==== Parameters ====
# * DBClusterIdentifier<~String> - The identifier of the DB cluster to create a snapshot for
# * DBClusterSnapshotIdentifier<~String> - The identifier of the DB cluster snapshot
# * Tags<~Array> - The tags to be assigned to the DB cluster snapshot
#
# ==== Returns ====
# * response<~Excon::Response>:
# * body<~Hash>:
def create_db_cluster_snapshot(identifier, name)
request(
'Action' => 'CreateDBClusterSnapshot',
'DBClusterIdentifier' => identifier,
'DBClusterSnapshotIdentifier' => name,
:parser => Fog::Parsers::AWS::RDS::CreateDBClusterSnapshot.new
)
end
end
class Mock
def create_db_cluster_snapshot(identifier, name)
response = Excon::Response.new
if data[:cluster_snapshots][name]
raise Fog::AWS::RDS::IdentifierTaken.new
end
cluster = self.data[:clusters][identifier]
raise Fog::AWS::RDS::NotFound.new("DBCluster #{identifier} not found") unless cluster
data = {
'AllocatedStorage' => cluster['AllocatedStorage'].to_i,
'ClusterCreateTime' => cluster['ClusterCreateTime'],
'DBClusterIdentifier' => identifier,
'DBClusterSnapshotIdentifier' => name,
'Engine' => cluster['Engine'],
'EngineVersion' => cluster['EngineVersion'],
'LicenseModel' => cluster['Engine'],
'MasterUsername' => cluster['MasterUsername'],
'SnapshotCreateTime' => Time.now,
'SnapshotType' => 'manual',
'StorageEncrypted' => cluster["StorageEncrypted"],
'Status' => 'creating',
}
self.data[:cluster_snapshots][name] = data
response.body = {
"ResponseMetadata" => { "RequestId" => Fog::AWS::Mock.request_id },
"CreateDBClusterSnapshotResult" => { "DBClusterSnapshot" => data.dup },
}
self.data[:cluster_snapshots][name]['SnapshotCreateTime'] = Time.now
response
end
end
end
end
end
|