Class: DnsMadeEasy::CLI::Commands::Zone::Apply

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

Overview

Applies a reviewed zone plan safely.

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



298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
# File 'lib/dnsmadeeasy/cli/commands/zone.rb', line 298

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

  plan_context = build_plan_context(options.fetch(:domain), options.fetch(:file),
                                    compare_ttl: options[:diff_ttl])
  return fail_with('Zone apply failed', plan_context.failure) if plan_context.failure?

  mode = apply_mode(options)
  executor = DnsMadeEasy::Zone::ApplyExecutor.new(
    client: DnsMadeEasy.client,
    domain: plan_context.value!.fetch(:domain),
    plan: plan_context.value!.fetch(:plan),
    remote_records: plan_context.value!.fetch(:remote_records),
    mode: mode,
    spinner_output: @err
  )
  executable_count = executor.executable_action_count
  confirm!(executable_count) unless options[:yes]

  result = executor.call
  return fail_with('Zone apply failed', result.failure) if result.failure?

  print_apply_summary(plan_context.value!.fetch(:domain), result.value!)
end