Class: Chef::Knife::DigitalOceanDomainRecordDestroy

Inherits:
Chef::Knife
  • Object
show all
Includes:
DigitalOceanBase
Defined in:
lib/chef/knife/digital_ocean_domain_record_destroy.rb

Instance Method Summary collapse

Methods included from DigitalOceanBase

#client, included, load_deps, #locate_config_value, #validate!, #wait_for_status

Instance Method Details

#runObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/chef/knife/digital_ocean_domain_record_destroy.rb', line 33

def run
  $stdout.sync = true

  validate!

  unless locate_config_value(:domain)
    ui.error('Domain cannot be empty. => -D <domain-name>')
    exit 1
  end

  unless locate_config_value(:record)
    ui.error('Record cannot be empty. => -R <record-id>')
    exit 1
  end

  result = client.domain_records.delete for_domain: locate_config_value(:domain), id: locate_config_value(:record)
  ui.info 'OK' if result == true || ui.error(JSON.parse(result)['message'])
end