class Google::Cloud::Dns::Change
# DNS Change
Represents a request containing additions or deletions or records. Additions and deletions can be done in bulk, in a single atomic transaction, and take effect at the same time in each authoritative DNS server.
@example
require "google/cloud/dns" dns = Google::Cloud::Dns.new zone = dns.zone "example-com" zone.changes.each do |change| puts "Change includes #{change.additions.count} additions " \ "and #{change.additions.count} deletions." end
Attributes
@private The Google
API Client object.
Public Class Methods
@private Create an empty Change
object.
# File lib/google/cloud/dns/change.rb, line 51 def initialize @zone = nil @gapi = {} end
Public Instance Methods
The records added in this change request.
# File lib/google/cloud/dns/change.rb, line 66 def additions Array(@gapi.additions).map { |gapi| Record.from_gapi gapi } end
The records removed in this change request.
# File lib/google/cloud/dns/change.rb, line 73 def deletions Array(@gapi.deletions).map { |gapi| Record.from_gapi gapi } end
Checks if the status is `“done”`.
# File lib/google/cloud/dns/change.rb, line 86 def done? return false if status.nil? "done".casecmp(status).zero? end
Unique identifier for the resource; defined by the server.
# File lib/google/cloud/dns/change.rb, line 59 def id @gapi.id end
Checks if the status is `“pending”`.
# File lib/google/cloud/dns/change.rb, line 93 def pending? return false if status.nil? "pending".casecmp(status).zero? end
Reloads the change with updated status from the DNS service.
# File lib/google/cloud/dns/change.rb, line 109 def reload! ensure_service! @gapi = zone.service.get_change @zone.id, id end
The time that this operation was started by the server.
# File lib/google/cloud/dns/change.rb, line 101 def started_at Time.parse @gapi.start_time rescue StandardError nil end
Status of the operation. Values are `“done”` and `“pending”`.
# File lib/google/cloud/dns/change.rb, line 80 def status @gapi.status end
Refreshes the change until the status is `done`. The delay between refreshes will incrementally increase.
@example
require "google/cloud/dns" dns = Google::Cloud::Dns.new zone = dns.zone "example-com" change = zone.change 1234567890 change.done? #=> false change.wait_until_done! change.done? #=> true
# File lib/google/cloud/dns/change.rb, line 129 def wait_until_done! backoff = ->(retries) { sleep 2 * retries + 5 } retries = 0 until done? backoff.call retries retries += 1 reload! end end
Protected Instance Methods
Raise an error unless an active service is available.
# File lib/google/cloud/dns/change.rb, line 152 def ensure_service! raise "Must have active connection" unless zone&.service end