# Cloud DNS API - Class Google::Cloud::Dns::Record (v1.2.0)

1.2.0 (latest) 1.1.1 1.0.0 0.37.0 0.36.1 0.35.1 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
[#name](https://docs.cloud.google.com/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](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-dns/latest/Google-Cloud-Dns-Record#Google__Cloud__Dns__Record_type_instance_ "Google::Cloud::Dns::Record#type (method)")
in a [Zone](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-dns/latest/Google-Cloud-Dns-Zone "Google::Cloud::Dns::Zone (class)"). Since it is a value object, a newly
created Record instance is transient until it is added to a Zone with
[Zone#update](https://docs.cloud.google.com/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
[Zone#add](https://docs.cloud.google.com/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](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-dns/latest/Google-Cloud-Dns-Zone#Google__Cloud__Dns__Zone_update_instance_ "Google::Cloud::Dns::Zone#update (method)")
block parameter can be used instead of [Zone#record](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-dns/latest/Google-Cloud-Dns-Zone#Google__Cloud__Dns__Zone_record_instance_ "Google::Cloud::Dns::Zone#record (method)")
or `Record.new` to create new records.

## Inherits

- Object

## Example

```ruby
require "google/cloud/dns"

dns = Google::Cloud::Dns.new
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
```

## Methods

### #data

    def data() -> Array<String>

The array of resource record data, as determined by `type` and defined
in [RFC 1035 (section
5)](http://tools.ietf.org/html/rfc1035#section-5) and [RFC 1034
(section 3.6.1)](http://tools.ietf.org/html/rfc1034#section-3.6.1).
For example: \["10 mail.example.com.", "20 mail2.example.com."\].
**Returns**

- (Array\<String\>)

### #data=

    def data=(value) -> Array<String>

The array of resource record data, as determined by `type` and defined
in [RFC 1035 (section
5)](http://tools.ietf.org/html/rfc1035#section-5) and [RFC 1034
(section 3.6.1)](http://tools.ietf.org/html/rfc1034#section-3.6.1).
For example: \["10 mail.example.com.", "20 mail2.example.com."\].
**Parameter**

- **value** (Array\<String\>)
**Returns**

- (Array\<String\>)

### #dup

    def dup()

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](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-dns/latest/Google-Cloud-Dns-Zone#Google__Cloud__Dns__Zone_update_instance_ "Google::Cloud::Dns::Zone#update (method)").

### #initialize

    def 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](https://cloud.google.com/dns/docs/records-overview). 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)](http://tools.ietf.org/html/rfc1035#section-5) and [RFC 1034
  (section 3.6.1)](http://tools.ietf.org/html/rfc1034#section-3.6.1). For example: \["10 mail.example.com.", "20 mail2.example.com."\].
**Returns**

- ([Record](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-dns/latest/Google-Cloud-Dns-Record)) --- a new instance of Record
**Raises**

- (ArgumentError)

### #name

    def name() -> String

The owner of the record. For example: `example.com.`.
**Returns**

- (String)

### #name=

    def name=(value) -> String

The owner of the record. For example: `example.com.`.
**Parameter**

- **value** (String)
**Returns**

- (String)

### #ttl

    def ttl() -> Integer

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

- (Integer)

### #ttl=

    def ttl=(value) -> Integer

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

- **value** (Integer)
**Returns**

- (Integer)

### #type

    def type() -> String

The identifier of a [supported record type](https://cloud.google.com/dns/docs/records-overview).
For example: `A`, `AAAA`, `CNAME`, `MX`, or `TXT`.
**Returns**

- (String)

### #type=

    def type=(value) -> String

The identifier of a [supported record type](https://cloud.google.com/dns/docs/records-overview).
For example: `A`, `AAAA`, `CNAME`, `MX`, or `TXT`.
**Parameter**

- **value** (String)
**Returns**

- (String)