Sha256: 71a21fde7cb7b94683f83d1870df5e2c8dcf908135343ffce8903da899177059

Contents?: true

Size: 1.99 KB

Versions: 15

Compression:

Stored size: 1.99 KB

Contents

unless Fog.mocking?

  module Fog
    module AWS
      class EC2

        # Describe all or specified availability zones
        #
        # ==== Params
        # * zone_name<~String> - List of availability zones to describe, defaults to all
        #
        # ==== Returns
        # * response<~Excon::Response>:
        #   * body<~Hash>:
        #     * 'requestId'<~String> - Id of request
        #     * 'availabilityZoneInfo'<~Array>:
        #       * 'regionName'<~String> - Name of region
        #       * 'zoneName'<~String> - Name of zone
        #       * 'zoneState'<~String> - State of zone
        def describe_availability_zones(zone_name = [])
          params = AWS.indexed_param('ZoneName', zone_name)
          request({
            'Action' => 'DescribeAvailabilityZones'
          }.merge!(params), Fog::Parsers::AWS::EC2::DescribeAvailabilityZones.new)
        end

      end
    end
  end

else

  module Fog
    module AWS
      class EC2

        def describe_availability_zones(zone_name = [])
          response = Excon::Response.new
          zone_name = [*zone_name]
          zones = {
            'us-east-1a' => {"zoneName"=>"us-east-1a", "regionName"=>"us-east-1", "zoneState"=>"available"}, 
            'us-east-1b' => {"zoneName"=>"us-east-1b", "regionName"=>"us-east-1", "zoneState"=>"available"}, 
            'us-east-1c' => {"zoneName"=>"us-east-1c", "regionName"=>"us-east-1", "zoneState"=>"available"}, 
            'us-east-1d' => {"zoneName"=>"us-east-1d", "regionName"=>"us-east-1", "zoneState"=>"available"}
          }
          if zone_name != []
            availability_zone_info = zones.reject {|key, value| !zone_name.include?(key)}.values
          else
            availability_zone_info = zones.values
          end

          response.status = 200
          response.body = {
            'requestId'             => Fog::AWS::Mock.request_id,
            'availabilityZoneInfo'  => availability_zone_info
          }
          response
        end

      end
    end
  end

end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
fog-0.0.56 lib/fog/aws/requests/ec2/describe_availability_zones.rb
fog-0.0.55 lib/fog/aws/requests/ec2/describe_availability_zones.rb
fog-0.0.54 lib/fog/aws/requests/ec2/describe_availability_zones.rb
fog-0.0.53 lib/fog/aws/requests/ec2/describe_availability_zones.rb
fog-0.0.52 lib/fog/aws/requests/ec2/describe_availability_zones.rb
fog-0.0.51 lib/fog/aws/requests/ec2/describe_availability_zones.rb
fog-0.0.50 lib/fog/aws/requests/ec2/describe_availability_zones.rb
fog-0.0.49 lib/fog/aws/requests/ec2/describe_availability_zones.rb
fog-0.0.48 lib/fog/aws/requests/ec2/describe_availability_zones.rb
fog-0.0.47 lib/fog/aws/requests/ec2/describe_availability_zones.rb
fog-0.0.46 lib/fog/aws/requests/ec2/describe_availability_zones.rb
fog-0.0.45 lib/fog/aws/requests/ec2/describe_availability_zones.rb
fog-0.0.44 lib/fog/aws/requests/ec2/describe_availability_zones.rb
fog-0.0.43 lib/fog/aws/requests/ec2/describe_availability_zones.rb
fog-0.0.42 lib/fog/aws/requests/ec2/describe_availability_zones.rb