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

Constants included from MessageHelpers

MessageHelpers::BOX_OPTIONS, MessageHelpers::KEY_WIDTH

Instance Method Summary collapse

Methods included from MessageHelpers

error, included, info, kv, print_box, success, warn

Instance Method Details

#call(**options) ⇒ Object



115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# File 'lib/dnsmadeeasy/cli/commands/zone.rb', line 115

def call(**options)
  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
  fail_export(result.failure) if result.failure?

  records_result = export_ready_records(result.value!, strict_rfc: options[:strict_rfc])
  fail_export(records_result.failure) if records_result.failure?

  records, warnings = records_result.value!
  export_records(
    domain,
    records,
    warnings: warnings,
    format: options[:format] || 'rfc',
    output: options[:output],
    ttl: export_ttl,
    include_apex_ns: options[:include_apex_ns]
  )
  success(
    [
      'Zone export complete.',
      kv('Domain', domain),
      kv('Records', records.length),
      kv('Destination', options[:output] || 'STDOUT')
    ].join("\n")
  )
end