epc 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (152) hide show
  1. data/lib/epc.rb +71 -54
  2. data/lib/epc/command/archive_command.rb +12 -0
  3. data/lib/epc/command/attach_libraryset_command.rb +1 -2
  4. data/lib/epc/command/attach_runtime_command.rb +0 -1
  5. data/lib/epc/command/base_command.rb +52 -63
  6. data/lib/epc/command/config/delete_config_command.rb +57 -0
  7. data/lib/epc/command/{list_config_command.rb → config/list_configs_command.rb} +1 -1
  8. data/lib/epc/command/config/update_config_command.rb +56 -0
  9. data/lib/epc/command/create_command.rb +0 -1
  10. data/lib/epc/command/delete_command.rb +16 -0
  11. data/lib/epc/command/{delete_dependency_command.rb → dependency/delete_dependency_command.rb} +14 -16
  12. data/lib/epc/command/deploy_command.rb +1 -2
  13. data/lib/epc/command/deployment/list_deployments_command.rb +49 -0
  14. data/lib/epc/command/deployment/show_deployment_command.rb +61 -0
  15. data/lib/epc/command/{update_deploymentproject_command.rb → deployment/update_deployment_command.rb} +3 -3
  16. data/lib/epc/command/{list_stages_command.rb → deploymentstage/list_deploymentstages_command.rb} +1 -1
  17. data/lib/epc/command/group/delete_group_command.rb +25 -0
  18. data/lib/epc/command/{list_groups_command.rb → group/list_groups_command.rb} +1 -1
  19. data/lib/epc/command/{show_group_command.rb → group/show_group_command.rb} +2 -9
  20. data/lib/epc/command/{update_group_command.rb → group/update_group_command.rb} +3 -20
  21. data/lib/epc/command/library/create_library_command.rb +2 -5
  22. data/lib/epc/command/library/delete_library_command.rb +23 -0
  23. data/lib/epc/command/{list_libraries_command.rb → library/list_libraries_command.rb} +1 -1
  24. data/lib/epc/command/librarylanguage/delete_librarylanguage_command.rb +24 -0
  25. data/lib/epc/command/{list_librarylanguages_command.rb → librarylanguage/list_librarylanguages_command.rb} +1 -1
  26. data/lib/epc/command/{update_librarylanguage_command.rb → librarylanguage/update_librarylanguage_command.rb} +6 -10
  27. data/lib/epc/command/libraryset/create_libraryset_command.rb +1 -6
  28. data/lib/epc/command/{delete_libraryset_command.rb → libraryset/delete_libraryset_command.rb} +2 -18
  29. data/lib/epc/command/{list_librarysets_command.rb → libraryset/list_librarysets_command.rb} +1 -1
  30. data/lib/epc/command/{show_libraryset_command.rb → libraryset/show_libraryset_command.rb} +2 -17
  31. data/lib/epc/command/{update_libraryset_command.rb → libraryset/update_libraryset_command.rb} +4 -16
  32. data/lib/epc/command/list_command.rb +22 -0
  33. data/lib/epc/command/list_metrics_command.rb +25 -0
  34. data/lib/epc/command/list_objecttypes_command.rb +2 -4
  35. data/lib/epc/command/list_versions_command.rb +0 -1
  36. data/lib/epc/command/{list_objectroles_command.rb → objectrole/list_objectroles_command.rb} +3 -3
  37. data/lib/epc/command/objectrole/update_objectrole_command.rb +14 -0
  38. data/lib/epc/command/{list_rolepermissions_command.rb → permission/list_permissions_command.rb} +2 -2
  39. data/lib/epc/command/{list_permissiongroups_command.rb → permissiongroup/list_permissiongroups_command.rb} +1 -1
  40. data/lib/epc/command/plugin/create_plugin_command.rb +42 -0
  41. data/lib/epc/command/plugin/delete_plugin_command.rb +26 -0
  42. data/lib/epc/command/plugin/list_plugins_command.rb +19 -0
  43. data/lib/epc/command/plugin/show_plugin_command.rb +29 -0
  44. data/lib/epc/command/plugin/update_plugin_command.rb +53 -0
  45. data/lib/epc/command/{archive_project_command.rb → project/archive_project_command.rb} +4 -3
  46. data/lib/epc/command/{delete_project_command.rb → project/delete_project_command.rb} +11 -7
  47. data/lib/epc/command/{list_projects_command.rb → project/list_projects_command.rb} +8 -9
  48. data/lib/epc/command/{show_project_command.rb → project/show_project_command.rb} +64 -29
  49. data/lib/epc/command/{unarchive_project_command.rb → project/unarchive_project_command.rb} +5 -4
  50. data/lib/epc/command/{update_project_command.rb → project/update_project_command.rb} +11 -5
  51. data/lib/epc/command/{list_projecttypes_command.rb → projecttype/list_projecttypes_command.rb} +1 -1
  52. data/lib/epc/command/{show_projecttype_command.rb → projecttype/show_projecttype_command.rb} +4 -3
  53. data/lib/epc/command/pull_command.rb +33 -35
  54. data/lib/epc/command/{delete_role_command.rb → role/delete_role_command.rb} +3 -4
  55. data/lib/epc/command/{list_roles_command.rb → role/list_roles_command.rb} +4 -3
  56. data/lib/epc/command/{show_role_command.rb → role/show_role_command.rb} +18 -10
  57. data/lib/epc/command/role/update_role_command.rb +95 -0
  58. data/lib/epc/command/{list_runtimes_command.rb → runtime/list_runtimes_command.rb} +0 -0
  59. data/lib/epc/command/servicedefinition/create_servicedefinition_command.rb +23 -0
  60. data/lib/epc/command/{list_servicedefinitions_command.rb → servicedefinition/list_servicedefinitions_command.rb} +1 -0
  61. data/lib/epc/command/{list_service_types_command.rb → servicetype/list_servicetypes_command.rb} +0 -0
  62. data/lib/epc/command/serviceversion/delete_serviceversion_command.rb +24 -0
  63. data/lib/epc/command/{list_serviceversions_command.rb → serviceversion/list_serviceversions_command.rb} +1 -1
  64. data/lib/epc/command/show_command.rb +27 -0
  65. data/lib/epc/command/show_instances_command.rb +33 -0
  66. data/lib/epc/command/show_metrics_command.rb +55 -0
  67. data/lib/epc/command/{archive_solution_command.rb → solution/archive_solution_command.rb} +2 -1
  68. data/lib/epc/command/solution/create_solution_command.rb +0 -1
  69. data/lib/epc/command/{delete_solution_command.rb → solution/delete_solution_command.rb} +5 -10
  70. data/lib/epc/command/solution/list_solutions_command.rb +1 -1
  71. data/lib/epc/command/{show_solution_command.rb → solution/show_solution_command.rb} +12 -7
  72. data/lib/epc/command/{unarchive_solution_command.rb → solution/unarchive_solution_command.rb} +1 -1
  73. data/lib/epc/command/solution/update_solution_command.rb +2 -1
  74. data/lib/epc/command/unarchive_command.rb +12 -0
  75. data/lib/epc/command/update_command.rb +15 -0
  76. data/lib/epc/command/update_rolepermissions_command.rb +2 -2
  77. data/lib/epc/command/{delete_user_command.rb → user/delete_user_command.rb} +4 -12
  78. data/lib/epc/command/{list_users_command.rb → user/list_users_command.rb} +1 -1
  79. data/lib/epc/command/{show_user_command.rb → user/show_user_command.rb} +3 -17
  80. data/lib/epc/command/{update_user_command.rb → user/update_user_command.rb} +2 -4
  81. data/lib/epc/config.rb +4 -1
  82. data/lib/epc/help.rb +50 -35
  83. data/lib/epc/runner.rb +16 -5
  84. data/lib/epc/version.rb +1 -1
  85. data/lib/epc/vertical_bar.rb +40 -0
  86. data/test/command/create_library_command_test.rb +5 -2
  87. data/test/command/create_libraryset_command_test.rb +1 -1
  88. data/test/command/create_plugin_command_test.rb +44 -0
  89. data/test/command/create_servicedefinition_command_test.rb +43 -0
  90. data/test/command/delete_config_command_test.rb +0 -11
  91. data/test/command/delete_dependency_command_test.rb +3 -11
  92. data/test/command/delete_library_command_test.rb +2 -15
  93. data/test/command/delete_librarylanguage_command_test.rb +2 -24
  94. data/test/command/delete_libraryset_command_test.rb +2 -24
  95. data/test/command/delete_plugin_command_test.rb +32 -0
  96. data/test/command/delete_project_command_test.rb +0 -6
  97. data/test/command/delete_role_command_test.rb +1 -1
  98. data/test/command/delete_serviceversion_command_test.rb +0 -22
  99. data/test/command/delete_solution_command_test.rb +4 -4
  100. data/test/command/delete_user_command_test.rb +2 -24
  101. data/test/command/list_config_command_test.rb +3 -3
  102. data/test/command/list_deployments_command_test.rb +17 -20
  103. data/test/command/list_deploymentstages_command_test.rb +2 -2
  104. data/test/command/list_metrics_command_test.rb +40 -0
  105. data/test/command/{list_rolepermissions_command_test.rb → list_permissions_command_test.rb} +2 -2
  106. data/test/command/list_plugins_command_test.rb +27 -0
  107. data/test/command/list_projects_command_test.rb +3 -5
  108. data/test/command/list_roles_command_test.rb +2 -3
  109. data/test/command/pull_command_test.rb +13 -9
  110. data/test/command/show_group_command_test.rb +1 -23
  111. data/test/command/show_instances_command_test.rb +33 -0
  112. data/test/command/show_libraryset_command_test.rb +0 -11
  113. data/test/command/show_metrics_command_test.rb +51 -0
  114. data/test/command/show_plugin_command_test.rb +28 -0
  115. data/test/command/show_project_command_test.rb +1 -1
  116. data/test/command/show_projecttype_command_test.rb +0 -5
  117. data/test/command/show_role_command_test.rb +1 -1
  118. data/test/command/show_solution_command_test.rb +1 -1
  119. data/test/command/show_user_command_test.rb +2 -22
  120. data/test/command/update_config_command_test.rb +3 -9
  121. data/test/command/{update_deploymentproject_command_test.rb → update_deployment_command_test.rb} +6 -11
  122. data/test/command/update_group_command_test.rb +1 -20
  123. data/test/command/update_librarylanguage_command_test.rb +0 -15
  124. data/test/command/update_libraryset_command_test.rb +0 -13
  125. data/test/command/update_plugin_command_test.rb +41 -0
  126. data/test/command/update_project_command_test.rb +3 -3
  127. data/test/command/update_role_command_test.rb +2 -1
  128. data/test/command/update_solution_command_test.rb +3 -9
  129. data/test/command/update_user_command_test.rb +0 -6
  130. metadata +177 -165
  131. data/lib/epc/command/define_service_command.rb +0 -37
  132. data/lib/epc/command/delete_config_command.rb +0 -63
  133. data/lib/epc/command/delete_group_command.rb +0 -40
  134. data/lib/epc/command/delete_library_command.rb +0 -30
  135. data/lib/epc/command/delete_librarylanguage_command.rb +0 -40
  136. data/lib/epc/command/delete_serviceversion_command.rb +0 -52
  137. data/lib/epc/command/list_approvals_command.rb +0 -27
  138. data/lib/epc/command/list_attachedlibraries_command.rb +0 -42
  139. data/lib/epc/command/list_boundservices_command.rb +0 -40
  140. data/lib/epc/command/list_dependencies_command.rb +0 -43
  141. data/lib/epc/command/list_deployments_command.rb +0 -68
  142. data/lib/epc/command/list_solutions_command.rb +0 -25
  143. data/lib/epc/command/show_deployment_command.rb +0 -57
  144. data/lib/epc/command/update_config_command.rb +0 -62
  145. data/lib/epc/command/update_role_command.rb +0 -47
  146. data/lib/epc/command/update_solution_command.rb +0 -45
  147. data/test/command/define_service_command_test.rb +0 -55
  148. data/test/command/delete_group_command_test.rb +0 -56
  149. data/test/command/list_approvals_command_test.rb +0 -41
  150. data/test/command/list_boundservices_command_test.rb +0 -46
  151. data/test/command/list_dependencies_command_test.rb +0 -46
  152. data/test/command/update_rolepermissions_command_test.rb +0 -54
@@ -1,7 +1,7 @@
1
1
  module EPC::Command
2
2
  class ListLibrarylanguagesCommand < BaseCommand
3
3
 
4
- def execute
4
+ def execute(target = nil)
5
5
  status, response, headers = client.get(EPC::Config::LIBRARY_LANGUAGES_PATH)
6
6
  if status.failure?
7
7
  say("Request failed: [#{response[:message]}]")
@@ -1,17 +1,13 @@
1
1
  module EPC::Command
2
2
  class UpdateLibrarylanguageCommand < BaseCommand
3
3
 
4
- def execute(language, new_name)
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
- if language_id.nil?
12
- say("Language could not be determined")
13
- return 1
14
- end
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
- if numeric?(language)
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?
@@ -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
- if library_set.nil?
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
 
@@ -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
- if numeric?(set)
12
- set_id = set.to_i
13
- else
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
- if set_id.nil?
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
- response.each do |type_name, identifier|
11
- object_types << {:type_name => type_name, :identifier => identifier}
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
 
@@ -18,7 +18,6 @@ module EPC::Command
18
18
 
19
19
  status, response, headers = client.get(EPC::Config::PROJECTS_PATH + "/#{project_id}/versions")
20
20
 
21
-
22
21
  if status.failure?
23
22
  say("Request failed: [#{response[:message]}]")
24
23
  elsif response.empty?
@@ -1,11 +1,11 @@
1
1
  module EPC::Command
2
2
  class ListObjectrolesCommand < BaseCommand
3
3
 
4
- def execute(obj = nil)
4
+ def execute(target = nil)
5
5
 
6
- raise FatalError, "You must specify an ObjectType and ObjectId" if obj.blank?
6
+ raise FatalError, "You must specify an TargetType and TargetId" if target.blank?
7
7
 
8
- obj_type, obj_id = obj.split(":")
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
@@ -1,6 +1,6 @@
1
1
  module EPC::Command
2
- class ListRolepermissionsCommand < BaseCommand
3
- def execute
2
+ class ListPermissionsCommand < BaseCommand
3
+ def execute(*args)
4
4
 
5
5
  status, response, headers = client.get(EPC::Config::PERMISSIONS_PATH)
6
6
 
@@ -1,7 +1,7 @@
1
1
  module EPC::Command
2
2
  class ListPermissiongroupsCommand < BaseCommand
3
3
 
4
- def execute
4
+ def execute(*args)
5
5
 
6
6
  status, response, headers = client.get(EPC::Config::PERMISSIONS_PATH)
7
7
 
@@ -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