File: describe_vpc_classic_link.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 (64 lines) | stat: -rw-r--r-- 2,429 bytes parent folder | download | duplicates (4)
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
60
61
62
63
64
module Fog
  module AWS
    class Compute
      class Real
        require 'fog/aws/parsers/compute/describe_vpc_classic_link'
        # Describes the ClassicLink status of one or more VPCs.
        #
        # ==== Parameters
        # * options<~Hash>
        #   * vpc_ids<~Array>  - An array of vpc ids to restruct the results to
        #   * filters<~Hash> - Filters to restrict the results to. Recognises is-classic-link-enabled in addition
        #                      to tag-key, tag-value and tag:key
        # === Returns
        # * response<~Excon::Response>:
        # * body<~Hash>:
        # * 'requestId'<~String>           - Id of request
        # * 'vpcSet'<~Array>               - array of VpcClassicLink
        #   * 'vpcId'<~String>
        #   * 'classicLinkEnabled'<~Boolean>
        #   * 'tagSet'<~Hash>
        #
        # (Amazon API Reference)[http://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeVpcClassicLink.html
        def describe_vpc_classic_link(options={})
          params = {}
          params.merge!(Fog::AWS.indexed_param('VpcId', options[:vpc_ids])) if options[:vpc_ids]
          params.merge!(Fog::AWS.indexed_filters(options[:filters])) if options[:filters]
          request({
            'Action'    => 'DescribeVpcClassicLink',
            :parser     => Fog::Parsers::AWS::Compute::DescribeVpcClassicLink.new
          }.merge(params))
        end
      end

      class Mock
        def describe_vpc_classic_link(options={})
          response = Excon::Response.new
          vpcs = self.data[:vpcs]
          if vpc_ids = options[:vpc_ids]
            vpcs = vpc_ids.collect do |vpc_id|
              vpc = vpcs.find{ |v| v['vpcId'] == vpc_id }
              raise Fog::AWS::Compute::NotFound.new("The VPC '#{vpc_id}' does not exist") unless vpc
              vpc
            end
          end
          vpcs = apply_tag_filters(vpcs, options[:filters], 'vpcId') if options[:filters]

          response.status = 200
          vpc_data = vpcs.collect do |vpc|
            {
              'vpcId' => vpc['vpcId'],
              'classicLinkEnabled' => vpc['classicLinkEnabled'],
              'tagSet' => self.data[:tag_sets][vpc['vpcId']] || {}
            }
          end
          response.body = {
            'requestId' => Fog::AWS::Mock.request_id,
            'vpcSet' => vpc_data
          }
          response
        end
      end
    end
  end
end