Class: Fog::DNS::Google::Records

Inherits:
Collection
  • Object
show all
Defined in:
lib/fog/dns/google/models/records.rb

Instance Method Summary collapse

Instance Method Details

#allArray<Fog::DNS::Google::Record>

Enumerates Resource Record Sets that have been created but not yet deleted

Returns:



13
14
15
16
17
18
19
20
21
22
# File 'lib/fog/dns/google/models/records.rb', line 13

def all
  requires :zone

  data = service.list_resource_record_sets(zone.identity)
                .to_h[:rrsets] || []
  load(data)
rescue ::Google::Apis::ClientError => e
  raise e unless e.status_code == 404
  []
end

#get(name, type) ⇒ Fog::DNS::Google::Record

Fetches the representation of an existing Resource Record Set

Parameters:

  • name (String)

    Resource Record Set name

  • type (String)

    Resource Record Set type

Returns:



30
31
32
33
34
35
36
37
38
39
# File 'lib/fog/dns/google/models/records.rb', line 30

def get(name, type)
  requires :zone

  records = service.list_resource_record_sets(zone.identity, :name => name, :type => type)
                   .to_h[:rrsets] || []
  records.any? ? new(records.first) : nil
rescue ::Google::Apis::ClientError => e
  raise e unless e.status_code == 404
  nil
end

#new(attributes = {}) ⇒ Fog::DNS::Google::Record

Creates a new instance of a Resource Record Set

Returns:



45
46
47
48
49
# File 'lib/fog/dns/google/models/records.rb', line 45

def new(attributes = {})
  requires :zone

  super({ :zone => zone }.merge!(attributes))
end