Class: ThreeScaleToolbox::Commands::ApplicationCommand::Create::CreateSubcommand

Inherits:
Cri::CommandRunner
  • Object
show all
Includes:
ThreeScaleToolbox::Command
Defined in:
lib/3scale_toolbox/commands/application_command/create_command.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ThreeScaleToolbox::Command

#config, #config_file, #exit_with_message, #fetch_required_option, included, #keep_alive, #remotes, #threescale_client, #verbose, #verify_ssl

Class Method Details

.commandObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# 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

Instance Method Details

#runObject



40
41
42
43
44
45
46
47
48
49
# File 'lib/3scale_toolbox/commands/application_command/create_command.rb', line 40

def run
  application = ThreeScaleToolbox::Entities::Application.create(
    remote: remote,
    account_id: .id,
    plan_id: plan.id,
    app_attrs: app_attrs
  )

  printer.print_record application.attrs
end