These examples all assume you have installed the fog-softlayer gem and that you have created a ~/.fog file, which contains the following:
default:
softlayer_username: <YOUR USERNAME>
softlayer_api_key: <YOUR API KEY>
require 'fog/softlayer'
@sl = Fog::DNS[:softlayer]
Create Domain
@domain = @sl.domains.create('yourdomain.com')
Create Record
record = {
'value' => '127.0.0.1',
'host' => '@',
'type' => 'a'
}
@domain.create_record(record)
List all domains
@domains = @sl.domains.all
@domain = @domains.first
Get specific domain by id
@domain = @sl.domains.get(123456)
Get specific domain by name
@domain = @sl.domains.get_by_name('yourdomain.com')
Get Domains Records
@domain = @sl.domains.get(123456)
@domain.records
Get specific record by id
@domain = @sl.domains.get(123456)
@domain.records.get(456789012)
or using the service:
@sl.records.get(456789012)
After this point we consider you have a Fog::DNS::Softlayer::Domain on @domain variable
Update Record Entry
@domain.records
@domain.records[3].value = "192.168.0.3"
@domain.records[3].save
After this point we consider you have a Fog::DNS::Softlayer::Domain on @domain variable
Destroy Domain
@domain = @sl.domains.get(123456)
@domain.destroy
@domain = @sl.domains.get(123456)
@domain.records.last.destroy