Class: DnsMadeEasy::CLI::Commands::Zone::Export

Inherits:
Base
  • Object
show all
Defined in:
lib/dnsmadeeasy/cli/commands/zone.rb

Overview

Exports DNS Made Easy records as canonical zone-file text.

Constant Summary

Constants inherited from Base

Base::DEFAULT_CREDENTIAL_PATHS, Base::SUPPORTED_FORMATS

Instance Method Summary collapse

Instance Method Details

#call(**options) ⇒ Object



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/dnsmadeeasy/cli/commands/zone.rb', line 86

def call(**options)
  configure_message_helpers
  configure_authentication(credentials: options[:credentials], api_key: options[:api_key],
                           api_secret: options[:api_secret])

  domain = options.fetch(:domain)
  export_ttl = options[:ttl] || 300
  result = DnsMadeEasy::Zone::RemoteAdapter.new(
    DnsMadeEasy.client.records_for(domain),
    domain: domain,
    default_ttl: export_ttl
  ).call

  if result.success?
    export_records(
      domain,
      result.value!,
      format: options[:format] || 'rfc',
      output: options[:output],
      ttl: export_ttl,
      include_apex_ns: options[:include_apex_ns]
    )
  else
    MessageHelpers.error("Zone export failed.\n#{result.failure.join("\n")}")
    raise ArgumentError, 'zone export failed'
  end
end