-
-
Notifications
You must be signed in to change notification settings - Fork 353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rds snapshot improvements #269
Merged
Merged
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
fd48293
modify db snapshot attribute api implementation
tekken a3f7b74
copy db snapshot api implementation
tekken 11b48aa
added EOF's
tekken 0da02e4
implemented copy db snapshot parser
tekken b546e98
updated parser used in copy_db_snapshot
tekken ab7bc56
Added tests for db snapshots
tekken 84b4064
added mock for modify_db_snapshot_attribute request
tekken 6c0043b
removed fog mock from db snapshot tests
tekken File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module Fog | ||
module Parsers | ||
module AWS | ||
module RDS | ||
class ModifyDbSnapshotAttribute < Fog::Parsers::Base | ||
def reset | ||
@response = { 'ModifyDbSnapshotAttributeResult' => {}, 'ResponseMetadata' => {} } | ||
end | ||
|
||
def start_element(name, attrs = []) | ||
super | ||
end | ||
|
||
def end_element(name) | ||
case name | ||
when 'RequestId' | ||
@response['ResponseMetadata'][name] = value | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
module Fog | ||
module AWS | ||
class RDS | ||
class Real | ||
require 'fog/aws/parsers/rds/create_db_snapshot' | ||
|
||
# Copy a db snapshot | ||
# | ||
# ==== Parameters | ||
# * source_db_snapshot_identifier<~String> - Id of db snapshot | ||
# * target_db_snapshot_identifier<~String> - Desired Id of the db snapshot copy | ||
# * 'copy_tags'<~Boolean> - true to copy all tags from the source DB snapshot to the target DB snapshot; otherwise false. | ||
# | ||
# ==== Returns | ||
# * response<~Excon::Response>: | ||
# * body<~Hash>: | ||
# | ||
# {Amazon API Reference}[http://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_CopyDBSnapshot.html] | ||
def copy_db_snapshot(source_db_snapshot_identifier, target_db_snapshot_identifier, copy_tags = false) | ||
request( | ||
'Action' => 'CopyDBSnapshot', | ||
'SourceDBSnapshotIdentifier' => source_db_snapshot_identifier, | ||
'TargetDBSnapshotIdentifier' => target_db_snapshot_identifier, | ||
'CopyTags' => copy_tags, | ||
:parser => Fog::Parsers::AWS::RDS::CreateDBSnapshot.new | ||
) | ||
end | ||
end | ||
|
||
class Mock | ||
# | ||
# Usage | ||
# | ||
# Fog::AWS[:rds].copy_db_snapshot("snap-original-id", "snap-backup-id", true) | ||
# | ||
|
||
def copy_db_snapshot(source_db_snapshot_identifier, target_db_snapshot_identifier, copy_tags = false) | ||
response = Excon::Response.new | ||
response.status = 200 | ||
snapshot_id = Fog::AWS::Mock.snapshot_id | ||
data = { | ||
'snapshotId' => snapshot_id, | ||
} | ||
self.data[:snapshots][snapshot_id] = data | ||
response.body = { | ||
'requestId' => Fog::AWS::Mock.request_id | ||
}.merge!(data) | ||
response | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
module Fog | ||
module AWS | ||
class RDS | ||
class Real | ||
require 'fog/aws/parsers/rds/modify_db_snapshot_attribute' | ||
|
||
# Modify db snapshot attributes | ||
# | ||
# ==== Parameters | ||
# * db_snapshot_identifier<~String> - Id of snapshot to modify | ||
# * attributes<~Hash>: | ||
# * 'Add.MemberId'<~Array> - One or more account ids to grant rds create permission to | ||
# * 'Remove.MemberId'<~Array> - One or more account ids to revoke rds create permission from | ||
# | ||
# {Amazon API Reference}[http://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_ModifyDBSnapshotAttribute.html] | ||
# | ||
def modify_db_snapshot_attribute(db_snapshot_identifier, attributes) | ||
params = {} | ||
params.merge!(Fog::AWS.indexed_param('ValuesToAdd.member.%d', attributes['Add.MemberId'] || [])) | ||
params.merge!(Fog::AWS.indexed_param('ValuesToRemove.member.%d', attributes['Remove.MemberId'] || [])) | ||
request({ | ||
'Action' => 'ModifyDBSnapshotAttribute', | ||
'DBSnapshotIdentifier' => db_snapshot_identifier, | ||
:idempotent => true, | ||
'AttributeName' => "restore", | ||
:parser => Fog::Parsers::AWS::RDS::ModifyDbSnapshotAttribute.new | ||
}.merge!(params)) | ||
end | ||
end | ||
end | ||
end | ||
end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this supposed to re-use create parser, or should it have it's own?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your right it should have its own.