diff --git a/lib/fog/aws/parsers/rds/restore_db_instance_from_db_snapshot.rb b/lib/fog/aws/parsers/rds/restore_db_instance_from_db_snapshot.rb new file mode 100644 index 000000000..d0796a852 --- /dev/null +++ b/lib/fog/aws/parsers/rds/restore_db_instance_from_db_snapshot.rb @@ -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 diff --git a/lib/fog/aws/parsers/rds/restore_db_instance_to_point_in_time.rb b/lib/fog/aws/parsers/rds/restore_db_instance_to_point_in_time.rb new file mode 100644 index 000000000..60d009d17 --- /dev/null +++ b/lib/fog/aws/parsers/rds/restore_db_instance_to_point_in_time.rb @@ -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 + diff --git a/lib/fog/aws/rds.rb b/lib/fog/aws/rds.rb index 2d9d3ff50..91e1be9a2 100644 --- a/lib/fog/aws/rds.rb +++ b/lib/fog/aws/rds.rb @@ -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 diff --git a/lib/fog/aws/requests/rds/restore_db_instance_from_db_snapshot.rb b/lib/fog/aws/requests/rds/restore_db_instance_from_db_snapshot.rb new file mode 100644 index 000000000..87e0fceec --- /dev/null +++ b/lib/fog/aws/requests/rds/restore_db_instance_from_db_snapshot.rb @@ -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 + diff --git a/lib/fog/aws/requests/rds/restore_db_instance_to_point_in_time.rb b/lib/fog/aws/requests/rds/restore_db_instance_to_point_in_time.rb new file mode 100644 index 000000000..a1a598f4e --- /dev/null +++ b/lib/fog/aws/requests/rds/restore_db_instance_to_point_in_time.rb @@ -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 + +