epc 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/epc.rb +71 -54
- data/lib/epc/command/archive_command.rb +12 -0
- data/lib/epc/command/attach_libraryset_command.rb +1 -2
- data/lib/epc/command/attach_runtime_command.rb +0 -1
- data/lib/epc/command/base_command.rb +52 -63
- data/lib/epc/command/config/delete_config_command.rb +57 -0
- data/lib/epc/command/{list_config_command.rb → config/list_configs_command.rb} +1 -1
- data/lib/epc/command/config/update_config_command.rb +56 -0
- data/lib/epc/command/create_command.rb +0 -1
- data/lib/epc/command/delete_command.rb +16 -0
- data/lib/epc/command/{delete_dependency_command.rb → dependency/delete_dependency_command.rb} +14 -16
- data/lib/epc/command/deploy_command.rb +1 -2
- data/lib/epc/command/deployment/list_deployments_command.rb +49 -0
- data/lib/epc/command/deployment/show_deployment_command.rb +61 -0
- data/lib/epc/command/{update_deploymentproject_command.rb → deployment/update_deployment_command.rb} +3 -3
- data/lib/epc/command/{list_stages_command.rb → deploymentstage/list_deploymentstages_command.rb} +1 -1
- data/lib/epc/command/group/delete_group_command.rb +25 -0
- data/lib/epc/command/{list_groups_command.rb → group/list_groups_command.rb} +1 -1
- data/lib/epc/command/{show_group_command.rb → group/show_group_command.rb} +2 -9
- data/lib/epc/command/{update_group_command.rb → group/update_group_command.rb} +3 -20
- data/lib/epc/command/library/create_library_command.rb +2 -5
- data/lib/epc/command/library/delete_library_command.rb +23 -0
- data/lib/epc/command/{list_libraries_command.rb → library/list_libraries_command.rb} +1 -1
- data/lib/epc/command/librarylanguage/delete_librarylanguage_command.rb +24 -0
- data/lib/epc/command/{list_librarylanguages_command.rb → librarylanguage/list_librarylanguages_command.rb} +1 -1
- data/lib/epc/command/{update_librarylanguage_command.rb → librarylanguage/update_librarylanguage_command.rb} +6 -10
- data/lib/epc/command/libraryset/create_libraryset_command.rb +1 -6
- data/lib/epc/command/{delete_libraryset_command.rb → libraryset/delete_libraryset_command.rb} +2 -18
- data/lib/epc/command/{list_librarysets_command.rb → libraryset/list_librarysets_command.rb} +1 -1
- data/lib/epc/command/{show_libraryset_command.rb → libraryset/show_libraryset_command.rb} +2 -17
- data/lib/epc/command/{update_libraryset_command.rb → libraryset/update_libraryset_command.rb} +4 -16
- data/lib/epc/command/list_command.rb +22 -0
- data/lib/epc/command/list_metrics_command.rb +25 -0
- data/lib/epc/command/list_objecttypes_command.rb +2 -4
- data/lib/epc/command/list_versions_command.rb +0 -1
- data/lib/epc/command/{list_objectroles_command.rb → objectrole/list_objectroles_command.rb} +3 -3
- data/lib/epc/command/objectrole/update_objectrole_command.rb +14 -0
- data/lib/epc/command/{list_rolepermissions_command.rb → permission/list_permissions_command.rb} +2 -2
- data/lib/epc/command/{list_permissiongroups_command.rb → permissiongroup/list_permissiongroups_command.rb} +1 -1
- data/lib/epc/command/plugin/create_plugin_command.rb +42 -0
- data/lib/epc/command/plugin/delete_plugin_command.rb +26 -0
- data/lib/epc/command/plugin/list_plugins_command.rb +19 -0
- data/lib/epc/command/plugin/show_plugin_command.rb +29 -0
- data/lib/epc/command/plugin/update_plugin_command.rb +53 -0
- data/lib/epc/command/{archive_project_command.rb → project/archive_project_command.rb} +4 -3
- data/lib/epc/command/{delete_project_command.rb → project/delete_project_command.rb} +11 -7
- data/lib/epc/command/{list_projects_command.rb → project/list_projects_command.rb} +8 -9
- data/lib/epc/command/{show_project_command.rb → project/show_project_command.rb} +64 -29
- data/lib/epc/command/{unarchive_project_command.rb → project/unarchive_project_command.rb} +5 -4
- data/lib/epc/command/{update_project_command.rb → project/update_project_command.rb} +11 -5
- data/lib/epc/command/{list_projecttypes_command.rb → projecttype/list_projecttypes_command.rb} +1 -1
- data/lib/epc/command/{show_projecttype_command.rb → projecttype/show_projecttype_command.rb} +4 -3
- data/lib/epc/command/pull_command.rb +33 -35
- data/lib/epc/command/{delete_role_command.rb → role/delete_role_command.rb} +3 -4
- data/lib/epc/command/{list_roles_command.rb → role/list_roles_command.rb} +4 -3
- data/lib/epc/command/{show_role_command.rb → role/show_role_command.rb} +18 -10
- data/lib/epc/command/role/update_role_command.rb +95 -0
- data/lib/epc/command/{list_runtimes_command.rb → runtime/list_runtimes_command.rb} +0 -0
- data/lib/epc/command/servicedefinition/create_servicedefinition_command.rb +23 -0
- data/lib/epc/command/{list_servicedefinitions_command.rb → servicedefinition/list_servicedefinitions_command.rb} +1 -0
- data/lib/epc/command/{list_service_types_command.rb → servicetype/list_servicetypes_command.rb} +0 -0
- data/lib/epc/command/serviceversion/delete_serviceversion_command.rb +24 -0
- data/lib/epc/command/{list_serviceversions_command.rb → serviceversion/list_serviceversions_command.rb} +1 -1
- data/lib/epc/command/show_command.rb +27 -0
- data/lib/epc/command/show_instances_command.rb +33 -0
- data/lib/epc/command/show_metrics_command.rb +55 -0
- data/lib/epc/command/{archive_solution_command.rb → solution/archive_solution_command.rb} +2 -1
- data/lib/epc/command/solution/create_solution_command.rb +0 -1
- data/lib/epc/command/{delete_solution_command.rb → solution/delete_solution_command.rb} +5 -10
- data/lib/epc/command/solution/list_solutions_command.rb +1 -1
- data/lib/epc/command/{show_solution_command.rb → solution/show_solution_command.rb} +12 -7
- data/lib/epc/command/{unarchive_solution_command.rb → solution/unarchive_solution_command.rb} +1 -1
- data/lib/epc/command/solution/update_solution_command.rb +2 -1
- data/lib/epc/command/unarchive_command.rb +12 -0
- data/lib/epc/command/update_command.rb +15 -0
- data/lib/epc/command/update_rolepermissions_command.rb +2 -2
- data/lib/epc/command/{delete_user_command.rb → user/delete_user_command.rb} +4 -12
- data/lib/epc/command/{list_users_command.rb → user/list_users_command.rb} +1 -1
- data/lib/epc/command/{show_user_command.rb → user/show_user_command.rb} +3 -17
- data/lib/epc/command/{update_user_command.rb → user/update_user_command.rb} +2 -4
- data/lib/epc/config.rb +4 -1
- data/lib/epc/help.rb +50 -35
- data/lib/epc/runner.rb +16 -5
- data/lib/epc/version.rb +1 -1
- data/lib/epc/vertical_bar.rb +40 -0
- data/test/command/create_library_command_test.rb +5 -2
- data/test/command/create_libraryset_command_test.rb +1 -1
- data/test/command/create_plugin_command_test.rb +44 -0
- data/test/command/create_servicedefinition_command_test.rb +43 -0
- data/test/command/delete_config_command_test.rb +0 -11
- data/test/command/delete_dependency_command_test.rb +3 -11
- data/test/command/delete_library_command_test.rb +2 -15
- data/test/command/delete_librarylanguage_command_test.rb +2 -24
- data/test/command/delete_libraryset_command_test.rb +2 -24
- data/test/command/delete_plugin_command_test.rb +32 -0
- data/test/command/delete_project_command_test.rb +0 -6
- data/test/command/delete_role_command_test.rb +1 -1
- data/test/command/delete_serviceversion_command_test.rb +0 -22
- data/test/command/delete_solution_command_test.rb +4 -4
- data/test/command/delete_user_command_test.rb +2 -24
- data/test/command/list_config_command_test.rb +3 -3
- data/test/command/list_deployments_command_test.rb +17 -20
- data/test/command/list_deploymentstages_command_test.rb +2 -2
- data/test/command/list_metrics_command_test.rb +40 -0
- data/test/command/{list_rolepermissions_command_test.rb → list_permissions_command_test.rb} +2 -2
- data/test/command/list_plugins_command_test.rb +27 -0
- data/test/command/list_projects_command_test.rb +3 -5
- data/test/command/list_roles_command_test.rb +2 -3
- data/test/command/pull_command_test.rb +13 -9
- data/test/command/show_group_command_test.rb +1 -23
- data/test/command/show_instances_command_test.rb +33 -0
- data/test/command/show_libraryset_command_test.rb +0 -11
- data/test/command/show_metrics_command_test.rb +51 -0
- data/test/command/show_plugin_command_test.rb +28 -0
- data/test/command/show_project_command_test.rb +1 -1
- data/test/command/show_projecttype_command_test.rb +0 -5
- data/test/command/show_role_command_test.rb +1 -1
- data/test/command/show_solution_command_test.rb +1 -1
- data/test/command/show_user_command_test.rb +2 -22
- data/test/command/update_config_command_test.rb +3 -9
- data/test/command/{update_deploymentproject_command_test.rb → update_deployment_command_test.rb} +6 -11
- data/test/command/update_group_command_test.rb +1 -20
- data/test/command/update_librarylanguage_command_test.rb +0 -15
- data/test/command/update_libraryset_command_test.rb +0 -13
- data/test/command/update_plugin_command_test.rb +41 -0
- data/test/command/update_project_command_test.rb +3 -3
- data/test/command/update_role_command_test.rb +2 -1
- data/test/command/update_solution_command_test.rb +3 -9
- data/test/command/update_user_command_test.rb +0 -6
- metadata +177 -165
- data/lib/epc/command/define_service_command.rb +0 -37
- data/lib/epc/command/delete_config_command.rb +0 -63
- data/lib/epc/command/delete_group_command.rb +0 -40
- data/lib/epc/command/delete_library_command.rb +0 -30
- data/lib/epc/command/delete_librarylanguage_command.rb +0 -40
- data/lib/epc/command/delete_serviceversion_command.rb +0 -52
- data/lib/epc/command/list_approvals_command.rb +0 -27
- data/lib/epc/command/list_attachedlibraries_command.rb +0 -42
- data/lib/epc/command/list_boundservices_command.rb +0 -40
- data/lib/epc/command/list_dependencies_command.rb +0 -43
- data/lib/epc/command/list_deployments_command.rb +0 -68
- data/lib/epc/command/list_solutions_command.rb +0 -25
- data/lib/epc/command/show_deployment_command.rb +0 -57
- data/lib/epc/command/update_config_command.rb +0 -62
- data/lib/epc/command/update_role_command.rb +0 -47
- data/lib/epc/command/update_solution_command.rb +0 -45
- data/test/command/define_service_command_test.rb +0 -55
- data/test/command/delete_group_command_test.rb +0 -56
- data/test/command/list_approvals_command_test.rb +0 -41
- data/test/command/list_boundservices_command_test.rb +0 -46
- data/test/command/list_dependencies_command_test.rb +0 -46
- data/test/command/update_rolepermissions_command_test.rb +0 -54
@@ -1,17 +1,13 @@
|
|
1
1
|
module EPC::Command
|
2
2
|
class UpdateLibrarylanguageCommand < BaseCommand
|
3
3
|
|
4
|
-
def execute(language,
|
5
|
-
if numeric?(language)
|
6
|
-
language_id = language.to_i
|
7
|
-
else
|
8
|
-
language_id = get_resource_id(EPC::Config::LIBRARY_LANGUAGES_PATH, :name, language)
|
9
|
-
end
|
4
|
+
def execute(language = nil, *args)
|
10
5
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
6
|
+
new_name = args[0] rescue nil
|
7
|
+
|
8
|
+
raise FatalError, "You need to specify the new library language name" if new_name.blank?
|
9
|
+
|
10
|
+
language_id = retrieve_identifier_for("LibraryLanguage", language)
|
15
11
|
|
16
12
|
status, response, headers = client.put(EPC::Config::LIBRARY_LANGUAGES_PATH + "/#{language_id}", :name => new_name )
|
17
13
|
|
@@ -13,12 +13,7 @@ module EPC::Command
|
|
13
13
|
params = {}
|
14
14
|
params[:name] = set
|
15
15
|
|
16
|
-
|
17
|
-
language_id = language.to_i
|
18
|
-
else
|
19
|
-
language_id = get_resource_id(EPC::Config::LIBRARY_LANGUAGES_PATH, :name, language, :case_sensitivity => false)
|
20
|
-
end
|
21
|
-
params[:language_id] = language_id
|
16
|
+
params[:language_id] = retrieve_identifier_for("LibraryLanguage", language)
|
22
17
|
|
23
18
|
status, response, headers = client.post(EPC::Config::LIBRARY_SETS_PATH, params)
|
24
19
|
if status.successful?
|
data/lib/epc/command/{delete_libraryset_command.rb → libraryset/delete_libraryset_command.rb}
RENAMED
@@ -1,29 +1,13 @@
|
|
1
1
|
module EPC::Command
|
2
2
|
class DeleteLibrarysetCommand < BaseCommand
|
3
3
|
|
4
|
-
def execute(set = nil)
|
5
|
-
if set.nil?
|
6
|
-
say("You need to specify a set id/name")
|
7
|
-
say(EPC::Help::COMMAND_USAGES[:delete_libraryset])
|
8
|
-
return 1
|
9
|
-
end
|
10
|
-
|
4
|
+
def execute(set = nil, *args)
|
11
5
|
proceed = ask_yn("Are you sure you want to delete the [#{set}] set? [Yn] ")
|
12
6
|
if proceed.upcase == "N"
|
13
7
|
return 1
|
14
8
|
end
|
15
9
|
|
16
|
-
|
17
|
-
if numeric?(set)
|
18
|
-
set_id = set.to_i
|
19
|
-
else
|
20
|
-
set_id = get_resource_id(EPC::Config::LIBRARY_SETS_PATH, :name, set)
|
21
|
-
end
|
22
|
-
|
23
|
-
if set_id.nil?
|
24
|
-
say("Set could not be determined")
|
25
|
-
return 1
|
26
|
-
end
|
10
|
+
set_id = retrieve_identifier_for("LibrarySet", set)
|
27
11
|
|
28
12
|
status, response, headers = client.delete(EPC::Config::LIBRARY_SETS_PATH + "/#{set_id}")
|
29
13
|
|
@@ -2,7 +2,7 @@ require 'time'
|
|
2
2
|
module EPC::Command
|
3
3
|
class ListLibrarysetsCommand < BaseCommand
|
4
4
|
|
5
|
-
def execute
|
5
|
+
def execute(target = nil)
|
6
6
|
status, response, headers = client.get(EPC::Config::LIBRARY_SETS_PATH)
|
7
7
|
if status.failure?
|
8
8
|
say("Request failed: [#{response[:message]}]")
|
@@ -2,23 +2,8 @@ require 'time'
|
|
2
2
|
module EPC::Command
|
3
3
|
class ShowLibrarysetCommand < BaseCommand
|
4
4
|
|
5
|
-
def execute(library_set = nil)
|
6
|
-
|
7
|
-
say("You must specify a library-set")
|
8
|
-
say(EPC::Help::COMMAND_USAGES[:show_libraryset])
|
9
|
-
return 1
|
10
|
-
end
|
11
|
-
|
12
|
-
if numeric?(library_set)
|
13
|
-
library_set_id = library_set.to_i
|
14
|
-
else
|
15
|
-
library_set_id = get_resource_id(EPC::Config::LIBRARY_SETS_PATH, :name, library_set)
|
16
|
-
end
|
17
|
-
|
18
|
-
if library_set_id.nil? || library_set_id == 0
|
19
|
-
say("Library set could not be determined")
|
20
|
-
return 1
|
21
|
-
end
|
5
|
+
def execute(library_set = nil, *args)
|
6
|
+
library_set_id = retrieve_identifier_for("LibrarySet", library_set)
|
22
7
|
|
23
8
|
status, response, headers = client.get(EPC::Config::LIBRARY_SETS_PATH + "/#{library_set_id}")
|
24
9
|
|
data/lib/epc/command/{update_libraryset_command.rb → libraryset/update_libraryset_command.rb}
RENAMED
@@ -1,23 +1,11 @@
|
|
1
1
|
module EPC::Command
|
2
2
|
class UpdateLibrarysetCommand < BaseCommand
|
3
|
-
|
4
|
-
def execute(set = nil)
|
5
|
-
if set.nil?
|
6
|
-
say("You must specify the library-set")
|
7
|
-
say(EPC::Help::COMMAND_USAGES[:update_libraryset])
|
8
|
-
return 1
|
9
|
-
end
|
10
3
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
set_id = get_resource_id(EPC::Config::LIBRARY_SETS_PATH, :name, set, :case_sensitivity => false)
|
15
|
-
end
|
4
|
+
required_options :add_library, :remove_library, :mode => :any?, :message => "You must specify a library to added or removed"
|
5
|
+
|
6
|
+
def execute(set = nil, *args)
|
16
7
|
|
17
|
-
|
18
|
-
say("Set could not be determined")
|
19
|
-
return 1
|
20
|
-
end
|
8
|
+
set_id = retrieve_identifier_for("LibrarySet", set)
|
21
9
|
|
22
10
|
if @options[:add_library].present?
|
23
11
|
lib = @options[:add_library]
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module EPC::Command
|
2
|
+
class ListCommand < BaseCommand
|
3
|
+
|
4
|
+
def execute(object_type = nil, *params)
|
5
|
+
klass = "EPC::Command::List#{pluralize(object_type.to_s).gsub("-","").capitalize}Command"
|
6
|
+
params = normalize_params(params)
|
7
|
+
command = eval(klass).new(client, @options)
|
8
|
+
command.go(*params)
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def pluralize(string)
|
14
|
+
case string.downcase
|
15
|
+
when "library"
|
16
|
+
return "Libraries"
|
17
|
+
end
|
18
|
+
return string + "s"
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
module EPC::Command
|
3
|
+
class ListMetricsCommand < BaseCommand
|
4
|
+
|
5
|
+
def execute
|
6
|
+
opts = options[:target] ? "?target=#{CGI.escape(options[:target])}" : ''
|
7
|
+
status, response, headers = client.get("#{EPC::Config::METRICS_PATH}#{opts}")
|
8
|
+
if status.failure?
|
9
|
+
say("Request failed: [#{response[:message]}]")
|
10
|
+
elsif response.empty?
|
11
|
+
if options[:target]
|
12
|
+
say("No metrics available for target #{options[:target]}.")
|
13
|
+
else
|
14
|
+
say("No metrics available.")
|
15
|
+
end
|
16
|
+
else
|
17
|
+
table = EPC::TabularOutputter.new(response, [:target, :id, :name, :type, :function])
|
18
|
+
say(table.print(:line_separator => false))
|
19
|
+
end
|
20
|
+
status
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
@@ -7,10 +7,8 @@ module EPC::Command
|
|
7
7
|
say("Request failed: [#{response[:message]}]")
|
8
8
|
else
|
9
9
|
object_types = []
|
10
|
-
|
11
|
-
|
12
|
-
end
|
13
|
-
obj_table = EPC::TabularOutputter.new(object_types, [:type_name, :identifier])
|
10
|
+
|
11
|
+
obj_table = EPC::TabularOutputter.new(response, [:type, :identifier])
|
14
12
|
say(obj_table.print)
|
15
13
|
end
|
16
14
|
|
@@ -1,11 +1,11 @@
|
|
1
1
|
module EPC::Command
|
2
2
|
class ListObjectrolesCommand < BaseCommand
|
3
3
|
|
4
|
-
def execute(
|
4
|
+
def execute(target = nil)
|
5
5
|
|
6
|
-
raise FatalError, "You must specify an
|
6
|
+
raise FatalError, "You must specify an TargetType and TargetId" if target.blank?
|
7
7
|
|
8
|
-
obj_type, obj_id =
|
8
|
+
obj_type, obj_id = target.split(":")
|
9
9
|
|
10
10
|
raise FatalError, "Parameters specified incorrectly" if obj_type.blank? || obj_id.blank?
|
11
11
|
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module EPC::Command
|
2
|
+
class UpdateObjectroleCommand < UpdateCommand
|
3
|
+
|
4
|
+
required_options :add_user, :remove_user, :add_group, :remove_group, :add_grant, :remove_grant, :mode => :any?, :message => "You must specify a user/group/grant to added or removed"
|
5
|
+
|
6
|
+
def execute(role = nil, *args)
|
7
|
+
role_id = retrieve_identifier_for("Role", role.split("."))
|
8
|
+
|
9
|
+
cmd = UpdateRoleCommand.new(client, @options)
|
10
|
+
return cmd.execute(role_id)
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module EPC::Command
|
2
|
+
class CreatePluginCommand < CreateCommand
|
3
|
+
|
4
|
+
def execute(*args)
|
5
|
+
keys = [:name, :plugin_version, :group]
|
6
|
+
args = args[1..3] rescue nil
|
7
|
+
|
8
|
+
raise FatalError, "You need to specify the name, version and group for the plugin" if args.size < 3
|
9
|
+
params = {}
|
10
|
+
|
11
|
+
keys.each_with_index{|key, idx| params[key] = args[idx]}
|
12
|
+
|
13
|
+
params[:extensions] = @options[:extensions].present?
|
14
|
+
params[:inherited] = @options[:inherited].present?
|
15
|
+
|
16
|
+
params[:configuration] = parse_plugin_opt(@options[:configuration]) if @options[:configuration].present?
|
17
|
+
params[:executions] = parse_plugin_opt(@options[:executions]) if @options[:executions].present?
|
18
|
+
|
19
|
+
status, response, headers = client.post(EPC::Config::PLUGINS_PATH, params)
|
20
|
+
|
21
|
+
if status.successful?
|
22
|
+
say("Plugin [#{args[0]}] created.")
|
23
|
+
else
|
24
|
+
say("Request failed: [#{response[:message]}]")
|
25
|
+
end
|
26
|
+
|
27
|
+
return status
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def parse_plugin_opt(opt)
|
33
|
+
type, content = opt.split(":")
|
34
|
+
if type != "file"
|
35
|
+
return opt
|
36
|
+
else
|
37
|
+
return read_file(content)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module EPC::Command
|
2
|
+
class DeletePluginCommand < UpdateCommand
|
3
|
+
|
4
|
+
def execute(plugin = nil, *args)
|
5
|
+
|
6
|
+
proceed = ask_yn("Are you sure you want to delete the [#{plugin}] plugin? [Yn] ")
|
7
|
+
if proceed.upcase == 'N'
|
8
|
+
return 1
|
9
|
+
end
|
10
|
+
|
11
|
+
plugin_id = retrieve_identifier_for("Plugin", plugin)
|
12
|
+
|
13
|
+
status, response, headers = client.delete(EPC::Config::PLUGINS_PATH + "/#{plugin_id}")
|
14
|
+
|
15
|
+
if status.successful?
|
16
|
+
say("Plugin deleted")
|
17
|
+
else
|
18
|
+
say("Request failed: [#{response[:message]}]")
|
19
|
+
end
|
20
|
+
|
21
|
+
return status
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module EPC::Command
|
2
|
+
class ListPluginsCommand < BaseCommand
|
3
|
+
|
4
|
+
def execute(*args)
|
5
|
+
|
6
|
+
|
7
|
+
status, response, headers = client.get(EPC::Config::PLUGINS_PATH)
|
8
|
+
|
9
|
+
if status.successful?
|
10
|
+
plugins_table = EPC::TabularOutputter.new(response, [:id, :name, :group, :plugin_version])
|
11
|
+
say(plugins_table.print)
|
12
|
+
else
|
13
|
+
say("Request failed: [#{response[:message]}]")
|
14
|
+
end
|
15
|
+
|
16
|
+
return status
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module EPC::Command
|
2
|
+
class ShowPluginCommand < ShowCommand
|
3
|
+
|
4
|
+
def execute(plugin = nil, *args)
|
5
|
+
|
6
|
+
plugin_id = retrieve_identifier_for("Plugin", plugin.split(":"))
|
7
|
+
|
8
|
+
|
9
|
+
status, response, headers = client.get(EPC::Config::PLUGINS_PATH + "/#{plugin_id}")
|
10
|
+
|
11
|
+
if status.successful?
|
12
|
+
plugin_table = EPC::TabularOutputter.new([response], [:id, :name, :plugin_version, :group, :inherited, :extensions])
|
13
|
+
exec_table = EPC::TabularOutputter.new([response], [:executions])
|
14
|
+
conf_table = EPC::TabularOutputter.new([response], [:configuration])
|
15
|
+
|
16
|
+
|
17
|
+
say(plugin_table.print)
|
18
|
+
say(exec_table.print)
|
19
|
+
say(conf_table.print)
|
20
|
+
else
|
21
|
+
say("Request failed: [#{response[:message]}]")
|
22
|
+
end
|
23
|
+
|
24
|
+
return status
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module EPC::Command
|
2
|
+
class UpdatePluginCommand < UpdateCommand
|
3
|
+
UPDATABLE_ATTRIBUTES = ["name", "plugin_version", "group", "inherited", "extensions", "executions", "configuration"]
|
4
|
+
|
5
|
+
def execute(plugin = nil, *args)
|
6
|
+
|
7
|
+
plugin_id = retrieve_identifier_for("Plugin", plugin)
|
8
|
+
|
9
|
+
args = args[1..3] rescue nil
|
10
|
+
|
11
|
+
raise FatalError, "You need to specify at least one attribute to update" if args.size < 1
|
12
|
+
params = {}
|
13
|
+
|
14
|
+
args.each do |arg|
|
15
|
+
key, val = arg.split("=")
|
16
|
+
next if key.blank?
|
17
|
+
params[key] = parse_plugin_opt(val)
|
18
|
+
end
|
19
|
+
|
20
|
+
params.each do |attr, val|
|
21
|
+
unless UPDATABLE_ATTRIBUTES.include?(attr)
|
22
|
+
params.delete(attr)
|
23
|
+
say("Cannot update #{attr}. Updatable attributes are: [#{UPDATABLE_ATTRIBUTES.join(', ')}]")
|
24
|
+
next
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
raise InputError, "You need to specify at least one attribute to update" if params.blank?
|
29
|
+
|
30
|
+
status, response, headers = client.put(EPC::Config::PLUGINS_PATH + "/#{plugin_id}", params)
|
31
|
+
|
32
|
+
if status.successful?
|
33
|
+
say("Plugin updated")
|
34
|
+
else
|
35
|
+
say("Request failed: [#{response[:message]}]")
|
36
|
+
end
|
37
|
+
|
38
|
+
return status
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def parse_plugin_opt(opt)
|
45
|
+
type, content = opt.split(":")
|
46
|
+
if type != "file"
|
47
|
+
return opt
|
48
|
+
else
|
49
|
+
return read_file(content)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|