epc 1.0.4 → 1.0.6

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 (194) hide show
  1. data/lib/epc.rb +3 -0
  2. data/lib/epc/client/base_client.rb +2 -1
  3. data/lib/epc/client/json_client.rb +22 -0
  4. data/lib/epc/command/archive_command.rb +1 -1
  5. data/lib/epc/command/attachto_command.rb +1 -1
  6. data/lib/epc/command/base_command.rb +35 -25
  7. data/lib/epc/command/build_command.rb +2 -2
  8. data/lib/epc/command/config/create_config_command.rb +1 -1
  9. data/lib/epc/command/config/delete_config_command.rb +4 -4
  10. data/lib/epc/command/config/list_configs_command.rb +1 -1
  11. data/lib/epc/command/config/update_config_command.rb +3 -3
  12. data/lib/epc/command/copy_command.rb +1 -1
  13. data/lib/epc/command/create_command.rb +1 -1
  14. data/lib/epc/command/delete_command.rb +2 -2
  15. data/lib/epc/command/deploy_command.rb +4 -3
  16. data/lib/epc/command/deployment/copy_deployment_command.rb +1 -1
  17. data/lib/epc/command/deployment/create_deployment_command.rb +3 -3
  18. data/lib/epc/command/deployment/list_deployments_command.rb +1 -1
  19. data/lib/epc/command/deployment/show_deployment_command.rb +1 -1
  20. data/lib/epc/command/deployment/submit_deployment_command.rb +1 -1
  21. data/lib/epc/command/deployment/update_deployment_command.rb +1 -1
  22. data/lib/epc/command/deployment/vote_deployment_command.rb +1 -1
  23. data/lib/epc/command/deploymentstage/list_deploymentstages_command.rb +1 -1
  24. data/lib/epc/command/detachfrom_command.rb +1 -1
  25. data/lib/epc/command/group/create_group_command.rb +1 -1
  26. data/lib/epc/command/group/delete_group_command.rb +1 -1
  27. data/lib/epc/command/group/list_groups_command.rb +1 -1
  28. data/lib/epc/command/group/show_group_command.rb +2 -1
  29. data/lib/epc/command/group/update_group_command.rb +1 -1
  30. data/lib/epc/command/library/create_library_command.rb +2 -2
  31. data/lib/epc/command/library/delete_library_command.rb +1 -1
  32. data/lib/epc/command/library/list_libraries_command.rb +1 -1
  33. data/lib/epc/command/librarylanguage/create_librarylanguage_command.rb +1 -1
  34. data/lib/epc/command/librarylanguage/delete_librarylanguage_command.rb +1 -1
  35. data/lib/epc/command/librarylanguage/list_librarylanguages_command.rb +1 -1
  36. data/lib/epc/command/librarylanguage/update_librarylanguage_command.rb +1 -1
  37. data/lib/epc/command/libraryset/create_libraryset_command.rb +2 -2
  38. data/lib/epc/command/libraryset/delete_libraryset_command.rb +1 -1
  39. data/lib/epc/command/libraryset/list_librarysets_command.rb +1 -1
  40. data/lib/epc/command/libraryset/show_libraryset_command.rb +1 -1
  41. data/lib/epc/command/libraryset/update_libraryset_command.rb +3 -3
  42. data/lib/epc/command/list_command.rb +1 -1
  43. data/lib/epc/command/objectrole/create_objectrole_command.rb +2 -1
  44. data/lib/epc/command/objectrole/list_objectroles_command.rb +1 -1
  45. data/lib/epc/command/objectrole/update_objectrole_command.rb +5 -1
  46. data/lib/epc/command/permission/list_permissions_command.rb +1 -1
  47. data/lib/epc/command/permissiongroup/list_permissiongroups_command.rb +1 -1
  48. data/lib/epc/command/plugin/create_plugin_command.rb +1 -1
  49. data/lib/epc/command/plugin/delete_plugin_command.rb +1 -1
  50. data/lib/epc/command/plugin/list_plugins_command.rb +1 -1
  51. data/lib/epc/command/plugin/show_plugin_command.rb +1 -1
  52. data/lib/epc/command/plugin/update_plugin_command.rb +2 -2
  53. data/lib/epc/command/project/archive_project_command.rb +1 -1
  54. data/lib/epc/command/project/attachto_project_command.rb +3 -3
  55. data/lib/epc/command/project/create_project_command.rb +2 -2
  56. data/lib/epc/command/project/delete_project_command.rb +1 -1
  57. data/lib/epc/command/project/detachfrom_project_command.rb +4 -4
  58. data/lib/epc/command/project/list_projects_command.rb +1 -1
  59. data/lib/epc/command/project/show_project_command.rb +2 -1
  60. data/lib/epc/command/project/unarchive_project_command.rb +1 -2
  61. data/lib/epc/command/project/update_project_command.rb +2 -2
  62. data/lib/epc/command/projecttype/create_projecttype_command.rb +3 -3
  63. data/lib/epc/command/projecttype/delete_projecttype_command.rb +2 -1
  64. data/lib/epc/command/projecttype/list_projecttypes_command.rb +1 -1
  65. data/lib/epc/command/projecttype/show_projecttype_command.rb +2 -1
  66. data/lib/epc/command/projecttype/update_projecttype_command.rb +4 -3
  67. data/lib/epc/command/pull_command.rb +12 -10
  68. data/lib/epc/command/push_command.rb +45 -29
  69. data/lib/epc/command/role/create_role_command.rb +1 -1
  70. data/lib/epc/command/role/delete_role_command.rb +2 -1
  71. data/lib/epc/command/role/list_roles_command.rb +2 -5
  72. data/lib/epc/command/role/show_role_command.rb +2 -2
  73. data/lib/epc/command/role/update_role_command.rb +1 -1
  74. data/lib/epc/command/runtime/create_runtime_command.rb +1 -1
  75. data/lib/epc/command/runtime/delete_runtime_command.rb +2 -1
  76. data/lib/epc/command/runtime/list_runtimes_command.rb +1 -1
  77. data/lib/epc/command/runtime/update_runtime_command.rb +4 -3
  78. data/lib/epc/command/runtimetype/list_runtimetypes_command.rb +1 -1
  79. data/lib/epc/command/servicedefinition/create_servicedefinition_command.rb +2 -2
  80. data/lib/epc/command/servicedefinition/delete_servicedefinition_command.rb +1 -1
  81. data/lib/epc/command/servicedefinition/list_servicedefinitions_command.rb +1 -1
  82. data/lib/epc/command/servicetype/list_servicetypes_command.rb +1 -1
  83. data/lib/epc/command/serviceversion/create_serviceversion_command.rb +2 -2
  84. data/lib/epc/command/serviceversion/delete_serviceversion_command.rb +3 -1
  85. data/lib/epc/command/serviceversion/list_serviceversions_command.rb +1 -1
  86. data/lib/epc/command/show_command.rb +1 -1
  87. data/lib/epc/command/solution/archive_solution_command.rb +1 -1
  88. data/lib/epc/command/solution/create_solution_command.rb +2 -2
  89. data/lib/epc/command/solution/delete_solution_command.rb +1 -1
  90. data/lib/epc/command/solution/list_solutions_command.rb +1 -1
  91. data/lib/epc/command/solution/show_solution_command.rb +1 -1
  92. data/lib/epc/command/solution/unarchive_solution_command.rb +1 -1
  93. data/lib/epc/command/solution/update_solution_command.rb +1 -1
  94. data/lib/epc/command/submit_command.rb +1 -1
  95. data/lib/epc/command/unarchive_command.rb +1 -1
  96. data/lib/epc/command/update_command.rb +1 -1
  97. data/lib/epc/command/user/create_user_command.rb +1 -1
  98. data/lib/epc/command/user/delete_user_command.rb +1 -1
  99. data/lib/epc/command/user/list_users_command.rb +1 -1
  100. data/lib/epc/command/user/show_user_command.rb +2 -1
  101. data/lib/epc/command/user/update_user_command.rb +3 -3
  102. data/lib/epc/command/userproperty/delete_user_property_command.rb +48 -0
  103. data/lib/epc/command/userproperty/get_user_property_command.rb +61 -0
  104. data/lib/epc/command/userproperty/list_user_properties_command.rb +1 -1
  105. data/lib/epc/command/userproperty/set_user_property_command.rb +52 -0
  106. data/lib/epc/command/vote_command.rb +1 -1
  107. data/lib/epc/config.rb +12 -0
  108. data/lib/epc/help.rb +20 -8
  109. data/lib/epc/runner.rb +22 -11
  110. data/lib/epc/version.rb +1 -1
  111. data/test/command/archive_project_command_test.rb +1 -1
  112. data/test/command/archive_solution_command_test.rb +1 -1
  113. data/test/command/build_command_test.rb +1 -1
  114. data/test/command/copy_deployment_command_test.rb +1 -1
  115. data/test/command/create_config_command_test.rb +1 -1
  116. data/test/command/create_deployment_command_test.rb +3 -3
  117. data/test/command/create_group_command_test.rb +1 -1
  118. data/test/command/create_library_command_test.rb +1 -1
  119. data/test/command/create_librarylanguage_command_test.rb +2 -2
  120. data/test/command/create_libraryset_command_test.rb +2 -2
  121. data/test/command/create_objectrole_command_test.rb +1 -1
  122. data/test/command/create_project_command_test.rb +2 -2
  123. data/test/command/create_projecttypes_command_test.rb +33 -0
  124. data/test/command/create_role_command_test.rb +10 -1
  125. data/test/command/create_runtime_command_test.rb +1 -1
  126. data/test/command/create_servicedefinition_command_test.rb +1 -1
  127. data/test/command/create_serviceversion_command_test.rb +1 -1
  128. data/test/command/create_solution_command_test.rb +2 -2
  129. data/test/command/create_user_command_test.rb +1 -1
  130. data/test/command/delete_config_command_test.rb +3 -3
  131. data/test/command/delete_library_command_test.rb +1 -1
  132. data/test/command/delete_librarylanguage_command_test.rb +1 -1
  133. data/test/command/delete_libraryset_command_test.rb +1 -1
  134. data/test/command/delete_plugin_command_test.rb +1 -1
  135. data/test/command/delete_project_command_test.rb +1 -1
  136. data/test/command/delete_projecttype_command_test.rb +1 -1
  137. data/test/command/delete_role_command_test.rb +1 -1
  138. data/test/command/delete_runtime_command_test.rb +1 -1
  139. data/test/command/delete_servicedefinition_command_test.rb +1 -1
  140. data/test/command/delete_serviceversion_command_test.rb +1 -1
  141. data/test/command/delete_solution_command_test.rb +1 -1
  142. data/test/command/delete_user_command_test.rb +1 -1
  143. data/test/command/delete_user_property_command_test.rb +60 -0
  144. data/test/command/deploy_command_test.rb +14 -6
  145. data/test/command/get_user_property_command_test.rb +58 -0
  146. data/test/command/list_command_test.rb +28 -0
  147. data/test/command/list_config_command_test.rb +1 -1
  148. data/test/command/list_deployments_command_test.rb +1 -1
  149. data/test/command/list_deploymentstages_command_test.rb +1 -1
  150. data/test/command/list_libraries_command_test.rb +1 -1
  151. data/test/command/list_librarylanguages_command_test.rb +1 -1
  152. data/test/command/list_librarysets_command_test.rb +1 -1
  153. data/test/command/list_objectroles_command_test.rb +1 -1
  154. data/test/command/list_permissiongroups_command_test.rb +1 -1
  155. data/test/command/list_permissions_command_test.rb +1 -1
  156. data/test/command/list_plugins_command_test.rb +1 -1
  157. data/test/command/list_projects_command_test.rb +1 -1
  158. data/test/command/list_projecttypes_command_test.rb +1 -1
  159. data/test/command/list_roles_command_test.rb +9 -1
  160. data/test/command/list_runtimes_command_test.rb +1 -1
  161. data/test/command/list_runtimetypes_command_test.rb +1 -1
  162. data/test/command/list_service_types_command_test.rb +1 -1
  163. data/test/command/list_servicedefinitions_command_test.rb +1 -1
  164. data/test/command/list_serviceversions_command_test.rb +1 -1
  165. data/test/command/list_solutions_command_test.rb +1 -1
  166. data/test/command/list_userproperties_command_test.rb +3 -3
  167. data/test/command/list_users_command_test.rb +1 -1
  168. data/test/command/pull_command_test.rb +8 -8
  169. data/test/command/push_command_test.rb +38 -8
  170. data/test/command/set_user_property_command_test.rb +50 -0
  171. data/test/command/show_command_test.rb +28 -0
  172. data/test/command/show_deployment_command_test.rb +1 -1
  173. data/test/command/show_group_command_test.rb +1 -1
  174. data/test/command/show_libraryset_command_test.rb +1 -1
  175. data/test/command/show_plugin_command_test.rb +1 -1
  176. data/test/command/show_project_command_test.rb +1 -1
  177. data/test/command/show_projecttype_command_test.rb +1 -1
  178. data/test/command/show_role_command_test.rb +1 -1
  179. data/test/command/show_solution_command_test.rb +1 -1
  180. data/test/command/show_user_command_test.rb +1 -1
  181. data/test/command/submit_deployment_command_test.rb +1 -1
  182. data/test/command/unarchive_project_command_test.rb +1 -1
  183. data/test/command/unarchive_solution_command_test.rb +1 -1
  184. data/test/command/update_config_command_test.rb +2 -2
  185. data/test/command/update_deployment_command_test.rb +1 -1
  186. data/test/command/update_group_command_test.rb +1 -1
  187. data/test/command/update_librarylanguage_command_test.rb +1 -1
  188. data/test/command/update_libraryset_command_test.rb +3 -3
  189. data/test/command/update_plugin_command_test.rb +2 -2
  190. data/test/command/update_project_command_test.rb +2 -2
  191. data/test/command/update_solution_command_test.rb +1 -1
  192. data/test/command/update_user_command_test.rb +2 -2
  193. data/test/command/vote_deployment_command_test.rb +1 -1
  194. metadata +38 -23
@@ -22,7 +22,7 @@ module EPC::Command
22
22
  if status.successful?
23
23
  say("Runtime [#{args[0]}] created")
24
24
  else
25
- say("Request failed: [#{response[:message]}]")
25
+ say_err("Request failed: [#{response[:message]}]")
26
26
  end
27
27
 
28
28
  return status
@@ -2,6 +2,7 @@ module EPC::Command
2
2
  class DeleteRuntimeCommand < DeleteCommand
3
3
 
4
4
  def execute(args)
5
+ require_object
5
6
 
6
7
  proceed = ask_yn("Are you sure you want to delete the [#{object_id}] runtime? [Yn] ")
7
8
  if proceed.upcase == 'N'
@@ -13,7 +14,7 @@ module EPC::Command
13
14
  if status.successful?
14
15
  say("Runtime deleted")
15
16
  else
16
- say("Request failed: [#{response[:message]}]")
17
+ say_err("Request failed: [#{response[:message]}]")
17
18
  end
18
19
 
19
20
  return status
@@ -4,7 +4,7 @@ module EPC::Command
4
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_err("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)
@@ -4,6 +4,7 @@ module EPC::Command
4
4
  UPDATABLE_ATTRIBUTES = ["name", "target", "deployment_stage", "username", "password", "agility_topology", "agility_environment", "runtime_env_type_id", "info"]
5
5
 
6
6
  def execute(args)
7
+ require_object
7
8
 
8
9
  raise FatalError, "You need to specify at least one attribute to update" if args.size < 1
9
10
  params = {}
@@ -17,7 +18,7 @@ module EPC::Command
17
18
  params.each do |attr, val|
18
19
  unless UPDATABLE_ATTRIBUTES.include?(attr)
19
20
  params.delete(attr)
20
- say("Cannot update #{attr}. Updatable attributes are: [#{UPDATABLE_ATTRIBUTES.join(', ')}]")
21
+ say_err("Cannot update #{attr}. Updatable attributes are: [#{UPDATABLE_ATTRIBUTES.join(', ')}]")
21
22
  next
22
23
  end
23
24
  end
@@ -27,7 +28,7 @@ module EPC::Command
27
28
  status, response, headers = client.get(EPC::Config::RUNTIMES_PATH + "/#{object_id}")
28
29
 
29
30
  unless status.successful?
30
- say("Request failed: [#{response[:message]}]")
31
+ say_err("Request failed: [#{response[:message]}]")
31
32
  return 1
32
33
  end
33
34
 
@@ -38,7 +39,7 @@ module EPC::Command
38
39
  if status.successful?
39
40
  say("Plugin updated")
40
41
  else
41
- say("Request failed: [#{response[:message]}]")
42
+ say_err("Request failed: [#{response[:message]}]")
42
43
  end
43
44
 
44
45
  return status
@@ -7,7 +7,7 @@ module EPC::Command
7
7
  types_table = EPC::TabularOutputter.new(response, [:id, :name])
8
8
  say(types_table.print)
9
9
  else
10
- say("Request failed: [#{response[:message]}]")
10
+ say_err("Request failed: [#{response[:message]}]")
11
11
  end
12
12
 
13
13
  return status
@@ -3,7 +3,7 @@ module EPC::Command
3
3
 
4
4
  def execute(args = [])
5
5
 
6
- require_target
6
+ require_target "You need to specify the ServiceType"
7
7
 
8
8
  service_name = args.first
9
9
 
@@ -11,7 +11,7 @@ module EPC::Command
11
11
 
12
12
  status, response, headers = client.post(EPC::Config::SERVICE_DEFINITIONS_PATH, {:name => service_name, :type_id => target_id})
13
13
  if status.failure?
14
- say("Service definition failed with: [#{response[:message]}]")
14
+ say_err("Service definition failed with: [#{response[:message]}]")
15
15
  else
16
16
  say("#{service_name} has been defined.")
17
17
  end
@@ -9,7 +9,7 @@ module EPC::Command
9
9
  if status.successful?
10
10
  say("Service definition deleted")
11
11
  else
12
- say("Request failed: [#{response[:message]}]")
12
+ say_err("Request failed: [#{response[:message]}]")
13
13
  end
14
14
 
15
15
  return status
@@ -5,7 +5,7 @@ module EPC::Command
5
5
 
6
6
  status, response, headers = client.get(EPC::Config::SERVICE_DEFINITIONS_PATH)
7
7
  if status.failure?
8
- say("Request failed with: [#{response['message']}]")
8
+ say_err("Request failed with: [#{response['message']}]")
9
9
  elsif response.empty?
10
10
  say("No service definitions found. You can create one with #{EPC::Help::COMMAND_USAGES[:create_servicedefinition]}")
11
11
  else
@@ -5,7 +5,7 @@ module EPC::Command
5
5
  status, response, headers = client.get(EPC::Config::SERVICE_TYPES_PATH)
6
6
 
7
7
  if status.failure?
8
- say("Service types retrieval failed with [#{response[:message]}]")
8
+ say_err("Service types retrieval failed with [#{response[:message]}]")
9
9
  elsif response.empty?
10
10
  say("There are no service types available")
11
11
  else
@@ -4,7 +4,7 @@ module EPC::Command
4
4
  def execute(args = [])
5
5
  label = args[0]
6
6
 
7
- require_target
7
+ require_target "You need to specify the ServiceDefinition"
8
8
 
9
9
  raise FatalError, "You need to specify the label for this service definition" if label.blank?
10
10
 
@@ -19,7 +19,7 @@ module EPC::Command
19
19
  if status.successful?
20
20
  say("Service version successfully created.")
21
21
  else
22
- say("Request failed: [#{response[:message]}]")
22
+ say_err("Request failed: [#{response[:message]}]")
23
23
  end
24
24
  return status
25
25
  end
@@ -3,6 +3,8 @@ module EPC::Command
3
3
 
4
4
  def execute(args = [])
5
5
 
6
+ require_object
7
+
6
8
  proceed = ask_yn("Are you sure you want to delete the [#{object_id}] service_version. Correct? [Yn] ")
7
9
  if proceed.upcase == 'N'
8
10
  return 1
@@ -13,7 +15,7 @@ module EPC::Command
13
15
  if status.successful?
14
16
  say("Service version deleted.")
15
17
  else
16
- say("Request failed: [#{response[:message]}]")
18
+ say_err("Request failed: [#{response[:message]}]")
17
19
  end
18
20
  return status
19
21
 
@@ -5,7 +5,7 @@ module EPC::Command
5
5
  status, response, headers = client.get(EPC::Config::SERVICE_VERSIONS_PATH)
6
6
 
7
7
  if status.failure?
8
- say("Request failed: [#{response[:message]}]")
8
+ say_err("Request failed: [#{response[:message]}]")
9
9
  elsif response.empty?
10
10
  say("No service-versions have been defined.")
11
11
  say("You can define one with epc create service-version.")
@@ -2,7 +2,7 @@ module EPC::Command
2
2
  class ShowCommand < BaseCommand
3
3
 
4
4
  def execute(*args)
5
- raise FatalError, "You need to specify the object for the command" if args.blank?
5
+ raise InputError, "You need to specify the object for the command" if args.blank?
6
6
  params = resolve_context(args)
7
7
  raise FatalError, "Could not determine ObjectType" if @object_type.blank?
8
8
  @klass_name = "EPC::Command::Show#{@object_type.to_s.gsub("-","").capitalize}Command"
@@ -7,7 +7,7 @@ module EPC::Command
7
7
  if status.successful?
8
8
  say("Solution has been archived.")
9
9
  else
10
- say("Solution could not be archived. Request failed with: [#{response[:message]}]")
10
+ say_err("Solution could not be archived. Request failed with: [#{response[:message]}]")
11
11
  end
12
12
  return status
13
13
  end
@@ -21,11 +21,11 @@ module EPC::Command
21
21
  end
22
22
  end
23
23
  else
24
- say("Solution creation failed [#{response[:message]}].")
24
+ say_err("Solution creation failed [#{response[:message]}].")
25
25
  end
26
26
  return status
27
27
  rescue Exception => ex
28
- say("Solution creation failed [#{ex}].")
28
+ say_err("Solution creation failed [#{ex}].")
29
29
  return 1
30
30
  end
31
31
  end
@@ -13,7 +13,7 @@ module EPC::Command
13
13
  remove_solution_metadata(project_solution_path(path)) if EPC::Config.is_solution_dir?(path) || EPC::Config.is_project_dir?(path)
14
14
  say("Solution deleted.")
15
15
  else
16
- say("Solution could not be deleted. Delete failed with: [#{response[:message]}]")
16
+ say_err("Solution could not be deleted. Delete failed with: [#{response[:message]}]")
17
17
  end
18
18
  return status
19
19
  end
@@ -13,7 +13,7 @@ module EPC::Command
13
13
  status, response, headers = client.get(EPC::Config::SOLUTIONS_PATH + path)
14
14
 
15
15
  if status.failure?
16
- say("Solutions retrieval failed with [#{response[:message]}]")
16
+ say_err("Solutions retrieval failed with [#{response[:message]}]")
17
17
  elsif response.empty?
18
18
  say("You have no solutions created. You can create them with epc create solution.")
19
19
  else
@@ -9,7 +9,7 @@ module EPC::Command
9
9
 
10
10
  status, response, message = client.get(EPC::Config::SOLUTIONS_PATH + "/#{object_id}?include=config_values,projects,deployments,deployment_configs")
11
11
  if status.failure?
12
- say("Request failed: [#{response[:message]}]")
12
+ say_err("Request failed: [#{response[:message]}]")
13
13
  return status
14
14
  end
15
15
 
@@ -6,7 +6,7 @@ module EPC::Command
6
6
  if status.successful?
7
7
  say("Solution has been unarchived.")
8
8
  else
9
- say("Solution could not be unarchived. Request failed with: [#{response[:message]}]")
9
+ say_err("Solution could not be unarchived. Request failed with: [#{response[:message]}]")
10
10
  end
11
11
  return status
12
12
 
@@ -31,7 +31,7 @@ module EPC::Command
31
31
  if args_hash.present?
32
32
  status, response, message = client.put(EPC::Config::SOLUTIONS_PATH + "/#{object_id}", args_hash)
33
33
  if status.failure?
34
- say("Update failed with: [#{response['message']}]")
34
+ say_err("Update failed with: [#{response['message']}]")
35
35
  else
36
36
  say("Update succesful")
37
37
  end
@@ -2,7 +2,7 @@ module EPC::Command
2
2
  class SubmitCommand < BaseCommand
3
3
 
4
4
  def execute(*args)
5
- raise FatalError, "You need to specify the object for the command" if args.blank?
5
+ raise InputError, "You need to specify the object for the command" if args.blank?
6
6
  params = resolve_context(args)
7
7
  @klass_name = "EPC::Command::Submit#{@object_type.to_s.gsub("-","").capitalize}Command"
8
8
  command = eval(@klass_name)
@@ -2,7 +2,7 @@ module EPC::Command
2
2
  class UnarchiveCommand < BaseCommand
3
3
 
4
4
  def execute(*args)
5
- raise FatalError, "You need to specify the object for the command" if args.blank?
5
+ raise InputError, "You need to specify the object for the command" if args.blank?
6
6
  params = resolve_context(args)
7
7
  @klass_name = "EPC::Command::Unarchive#{@object_type.to_s.gsub("-","").capitalize}Command"
8
8
  command = eval(@klass_name).new(client, @options)
@@ -2,7 +2,7 @@ module EPC::Command
2
2
  class UpdateCommand < BaseCommand
3
3
 
4
4
  def execute(*args)
5
- raise FatalError, "You need to specify the object for the command" if args.blank?
5
+ raise InputError, "You need to specify the object for the command" if args.blank?
6
6
  params = resolve_context(args, {:skip_object_resolution => Proc.new{|type, id| type.downcase == "config" || type.downcase == "objectrole"}})
7
7
  @klass_name = "EPC::Command::Update#{@object_type.to_s.gsub("-","").capitalize}Command"
8
8
  command = eval(@klass_name)
@@ -17,7 +17,7 @@ module EPC::Command
17
17
  if status.successful? && response
18
18
  say("Successfully created the user with [#{target_url}]")
19
19
  elsif response
20
- say("User creation failed [#{response[:message]}].")
20
+ say_err("User creation failed [#{response[:message]}].")
21
21
  end
22
22
  return status
23
23
 
@@ -12,7 +12,7 @@ module EPC::Command
12
12
  if status == 200
13
13
  say("User deleted")
14
14
  else
15
- say("Request failed: [#{response[:message]}]")
15
+ say_err("Request failed: [#{response[:message]}]")
16
16
  end
17
17
 
18
18
  return status
@@ -7,7 +7,7 @@ module EPC::Command
7
7
  status, response, headers = client.get(EPC::Config::USERS_PATH)
8
8
 
9
9
  if status != 200
10
- say("Request failed: [#{response[:message]}]")
10
+ say_err("Request failed: [#{response[:message]}]")
11
11
  elsif response.empty?
12
12
  say("No users defined")
13
13
  else
@@ -2,11 +2,12 @@ module EPC::Command
2
2
  class ShowUserCommand < ShowCommand
3
3
 
4
4
  def execute(args = [])
5
+ require_object
5
6
 
6
7
  status, response, headers = client.get(EPC::Config::USERS_PATH + "/#{object_id}?include=user_groups")
7
8
 
8
9
  if status != 200
9
- say("Request failed: [#{response[:message]}]")
10
+ say_err("Request failed: [#{response[:message]}]")
10
11
  return status
11
12
  end
12
13
 
@@ -3,7 +3,7 @@ module EPC::Command
3
3
 
4
4
  required_options :email, :password, :mode => :any?, :message => "You must specify the attribute to be updated: email/password"
5
5
 
6
- def execute(args)
6
+ def execute(args = [])
7
7
 
8
8
  if @options[:password].present?
9
9
  email = get_resource_attribute(EPC::Config::USERS_PATH, :email, :id, object_id.to_i)
@@ -16,7 +16,7 @@ module EPC::Command
16
16
  if status.successful?
17
17
  say("Password change successful")
18
18
  else
19
- say("Request failed: [#{response[:message]}]")
19
+ say_err("Request failed: [#{response[:message]}]")
20
20
  end
21
21
 
22
22
  return status
@@ -33,7 +33,7 @@ module EPC::Command
33
33
  if status.successful?
34
34
  say("User updated")
35
35
  else
36
- say("Request failed: [#{response[:message]}]")
36
+ say_err("Request failed: [#{response[:message]}]")
37
37
  end
38
38
 
39
39
  return status
@@ -0,0 +1,48 @@
1
+ module EPC::Command
2
+ class DeleteUserpropertyCommand < DeleteCommand
3
+
4
+ def execute(*args)
5
+ path = if @options[:all]
6
+ @entity_name = 'properties'
7
+ retrieve_user_id
8
+ @message = "all properties for User [#{@user_id}]"
9
+ "/for/User/#{@user_id}"
10
+ else
11
+ @entity_name = 'property'
12
+ if @object_id.blank?
13
+ say("User property identifier is missing.")
14
+ return 1
15
+ else
16
+ @message = "user property [#{@object_id}]"
17
+ if @object_id.to_i.to_s != @object_id.to_s
18
+ retrieve_user_id
19
+ @object_id = retrieve_identifier_for("EntityProperty", "#{@object_id}:#{@user_id}:User")
20
+ end
21
+ end
22
+ "/#{@object_id}"
23
+ end
24
+
25
+ proceed = ask_yn("Are you sure you want to delete #{@message}. Correct? [Yn] ")
26
+
27
+ if proceed.upcase == 'N'
28
+ return 1
29
+ end
30
+
31
+ status, response, message = client.delete(EPC::Config::ENTITY_PROPERTIES_PATH + path)
32
+ if status.successful?
33
+ say("User #{@entity_name} deleted.")
34
+ else
35
+ say_err("User #{@entity_name} could not be deleted. Delete failed with: [#{response[:message]}]")
36
+ end
37
+
38
+ return status
39
+ end
40
+
41
+ private
42
+
43
+ def retrieve_user_id
44
+ @user_id = retrieve_identifier_for("User", EPC::Config.username)
45
+ end
46
+
47
+ end
48
+ end
@@ -0,0 +1,61 @@
1
+ module EPC::Command
2
+ class GetUserPropertyCommand < BaseCommand
3
+ def execute(*args)
4
+ identifier = args[1] || (args[0].split(":")[1] rescue nil)
5
+
6
+ if @options[:file] && File.exists?(@options[:file])
7
+ proceed = ask_yn("File #{@options[:file]} already exists. Overwrite? [Yn]: ")
8
+ if proceed.upcase == 'N'
9
+ return 1
10
+ end
11
+ end
12
+
13
+ if identifier.blank? && !@options[:all]
14
+ say_err("User property identifier is missing.")
15
+ return 1
16
+ elsif @options[:all]
17
+ retrieve_user_id
18
+ path = EPC::Config::ENTITY_PROPERTIES_PATH + "/for/User/#{@user_id}"
19
+ elsif identifier.to_i.to_s == identifier
20
+ path = EPC::Config::ENTITY_PROPERTIES_PATH + "/#{identifier}"
21
+ else
22
+ retrieve_user_id
23
+ identifier = retrieve_identifier_for("EntityProperty", "#{identifier}:#{@user_id}:User")
24
+ path = EPC::Config::ENTITY_PROPERTIES_PATH + "/#{identifier}"
25
+ end
26
+
27
+ status, response, headers = client.get(path)
28
+
29
+ if status.failure?
30
+ say("Request failed with [#{response[:message]}]")
31
+ else
32
+ response = [response] unless response.is_a?(Array)
33
+ if @options[:file]
34
+ begin
35
+ File.open(@options[:file], "w+") do |f|
36
+ response.each do |r|
37
+ f << r.delete_if{|k,v| ![:id, :name, :value].include?(k)}.to_json
38
+ f << "\n"
39
+ end
40
+ end
41
+ say("User properties were saved to #{@options[:file]}")
42
+ rescue Exception => ex
43
+ say_err("User properties could not be saved (#{ex.to_s})")
44
+ return 1
45
+ end
46
+ else
47
+ properties_table = EPC::TabularOutputter.new(response, [:id, :name, :value])
48
+ say(properties_table.print)
49
+ end
50
+ end
51
+
52
+ return status
53
+ end
54
+
55
+ private
56
+ def retrieve_user_id
57
+ @user_id = retrieve_identifier_for("User", EPC::Config.username)
58
+ end
59
+
60
+ end
61
+ end