1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[aws|rds] Basic support for restoring servers.

Adds RDS#restore_db_instance_from_db_snapshot and
RDS#restore_db_instance_to_point_in_time
This commit is contained in:
Aaron Suggs 2011-03-10 15:06:03 -05:00 committed by geemus
parent b461fb05ba
commit e3c646b03d
5 changed files with 144 additions and 3 deletions

View file

@ -0,0 +1,34 @@
module Fog
module Parsers
module AWS
module RDS
require 'fog/aws/parsers/rds/db_parser'
class RestoreDBInstanceFromDBSnapshot < Fog::Parsers::AWS::RDS::DbParser
def reset
@response = { 'RestoreDBInstanceFromDBSnapshot' => {}, 'ResponseMetadata' => {} }
super
end
def start_element(name, attrs = [])
super
end
def end_element(name)
case name
when 'DBInstance'
@response['RestoreDBInstanceFromDBSnapshot']['DBInstance'] = @db_instance
@db_instance = fresh_instance
when 'RequestId'
@response['ResponseMetadata'][name] = @value
else
super
end
end
end
end
end
end
end

View file

@ -0,0 +1,35 @@
module Fog
module Parsers
module AWS
module RDS
require 'fog/aws/parsers/rds/db_parser'
class RestoreDBInstanceToPointInTime < Fog::Parsers::AWS::RDS::DbParser
def reset
@response = { 'RestoreDBInstanceToPointInTime' => {}, 'ResponseMetadata' => {} }
super
end
def start_element(name, attrs = [])
super
end
def end_element(name)
case name
when 'DBInstance'
@response['RestoreDBInstanceToPointInTime']['DBInstance'] = @db_instance
@db_instance = fresh_instance
when 'RequestId'
@response['ResponseMetadata'][name] = @value
else
super
end
end
end
end
end
end
end

View file

@ -4,7 +4,7 @@ module Fog
class NotFound < Fog::Errors::Error; end
class IdentifierTaken < Fog::Errors::Error; end
requires :aws_access_key_id, :aws_secret_access_key
recognizes :region, :host, :path, :port, :scheme, :persistent
@ -16,7 +16,7 @@ module Fog
request :delete_db_instance
request :reboot_db_instance
request :create_db_instance_read_replica
request :describe_db_snapshots
request :create_db_snapshot
request :delete_db_snapshot
@ -34,7 +34,10 @@ module Fog
request :revoke_db_security_group_ingress
request :describe_db_parameters
request :restore_db_instance_from_db_snapshot
request :restore_db_instance_to_point_in_time
model_path 'fog/aws/rds/models'
model :server
collection :servers

View file

@ -0,0 +1,34 @@
module Fog
module AWS
class RDS
class Real
require 'fog/aws/parsers/rds/restore_db_instance_from_db_snapshot'
# Restores a DB Instance from a DB Snapshot
# http://docs.amazonwebservices.com/AmazonRDS/latest/APIReference/index.html?API_RestoreDBInstanceFromDBSnapshot.html
# ==== Returns
# * response<~Excon::Response>:
# * body<~Hash>:
def restore_db_instance_from_db_snapshot(snapshot_id, db_name, opts={})
request({
'Action' => 'RestoreDBInstanceFromDBSnapshot',
'DBSnapshotIdentifier' => snapshot_id,
'DBInstanceIdentifier' => db_name,
:parser => Fog::Parsers::AWS::RDS::RestoreDBInstanceFromDBSnapshot.new,
}.merge(opts))
end
end
class Mock
def restore_db_instance_from_db_snapshot(snapshot_id, db_id, options={})
Fog::Mock.not_implemented
end
end
end
end
end

View file

@ -0,0 +1,35 @@
module Fog
module AWS
class RDS
class Real
require 'fog/aws/parsers/rds/restore_db_instance_to_point_in_time'
# Restores a DB Instance to a point in time
# http://docs.amazonwebservices.com/AmazonRDS/latest/APIReference/index.html?API_RestoreDBInstanceToPointInTime.html
# ==== Returns
# * response<~Excon::Response>:
# * body<~Hash>:
def restore_db_instance_to_point_in_time(source_db_name, target_db_name, opts={})
request({
'Action' => 'RestoreDBInstanceToPointInTime',
'SourceDBInstanceIdentifier' => source_db_name,
'TargetDBInstanceIdentifier' => target_db_name,
:parser => Fog::Parsers::AWS::RDS::RestoreDBInstanceToPointInTime.new,
}.merge(opts))
end
end
class Mock
def restore_db_instance_to_point_in_time(source_db_name, target_db_name, opts={})
Fog::Mock.not_implemented
end
end
end
end
end