Module: DnsMadeEasy

Defined in:
lib/dnsmadeeasy.rb,
lib/dnsmadeeasy.rb,
lib/dnsmadeeasy/types.rb,
lib/dnsmadeeasy/runner.rb,
lib/dnsmadeeasy/version.rb,
lib/dnsmadeeasy/cli/input.rb,
lib/dnsmadeeasy/zone/diff.rb,
lib/dnsmadeeasy/zone/file.rb,
lib/dnsmadeeasy/zone/plan.rb,
lib/dnsmadeeasy/api/client.rb,
lib/dnsmadeeasy/credentials.rb,
lib/dnsmadeeasy/zone/parser.rb,
lib/dnsmadeeasy/zone/record.rb,
lib/dnsmadeeasy/cli/commands.rb,
lib/dnsmadeeasy/cli/launcher.rb,
lib/dnsmadeeasy/cli/box_output.rb,
lib/dnsmadeeasy/zone/record_set.rb,
lib/dnsmadeeasy/zone/serializer.rb,
lib/dnsmadeeasy/zone/plan_action.rb,
lib/dnsmadeeasy/cli/commands/base.rb,
lib/dnsmadeeasy/cli/commands/zone.rb,
lib/dnsmadeeasy/zone/apply_result.rb,
lib/dnsmadeeasy/zone/plan_renderer.rb,
lib/dnsmadeeasy/cli/message_helpers.rb,
lib/dnsmadeeasy/zone/apply_executor.rb,
lib/dnsmadeeasy/zone/remote_adapter.rb,
lib/dnsmadeeasy/zone/remote_records.rb,
lib/dnsmadeeasy/cli/commands/account.rb,
lib/dnsmadeeasy/cli/commands/version.rb,
lib/dnsmadeeasy/credentials/api_keys.rb,
lib/dnsmadeeasy/zone/provider_record.rb,
lib/dnsmadeeasy/credentials/yaml_file.rb,
lib/dnsmadeeasy/cli/commands/legacy_operation.rb

Defined Under Namespace

Modules: Api, CLI, Credentials, Types, Zone Classes: APIKeyAndSecretMissingError, AbstractMethodError, AuthenticationError, Error, InvalidCredentialKeys, InvalidCredentialsFormatError, NoDomainError, NoSuchAccountError, Runner

Constant Summary collapse

API_BASE_URL_PRODUCTION =
'https://api.dnsmadeeasy.com/V2.0'
API_BASE_URL_SANDBOX =
'https://api.sandbox.dnsmadeeasy.com/V2.0'
VERSION =

Version 1.0+ is supporting zone file manipulation

'1.0.0'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.default_api_keyObject

Returns the value of attribute default_api_key.



54
55
56
# File 'lib/dnsmadeeasy.rb', line 54

def default_api_key
  @default_api_key
end

.default_api_secretObject

Returns the value of attribute default_api_secret.



54
55
56
# File 'lib/dnsmadeeasy.rb', line 54

def default_api_secret
  @default_api_secret
end

Class Method Details

.api_keyObject



89
90
91
# File 'lib/dnsmadeeasy.rb', line 89

def api_key
  default_api_key
end

.api_key=(value) ⇒ Object



85
86
87
# File 'lib/dnsmadeeasy.rb', line 85

def api_key=(value)
  self.default_api_key = value
end

.api_secretObject



97
98
99
# File 'lib/dnsmadeeasy.rb', line 97

def api_secret
  default_api_secret
end

.api_secret=(value) ⇒ Object



93
94
95
# File 'lib/dnsmadeeasy.rb', line 93

def api_secret=(value)
  self.default_api_secret = value
end

.clientObject



101
102
103
# File 'lib/dnsmadeeasy.rb', line 101

def client(**)
  @client ||= create_client(false, **)
end

.configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (DnsMadeEasy)

    the object that the method was called on



57
58
59
# File 'lib/dnsmadeeasy.rb', line 57

def configure
  yield(self) if block_given?
end

.configure_from_file(file = nil, account = nil, encryption_key = nil) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/dnsmadeeasy.rb', line 61

def configure_from_file(file = nil,
                         = nil,
                        encryption_key = nil)
  credentials = ::DnsMadeEasy::Credentials.keys_from_file(
    file: file || ::DnsMadeEasy::Credentials.default_credentials_path(user: ENV.fetch('USER', nil)),
    account: ,
    encryption_key: encryption_key
  )
  raise APIKeyAndSecretMissingError, "Unable to load valid api keys from #{file}!" unless credentials

  configure do |config|
    config.api_key    = credentials.api_key
    config.api_secret = credentials.api_secret
  end
end

.create_client(sandbox = false, api_key: default_api_key, api_secret: default_api_secret) ⇒ Object



109
110
111
112
113
114
115
116
117
# File 'lib/dnsmadeeasy.rb', line 109

def create_client(sandbox = false,
                  api_key: default_api_key,
                  api_secret: default_api_secret,

                  **)
  raise APIKeyAndSecretMissingError, 'Please set #api_key and #api_secret' unless api_key && api_secret

  ::DnsMadeEasy::Api::Client.new(api_key, api_secret, sandbox, **)
end

.credentials_from_file(file: DnsMadeEasy::Credentials.default_credentials_path, account: nil, encryption_key: nil) ⇒ Object



77
78
79
80
81
82
83
# File 'lib/dnsmadeeasy.rb', line 77

def credentials_from_file(file: DnsMadeEasy::Credentials.default_credentials_path,
                          account: nil,
                          encryption_key: nil)
  DnsMadeEasy::Credentials.keys_from_file file: file,
                                          account: ,
                                          encryption_key: encryption_key
end

.method_missing(method) ⇒ Object

Basically delegate it all to the Client instance if the method call is supported.



122
123
124
125
126
127
128
# File 'lib/dnsmadeeasy.rb', line 122

def method_missing(method, ...)
  if client.respond_to?(method)
    client.send(method, ...)
  else
    super
  end
end

.respond_to_missing?(method, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


130
131
132
133
134
# File 'lib/dnsmadeeasy.rb', line 130

def respond_to_missing?(method, include_private = false)
  client.respond_to?(method, include_private) || super
rescue APIKeyAndSecretMissingError
  super
end

.sandbox_clientObject



105
106
107
# File 'lib/dnsmadeeasy.rb', line 105

def sandbox_client(**)
  @sandbox_client ||= create_client(true, **)
end