File: modify_db_snapshot_attribute.rb

package info (click to toggle)
ruby-fog-aws 3.3.0-5
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 7,816 kB
  • sloc: ruby: 68,587; makefile: 6
file content (48 lines) | stat: -rw-r--r-- 1,811 bytes parent folder | download | duplicates (5)
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
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
      class Mock
        #
        # Usage
        #
        # Fog::AWS[:rds].modify_db_snapshot_attribute("snap-identifier", {"Add.MemberId"=>"389480430104"})
        #

        def modify_db_snapshot_attribute(db_snapshot_identifier, attributes)
          response = Excon::Response.new
          response.status = 200
          response.body = {
            'requestId' => Fog::AWS::Mock.request_id
          }.merge!(data)
          response
        end
      end
    end
  end
end