Class: Fog::Parsers::AWS::Compute::DescribeImages

Inherits:
Base
  • Object
show all
Defined in:
lib/fog/aws/parsers/compute/describe_images.rb

Instance Method Summary collapse

Instance Method Details

#end_element(name) ⇒ Object



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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/fog/aws/parsers/compute/describe_images.rb', line 28

def end_element(name)
  if @in_block_device_mapping
    case name
      when 'blockDeviceMapping'
        @in_block_device_mapping = false
      when 'deviceName', 'virtualName', 'snapshotId', 'deleteOnTermination', 'volumeType', 'encrypted'
        @block_device_mapping[name] = value
      when 'volumeSize'
        @block_device_mapping[name] = value.to_i
      when 'item'
        @image['blockDeviceMapping'] << @block_device_mapping
        @block_device_mapping = {}
    end
  elsif @in_product_codes
    case name
    when 'productCode'
      @image['productCodes'] << value
    when 'productCodes'
      @in_product_codes = false
    end
  elsif @in_tag_set
    case name
      when 'item'
        @image['tagSet'][@tag['key']] = @tag['value']
        @tag = {}
      when 'key', 'value'
        @tag[name] = value
      when 'tagSet'
        @in_tag_set = false
    end
  elsif @in_state_reason
    case name
    when 'code', 'message'
      @state_reason[name] = value
    when 'stateReason'
      @image['stateReason'] = @state_reason
      @state_reason = {}
      @in_state_reason = false
    end
  else
    case name
    when 'architecture', 'description', 'hypervisor', 'imageId', 'imageLocation', 'imageOwnerAlias', 'imageOwnerId', 'imageState', 'imageType', 'kernelId', 'name', 'platform', 'ramdiskId', 'rootDeviceType','rootDeviceName','virtualizationType'
      @image[name] = value
    when 'isPublic','enaSupport'
      if value == 'true'
        @image[name] = true
      else
        @image[name] = false
      end
    when 'creationDate'
      @image[name] = Time.parse(value) if value && !value.empty?
    when 'item'
      @response['imagesSet'] << @image
      @image = { 'blockDeviceMapping' => [], 'productCodes' => [], 'stateReason' => {}, 'tagSet' => {} }
    when 'requestId'
      @response[name] = value
    end
  end
end

#resetObject



6
7
8
9
10
11
12
# File 'lib/fog/aws/parsers/compute/describe_images.rb', line 6

def reset
  @block_device_mapping = {}
  @image = { 'blockDeviceMapping' => [], 'productCodes' => [], 'stateReason' => {}, 'tagSet' => {} }
  @response = { 'imagesSet' => [] }
  @state_reason = {}
  @tag = {}
end

#start_element(name, attrs = []) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/fog/aws/parsers/compute/describe_images.rb', line 14

def start_element(name, attrs = [])
  super
  case name
  when 'blockDeviceMapping'
    @in_block_device_mapping = true
  when 'productCodes'
    @in_product_codes = true
  when 'stateReason'
    @in_state_reason = true
  when 'tagSet'
    @in_tag_set = true
  end
end