epc 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -0,0 +1,34 @@
1
+ module EPC::Command
2
+ class CreateRuntimeCommand < CreateCommand
3
+
4
+ def execute(args = [])
5
+ require_target
6
+
7
+ raise FatalError, "You need to specify all mandatory parameters" if args.size < 5
8
+
9
+ params = {}
10
+ params[:name] = args[0]
11
+ params[:target] = args[1]
12
+ params[:runtime_env_type_id] = target_id
13
+ params[:deployment_stage_id] = retrieve_identifier_for("DeploymentStage", args[2])
14
+ params[:username] = args[3]
15
+ params[:password] = args[4]
16
+ params[:info] = @options[:info] if @options[:info].present?
17
+ params[:agility_topology_id] = @options[:agility_topology] if @options[:agility_topology].present?
18
+ params[:agility_environment_id] = @options[:agility_environment] if @options[:agility_environment].present?
19
+
20
+ status, response, headers = client.post(EPC::Config::RUNTIMES_PATH, params)
21
+
22
+ if status.successful?
23
+ say("Runtime [#{args[0]}] created")
24
+ else
25
+ say("Request failed: [#{response[:message]}]")
26
+ end
27
+
28
+ return status
29
+
30
+ end
31
+
32
+ end
33
+
34
+ end
@@ -0,0 +1,24 @@
1
+ module EPC::Command
2
+ class DeleteRuntimeCommand < DeleteCommand
3
+
4
+ def execute(args)
5
+
6
+ proceed = ask_yn("Are you sure you want to delete the [#{object_id}] runtime? [Yn] ")
7
+ if proceed.upcase == 'N'
8
+ return 1
9
+ end
10
+
11
+ status, response, headers = client.delete(EPC::Config::RUNTIMES_PATH + "/#{object_id}")
12
+
13
+ if status.successful?
14
+ say("Runtime deleted")
15
+ else
16
+ say("Request failed: [#{response[:message]}]")
17
+ end
18
+
19
+ return status
20
+
21
+ end
22
+
23
+ end
24
+ end
@@ -1,10 +1,10 @@
1
1
  module EPC::Command
2
2
  class ListRuntimesCommand < BaseCommand
3
3
 
4
- def execute(*args)
4
+ def execute(args = [])
5
5
  status, response, headers = client.get(EPC::Config::RUNTIMES_PATH)
6
6
  if status.failure?
7
- say("Request failed with: [#{response['message']}]")
7
+ say("Request failed with: [#{response[:message]}]")
8
8
  else
9
9
  runtime_envs_table = EPC::TabularOutputter.new(response, [:id, :name])
10
10
  say(runtime_envs_table.print)
@@ -0,0 +1,49 @@
1
+ module EPC::Command
2
+ class UpdateRuntimeCommand < UpdateCommand
3
+
4
+ UPDATABLE_ATTRIBUTES = ["name", "target", "deployment_stage", "username", "password", "agility_topology", "agility_environment", "runtime_env_type_id", "info"]
5
+
6
+ def execute(args)
7
+
8
+ raise FatalError, "You need to specify at least one attribute to update" if args.size < 1
9
+ params = {}
10
+
11
+ args.each do |arg|
12
+ key, val = arg.split("=")
13
+ next if key.blank?
14
+ params[key] = val
15
+ end
16
+
17
+ params.each do |attr, val|
18
+ unless UPDATABLE_ATTRIBUTES.include?(attr)
19
+ params.delete(attr)
20
+ say("Cannot update #{attr}. Updatable attributes are: [#{UPDATABLE_ATTRIBUTES.join(', ')}]")
21
+ next
22
+ end
23
+ end
24
+
25
+ raise InputError, "You need to specify at least one attribute to update" if params.blank?
26
+
27
+ status, response, headers = client.get(EPC::Config::RUNTIMES_PATH + "/#{object_id}")
28
+
29
+ unless status.successful?
30
+ say("Request failed: [#{response[:message]}]")
31
+ return 1
32
+ end
33
+
34
+ runtime_attrs = response.merge(params.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo})
35
+
36
+ status, response, headers = client.put(EPC::Config::RUNTIMES_PATH + "/#{object_id}", runtime_attrs)
37
+
38
+ if status.successful?
39
+ say("Plugin updated")
40
+ else
41
+ say("Request failed: [#{response[:message]}]")
42
+ end
43
+
44
+ return status
45
+
46
+ end
47
+
48
+ end
49
+ end
@@ -0,0 +1,17 @@
1
+ module EPC::Command
2
+ class ListRuntimetypesCommand < ListCommand
3
+ def execute(args = [])
4
+ status, response, headers = client.get(EPC::Config::RUNTIMES_PATH + "_types")
5
+
6
+ if status.successful?
7
+ types_table = EPC::TabularOutputter.new(response, [:id, :name])
8
+ say(types_table.print)
9
+ else
10
+ say("Request failed: [#{response[:message]}]")
11
+ end
12
+
13
+ return status
14
+
15
+ end
16
+ end
17
+ end
@@ -1,16 +1,15 @@
1
1
  module EPC::Command
2
2
  class CreateServicedefinitionCommand < BaseCommand
3
3
 
4
- def execute(target, *args)
4
+ def execute(args = [])
5
5
 
6
- service_name = args.first
7
- service_type = args[1]
6
+ require_target
8
7
 
9
- raise FatalError, "You must specify both the service definition name and service type" if service_name.blank? || service_type.blank?
8
+ service_name = args.first
10
9
 
11
- service_type_id = retrieve_identifier_for("ServiceType", service_type)
10
+ raise FatalError, "You must specify the name of the service definition" if service_name.blank?
12
11
 
13
- status, response, headers = client.post(EPC::Config::SERVICE_DEFINITIONS_PATH, {:name => service_name, :type_id => service_type_id})
12
+ status, response, headers = client.post(EPC::Config::SERVICE_DEFINITIONS_PATH, {:name => service_name, :type_id => target_id})
14
13
  if status.failure?
15
14
  say("Service definition failed with: [#{response[:message]}]")
16
15
  else
@@ -0,0 +1,18 @@
1
+ module EPC::Command
2
+ class DeleteServicedefinitionCommand < BaseCommand
3
+
4
+ def execute(args = [])
5
+ require_object
6
+
7
+ status, response, headers = client.delete(EPC::Config::SERVICE_DEFINITIONS_PATH + "/#{object_id}")
8
+
9
+ if status.successful?
10
+ say("Service definition deleted")
11
+ else
12
+ say("Request failed: [#{response[:message]}]")
13
+ end
14
+
15
+ return status
16
+ end
17
+ end
18
+ end
@@ -1,13 +1,13 @@
1
1
  module EPC::Command
2
2
  class ListServicedefinitionsCommand < BaseCommand
3
3
 
4
- def execute(*args)
4
+ def execute(args = [])
5
5
 
6
6
  status, response, headers = client.get(EPC::Config::SERVICE_DEFINITIONS_PATH)
7
7
  if status.failure?
8
8
  say("Request failed with: [#{response['message']}]")
9
9
  elsif response.empty?
10
- say("No service definitions found. You can define one with #{EPC::Help::COMMAND_USAGES[:define_service]}")
10
+ say("No service definitions found. You can create one with #{EPC::Help::COMMAND_USAGES[:create_servicedefinition]}")
11
11
  else
12
12
  response.each { |resp| resp[:definition_type] = resp[:service_type][:name] }
13
13
  definitions_table = EPC::TabularOutputter.new(response, [:id, :name, :definition_type])
@@ -1,7 +1,7 @@
1
1
  module EPC::Command
2
2
  class ListServicetypesCommand < BaseCommand
3
3
 
4
- def execute(*args)
4
+ def execute(args = [])
5
5
  status, response, headers = client.get(EPC::Config::SERVICE_TYPES_PATH)
6
6
 
7
7
  if status.failure?
@@ -1,24 +1,20 @@
1
1
  module EPC::Command
2
- class CreateServiceversionCommand < BaseCommand
2
+ class CreateServiceversionCommand < CreateCommand
3
3
 
4
- def execute(*params)
5
- label = params[1]
6
- definition = params[2]
4
+ def execute(args = [])
5
+ label = args[0]
7
6
 
8
- raise FatalError, "Label and definition identifier are both required." if label.nil? || definition.nil?
7
+ require_target
9
8
 
10
- if numeric?(definition)
11
- definition_id = definition.to_i
12
- else
13
- definition_id = get_resource_id(EPC::Config::SERVICE_DEFINITIONS_PATH, "name", definition)
14
- end
9
+ raise FatalError, "You need to specify the label for this service definition" if label.blank?
15
10
 
16
- raise InputError, "Service definition not found" if definition_id.nil?
11
+ @options[:backwards_compatible] = "false" if @options[:backwards_compatible].blank?
12
+ @options[:reversible] = "false" if @options[:reversible].blank?
17
13
 
18
14
  up_script = read_file(@options[:up_script]) unless blank?(@options[:up_script])
19
15
  down_script = read_file(@options[:down_script]) unless blank?(@options[:down_script])
20
16
 
21
- status, response, headers = client.post(EPC::Config::SERVICE_VERSIONS_PATH, {:label => label, :definition_id => definition_id, :up_script => up_script, :down_script => down_script})
17
+ status, response, headers = client.post(EPC::Config::SERVICE_VERSIONS_PATH, {:label => label, :service_definition_id => target_id, :up_script => up_script, :down_script => down_script, :backwards_compatible => @options[:backwards_compatible], :reversible => @options[:reversible]})
22
18
 
23
19
  if status.successful?
24
20
  say("Service version successfully created.")
@@ -1,16 +1,14 @@
1
1
  module EPC::Command
2
2
  class DeleteServiceversionCommand < DeleteCommand
3
3
 
4
- def execute(service_version = nil, *args)
4
+ def execute(args = [])
5
5
 
6
- proceed = ask_yn("Are you sure you want to delete the [#{service_version}] service_version. Correct? [Yn] ")
6
+ proceed = ask_yn("Are you sure you want to delete the [#{object_id}] service_version. Correct? [Yn] ")
7
7
  if proceed.upcase == 'N'
8
8
  return 1
9
9
  end
10
-
11
- service_version_id = retrieve_identifier_for("ServiceVersion", (service_version.split(":") rescue service_version))
12
10
 
13
- status, response, headers = client.delete(EPC::Config::SERVICE_VERSIONS_PATH + "/#{service_version_id}")
11
+ status, response, headers = client.delete(EPC::Config::SERVICE_VERSIONS_PATH + "/#{object_id}")
14
12
 
15
13
  if status.successful?
16
14
  say("Service version deleted.")
@@ -1,7 +1,7 @@
1
1
  module EPC::Command
2
2
  class ListServiceversionsCommand < BaseCommand
3
3
 
4
- def execute(target = nil)
4
+ def execute(args = [])
5
5
  status, response, headers = client.get(EPC::Config::SERVICE_VERSIONS_PATH)
6
6
 
7
7
  if status.failure?
@@ -10,6 +10,13 @@ module EPC::Command
10
10
  say("No service-versions have been defined.")
11
11
  say("You can define one with epc create service-version.")
12
12
  else
13
+ response.each do |service_version|
14
+ service_version[:service_definition_id], service_version[:service_definition_name] = if service_version[:service_definition].present?
15
+ [service_version[:service_definition][:id], service_version[:service_definition][:name]]
16
+ else
17
+ [nil, nil]
18
+ end
19
+ end
13
20
  service_versions_table = EPC::TabularOutputter.new(response, {:id => "ID", :label => "LABEL", :service_definition_id => "DEFINITION ID", :service_definition_name => "DEFINITION NAME"})
14
21
  say(service_versions_table.print)
15
22
  end
@@ -1,15 +1,14 @@
1
1
  module EPC::Command
2
2
  class ShowCommand < BaseCommand
3
3
 
4
- def execute(object = nil, *params)
5
- @object_type = object.split(":").first rescue nil
6
- @object_id = object.split(":")[1..-1].join(":") rescue nil
7
- raise FatalError, "Object incorrectly specified" if @object_type.blank?
8
- klass = "EPC::Command::Show#{@object_type.to_s.gsub("-","").capitalize}Command"
9
- params = normalize_params(params)
10
- command = eval(klass).new(client, @options)
11
- check_params
12
- command.go(@object_id, *params)
4
+ def execute(*args)
5
+ raise FatalError, "You need to specify the object for the command" if args.blank?
6
+ params = resolve_context(args)
7
+ raise FatalError, "Could not determine ObjectType" if @object_type.blank?
8
+ @klass_name = "EPC::Command::Show#{@object_type.to_s.gsub("-","").capitalize}Command"
9
+ command = eval(@klass_name).new(client, @options)
10
+ command.context_params = context_params
11
+ command.execute(params)
13
12
  end
14
13
 
15
14
  private
@@ -1,10 +1,10 @@
1
1
  module EPC::Command
2
2
  class ShowMetricsCommand < BaseCommand
3
3
 
4
- def execute(*args)
4
+ def execute(args = [])
5
5
 
6
- id = args[2]
7
- metrics = args[3]
6
+ id = args[0]
7
+ metrics = args[1]
8
8
 
9
9
  if id.nil?
10
10
  say("You must specify the target object id.")
@@ -1,15 +1,9 @@
1
1
  module EPC::Command
2
2
  class ArchiveSolutionCommand < ArchiveCommand
3
- def execute(solution_name = nil)
3
+ def execute(args = [])
4
+ require_object
4
5
 
5
- path = "."
6
- path = File.expand_path(path)
7
-
8
- solution_id, solution_name = infer_solution_context(solution_name, path, {:get_solution_name => true})
9
-
10
- raise FatalError, "Solution could not be inferred" if solution_id.nil?
11
-
12
- status, response, message = client.put(EPC::Config::SOLUTIONS_PATH + "/#{solution_id}", {:archived => true, :name => solution_name})
6
+ status, response, message = client.put(EPC::Config::SOLUTIONS_PATH + "/#{object_id}", {:archived => true})
13
7
  if status.successful?
14
8
  say("Solution has been archived.")
15
9
  else
@@ -19,4 +13,3 @@ module EPC::Command
19
13
  end
20
14
  end
21
15
  end
22
-
@@ -1,8 +1,8 @@
1
1
  module EPC::Command
2
2
  class CreateSolutionCommand < BaseCommand
3
3
 
4
- def execute(*params)
5
- name = params[1]
4
+ def execute(params)
5
+ name = params[0]
6
6
 
7
7
  begin
8
8
  status, response, headers = client.post("#{EPC::Config::SOLUTIONS_PATH}", { :name => name })
@@ -1,18 +1,14 @@
1
1
  module EPC::Command
2
2
  class DeleteSolutionCommand < DeleteCommand
3
- def execute(solution_name = nil, *args)
3
+ def execute(args = [])
4
4
  path = File.expand_path(".")
5
- solution_name = nil if solution_name.blank?
6
- solution_id, solution_name = infer_solution_context(solution_name, path, :get_solution_name => true)
7
5
 
8
- raise FatalError, "Solution could not be inferred" if solution_id.blank?
9
-
10
- proceed = ask_yn("Are you sure you want to delete [#{solution_id} - #{solution_name}]. Correct? [Yn] ")
6
+ proceed = ask_yn("Are you sure you want to delete [#{object_id}]. Correct? [Yn] ")
11
7
  if proceed.upcase == 'N'
12
8
  return 1
13
9
  end
14
10
 
15
- status, response, message = client.delete(EPC::Config::SOLUTIONS_PATH + "/#{solution_id}")
11
+ status, response, message = client.delete(EPC::Config::SOLUTIONS_PATH + "/#{object_id}")
16
12
  if status.successful?
17
13
  remove_solution_metadata(project_solution_path(path)) if EPC::Config.is_solution_dir?(path) || EPC::Config.is_project_dir?(path)
18
14
  say("Solution deleted.")
@@ -2,8 +2,15 @@ require 'time'
2
2
  module EPC::Command
3
3
  class ListSolutionsCommand < BaseCommand
4
4
 
5
- def execute(*args)
6
- status, response, headers = client.get(EPC::Config::SOLUTIONS_PATH)
5
+ def execute(args = [])
6
+ fields = [:id, :name, :build_status, :created_at, :creator_id, :creator_name]
7
+ path = if @options[:archived]
8
+ fields << :archived
9
+ "?include=archived"
10
+ else
11
+ ""
12
+ end
13
+ status, response, headers = client.get(EPC::Config::SOLUTIONS_PATH + path)
7
14
 
8
15
  if status.failure?
9
16
  say("Solutions retrieval failed with [#{response[:message]}]")
@@ -14,8 +21,9 @@ module EPC::Command
14
21
  resp[:created_at] = Time.parse(resp[:created_at]).strftime("%m/%d/%Y %I:%M%p")
15
22
  resp[:creator_id] = resp[:created_by][:id] rescue nil
16
23
  resp[:creator_name] = resp[:created_by][:name] rescue nil
24
+ resp[:archived] = ((resp[:archived].to_s == "true") ? 't' : 'f') if @options[:archived]
17
25
  end
18
- solutions_table = EPC::TabularOutputter.new(response, [:id, :name, :build_status, :created_at, :creator_id, :creator_name])
26
+ solutions_table = EPC::TabularOutputter.new(response, fields)
19
27
  say(solutions_table.print)
20
28
  end
21
29
  return status
@@ -2,14 +2,12 @@ require 'time'
2
2
  module EPC::Command
3
3
  class ShowSolutionCommand < ShowCommand
4
4
 
5
- def execute(solution_name = nil, *args)
6
- path = File.expand_path(".")
7
-
8
- solution_id, solution_name = infer_solution_context(solution_name, path, {:get_solution_name => true})
5
+ def execute(args = [])
6
+ require_object
9
7
 
10
- raise InputError, "Solution not found" if solution_id.nil?
8
+ path = File.expand_path(".")
11
9
 
12
- status, response, message = client.get(EPC::Config::SOLUTIONS_PATH + "/#{solution_id}?include=config_values,projects,deployments,deployment_configs")
10
+ status, response, message = client.get(EPC::Config::SOLUTIONS_PATH + "/#{object_id}?include=config_values,projects,deployments,deployment_configs")
13
11
  if status.failure?
14
12
  say("Request failed: [#{response[:message]}]")
15
13
  return status
@@ -1,20 +1,15 @@
1
1
  module EPC::Command
2
2
  class UnarchiveSolutionCommand < UnarchiveCommand
3
- def execute(solution_name = nil)
4
- path = "."
5
- path = File.expand_path(path)
3
+ def execute(args = [])
6
4
 
7
- solution_id, solution_name = infer_solution_context(solution_name, path, {:get_solution_name => true})
8
-
9
- raise FatalError, "Solution could not be inferred" if solution_id.nil?
10
-
11
- status, response, message = client.put(EPC::Config::SOLUTIONS_PATH + "/#{solution_id}", {:archived => false, :name => solution_name})
5
+ status, response, message = client.put(EPC::Config::SOLUTIONS_PATH + "/#{object_id}", {:archived => false})
12
6
  if status.successful?
13
7
  say("Solution has been unarchived.")
14
8
  else
15
9
  say("Solution could not be unarchived. Request failed with: [#{response[:message]}]")
16
10
  end
17
11
  return status
12
+
18
13
  end
19
14
  end
20
15
  end