Class: Google::Cloud::Dns::Zone::Transaction
- Inherits:
-
Object
- Object
- Google::Cloud::Dns::Zone::Transaction
- Defined in:
- lib/google/cloud/dns/zone/transaction.rb
Overview
DNS Zone Transaction
This object is used by #update when passed a block. These methods are used to update the records that are sent to the Google Cloud DNS API.
Instance Method Summary collapse
-
#add(name, type, ttl, data) ⇒ Object
Adds a record to the Zone.
-
#modify(name, type) {|record| ... } ⇒ Object
Modifies records on the Zone.
-
#remove(name, type) ⇒ Object
Removes records from the Zone.
-
#replace(name, type, ttl, data) ⇒ Object
Replaces existing records on the Zone.
Instance Method Details
#add(name, type, ttl, data) ⇒ Object
Adds a record to the Zone.
80 81 82 |
# File 'lib/google/cloud/dns/zone/transaction.rb', line 80 def add name, type, ttl, data @additions += Array(@zone.record(name, type, ttl, data)) end |
#modify(name, type) {|record| ... } ⇒ Object
Modifies records on the Zone. Records matching the name
and type
are yielded to the block where they can be modified.
165 166 167 168 169 170 171 |
# File 'lib/google/cloud/dns/zone/transaction.rb', line 165 def modify name, type, &block existing = @zone.records(name, type).all.to_a updated = existing.map(&:dup) updated.each(&block) @additions += updated @deletions += existing end |
#remove(name, type) ⇒ Object
Removes records from the Zone. The records are looked up before they are removed.
103 104 105 |
# File 'lib/google/cloud/dns/zone/transaction.rb', line 103 def remove name, type @deletions += @zone.records(name, type).all.to_a end |
#replace(name, type, ttl, data) ⇒ Object
Replaces existing records on the Zone. Records matching the name
and type
are replaced.
137 138 139 140 |
# File 'lib/google/cloud/dns/zone/transaction.rb', line 137 def replace name, type, ttl, data remove name, type add name, type, ttl, data end |