class ThreeScaleToolbox::Commands::ApplicationCommand::Create::CreateSubcommand
Public Class Methods
command()
click to toggle source
# File lib/3scale_toolbox/commands/application_command/create_command.rb, line 16 def self.command Cri::Command.define do name 'create' usage 'create [opts] <remote> <account> <service> <application-plan> <name>' summary 'create one application' description 'create one application linked to given account and application plan' option nil, 'user-key', 'User Key (API Key) of the application to be created.', argument: :required option nil, 'application-id', 'App ID or Client ID (for OAuth and OpenID Connect authentication modes) of the application to be created. ', argument: :required option nil, 'application-key', 'App Key(s) or Client Secret (for OAuth and OpenID Connect authentication modes) of the application to be created.' , argument: :required option nil, :description, 'Application description', argument: :required option nil, :'redirect-url', 'OpenID Connect redirect url', argument: :required ThreeScaleToolbox::CLI.output_flag(self) param :remote param :account param :service param :plan param :name runner CreateSubcommand end end
Public Instance Methods
run()
click to toggle source
# File lib/3scale_toolbox/commands/application_command/create_command.rb, line 40 def run application = ThreeScaleToolbox::Entities::Application.create( remote: remote, account_id: account.id, plan_id: plan.id, app_attrs: app_attrs ) printer.print_record application.attrs end
Private Instance Methods
account()
click to toggle source
# File lib/3scale_toolbox/commands/application_command/create_command.rb, line 76 def account @account ||= find_account end
account_ref()
click to toggle source
# File lib/3scale_toolbox/commands/application_command/create_command.rb, line 72 def account_ref arguments[:account] end
app_attrs()
click to toggle source
# File lib/3scale_toolbox/commands/application_command/create_command.rb, line 53 def app_attrs { 'name' => name, 'description' => description, 'user_key' => options[:'user-key'], 'application_id' => options[:'application-id'], 'application_key' => options[:'application-key'], 'redirect_url' => options[:'redirect-url'], }.compact end
description()
click to toggle source
# File lib/3scale_toolbox/commands/application_command/create_command.rb, line 64 def description options[:description] || name end
find_account()
click to toggle source
# File lib/3scale_toolbox/commands/application_command/create_command.rb, line 80 def find_account Entities::Account.find(remote: remote, ref: account_ref).tap do |acc| raise ThreeScaleToolbox::Error, "Account #{account_ref} does not exist" if acc.nil? end end
find_plan()
click to toggle source
# File lib/3scale_toolbox/commands/application_command/create_command.rb, line 109 def find_plan Entities::ApplicationPlan.find(service: service, ref: plan_ref).tap do |plan| raise ThreeScaleToolbox::Error, "Application plan #{plan_ref} does not exist" if plan.nil? end end
find_service()
click to toggle source
# File lib/3scale_toolbox/commands/application_command/create_command.rb, line 95 def find_service Entities::Service.find(remote: remote, ref: service_ref).tap do |svc| raise ThreeScaleToolbox::Error, "Service #{service_ref} does not exist" if svc.nil? end end
name()
click to toggle source
# File lib/3scale_toolbox/commands/application_command/create_command.rb, line 68 def name arguments[:name] end
plan()
click to toggle source
# File lib/3scale_toolbox/commands/application_command/create_command.rb, line 105 def plan @plan ||= find_plan end
plan_ref()
click to toggle source
# File lib/3scale_toolbox/commands/application_command/create_command.rb, line 101 def plan_ref arguments[:plan] end
printer()
click to toggle source
# File lib/3scale_toolbox/commands/application_command/create_command.rb, line 119 def printer # keep backwards compatibility options.fetch(:output, CustomPrinter.new) end
remote()
click to toggle source
# File lib/3scale_toolbox/commands/application_command/create_command.rb, line 115 def remote @remote ||= threescale_client(arguments[:remote]) end
service()
click to toggle source
# File lib/3scale_toolbox/commands/application_command/create_command.rb, line 91 def service @service ||= find_service end
service_ref()
click to toggle source
# File lib/3scale_toolbox/commands/application_command/create_command.rb, line 87 def service_ref arguments[:service] end