class ThreeScaleToolbox::Commands::ServiceCommand::CreateSubcommand

Public Class Methods

command() click to toggle source
# File lib/3scale_toolbox/commands/service_command/create_command.rb, line 17
def self.command
  Cri::Command.define do
    name        'create'
    usage       'create [options] <remote> <service-name>'
    summary     'Create a service'
    description 'Create a service'

    param   :remote
    param   :service_name

    ThreeScaleToolbox::CLI.output_flag(self)
    option :d, :'deployment-mode', "Specify the deployment mode of the service", argument: :required
    option :s, :'system-name', "Specify the system-name of the service", argument: :required
    option :a, :'authentication-mode', "Specify authentication mode of the service ('1' for API key, '2' for App Id / App Key, 'oauth' for OAuth mode, 'oidc' for OpenID Connect)", argument: :required
    option nil, :description, "Specify the description of the service", argument: :required
    option nil, :'support-email', "Specify the support email of the service", argument: :required

    runner CreateSubcommand
  end
end

Public Instance Methods

run() click to toggle source
# File lib/3scale_toolbox/commands/service_command/create_command.rb, line 38
def run
  service = Entities::Service.create(remote: remote, service_params: create_params)
  printer.print_record service.attrs
end

Private Instance Methods

create_params() click to toggle source
# File lib/3scale_toolbox/commands/service_command/create_command.rb, line 59
def create_params
  service_name = arguments[:service_name]
  create_service_attrs = parse_options
  create_service_attrs['name'] = service_name
  create_service_attrs
end
parse_options() click to toggle source
# File lib/3scale_toolbox/commands/service_command/create_command.rb, line 49
def parse_options
  {
    "deployment_option" => options[:'deployment-mode'],
    "system_name" => options[:'system-name'],
    "backend_version" => options[:'authentication-mode'],
    "description" => options[:description],
    "support_email" => options[:'support-email'],
  }.compact
end
printer() click to toggle source
# File lib/3scale_toolbox/commands/service_command/create_command.rb, line 66
def printer
  # keep backwards compatibility
  options.fetch(:output, CustomPrinter.new)
end
remote() click to toggle source
# File lib/3scale_toolbox/commands/service_command/create_command.rb, line 45
def remote
  @remote ||= threescale_client(arguments[:remote])
end