Class: Aws::Ec2::QEc2NetworkInterfacesParser

Inherits:
AwsParser
  • Object
show all
Defined in:
lib/ec2/ec2.rb

Overview

:nodoc:

Constant Summary

Constants inherited from AwsParser

AwsParser::DEFAULT_XML_LIBRARY

Instance Attribute Summary

Attributes inherited from AwsParser

#result, #xml_lib, #xmlpath

Instance Method Summary collapse

Methods inherited from AwsParser

#method_missing, #parse, #tag_end, #tag_start, #tagtext, #text, xml_lib, xml_lib=

Constructor Details

#initialize(opts = {}) ⇒ QEc2NetworkInterfacesParser

Returns a new instance of QEc2NetworkInterfacesParser.



2559
2560
2561
2562
# File 'lib/ec2/ec2.rb', line 2559

def initialize(opts = {})
  super(opts)
  @level = ['top']
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Aws::AwsParser

Instance Method Details

#resetObject



2709
2710
2711
# File 'lib/ec2/ec2.rb', line 2709

def reset
  @result = []
end

#tagend(name) ⇒ Object



2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
# File 'lib/ec2/ec2.rb', line 2591

def tagend(name)
  wrapper = @level.last
  case wrapper
  when 'top'  # parse top level
    case name
    when 'networkInterfaceId'
      @iface[:network_interface_id] = @text
    when 'subnetId'
      @iface[:subnet_id] = @text
    when 'vpcId'
      @iface[:vpc_id] = @text
    when 'availabilityZone'
      @iface[:availability_zone] = @text
    when 'description'
      @iface[:description] = @text
    when 'ownerId'
      @iface[:owner_id] = @text
    when 'requesterId'
      @iface[:requester_id] = @text
    when 'requesterManaged'
      @iface[:requester_managed] = @text
    when 'status'
      @iface[:status] = @text
    when 'macAddress'
      @iface[:mac_address] = @text
    when 'privateIpAddress'
      @iface[:private_ip_address] = @text
    when 'privateDnsName'
      @iface[:private_dns_name] = @text
    when 'sourceDestCheck'
      @iface[:source_dest_check] = @text
    when 'networkInterface'
      @result = @iface
    when 'item'
      @result << @iface
    end
  when 'groupSet'  # parse gorupset
    case name
    when 'groupId'
      @group_item[:group_id] = @text
    when 'groupName'
      @group_item[:group_name] = @text
    when 'item'
      @iface[:group_set] << @group_item
      @group_item = {}
    when 'groupSet'
      @level.pop
    end
  when 'attachment'  # parse attachment
    case name
    when 'attachmentId'
      @iface[:attachment][:attachment_id] = @text
    when 'instanceId'
      @iface[:attachment][:instance_id] = @text
    when 'instanceOwnerId'
      @iface[:attachment][:instance_owner_id] = @text
    when 'deviceIndex'
      @iface[:attachment][:device_index] = @text
    when 'status'
      @iface[:attachment][:status] = @text
    when 'attachTime'
      @iface[:attachment][:attach_time] = @text
    when 'deleteOnTermination'
      @iface[:attachment][:delete_on_termination] = @text
    when 'attachment'
      @level.pop
    end
  when 'tagSet'  # parse tagset
    case name
    when 'key'
      @tag_set_item[:key] = @text
    when 'value'
      @tag_set_item[:value] = @text
    when 'item'
      @iface[:tag_set] << @tag_set_item
      @tag_set_item = {}
    when 'tagSet'
      @level.pop
    end
  when 'association'  # parse assoc
    case name
    when 'publicIp'
      @association[:public_ip] = @text
    when 'publicDnsName'
      @association[:public_dns_name] = @text
    when 'ipOwnerId'
      @association[:ip_owner_id] = @text
    when 'allocationID'
      @association[:allocation_id] = @text
    when 'associationID'
      @association[:association_id] = @text
    when 'association'
      @level.pop

      # `association` can belong both to `NetworkInterfaceType` and `NetworkInterfacePrivateIpAddressesSetItemType`
      if @level.last == 'top'
        @iface[:association] = @association
      else
        @ip_address_item[:association] = @association
      end
    end
  when 'privateIpAddressesSet'  # parse pirvate addresses set
    case name
    when 'privateIpAddress'
      @ip_address_item[:private_ip_address] = @text
    when 'privateDnsName'
      @ip_address_item[:private_dns_name] = @text
    when 'primary'
      @ip_address_item[:primary] = @text
    when 'item'
      @iface[:private_ip_addresses_set] << @ip_address_item
      @ip_address_item = {}
    when 'privateIpAddressesSet'
      @level.pop
    end
  end
end

#tagstart(name, attribute) ⇒ Object



2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
# File 'lib/ec2/ec2.rb', line 2564

def tagstart(name, attribute)
  case name
  when 'groupSet'
    @level.push(name)
    @iface[:group_set] = []
    @group_item = {}
  when 'attachment'
    @level.push(name)
    @iface[:attachment] = {}
  when 'tagSet'
    @level.push(name)
    @iface[:tag_set] = []
    @tag_set_item = {}
  when 'association'
    @level.push(name)
    @association = {}
  when 'privateIpAddressesSet'
    @level.push(name)
    @iface[:private_ip_addresses_set] = []
    @ip_address_item = {}
  when 'networkInterface'
    @iface = {}
  when 'item'
    @iface = {} if @level.last == 'top'
  end
end