Sha256: b3919856025d3bda422acdc1d16b95c50d7f910ec9f511ddde4e767a5f7a8c58

Contents?: true

Size: 1.92 KB

Versions: 26

Compression:

Stored size: 1.92 KB

Contents

module Fog
  module Parsers
    module Compute
      module AWS
        class DescribeReservedInstances < Fog::Parsers::Base
          def get_default_item
            {'tagSet' => {}, 'recurringCharges' => {}}
          end

          def reset
            @context = []
            # Note:  <recurringCharges> should also be handled as a set, but do not want to disrupt anyone relying on
            # it currently being flatted
            @contexts = ['reservedInstancesSet', 'tagSet']
            @reserved_instance = get_default_item
            @response = { 'reservedInstancesSet' => [] }
            @tag = {}
          end

          def start_element(name, attrs = [])
            super
            if @contexts.include?(name)
              @context.push(name)
            end
          end

          def end_element(name)
            case name
            when 'availabilityZone', 'instanceType', 'productDescription', 'reservedInstancesId', 'state', 'offeringType', 'instanceTenancy'
              @reserved_instance[name] = value
            when 'duration', 'instanceCount'
              @reserved_instance[name] = value.to_i
            when 'fixedPrice', 'amount', 'usagePrice'
              @reserved_instance[name] = value.to_f
            when *@contexts
              @context.pop
            when 'item'
              case @context.last
              when 'reservedInstancesSet'
                @response['reservedInstancesSet'] << @reserved_instance
                @reserved_instance = get_default_item
              when 'tagSet'
                @reserved_instance['tagSet'][@tag['key']] = @tag['value']
                @tag = {}
              end
            when 'key', 'value'
              @tag[name] = value
            when 'requestId'
              @response[name] = value
            when 'start','end'
              @reserved_instance[name] = Time.parse(value)
            end
          end
        end
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 2 rubygems

Version Path
fog-aws-1.1.0 lib/fog/aws/parsers/compute/describe_reserved_instances.rb
fog-aws-1.0.0 lib/fog/aws/parsers/compute/describe_reserved_instances.rb
fog-aws-0.13.0 lib/fog/aws/parsers/compute/describe_reserved_instances.rb
fog-aws-0.12.0 lib/fog/aws/parsers/compute/describe_reserved_instances.rb
fog-aws-0.11.0 lib/fog/aws/parsers/compute/describe_reserved_instances.rb
fog-aws-0.10.0 lib/fog/aws/parsers/compute/describe_reserved_instances.rb
fog-aws-0.9.4 lib/fog/aws/parsers/compute/describe_reserved_instances.rb
fog-aws-0.9.3 lib/fog/aws/parsers/compute/describe_reserved_instances.rb
fog-aws-0.9.2 lib/fog/aws/parsers/compute/describe_reserved_instances.rb
fog-aws-0.9.1 lib/fog/aws/parsers/compute/describe_reserved_instances.rb
fog-aws-0.9.0 lib/fog/aws/parsers/compute/describe_reserved_instances.rb
fog-aws-0.8.1 lib/fog/aws/parsers/compute/describe_reserved_instances.rb
fog-aws-0.8.0 lib/fog/aws/parsers/compute/describe_reserved_instances.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-aws-0.7.5/lib/fog/aws/parsers/compute/describe_reserved_instances.rb
fog-aws-0.7.6 lib/fog/aws/parsers/compute/describe_reserved_instances.rb
fog-aws-0.7.5 lib/fog/aws/parsers/compute/describe_reserved_instances.rb
fog-aws-0.7.4 lib/fog/aws/parsers/compute/describe_reserved_instances.rb
fog-aws-0.7.3 lib/fog/aws/parsers/compute/describe_reserved_instances.rb
fog-aws-0.7.2 lib/fog/aws/parsers/compute/describe_reserved_instances.rb
fog-aws-0.6.0 lib/fog/aws/parsers/compute/describe_reserved_instances.rb