Sha256: 9e2b146109be1c3bbe17173f9d40f57302ef83c0d791e5553edb3bd39634efde

Contents?: true

Size: 1.9 KB

Versions: 23

Compression:

Stored size: 1.9 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'
              @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

23 entries across 23 versions & 5 rubygems

Version Path
vagrant-cloudstack-1.1.0 vendor/bundle/gems/fog-1.22.1/lib/fog/aws/parsers/compute/describe_reserved_instances.rb
fog-aws-0.1.2 lib/fog/aws/parsers/compute/describe_reserved_instances.rb
fog-aws-0.1.1 lib/fog/aws/parsers/compute/describe_reserved_instances.rb
fog-aws-0.1.0 lib/fog/aws/parsers/compute/describe_reserved_instances.rb
fog-aws-0.0.8 lib/fog/aws/parsers/compute/describe_reserved_instances.rb
fog-aws-0.0.7 lib/fog/aws/parsers/compute/describe_reserved_instances.rb
fog-aws-0.0.6 lib/fog/aws/parsers/compute/describe_reserved_instances.rb
fog-aws-0.0.5 lib/fog/aws/parsers/compute/describe_reserved_instances.rb
fog-1.26.0 lib/fog/aws/parsers/compute/describe_reserved_instances.rb
fog-1.25.0 lib/fog/aws/parsers/compute/describe_reserved_instances.rb
nsidc-fog-1.24.1 lib/fog/aws/parsers/compute/describe_reserved_instances.rb
fog-1.24.0 lib/fog/aws/parsers/compute/describe_reserved_instances.rb
ns-fog-1.22.11 lib/fog/aws/parsers/compute/describe_reserved_instances.rb
ns-fog-1.22.10 lib/fog/aws/parsers/compute/describe_reserved_instances.rb
ns-fog-1.22.9 lib/fog/aws/parsers/compute/describe_reserved_instances.rb
ns-fog-1.22.8 lib/fog/aws/parsers/compute/describe_reserved_instances.rb
ns-fog-1.22.7 lib/fog/aws/parsers/compute/describe_reserved_instances.rb
ns-fog-1.22.6 lib/fog/aws/parsers/compute/describe_reserved_instances.rb
fog-1.23.0 lib/fog/aws/parsers/compute/describe_reserved_instances.rb
ns-fog-1.22.4 lib/fog/aws/parsers/compute/describe_reserved_instances.rb