Class: Morpheus::Cli::IntegrationsCommand
Instance Attribute Summary
Attributes included from CliCommand
#no_prompt
Instance Method Summary
collapse
#accounts_interface, #find_account_by_id, #find_account_by_name, #find_account_by_name_or_id, #find_account_from_options, #find_all_user_ids, #find_role_by_id, #find_role_by_name, #find_role_by_name_or_id, #find_user_by_id, #find_user_by_username, #find_user_by_username_or_id, #find_user_group_by_id, #find_user_group_by_name, #find_user_group_by_name_or_id, #format_access_string, #format_role_type, #format_user_role_names, #get_access_color, #get_access_string, included, #print_accounts_table, #print_roles_table, #print_users_table, #roles_interface, #user_groups_interface, #users_interface
Methods included from CliCommand
#apply_options, #build_common_options, #build_option_type_options, #build_standard_add_options, #build_standard_delete_options, #build_standard_get_options, #build_standard_list_options, #build_standard_post_options, #build_standard_put_options, #build_standard_remove_options, #build_standard_update_options, #command_name, #default_refresh_interval, #default_subcommand, #establish_remote_appliance_connection, #full_command_usage, #get_subcommand_description, #handle_subcommand, included, #interactive?, #my_help_command, #my_terminal, #my_terminal=, #parse_bytes_param, #parse_id_list, #parse_list_options, #parse_list_subtitles, #parse_passed_options, #parse_payload, #parse_query_options, #print, #print_error, #println, #puts, #puts_error, #raise_args_error, #raise_command_error, #render_response, #render_with_format, #run_command_for_each_arg, #subcommand_aliases, #subcommand_description, #subcommand_usage, #subcommands, #usage, #verify_args!, #visible_subcommands
Instance Method Details
#connect(opts) ⇒ Object
12
13
14
15
|
# File 'lib/morpheus/cli/integrations_command.rb', line 12
def connect(opts)
@api_client = establish_remote_appliance_connection(opts)
@integrations_interface = @api_client.integrations
end
|
#handle(args) ⇒ Object
17
18
19
|
# File 'lib/morpheus/cli/integrations_command.rb', line 17
def handle(args)
handle_subcommand(args)
end
|
#list(args) ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
# File 'lib/morpheus/cli/integrations_command.rb', line 21
def list(args)
options = {}
params = {}
optparse = Morpheus::Cli::OptionParser.new do |opts|
opts.banner = subcommand_usage()
build_common_options(opts, options, [:list, :query, :json, :yaml, :csv, :fields, :dry_run, :remote])
opts. = "List integrations."
end
optparse.parse!(args)
connect(options)
if args.count != 0
raise_command_error "wrong number of arguments, expected 0 and got (#{args.count}) #{args}\n#{optparse}"
return 1
end
begin
params.merge!(parse_list_options(options))
@integrations_interface.setopts(options)
if options[:dry_run]
print_dry_run @integrations_interface.dry.list(params)
return
end
json_response = @integrations_interface.list(params)
render_result = render_with_format(json_response, options, 'integrations')
return 0 if render_result
title = "Morpheus Integrations"
subtitles = []
subtitles += parse_list_subtitles(options)
print_h1 title, subtitles
integrations = json_response['integrations']
if integrations.empty?
print cyan,"No integrations found.",reset,"\n"
else
rows = integrations.collect do |it|
{
id: it['id'],
name: it['name'],
status: format_integration_status(it),
last_updated: format_local_dt(it['statusDate']),
type: it['integrationType'] ? it['integrationType']['name'] : ''
}
end
columns = [ :id, :name, :status, :last_updated, :type]
print as_pretty_table(rows, columns)
end
print reset,"\n"
return 0
rescue RestClient::Exception => e
print_rest_exception(e, options)
exit 1
end
end
|