Class: AWS::Route53::ChangeBatch

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/aws/route_53/change_batch.rb

Overview

Modify resource record sets with ChangeBatch

batch = AWS::Route53::ChangeBatch.new(hosted_zone_id)
batch << AWS::Route53::CreateRequest.new('foo.example.com.', 'A', :resource_records => [{:value => '192.168.0.1'}])
batch << AWS::Route53::DeleteRequest.new('bar.example.com.', 'CNAME')
batch << AWS::Route53::DeleteRequest.new('baz.example.com.', 'AAAA')
batch << AWS::Route53::CreateRequest.new('baz.example.com.', 'AAAA', :resource_records => [{:value => '192.168.0.3'}])

batch.call

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#changesArray<ChangeRequest> (readonly)

Returns:



44
45
46
# File 'lib/aws/route_53/change_batch.rb', line 44

def changes
  @changes
end

#commentString (readonly)

Returns:

  • (String)


47
48
49
# File 'lib/aws/route_53/change_batch.rb', line 47

def comment
  @comment
end

#hosted_zone_idString (readonly)

Returns:

  • (String)


41
42
43
# File 'lib/aws/route_53/change_batch.rb', line 41

def hosted_zone_id
  @hosted_zone_id
end

Instance Method Details

#call(options = {}) ⇒ ChangeInfo

Calls change batch request.

Returns:



60
61
62
63
64
65
66
67
68
# File 'lib/aws/route_53/change_batch.rb', line 60

def call options={}
  resp = client.change_resource_record_sets(options.merge(self.to_hash))
  if resp[:change_info][:id]
    ChangeInfo.new_from(:change_resource_record_sets,
                        resp[:change_info],
                        resp[:change_info][:id],
                        :config => config)
  end
end

#each(&block) ⇒ Object

Enumerates over changes.



71
72
73
# File 'lib/aws/route_53/change_batch.rb', line 71

def each(&block)
  @changes.each(&block)
end

#lengthInteger Also known as: size

Returns length of changes.

Returns:

  • (Integer)


77
78
79
# File 'lib/aws/route_53/change_batch.rb', line 77

def length
  @changes.length
end

#push(change) ⇒ Array Also known as: <<

Parameters:

Returns:

  • (Array)


51
52
53
# File 'lib/aws/route_53/change_batch.rb', line 51

def push change
  @changes.push(change)
end

#to_hashHash

Build query from change batch.

Returns:

  • (Hash)


85
86
87
88
89
90
91
92
93
94
95
# File 'lib/aws/route_53/change_batch.rb', line 85

def to_hash
  q = {}
  q[:hosted_zone_id] = hosted_zone_id
  q[:change_batch] = {}
  q[:change_batch][:comment] = comment if comment
  q[:change_batch][:changes] = []
  self.each { |change|
    q[:change_batch][:changes] << change.to_hash
  }
  q
end