epc 1.0.3 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (196) hide show
  1. data/lib/epc.rb +25 -5
  2. data/lib/epc/client/json_client.rb +4 -4
  3. data/lib/epc/command/archive_command.rb +7 -6
  4. data/lib/epc/command/attachto_command.rb +13 -0
  5. data/lib/epc/command/base_command.rb +120 -29
  6. data/lib/epc/command/config/create_config_command.rb +7 -11
  7. data/lib/epc/command/config/delete_config_command.rb +5 -5
  8. data/lib/epc/command/config/list_configs_command.rb +5 -5
  9. data/lib/epc/command/config/update_config_command.rb +11 -10
  10. data/lib/epc/command/copy_command.rb +14 -0
  11. data/lib/epc/command/create_command.rb +9 -5
  12. data/lib/epc/command/delete_command.rb +9 -9
  13. data/lib/epc/command/{copy_deployment_command.rb → deployment/copy_deployment_command.rb} +6 -5
  14. data/lib/epc/command/deployment/create_deployment_command.rb +15 -15
  15. data/lib/epc/command/deployment/list_deployments_command.rb +2 -4
  16. data/lib/epc/command/deployment/show_deployment_command.rb +5 -7
  17. data/lib/epc/command/deployment/submit_deployment_command.rb +15 -0
  18. data/lib/epc/command/deployment/update_deployment_command.rb +5 -14
  19. data/lib/epc/command/deployment/vote_deployment_command.rb +23 -0
  20. data/lib/epc/command/deploymentstage/list_deploymentstages_command.rb +1 -1
  21. data/lib/epc/command/detachfrom_command.rb +13 -0
  22. data/lib/epc/command/group/create_group_command.rb +3 -3
  23. data/lib/epc/command/group/delete_group_command.rb +4 -5
  24. data/lib/epc/command/group/show_group_command.rb +2 -3
  25. data/lib/epc/command/group/update_group_command.rb +9 -7
  26. data/lib/epc/command/library/create_library_command.rb +1 -2
  27. data/lib/epc/command/library/delete_library_command.rb +4 -5
  28. data/lib/epc/command/library/list_libraries_command.rb +1 -1
  29. data/lib/epc/command/librarylanguage/create_librarylanguage_command.rb +1 -1
  30. data/lib/epc/command/librarylanguage/delete_librarylanguage_command.rb +3 -5
  31. data/lib/epc/command/librarylanguage/list_librarylanguages_command.rb +1 -1
  32. data/lib/epc/command/librarylanguage/update_librarylanguage_command.rb +4 -5
  33. data/lib/epc/command/libraryset/create_libraryset_command.rb +5 -4
  34. data/lib/epc/command/libraryset/delete_libraryset_command.rb +4 -6
  35. data/lib/epc/command/libraryset/list_librarysets_command.rb +2 -2
  36. data/lib/epc/command/libraryset/show_libraryset_command.rb +3 -3
  37. data/lib/epc/command/libraryset/update_libraryset_command.rb +4 -3
  38. data/lib/epc/command/list_command.rb +10 -14
  39. data/lib/epc/command/list_objecttypes_command.rb +1 -1
  40. data/lib/epc/command/objectrole/create_objectrole_command.rb +4 -5
  41. data/lib/epc/command/objectrole/list_objectroles_command.rb +3 -8
  42. data/lib/epc/command/objectrole/update_objectrole_command.rb +3 -1
  43. data/lib/epc/command/permission/list_permissions_command.rb +1 -1
  44. data/lib/epc/command/permissiongroup/list_permissiongroups_command.rb +1 -1
  45. data/lib/epc/command/plugin/create_plugin_command.rb +1 -2
  46. data/lib/epc/command/plugin/delete_plugin_command.rb +4 -6
  47. data/lib/epc/command/plugin/list_plugins_command.rb +1 -1
  48. data/lib/epc/command/plugin/show_plugin_command.rb +2 -5
  49. data/lib/epc/command/plugin/update_plugin_command.rb +2 -6
  50. data/lib/epc/command/project/archive_project_command.rb +3 -12
  51. data/lib/epc/command/project/attachto_project_command.rb +133 -0
  52. data/lib/epc/command/project/create_project_command.rb +6 -6
  53. data/lib/epc/command/project/delete_project_command.rb +3 -24
  54. data/lib/epc/command/project/detachfrom_project_command.rb +66 -0
  55. data/lib/epc/command/project/list_projects_command.rb +12 -7
  56. data/lib/epc/command/project/show_project_command.rb +26 -25
  57. data/lib/epc/command/project/show_project_snapshot_command.rb +41 -0
  58. data/lib/epc/command/project/unarchive_project_command.rb +3 -10
  59. data/lib/epc/command/project/update_project_command.rb +5 -18
  60. data/lib/epc/command/projecttype/create_projecttype_command.rb +37 -0
  61. data/lib/epc/command/projecttype/delete_projecttype_command.rb +24 -0
  62. data/lib/epc/command/projecttype/list_projecttypes_command.rb +1 -1
  63. data/lib/epc/command/projecttype/show_projecttype_command.rb +2 -4
  64. data/lib/epc/command/projecttype/update_projecttype_command.rb +61 -0
  65. data/lib/epc/command/push_command.rb +14 -8
  66. data/lib/epc/command/role/create_role_command.rb +26 -3
  67. data/lib/epc/command/role/delete_role_command.rb +3 -5
  68. data/lib/epc/command/role/list_roles_command.rb +7 -3
  69. data/lib/epc/command/role/show_role_command.rb +8 -5
  70. data/lib/epc/command/role/update_role_command.rb +14 -66
  71. data/lib/epc/command/runtime/create_runtime_command.rb +34 -0
  72. data/lib/epc/command/runtime/delete_runtime_command.rb +24 -0
  73. data/lib/epc/command/runtime/list_runtimes_command.rb +2 -2
  74. data/lib/epc/command/runtime/update_runtime_command.rb +49 -0
  75. data/lib/epc/command/runtimetype/list_runtimetypes_command.rb +17 -0
  76. data/lib/epc/command/servicedefinition/create_servicedefinition_command.rb +5 -6
  77. data/lib/epc/command/servicedefinition/delete_servicedefinition_command.rb +18 -0
  78. data/lib/epc/command/servicedefinition/list_servicedefinitions_command.rb +2 -2
  79. data/lib/epc/command/servicetype/list_servicetypes_command.rb +1 -1
  80. data/lib/epc/command/serviceversion/create_serviceversion_command.rb +8 -12
  81. data/lib/epc/command/serviceversion/delete_serviceversion_command.rb +3 -5
  82. data/lib/epc/command/serviceversion/list_serviceversions_command.rb +8 -1
  83. data/lib/epc/command/show_command.rb +8 -9
  84. data/lib/epc/command/show_metrics_command.rb +3 -3
  85. data/lib/epc/command/solution/archive_solution_command.rb +3 -10
  86. data/lib/epc/command/solution/create_solution_command.rb +2 -2
  87. data/lib/epc/command/solution/delete_solution_command.rb +3 -7
  88. data/lib/epc/command/solution/list_solutions_command.rb +11 -3
  89. data/lib/epc/command/solution/show_solution_command.rb +4 -6
  90. data/lib/epc/command/solution/unarchive_solution_command.rb +3 -8
  91. data/lib/epc/command/solution/update_solution_command.rb +4 -6
  92. data/lib/epc/command/submit_command.rb +16 -0
  93. data/lib/epc/command/unarchive_command.rb +7 -6
  94. data/lib/epc/command/update_command.rb +9 -8
  95. data/lib/epc/command/user/create_user_command.rb +2 -3
  96. data/lib/epc/command/user/delete_user_command.rb +3 -5
  97. data/lib/epc/command/user/list_users_command.rb +1 -1
  98. data/lib/epc/command/user/show_user_command.rb +2 -4
  99. data/lib/epc/command/user/update_user_command.rb +3 -14
  100. data/lib/epc/command/userproperty/list_user_properties_command.rb +23 -0
  101. data/lib/epc/command/vote_command.rb +16 -0
  102. data/lib/epc/config.rb +7 -1
  103. data/lib/epc/help.rb +51 -48
  104. data/lib/epc/modules/config.rb +39 -0
  105. data/lib/epc/modules/role.rb +133 -0
  106. data/lib/epc/runner.rb +23 -12
  107. data/lib/epc/version.rb +1 -1
  108. data/test/command/archive_project_command_test.rb +2 -13
  109. data/test/command/archive_solution_command_test.rb +4 -14
  110. data/test/command/copy_deployment_command_test.rb +4 -8
  111. data/test/command/create_config_command_test.rb +23 -23
  112. data/test/command/create_deployment_command_test.rb +33 -32
  113. data/test/command/create_group_command_test.rb +2 -2
  114. data/test/command/create_library_command_test.rb +6 -6
  115. data/test/command/create_librarylanguage_command_test.rb +3 -3
  116. data/test/command/create_libraryset_command_test.rb +6 -26
  117. data/test/command/create_objectrole_command_test.rb +4 -13
  118. data/test/command/create_project_command_test.rb +27 -13
  119. data/test/command/create_role_command_test.rb +3 -2
  120. data/test/command/create_runtime_command_test.rb +37 -0
  121. data/test/command/create_servicedefinition_command_test.rb +4 -17
  122. data/test/command/create_serviceversion_command_test.rb +8 -22
  123. data/test/command/create_solution_command_test.rb +5 -5
  124. data/test/command/create_user_command_test.rb +4 -4
  125. data/test/command/delete_config_command_test.rb +8 -15
  126. data/test/command/delete_library_command_test.rb +3 -4
  127. data/test/command/delete_librarylanguage_command_test.rb +3 -4
  128. data/test/command/delete_libraryset_command_test.rb +3 -4
  129. data/test/command/delete_plugin_command_test.rb +3 -4
  130. data/test/command/delete_project_command_test.rb +2 -10
  131. data/test/command/delete_projecttype_command_test.rb +31 -0
  132. data/test/command/delete_role_command_test.rb +5 -14
  133. data/test/command/delete_runtime_command_test.rb +31 -0
  134. data/test/command/delete_servicedefinition_command_test.rb +31 -0
  135. data/test/command/delete_serviceversion_command_test.rb +3 -2
  136. data/test/command/delete_solution_command_test.rb +3 -16
  137. data/test/command/delete_user_command_test.rb +3 -3
  138. data/test/command/list_config_command_test.rb +1 -0
  139. data/test/command/list_deployments_command_test.rb +11 -41
  140. data/test/command/list_objectroles_command_test.rb +4 -14
  141. data/test/command/list_projects_command_test.rb +0 -14
  142. data/test/command/list_roles_command_test.rb +3 -1
  143. data/test/command/list_runtimes_command_test.rb +2 -3
  144. data/test/command/list_runtimetypes_command_test.rb +29 -0
  145. data/test/command/list_userproperties_command_test.rb +33 -0
  146. data/test/command/push_command_test.rb +9 -1
  147. data/test/command/show_deployment_command_test.rb +36 -0
  148. data/test/command/show_group_command_test.rb +2 -1
  149. data/test/command/show_libraryset_command_test.rb +5 -3
  150. data/test/command/show_metrics_command_test.rb +4 -4
  151. data/test/command/show_plugin_command_test.rb +4 -4
  152. data/test/command/show_project_command_test.rb +5 -17
  153. data/test/command/show_project_snapshot_test.rb +33 -0
  154. data/test/command/show_projecttype_command_test.rb +5 -11
  155. data/test/command/show_role_command_test.rb +5 -12
  156. data/test/command/show_solution_command_test.rb +2 -15
  157. data/test/command/show_user_command_test.rb +4 -3
  158. data/test/command/submit_deployment_command_test.rb +4 -11
  159. data/test/command/unarchive_project_command_test.rb +2 -14
  160. data/test/command/unarchive_solution_command_test.rb +6 -16
  161. data/test/command/update_config_command_test.rb +14 -3
  162. data/test/command/update_deployment_command_test.rb +12 -26
  163. data/test/command/update_group_command_test.rb +2 -10
  164. data/test/command/update_librarylanguage_command_test.rb +5 -3
  165. data/test/command/update_libraryset_command_test.rb +4 -2
  166. data/test/command/update_plugin_command_test.rb +5 -4
  167. data/test/command/update_project_command_test.rb +6 -20
  168. data/test/command/update_role_command_test.rb +11 -8
  169. data/test/command/update_solution_command_test.rb +6 -12
  170. data/test/command/update_user_command_test.rb +3 -19
  171. data/test/command/vote_deployment_command_test.rb +2 -6
  172. metadata +66 -63
  173. data/lib/epc/command/attach_library_command.rb +0 -82
  174. data/lib/epc/command/attach_libraryset_command.rb +0 -31
  175. data/lib/epc/command/attach_runtime_command.rb +0 -26
  176. data/lib/epc/command/bind_service_command.rb +0 -35
  177. data/lib/epc/command/create_dependency_command.rb +0 -43
  178. data/lib/epc/command/dependency/delete_dependency_command.rb +0 -38
  179. data/lib/epc/command/detach_library_command.rb +0 -35
  180. data/lib/epc/command/detach_libraryset_command.rb +0 -8
  181. data/lib/epc/command/list_versions_command.rb +0 -38
  182. data/lib/epc/command/submit_deployment_command.rb +0 -19
  183. data/lib/epc/command/unbind_service_command.rb +0 -42
  184. data/lib/epc/command/undefine_service_command.rb +0 -33
  185. data/lib/epc/command/update_rolepermissions_command.rb +0 -83
  186. data/lib/epc/command/vote_deployment_command.rb +0 -29
  187. data/test/command/attach_library_command_test.rb +0 -124
  188. data/test/command/attach_libraryset_command_test.rb +0 -49
  189. data/test/command/attach_runtime_command_test.rb +0 -44
  190. data/test/command/bind_service_command_test.rb +0 -46
  191. data/test/command/create_dependency_command_test.rb +0 -55
  192. data/test/command/create_plugin_command_test.rb +0 -44
  193. data/test/command/delete_dependency_command_test.rb +0 -42
  194. data/test/command/detach_library_command_test.rb +0 -53
  195. data/test/command/unbind_service_command_test.rb +0 -48
  196. data/test/command/undefine_service_command_test.rb +0 -49
@@ -1,24 +1,26 @@
1
1
  module EPC::Command
2
2
  class UpdateGroupCommand < BaseCommand
3
3
 
4
- required_options :add_user, :remove_user, :mode => :any?, :message => "You must specify a user/group/grant to added or removed"
4
+ required_options :add_user, :remove_user, :mode => :any?, :message => "You must specify a user to added or removed"
5
5
 
6
- def execute(group = nil, *args)
7
-
8
- group_id = retrieve_identifier_for("UserGroup", group)
6
+ def execute(args)
9
7
 
10
8
  failures = []
11
9
  if @options[:add_user].present?
12
- status, response, headers = client.put(EPC::Config::GROUPS_PATH + "/#{group_id}/add_user", {:user_id => @options[:add_user]})
10
+ user_id = retrieve_identifier_for("User", @options[:add_user])
11
+ raise FatalError, "User not found" if user_id.blank?
12
+ status, response, headers = client.put(EPC::Config::GROUPS_PATH + "/#{object_id}/add_user", {:user_id => user_id})
13
13
  say("User added to group") if status.successful?
14
14
  end
15
15
 
16
16
  if @options[:remove_user].present?
17
- status, response, headers = client.put(EPC::Config::GROUPS_PATH + "/#{group_id}/remove_user", {:user_id => @options[:remove_user]})
17
+ user_id = retrieve_identifier_for("User", @options[:remove_user])
18
+ raise FatalError, "User not found" if user_id.blank?
19
+ status, response, headers = client.put(EPC::Config::GROUPS_PATH + "/#{object_id}/remove_user", {:user_id => user_id})
18
20
  say("User removed from group") if status.successful?
19
21
  end
20
22
 
21
- say("Request failed: [#{response[:message]}]") if status.failure?
23
+ say("Request failed: [#{response[:message]}]") unless status.successful?
22
24
  return status
23
25
  end
24
26
 
@@ -1,7 +1,7 @@
1
1
  module EPC::Command
2
2
  class CreateLibraryCommand < BaseCommand
3
3
 
4
- def execute(target = nil, *args)
4
+ def execute(args = [])
5
5
 
6
6
  raise FatalError, "Parameters incorrectly specified" if args.size < 3
7
7
 
@@ -9,7 +9,6 @@ module EPC::Command
9
9
  params[:name] = args[0]
10
10
 
11
11
  params[:language_id] = retrieve_identifier_for("LibraryLanguage", args[1])
12
-
13
12
 
14
13
  raise InputError, "Unable to determine library language" if params[:language_id].nil? || params[:language_id] == 0
15
14
 
@@ -1,16 +1,15 @@
1
1
  module EPC::Command
2
2
  class DeleteLibraryCommand < BaseCommand
3
3
 
4
- def execute(library = nil, *args)
4
+ def execute(args)
5
+ require_object
5
6
 
6
- proceed = ask_yn("Are you sure you want to delete the [#{library}] library? [Yn] ")
7
+ proceed = ask_yn("Are you sure you want to delete the [#{object_id}] library? [Yn] ")
7
8
  if proceed.upcase == 'N'
8
9
  return 1
9
10
  end
10
11
 
11
- library_id = retrieve_identifier_for("Library", library.split(":"))
12
-
13
- status, response, headers = client.delete(EPC::Config::LIBRARIES_PATH + "/#{library_id}")
12
+ status, response, headers = client.delete(EPC::Config::LIBRARIES_PATH + "/#{object_id}")
14
13
  if status.successful?
15
14
  say("Library deleted")
16
15
  else
@@ -1,7 +1,7 @@
1
1
  module EPC::Command
2
2
  class ListLibrariesCommand < BaseCommand
3
3
 
4
- def execute(target = nil, *args)
4
+ def execute(args = [])
5
5
  status, response, headers = client.get(EPC::Config::LIBRARIES_PATH)
6
6
 
7
7
  if status.failure?
@@ -1,7 +1,7 @@
1
1
  module EPC::Command
2
2
  class CreateLibrarylanguageCommand < BaseCommand
3
3
 
4
- def execute(target = nil, *names)
4
+ def execute(names = [])
5
5
 
6
6
  raise FatalError, "You need to specify a name for the language" if names.blank?
7
7
 
@@ -1,15 +1,13 @@
1
1
  module EPC::Command
2
2
  class DeleteLibrarylanguageCommand < DeleteCommand
3
3
 
4
- def execute(language = nil, *args)
5
- proceed = ask_yn("Are you sure you want to delete the [#{language}] language? [Yn] ")
4
+ def execute(args = [])
5
+ proceed = ask_yn("Are you sure you want to delete the [#{object_id}] language? [Yn] ")
6
6
  if proceed.upcase == "N"
7
7
  return 1
8
8
  end
9
9
 
10
- language_id = retrieve_identifier_for("LibraryLanguage", language)
11
-
12
- status, response, headers = client.delete(EPC::Config::LIBRARY_LANGUAGES_PATH + "/#{language_id}")
10
+ status, response, headers = client.delete(EPC::Config::LIBRARY_LANGUAGES_PATH + "/#{object_id}")
13
11
 
14
12
  if status.successful?
15
13
  say("Language deleted")
@@ -1,7 +1,7 @@
1
1
  module EPC::Command
2
2
  class ListLibrarylanguagesCommand < BaseCommand
3
3
 
4
- def execute(target = nil)
4
+ def execute(args = [])
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,15 +1,14 @@
1
1
  module EPC::Command
2
- class UpdateLibrarylanguageCommand < BaseCommand
2
+ class UpdateLibrarylanguageCommand < UpdateCommand
3
3
 
4
- def execute(language = nil, *args)
4
+ def execute(args = [])
5
+ require_object
5
6
 
6
7
  new_name = args[0] rescue nil
7
8
 
8
9
  raise FatalError, "You need to specify the new library language name" if new_name.blank?
9
10
 
10
- language_id = retrieve_identifier_for("LibraryLanguage", language)
11
-
12
- status, response, headers = client.put(EPC::Config::LIBRARY_LANGUAGES_PATH + "/#{language_id}", :name => new_name )
11
+ status, response, headers = client.put(EPC::Config::LIBRARY_LANGUAGES_PATH + "/#{object_id}", :name => new_name )
13
12
 
14
13
  if status.successful?
15
14
  say("Language updated")
@@ -1,13 +1,12 @@
1
1
  module EPC::Command
2
2
  class CreateLibrarysetCommand < BaseCommand
3
3
 
4
- def execute(*params)
4
+ def execute(params = [])
5
5
 
6
- set = params[1]
7
- language = params[2]
6
+ set = params[0]
7
+ language = params[1]
8
8
 
9
9
  raise FatalError, "You need to specify a name for the set" if set.blank?
10
-
11
10
  raise FatalError, "You need to specify a language" if language.blank?
12
11
 
13
12
  params = {}
@@ -15,6 +14,8 @@ module EPC::Command
15
14
 
16
15
  params[:language_id] = retrieve_identifier_for("LibraryLanguage", language)
17
16
 
17
+ raise InputError, "Request failed: Language [#{language}] not found" if params[:language_id].blank? && @options[:file].blank?
18
+
18
19
  status, response, headers = client.post(EPC::Config::LIBRARY_SETS_PATH, params)
19
20
  if status.successful?
20
21
  say("Set [#{set}] created")
@@ -1,15 +1,13 @@
1
1
  module EPC::Command
2
- class DeleteLibrarysetCommand < BaseCommand
2
+ class DeleteLibrarysetCommand < DeleteCommand
3
3
 
4
- def execute(set = nil, *args)
5
- proceed = ask_yn("Are you sure you want to delete the [#{set}] set? [Yn] ")
4
+ def execute(args = [])
5
+ proceed = ask_yn("Are you sure you want to delete the [#{object_id}] set? [Yn] ")
6
6
  if proceed.upcase == "N"
7
7
  return 1
8
8
  end
9
9
 
10
- set_id = retrieve_identifier_for("LibrarySet", set)
11
-
12
- status, response, headers = client.delete(EPC::Config::LIBRARY_SETS_PATH + "/#{set_id}")
10
+ status, response, headers = client.delete(EPC::Config::LIBRARY_SETS_PATH + "/#{object_id}")
13
11
 
14
12
  if status.successful?
15
13
  say("Set deleted")
@@ -1,8 +1,8 @@
1
1
  require 'time'
2
2
  module EPC::Command
3
- class ListLibrarysetsCommand < BaseCommand
3
+ class ListLibrarysetsCommand < ListCommand
4
4
 
5
- def execute(target = nil)
5
+ def execute(args = [])
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,10 +2,10 @@ require 'time'
2
2
  module EPC::Command
3
3
  class ShowLibrarysetCommand < BaseCommand
4
4
 
5
- def execute(library_set = nil, *args)
6
- library_set_id = retrieve_identifier_for("LibrarySet", library_set)
5
+ def execute(args = [])
6
+ require_object
7
7
 
8
- status, response, headers = client.get(EPC::Config::LIBRARY_SETS_PATH + "/#{library_set_id}")
8
+ status, response, headers = client.get(EPC::Config::LIBRARY_SETS_PATH + "/#{object_id}")
9
9
 
10
10
  if status.failure?
11
11
  say("Request failed: [#{response[:message]}]")
@@ -3,9 +3,10 @@ module EPC::Command
3
3
 
4
4
  required_options :add_library, :remove_library, :mode => :any?, :message => "You must specify a library to added or removed"
5
5
 
6
- def execute(set = nil, *args)
6
+ def execute(args)
7
+ require_object
7
8
 
8
- set_id = retrieve_identifier_for("LibrarySet", set)
9
+ set_id = object_id
9
10
 
10
11
  if @options[:add_library].present?
11
12
  lib = @options[:add_library]
@@ -24,7 +25,7 @@ module EPC::Command
24
25
  lib = @options[:remove_library]
25
26
  lib_id = extract_library_id(lib)
26
27
 
27
- status, response, headers = client.post(EPC::Config::LIBRARY_SETS_PATH + "/#{set_id}/detach_library/#{lib_id}")
28
+ status, response, headers = client.delete(EPC::Config::LIBRARY_SETS_PATH + "/#{set_id}/detach_library/#{lib_id}")
28
29
  if status.successful?
29
30
  say("Library [#{lib}] removed from set")
30
31
  else
@@ -1,21 +1,17 @@
1
1
  module EPC::Command
2
2
  class ListCommand < BaseCommand
3
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
4
+ def execute(*args)
5
+ raise FatalError, "You need to specify the object for the command" if args.blank?
6
+ params = resolve_context(args, {:skip_object_resolution => Proc.new{|type, id| type.downcase == "versions"}})
7
+ raise FatalError, "Object type cound not be determined" if @object_type.blank?
8
+ @klass_name = "EPC::Command::List#{@object_type.to_s.gsub("-","").capitalize}Command"
9
+ command = eval(@klass_name)
10
+ command.include_module("config") if object_type.downcase == "configs"
11
+ command = command.new(client, @options)
12
+ command.context_params = context_params
13
+ command.execute(params)
12
14
 
13
- def pluralize(string)
14
- case string.downcase
15
- when "library"
16
- return "Libraries"
17
- end
18
- return string + "s"
19
15
  end
20
16
 
21
17
  end
@@ -1,6 +1,6 @@
1
1
  module EPC::Command
2
2
  class ListObjecttypesCommand < BaseCommand
3
- def execute
3
+ def execute(args = [])
4
4
  status, response, headers = client.get(EPC::Config::OBJECT_TYPES_PATH)
5
5
 
6
6
  if status.failure?
@@ -1,12 +1,11 @@
1
1
  module EPC::Command
2
2
  class CreateObjectroleCommand < BaseCommand
3
- def execute(*params)
4
- obj_type, obj_id = params[0].split(":") rescue [nil, nil]
5
- name = params[1]
3
+ def execute(args = [])
4
+ name = args[0]
6
5
 
7
- raise FatalError, "Parameters incorrectly specified" if obj_type.blank? || obj_id.blank? || name.blank?
6
+ raise FatalError, "Name is required" if name.blank?
8
7
 
9
- status, response, headers = client.post(EPC::Config::ROLES_PATH, {:name => name, :owner_type => obj_type, :owner_id => obj_id})
8
+ status, response, headers = client.post(EPC::Config::ROLES_PATH, {:name => name, :owner_type => target_type, :owner_id => target_id})
10
9
 
11
10
  if status.successful?
12
11
  say("Role [#{name}] created")
@@ -1,15 +1,10 @@
1
1
  module EPC::Command
2
2
  class ListObjectrolesCommand < BaseCommand
3
3
 
4
- def execute(target = nil)
5
-
6
- raise FatalError, "You must specify an TargetType and TargetId" if target.blank?
7
-
8
- obj_type, obj_id = target.split(":")
9
-
10
- raise FatalError, "Parameters specified incorrectly" if obj_type.blank? || obj_id.blank?
4
+ def execute(args = [])
5
+ require_target
11
6
 
12
- status, response, headers = client.get(EPC::Config::ROLES_PATH + "/for_object/#{obj_type}/#{obj_id}")
7
+ status, response, headers = client.get(EPC::Config::ROLES_PATH + "/for_object/#{target_type}/#{target_id}")
13
8
 
14
9
  if status.successful?
15
10
  roles_table = EPC::TabularOutputter.new(response, [:id, :name])
@@ -4,9 +4,11 @@ module EPC::Command
4
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
5
 
6
6
  def execute(role = nil, *args)
7
- role_id = retrieve_identifier_for("Role", role.split("."))
7
+ role_id = retrieve_identifier_for("Role", object_id.split(":"))
8
8
 
9
9
  cmd = UpdateRoleCommand.new(client, @options)
10
+ cmd.object_id = role_id
11
+ cmd.object_type = "Role"
10
12
  return cmd.execute(role_id)
11
13
 
12
14
  end
@@ -1,6 +1,6 @@
1
1
  module EPC::Command
2
2
  class ListPermissionsCommand < BaseCommand
3
- def execute(*args)
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(*args)
4
+ def execute(args = [])
5
5
 
6
6
  status, response, headers = client.get(EPC::Config::PERMISSIONS_PATH)
7
7
 
@@ -1,9 +1,8 @@
1
1
  module EPC::Command
2
2
  class CreatePluginCommand < CreateCommand
3
3
 
4
- def execute(*args)
4
+ def execute(args = [])
5
5
  keys = [:name, :plugin_version, :group]
6
- args = args[1..3] rescue nil
7
6
 
8
7
  raise FatalError, "You need to specify the name, version and group for the plugin" if args.size < 3
9
8
  params = {}
@@ -1,16 +1,14 @@
1
1
  module EPC::Command
2
- class DeletePluginCommand < UpdateCommand
2
+ class DeletePluginCommand < DeleteCommand
3
3
 
4
- def execute(plugin = nil, *args)
4
+ def execute(argss = [])
5
5
 
6
- proceed = ask_yn("Are you sure you want to delete the [#{plugin}] plugin? [Yn] ")
6
+ proceed = ask_yn("Are you sure you want to delete the [#{object_id}] plugin? [Yn] ")
7
7
  if proceed.upcase == 'N'
8
8
  return 1
9
9
  end
10
10
 
11
- plugin_id = retrieve_identifier_for("Plugin", plugin)
12
-
13
- status, response, headers = client.delete(EPC::Config::PLUGINS_PATH + "/#{plugin_id}")
11
+ status, response, headers = client.delete(EPC::Config::PLUGINS_PATH + "/#{object_id}")
14
12
 
15
13
  if status.successful?
16
14
  say("Plugin deleted")
@@ -1,7 +1,7 @@
1
1
  module EPC::Command
2
2
  class ListPluginsCommand < BaseCommand
3
3
 
4
- def execute(*args)
4
+ def execute(args)
5
5
 
6
6
 
7
7
  status, response, headers = client.get(EPC::Config::PLUGINS_PATH)
@@ -1,12 +1,9 @@
1
1
  module EPC::Command
2
2
  class ShowPluginCommand < ShowCommand
3
3
 
4
- def execute(plugin = nil, *args)
4
+ def execute(args = [])
5
5
 
6
- plugin_id = retrieve_identifier_for("Plugin", plugin.split(":"))
7
-
8
-
9
- status, response, headers = client.get(EPC::Config::PLUGINS_PATH + "/#{plugin_id}")
6
+ status, response, headers = client.get(EPC::Config::PLUGINS_PATH + "/#{object_id}")
10
7
 
11
8
  if status.successful?
12
9
  plugin_table = EPC::TabularOutputter.new([response], [:id, :name, :plugin_version, :group, :inherited, :extensions])
@@ -2,11 +2,7 @@ module EPC::Command
2
2
  class UpdatePluginCommand < UpdateCommand
3
3
  UPDATABLE_ATTRIBUTES = ["name", "plugin_version", "group", "inherited", "extensions", "executions", "configuration"]
4
4
 
5
- def execute(plugin = nil, *args)
6
-
7
- plugin_id = retrieve_identifier_for("Plugin", plugin)
8
-
9
- args = args[1..3] rescue nil
5
+ def execute(args)
10
6
 
11
7
  raise FatalError, "You need to specify at least one attribute to update" if args.size < 1
12
8
  params = {}
@@ -27,7 +23,7 @@ module EPC::Command
27
23
 
28
24
  raise InputError, "You need to specify at least one attribute to update" if params.blank?
29
25
 
30
- status, response, headers = client.put(EPC::Config::PLUGINS_PATH + "/#{plugin_id}", params)
26
+ status, response, headers = client.put(EPC::Config::PLUGINS_PATH + "/#{object_id}", params)
31
27
 
32
28
  if status.successful?
33
29
  say("Plugin updated")
@@ -1,18 +1,10 @@
1
1
  module EPC::Command
2
2
  class ArchiveProjectCommand < ArchiveCommand
3
3
 
4
- def execute(project = nil)
5
- path = "."
6
- path = File.expand_path(path)
4
+ def execute(args = [])
5
+ require_object
7
6
 
8
- solution_name, project_name = project.split(":") rescue [nil, nil]
9
-
10
- solution_id, solution_name = infer_solution_context(solution_name, path, {:get_solution_name => true})
11
- project_id, project_name = infer_project_context(project_name, path, solution_id, {:get_project_name => true})
12
-
13
- raise FatalError, "Project could not be inferred" if project_id.nil?
14
-
15
- status, response, message = client.put(EPC::Config::PROJECTS_PATH + "/#{project_id}", {:archived => true})
7
+ status, response, message = client.put(EPC::Config::PROJECTS_PATH + "/#{object_id}", {:archived => true})
16
8
  if status.successful?
17
9
  say("Project has been archived.")
18
10
  else
@@ -22,4 +14,3 @@ module EPC::Command
22
14
  end
23
15
  end
24
16
  end
25
-