Reference documentation and code samples for the Cloud DNS API class Google::Cloud::Dns::Record.
DNS Record
Represents a set of DNS resource records (RRs) for a given#nameand#typein aZone. Since it is a value object, a newly
created Record instance is transient until it is added to a Zone withZone#update. Note thatZone#addand theZone#updateblock parameter can be used instead ofZone#recordorRecord.newto create new records.
The array of resource record data, as determined bytypeand defined
inRFC 1035 (section
5)andRFC 1034
(section 3.6.1).
For example: ["10 mail.example.com.", "20 mail2.example.com."].
Returns
(Array<String>)
#data=
defdata=(value)->Array<String>
The array of resource record data, as determined bytypeand defined
inRFC 1035 (section
5)andRFC 1034
(section 3.6.1).
For example: ["10 mail.example.com.", "20 mail2.example.com."].
Parameter
value(Array<String>)
Returns
(Array<String>)
#dup
defdup()
Returns a deep copy of the record. Useful for updating records, since
the original, unmodified record must be passed for deletion when usingZone#update.
#initialize
definitialize(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 asupported 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 bytypeand defined inRFC
1035 (section 5)andRFC 1034
(section 3.6.1).
For example: ["10 mail.example.com.", "20 mail2.example.com."].
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["# Cloud DNS API - Class Google::Cloud::Dns::Record (v1.1.0)\n\nVersion latestkeyboard_arrow_down\n\n- [1.1.0 (latest)](/ruby/docs/reference/google-cloud-dns/latest/Google-Cloud-Dns-Record)\n- [1.0.0](/ruby/docs/reference/google-cloud-dns/1.0.0/Google-Cloud-Dns-Record)\n- [0.37.0](/ruby/docs/reference/google-cloud-dns/0.37.0/Google-Cloud-Dns-Record)\n- [0.36.1](/ruby/docs/reference/google-cloud-dns/0.36.1/Google-Cloud-Dns-Record)\n- [0.35.1](/ruby/docs/reference/google-cloud-dns/0.35.1/Google-Cloud-Dns-Record) \nReference documentation and code samples for the Cloud DNS API class Google::Cloud::Dns::Record.\n\nDNS Record\n----------\n\nRepresents a set of DNS resource records (RRs) for a given\n[#name](/ruby/docs/reference/google-cloud-dns/latest/Google-Cloud-Dns-Record#Google__Cloud__Dns__Record_name_instance_ \"Google::Cloud::Dns::Record#name (method)\") and [#type](/ruby/docs/reference/google-cloud-dns/latest/Google-Cloud-Dns-Record#Google__Cloud__Dns__Record_type_instance_ \"Google::Cloud::Dns::Record#type (method)\")\nin a [Zone](/ruby/docs/reference/google-cloud-dns/latest/Google-Cloud-Dns-Zone \"Google::Cloud::Dns::Zone (class)\"). Since it is a value object, a newly\ncreated Record instance is transient until it is added to a Zone with\n[Zone#update](/ruby/docs/reference/google-cloud-dns/latest/Google-Cloud-Dns-Zone#Google__Cloud__Dns__Zone_update_instance_ \"Google::Cloud::Dns::Zone#update (method)\"). Note that\n[Zone#add](/ruby/docs/reference/google-cloud-dns/latest/Google-Cloud-Dns-Zone#Google__Cloud__Dns__Zone_add_instance_ \"Google::Cloud::Dns::Zone#add (method)\") and the [Zone#update](/ruby/docs/reference/google-cloud-dns/latest/Google-Cloud-Dns-Zone#Google__Cloud__Dns__Zone_update_instance_ \"Google::Cloud::Dns::Zone#update (method)\")\nblock parameter can be used instead of [Zone#record](/ruby/docs/reference/google-cloud-dns/latest/Google-Cloud-Dns-Zone#Google__Cloud__Dns__Zone_record_instance_ \"Google::Cloud::Dns::Zone#record (method)\")\nor `Record.new` to create new records. \n\nInherits\n--------\n\n- Object\n\nExample\n-------\n\n```ruby\nrequire \"google/cloud/dns\"\n\ndns = Google::Cloud::Dns.new\nzone = dns.zone \"example-com\"\n\nzone.records.count #=\u003e 2\nrecord = zone.record \"example.com.\", \"A\", 86400, \"1.2.3.4\"\nzone.records.count #=\u003e 2\nchange = zone.update record\nzone.records.count #=\u003e 3\n```\n\nMethods\n-------\n\n### #data\n\n def data() -\u003e Array\u003cString\u003e\n\nThe array of resource record data, as determined by `type` and defined\nin [RFC 1035 (section\n5)](http://tools.ietf.org/html/rfc1035#section-5) and [RFC 1034\n(section 3.6.1)](http://tools.ietf.org/html/rfc1034#section-3.6.1).\nFor example: \\[\"10 mail.example.com.\", \"20 mail2.example.com.\"\\]. \n**Returns**\n\n- (Array\\\u003cString\\\u003e)\n\n### #data=\n\n def data=(value) -\u003e Array\u003cString\u003e\n\nThe array of resource record data, as determined by `type` and defined\nin [RFC 1035 (section\n5)](http://tools.ietf.org/html/rfc1035#section-5) and [RFC 1034\n(section 3.6.1)](http://tools.ietf.org/html/rfc1034#section-3.6.1).\nFor example: \\[\"10 mail.example.com.\", \"20 mail2.example.com.\"\\]. \n**Parameter**\n\n- **value** (Array\\\u003cString\\\u003e) \n**Returns**\n\n- (Array\\\u003cString\\\u003e)\n\n### #dup\n\n def dup()\n\nReturns a deep copy of the record. Useful for updating records, since\nthe original, unmodified record must be passed for deletion when using\n[Zone#update](/ruby/docs/reference/google-cloud-dns/latest/Google-Cloud-Dns-Zone#Google__Cloud__Dns__Zone_update_instance_ \"Google::Cloud::Dns::Zone#update (method)\").\n\n### #initialize\n\n def initialize(name, type, ttl, data) -\u003e Record\n\nCreates a Record value object. \n**Parameters**\n\n- **name** (String) --- The owner of the record. For example: `example.com.`.\n- **type** (String) --- The identifier of a [supported record\n type](https://cloud.google.com/dns/what-is-cloud-dns). For example: `A`, `AAAA`, `CNAME`, `MX`, or `TXT`.\n- **ttl** (Integer) --- The number of seconds that the record can be cached by resolvers.\n- **data** (String, Array\\\u003cString\\\u003e) --- The resource record data, as determined by `type` and defined in [RFC\n 1035 (section 5)](http://tools.ietf.org/html/rfc1035#section-5) and [RFC 1034\n(section 3.6.1)](http://tools.ietf.org/html/rfc1034#section-3.6.1). For example: \\[\"10 mail.example.com.\", \"20 mail2.example.com.\"\\]. \n**Returns**\n\n- ([Record](./Google-Cloud-Dns-Record)) --- a new instance of Record \n**Raises**\n\n- (ArgumentError)\n\n### #name\n\n def name() -\u003e String\n\nThe owner of the record. For example: `example.com.`. \n**Returns**\n\n- (String)\n\n### #name=\n\n def name=(value) -\u003e String\n\nThe owner of the record. For example: `example.com.`. \n**Parameter**\n\n- **value** (String) \n**Returns**\n\n- (String)\n\n### #ttl\n\n def ttl() -\u003e Integer\n\nThe number of seconds that the record can be cached by resolvers. \n**Returns**\n\n- (Integer)\n\n### #ttl=\n\n def ttl=(value) -\u003e Integer\n\nThe number of seconds that the record can be cached by resolvers. \n**Parameter**\n\n- **value** (Integer) \n**Returns**\n\n- (Integer)\n\n### #type\n\n def type() -\u003e String\n\nThe identifier of a [supported record type](https://cloud.google.com/dns/what-is-cloud-dns#supported_record_types).\nFor example: `A`, `AAAA`, `CNAME`, `MX`, or `TXT`. \n**Returns**\n\n- (String)\n\n### #type=\n\n def type=(value) -\u003e String\n\nThe identifier of a [supported record type](https://cloud.google.com/dns/what-is-cloud-dns#supported_record_types).\nFor example: `A`, `AAAA`, `CNAME`, `MX`, or `TXT`. \n**Parameter**\n\n- **value** (String) \n**Returns**\n\n- (String)"]]