Class: Google::Cloud::Dns::Record

Inherits:
Object
  • Object
show all
Defined in:
lib/google/cloud/dns/record.rb,
lib/google/cloud/dns/record/list.rb

Overview

DNS Record

Represents a set of DNS resource records (RRs) for a given #name and #type in a Zone. Since it is a value object, a newly created Record instance is transient until it is added to a Zone with Zone#update. Note that Zone#add and the Zone#update block parameter can be used instead of Zone#record or Record.new to create new records.

Examples:

require "google/cloud"

gcloud = Google::Cloud.new
dns = gcloud.dns
zone = dns.zone "example-com"

zone.records.count #=> 2
record = zone.record "example.com.", "A", 86400, "1.2.3.4"
zone.records.count #=> 2
change = zone.update record
zone.records.count #=> 3

Defined Under Namespace

Classes: List

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, type, ttl, data) ⇒ Record

Creates a Record value object.

Parameters:

  • 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, or TXT.

  • 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: ["10 mail.example.com.", "20 mail2.example.com."].



98
99
100
101
102
103
104
105
106
107
# File 'lib/google/cloud/dns/record.rb', line 98

def initialize name, type, ttl, data
  fail ArgumentError, "name is required" unless name
  fail ArgumentError, "type is required" unless type
  fail ArgumentError, "ttl is required" unless ttl
  fail ArgumentError, "data is required" unless data
  @name = name.to_s
  @type = type.to_s.upcase
  @ttl = Integer(ttl)
  @data = Array(data)
end

Instance Attribute Details

#dataArray<String>

The array of resource record data, as determined by type and defined in RFC 1035 (section 5) and RFC 1034 (section 3.6.1). For example: ["10 mail.example.com.", "20 mail2.example.com."].

Returns:

  • (Array<String>)


79
80
81
# File 'lib/google/cloud/dns/record.rb', line 79

def data
  @data
end

#nameString

The owner of the record. For example: example.com..

Returns:

  • (String)


52
53
54
# File 'lib/google/cloud/dns/record.rb', line 52

def name
  @name
end

#ttlInteger

The number of seconds that the record can be cached by resolvers.

Returns:

  • (Integer)


68
69
70
# File 'lib/google/cloud/dns/record.rb', line 68

def ttl
  @ttl
end

#typeString

The identifier of a supported record type . For example: A, AAAA, CNAME, MX, or TXT.

Returns:

  • (String)


61
62
63
# File 'lib/google/cloud/dns/record.rb', line 61

def type
  @type
end

Instance Method Details

#dupObject

Returns a deep copy of the record. Useful for updating records, since the original, unmodified record must be passed for deletion when using Zone#update.



123
124
125
126
127
# File 'lib/google/cloud/dns/record.rb', line 123

def dup
  other = super
  other.data = data.map(&:dup)
  other
end