File: describe_cache_subnet_groups.rb

package info (click to toggle)
ruby-fog-aws 3.18.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,140 kB
  • sloc: ruby: 73,328; javascript: 14; makefile: 9; sh: 4
file content (59 lines) | stat: -rw-r--r-- 2,040 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
49
50
51
52
53
54
55
56
57
58
59
module Fog
  module AWS
    class Elasticache
      class Real
        require 'fog/aws/parsers/elasticache/describe_cache_subnet_groups'

        # This API returns a list of CacheSubnetGroup descriptions. If a CacheSubnetGroupName is specified, the list will contain only
        # the descriptions of the specified CacheSubnetGroup
        # http://docs.aws.amazon.com/AmazonElastiCache/latest/APIReference/API_DescribeCacheSubnetGroups.html
        # ==== Parameters
        # * CacheSubnetGroupName <~String> - The name of a specific database subnet group to return details for.
        # ==== Returns
        # * response<~Excon::Response>:
        #   * body<~Hash>:
        def describe_cache_subnet_groups(name = nil, opts = {})
          params = {}
          if opts[:marker]
            params['Marker'] = opts[:marker]
          end
          if name
            params['CacheSubnetGroupName'] = name
          end
          if opts[:max_records]
            params['MaxRecords'] = opts[:max_records]
          end

          request({
            'Action'  => 'DescribeCacheSubnetGroups',
            :parser   => Fog::Parsers::AWS::Elasticache::DescribeCacheSubnetGroups.new
          }.merge(params))
        end
      end

      class Mock
        def describe_cache_subnet_groups(name = nil, opts = {})
          response = Excon::Response.new

          subnet_group_set = []
          if name
            if subnet_group = self.data[:subnet_groups][name]
              subnet_group_set << subnet_group
            else
              raise Fog::AWS::Elasticache::NotFound.new("Subnet Group #{name} not found")
            end
          else
            subnet_group_set = self.data[:subnet_groups].values
          end

          response.status = 200
          response.body = {
            "ResponseMetadata"=>{ "RequestId"=> Fog::AWS::Mock.request_id },
            "DescribeCacheSubnetGroupsResult" => { "CacheSubnetGroups" => subnet_group_set }
          }
          response
        end
      end
    end
  end
end