Class: Fog::DNS::Softlayer::Domains

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

Instance Method Summary collapse

Instance Method Details

#allObject



18
19
20
21
# File 'lib/fog/softlayer/models/dns/domains.rb', line 18

def all
  data = service.get_domains.body
  load(data)
end

#create(name) ⇒ Object



43
44
45
46
47
48
49
50
51
# File 'lib/fog/softlayer/models/dns/domains.rb', line 43

def create(name)
  template_object = {
    'name' => name,
    'resourceRecords' => {},
  }
  response = service.create_domain(template_object)
  data = response.body
  new.merge_attributes(data)
end

#get(identifier) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/fog/softlayer/models/dns/domains.rb', line 23

def get(identifier)
  return nil if identifier.nil? || identifier == ""
  response = service.get_domain(identifier)
  data = response.body
  new.merge_attributes(data)
rescue Excon::Errors::NotFound
  nil
end

#get_by_name(name) ⇒ Object



32
33
34
35
36
37
38
39
40
# File 'lib/fog/softlayer/models/dns/domains.rb', line 32

def get_by_name(name)
  return nil if name.nil? || name == ""
  response = service.get_domain_by_name(name)
  data = response.body
  return false if data.empty?
  new.merge_attributes(data.first)
rescue Excon::Errors::NotFound
  nil
end