Reference documentation and code samples for the google-cloud-dns class Google::Cloud::Dns::Zone::Transaction.
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.
Inherits
- Object
Example
require "google/cloud/dns" dns = Google::Cloud::Dns.new zone = dns.zone "example-com" zone.update do |tx| tx.add "example.com.", "A", 86400, "1.2.3.4" tx.remove "example.com.", "TXT" tx.replace "example.com.", "MX", 86400, ["10 mail1.example.com.", "20 mail2.example.com."] tx.modify "www.example.com.", "CNAME" do |cname| cname.ttl = 86400 # only change the TTL end end
Methods
#add
def add(name, type, ttl, data)
Adds a record to the Zone.
-
name (String) — The owner of the record. For example:
example.com.
. -
type (String) — The identifier of a supported record
type.
For example:
A
,AAAA
,CNAME
,MX
, orTXT
. - ttl (Integer) — The number of seconds that the record can be cached by resolvers.
-
data (String, Array<String>) — The resource record data, as
determined by
type
and defined in RFC 1035 (section 5) and RFC 1034 (section 3.6.1). For example:192.0.2.1
orexample.com.
.
require "google/cloud/dns" dns = Google::Cloud::Dns.new zone = dns.zone "example-com" zone.update do |tx| tx.add "example.com.", "A", 86400, "1.2.3.4" end
#modify
def modify(name, type, &block) { |record| ... }
Modifies records on the Zone. Records matching the name
and type
are yielded to the block where they can be modified.
-
name (String) — The owner of the record. For example:
example.com.
. -
type (String) — The identifier of a supported record
type.
For example:
A
,AAAA
,CNAME
,MX
, orTXT
.
- (record) — a block yielding each matching record
- record (Record) — the record to be modified
require "google/cloud/dns" dns = Google::Cloud::Dns.new zone = dns.zone "example-com" zone.update do |tx| tx.modify "www.example.com.", "CNAME" do |cname| cname.ttl = 86400 # only change the TTL end end
#remove
def remove(name, type)
Removes records from the Zone. The records are looked up before they are removed.
-
name (String) — The owner of the record. For example:
example.com.
. -
type (String) — The identifier of a supported record
type.
For example:
A
,AAAA
,CNAME
,MX
, orTXT
.
require "google/cloud/dns" dns = Google::Cloud::Dns.new zone = dns.zone "example-com" zone.update do |tx| tx.remove "example.com.", "TXT" end
#replace
def replace(name, type, ttl, data)
Replaces existing records on the Zone. Records matching the name
and type
are replaced.
-
name (String) — The owner of the record. For example:
example.com.
. -
type (String) — The identifier of a supported record
type.
For example:
A
,AAAA
,CNAME
,MX
, orTXT
. - ttl (Integer) — The number of seconds that the record can be cached by resolvers.
-
data (String, Array<String>) — The resource record data, as
determined by
type
and defined in RFC 1035 (section 5) and RFC 1034 (section 3.6.1). For example:192.0.2.1
orexample.com.
.
require "google/cloud/dns" dns = Google::Cloud::Dns.new zone = dns.zone "example-com" zone.update do |tx| tx.replace "example.com.", "MX", 86400, ["10 mail1.example.com.", "20 mail2.example.com."] end