Class: DnsMadeEasy::CLI::Commands::AccountOperation
- Inherits:
-
Base
- Object
- Dry::CLI::Command
- Base
- DnsMadeEasy::CLI::Commands::AccountOperation
show all
- Defined in:
- lib/dnsmadeeasy/cli/commands/account.rb
Overview
Base command for generated account operation subcommands.
Constant Summary
Constants inherited
from Base
Base::DEFAULT_CREDENTIAL_PATHS, Base::SUPPORTED_FORMATS
MessageHelpers::BOX_OPTIONS
Class Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
error, included, info, print_box, success, warn
Class Attribute Details
.operation_name ⇒ Object
Returns the value of attribute operation_name.
145
146
147
|
# File 'lib/dnsmadeeasy/cli/commands/account.rb', line 145
def operation_name
@operation_name
end
|
.operation_parameters ⇒ Object
Returns the value of attribute operation_parameters.
145
146
147
|
# File 'lib/dnsmadeeasy/cli/commands/account.rb', line 145
def operation_parameters
@operation_parameters
end
|
Class Method Details
.define_operation_arguments ⇒ Object
148
149
150
151
152
|
# File 'lib/dnsmadeeasy/cli/commands/account.rb', line 148
def define_operation_arguments
required_operation_parameters.each do |parameter_name|
argument parameter_name, required: true, desc: humanize_parameter_name(parameter_name)
end
end
|
.define_record_type_option ⇒ Object
154
155
156
157
|
# File 'lib/dnsmadeeasy/cli/commands/account.rb', line 154
def define_record_type_option
option :record_type, aliases: ['t'], values: Account::RECORD_TYPES, required: false,
desc: 'Filter returned records by type'
end
|
.humanize_parameter_name(parameter_name) ⇒ Object
171
172
173
|
# File 'lib/dnsmadeeasy/cli/commands/account.rb', line 171
def humanize_parameter_name(parameter_name)
parameter_name.to_s.tr('_', ' ')
end
|
.optional_operation_parameters ⇒ Object
165
166
167
168
169
|
# File 'lib/dnsmadeeasy/cli/commands/account.rb', line 165
def optional_operation_parameters
operation_parameters.filter_map do |parameter_type, parameter_name|
parameter_name if parameter_type == :opt && parameter_name != :options
end
end
|
.required_operation_parameters ⇒ Object
159
160
161
162
163
|
# File 'lib/dnsmadeeasy/cli/commands/account.rb', line 159
def required_operation_parameters
operation_parameters.filter_map do |parameter_type, parameter_name|
parameter_name if parameter_type == :req
end
end
|
Instance Method Details
#call(format: nil, credentials: nil, api_key: nil, api_secret: nil, record_type: nil, **arguments) ⇒ Object
176
177
178
179
180
181
|
# File 'lib/dnsmadeeasy/cli/commands/account.rb', line 176
def call(format: nil, credentials: nil, api_key: nil, api_secret: nil, record_type: nil, **arguments)
configure_authentication(credentials: credentials, api_key: api_key, api_secret: api_secret)
result = DnsMadeEasy.client.public_send(self.class.operation_name, *operation_arguments(arguments))
result = filter_records_by_type(result, record_type) if record_type && record_list_operation?
print_result(result, format)
end
|