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

Inherits:
Base
  • Object
show all
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

Instance Method Summary collapse

Methods included from MessageHelpers

error, included, info, print_box, success, warn

Instance Method Details

#call(**options) ⇒ Object



241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
# File 'lib/dnsmadeeasy/cli/commands/zone.rb', line 241

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(:file), options[:domain], 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