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
data/lib/epc.rb CHANGED
@@ -144,6 +144,9 @@ module EPC
144
144
  autoload(:UpdateProjecttypeCommand, "#{ROOT}/epc/command/projecttype/update_projecttype_command")
145
145
  autoload(:ShowProjectSnapshotCommand, "#{ROOT}/epc/command/project/show_project_snapshot_command")
146
146
  autoload(:ListUserpropertiesCommand, "#{ROOT}/epc/command/userproperty/list_user_properties_command")
147
+ autoload(:SetUserPropertyCommand, "#{ROOT}/epc/command/userproperty/set_user_property_command")
148
+ autoload(:GetUserPropertyCommand, "#{ROOT}/epc/command/userproperty/get_user_property_command")
149
+ autoload(:DeleteUserpropertyCommand, "#{ROOT}/epc/command/userproperty/delete_user_property_command")
147
150
 
148
151
 
149
152
  autoload(:CreateCommand, "#{ROOT}/epc/command/create_command")
@@ -9,7 +9,7 @@ module EPC
9
9
  class BadResponse < RuntimeError; end
10
10
  class HTTPException < RuntimeError; end
11
11
 
12
- def initialize(target_url=EPC::Config::DEFAULT_TARGET, caller_id = nil, auth_token = nil)
12
+ def initialize(target_url=EPC::Config::DEFAULT_TARGET, caller_id = nil, auth_token = nil, debug = false)
13
13
  target_url = "http://#{target_url}" unless target_url =~ /^https?/
14
14
  target_url = target_url.gsub(/\/+$/, '')
15
15
  @target = target_url
@@ -17,6 +17,7 @@ module EPC
17
17
  @caller_id = caller_id || EPC::Config.caller_id
18
18
  @auth_token = auth_token || EPC::Config.auth_token
19
19
  @digest = OpenSSL::Digest::Digest.new('sha256')
20
+ @debug = debug
20
21
  end
21
22
 
22
23
  # returns an array of status, body, response_headers
@@ -4,8 +4,10 @@ require 'json'
4
4
  module EPC::Client
5
5
  class JsonClient < HttpClient
6
6
  def get(url, skip_signature = false)
7
+ debug_request(:get, url) if @debug
7
8
  begin
8
9
  status, body, headers = super(url, 'application/json', skip_signature)
10
+ debug_response(status, json_parse(body), headers) if @debug
9
11
  [status, json_parse(body), headers]
10
12
  rescue JSON::ParserError
11
13
  raise BadResponse, "Invalid response received. Response status: #{status}", body
@@ -13,8 +15,10 @@ module EPC::Client
13
15
  end
14
16
 
15
17
  def post(url, payload = {}, skip_signature = false)
18
+ debug_request(:post, url, payload) if @debug
16
19
  begin
17
20
  status, body, headers = super(url, payload.to_json, 'application/json', {}, skip_signature)
21
+ debug_response(status, json_parse(body), headers) if @debug
18
22
  [status, json_parse(body), headers]
19
23
  rescue JSON::ParserError
20
24
  raise BadResponse, "Invalid response received. Response status: #{status}", body
@@ -22,8 +26,10 @@ module EPC::Client
22
26
  end
23
27
 
24
28
  def put(url, payload = {})
29
+ debug_request(:put, url, payload) if @debug
25
30
  begin
26
31
  status, body, headers = super(url, payload.to_json, 'application/json')
32
+ debug_response(status, json_parse(body), headers) if @debug
27
33
  [status, json_parse(body), headers]
28
34
  rescue JSON::ParserError
29
35
  raise BadResponse, "Invalid response received. Response status: #{status}", body
@@ -31,8 +37,10 @@ module EPC::Client
31
37
  end
32
38
 
33
39
  def delete(url, payload = {})
40
+ debug_request(:delete, url, payload) if @debug
34
41
  begin
35
42
  status, body, headers = super(url, payload.to_json, 'application/json')
43
+ debug_response(status, json_parse(body), headers) if @debug
36
44
  [status, json_parse(body), headers]
37
45
  rescue JSON::ParserError
38
46
  raise BadResponse, "Invalid response received. Response status: #{status}", body
@@ -41,6 +49,20 @@ module EPC::Client
41
49
 
42
50
  private
43
51
 
52
+ def debug_request(action, url, payload = nil)
53
+ say("\n## Request data")
54
+ say("\t" + action.to_s.capitalize + ": #{url}")
55
+ say("\t" + payload.to_s) if payload.present?
56
+ end
57
+
58
+ def debug_response(status, body, headers)
59
+ say("\n## Response data")
60
+ say("\tStatus: " + status.to_s)
61
+ say("\tResponse: " + body.to_s)
62
+ say("\tHeaders: " + headers.to_s)
63
+ say("\n\n")
64
+ end
65
+
44
66
  def json_parse(body)
45
67
  JSON.parse(body, :symbolize_names => true) if body
46
68
  end
@@ -2,7 +2,7 @@ module EPC::Command
2
2
  class ArchiveCommand < 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::Archive#{@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 AttachtoCommand < 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::Attachto#{@object_type.to_s.gsub("-","").capitalize}Command"
8
8
  command = eval(@klass_name).new(client, @options)
@@ -15,22 +15,7 @@ module EPC
15
15
  attr_accessor :object_id
16
16
  attr_accessor :target_type
17
17
  attr_accessor :target_id
18
- attr_accessor :klass_name
19
-
20
- @@retrieval_rules = {
21
- :Role => {
22
- :required_type => :numeric,
23
- },
24
- :User => {
25
- :required_type => :numeric,
26
- },
27
- :UserGroup => {
28
- :required_type => :numeric,
29
- },
30
- :LibrarySet => {
31
- :required_type => :numeric,
32
- }
33
- }
18
+ attr_writer :klass_name
34
19
 
35
20
  @@required_options = []
36
21
 
@@ -78,6 +63,11 @@ module EPC
78
63
  end
79
64
  end
80
65
 
66
+ def say_err(statement)
67
+ EPC::Config.say_err(statement)
68
+ end
69
+
70
+
81
71
  def check_options
82
72
  @@required_options.each do |req_opt|
83
73
  raise FatalError, req_opt[:message] unless req_opt[:name].map{|opt| @options[opt].present?}.send(req_opt[:mode])
@@ -93,6 +83,11 @@ module EPC
93
83
  @object_type, @object_id, @target_type, @target_id = params
94
84
  end
95
85
 
86
+ def klass_name
87
+ return self.class.name if @klass_name.blank?
88
+ @klass_name
89
+ end
90
+
96
91
  private
97
92
 
98
93
  def translate_status_to_exit_code(status)
@@ -148,21 +143,35 @@ module EPC
148
143
  return target_type.present? && target_id.present?
149
144
  end
150
145
 
151
- def require_object
152
- raise InputError, "#{object_type.capitalize} not found" if object_type.blank? || object_id.blank?
146
+
147
+ def has_object?
148
+ return object_type.present? && object_id.present?
153
149
  end
154
150
 
155
- def require_target
156
- raise InputError, "Target incorrectly specified" if target_type.blank? || target_id.blank?
151
+ def require_object(msg = "You need to specify the object")
152
+ if object_type.blank?
153
+ raise FatalError, msg
154
+ elsif object_id.blank?
155
+ raise InputError, "#{object_type.capitalize} not found" if object_type.blank? || object_id.blank?
156
+ end
157
+ end
158
+
159
+ def require_target(msg = "You need to specify the target")
160
+ if target_type.blank?
161
+ raise FatalError, msg
162
+ elsif target_id.blank?
163
+ raise InputError, "#{target_type.capitalize} not found"
164
+ end
157
165
  end
158
166
 
159
167
  def resolve_context(args, opts = {})
160
168
  defaults = {
161
169
  :skip_object_resolution => Proc.new{|type, id| false},
162
- :skip_target_resolution => Proc.new{|type, id| false}
170
+ :skip_target_resolution => Proc.new{|type, id| false},
171
+ :accept_no_object => false
163
172
  }.merge!(opts)
164
173
  @object_id, @object_type, args = parse_context_param(args, defaults[:skip_object_resolution])
165
- raise InputError, "Invalid command" if @object_type.blank?
174
+ raise NameError if @object_type.blank? && !defaults[:accept_no_object]
166
175
  @target_id, @target_type, args = parse_context_param(args, defaults[:skip_target_resolution])
167
176
  return args
168
177
  end
@@ -170,7 +179,7 @@ module EPC
170
179
  def parse_context_param(params, skip_proc)
171
180
  return [nil, nil, params] unless is_context_param?((params.first rescue nil))
172
181
  param = params.shift
173
- param_parts = param.split(":")
182
+ param_parts = param.split(":")
174
183
  type = param_parts[0]
175
184
  id = param_parts[1..-1].join(":")
176
185
  if skip_proc.call(type, id)
@@ -298,7 +307,8 @@ module EPC
298
307
  solution
299
308
  user
300
309
  metrics
301
- user-properties
310
+ userproperty
311
+ userproperties
302
312
  )
303
313
 
304
314
  end
@@ -307,7 +317,7 @@ module EPC
307
317
  entity = entity.to_sym
308
318
  match_value = args.join(":")
309
319
  return nil if match_value.blank?
310
- rule = @@retrieval_rules[entity.to_sym] || {:required_type => :numeric}
320
+ rule = {:required_type => :numeric}
311
321
  if rule[:required_type] == :numeric
312
322
  if numeric?(match_value)
313
323
  return match_value.to_i
@@ -58,7 +58,7 @@ module EPC::Command
58
58
  return poll_for_build_status(id)
59
59
  end
60
60
  else
61
- say("Failed to find the project ID in the EPC configuration. Aborting")
61
+ say_err("Failed to find the project ID in the EPC configuration. Aborting")
62
62
  end
63
63
  return 1
64
64
  end
@@ -75,7 +75,7 @@ module EPC::Command
75
75
  say("Successfully kicked off a build with [#{target_url}]")
76
76
  return true, response[:id]
77
77
  else
78
- say("Build kickoff failed [#{response[:message]}]. Aborting.")
78
+ say_err("Build kickoff failed [#{response[:message]}]. Aborting.")
79
79
  return false
80
80
  end
81
81
  end
@@ -43,7 +43,7 @@ module EPC::Command
43
43
  if status.successful?
44
44
  say("Configuration values saved.")
45
45
  else
46
- say("Request failed with message [#{response[:message]}]")
46
+ say_err("Request failed with message [#{response[:message]}]")
47
47
  end
48
48
  return status
49
49
  end
@@ -27,7 +27,7 @@ module EPC::Command
27
27
 
28
28
  key_id = existing_keys.detect{|k| k[:name] == key }[:id] rescue nil
29
29
  if key_id.nil?
30
- say("#{key} is not defined.")
30
+ say_err("#{key} is not defined.")
31
31
  return 1
32
32
  end
33
33
 
@@ -44,10 +44,10 @@ module EPC::Command
44
44
  end
45
45
 
46
46
  status, response, headers = client.delete(EPC::Config::CONFIGURATIONS_PATH + "/#{key_id}")
47
- if status.failure?
48
- say("Request failed: [#{response[:message]}]")
49
- else
47
+ if status.successful?
50
48
  say("#{key} succesfully removed.")
49
+ else
50
+ say_err("Request failed: [#{response[:message]}]")
51
51
  end
52
52
  return status
53
53
 
@@ -43,7 +43,7 @@ module EPC::Command
43
43
  status, response, headers = client.get(path)
44
44
  @status = status
45
45
  if status.failure?
46
- say("Configuration retrieval failed with [#{response[:message]}]")
46
+ say_err("Configuration retrieval failed with [#{response[:message]}]")
47
47
  return false
48
48
  end
49
49
 
@@ -22,7 +22,7 @@ module EPC::Command
22
22
  status, response, headers = client.get(request_path)
23
23
 
24
24
  if status.failure?
25
- say("Configuration retrieval failed with [#{response[:message]}]")
25
+ say_err("Configuration retrieval failed with [#{response[:message]}]")
26
26
  return status
27
27
  end
28
28
 
@@ -31,7 +31,7 @@ module EPC::Command
31
31
  key_id = keys.detect{|k| k[:name] == object_id}[:id] rescue nil
32
32
 
33
33
  if key_id.nil?
34
- say("Key does not exist.")
34
+ say_err("Key does not exist.")
35
35
  return 1
36
36
  end
37
37
 
@@ -49,7 +49,7 @@ module EPC::Command
49
49
  say("#{object_id} saved.")
50
50
  end
51
51
  else
52
- say("Request failed with message [#{response[:message]}]")
52
+ say_err("Request failed with message [#{response[:message]}]")
53
53
  end
54
54
  return status
55
55
  end
@@ -2,7 +2,7 @@ module EPC::Command
2
2
  class CopyCommand < 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::Copy#{@object_type.to_s.gsub("-","").capitalize}Command"
@@ -2,7 +2,7 @@ module EPC::Command
2
2
  class CreateCommand < 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::Create#{@object_type.to_s.gsub("-","").capitalize}Command"
8
8
  command = eval(@klass_name)
@@ -2,8 +2,8 @@ module EPC::Command
2
2
  class DeleteCommand < BaseCommand
3
3
 
4
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 == "config" || type.downcase == "objectrole"}})
5
+ raise InputError, "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 == "config" || type.downcase == "objectrole" || type.downcase == "userproperty"}})
7
7
  @klass_name = "EPC::Command::Delete#{@object_type.to_s.gsub("-","").capitalize}Command"
8
8
  command = eval(@klass_name)
9
9
  command.include_module(object_type)
@@ -11,7 +11,7 @@ module EPC::Command
11
11
  path = File.expand_path(path)
12
12
 
13
13
  if !( EPC::Config.is_solution_dir?(path) || EPC::Config.is_project_dir?(path)) && @options[:deployment_id].nil?
14
- say("This is not a solution directory.")
14
+ say_err("This is not a solution directory.")
15
15
  return 1
16
16
  end
17
17
 
@@ -59,7 +59,7 @@ module EPC::Command
59
59
  display_statuses(deployment_status, response[:deployed_projects])
60
60
  end
61
61
  rescue Exception => ex
62
- say("Deploy failed [#{ex.to_s}].")
62
+ say_err("Deploy failed [#{ex.to_s}].")
63
63
  return 1
64
64
  end
65
65
  return status
@@ -131,7 +131,8 @@ module EPC::Command
131
131
  def display_statuses(deployment_status, deployed_projects)
132
132
  say("\nStatus = #{deployment_status}\n")
133
133
  deployed_projects.each do |project|
134
- say("#{project[:project_name]} -> #{project[:uris].join(",")}\n")
134
+ uris = project[:uris].join(",") rescue "N/A"
135
+ say("#{project[:project_name]} -> #{uris}\n") rescue ""
135
136
  end
136
137
 
137
138
  end
@@ -10,7 +10,7 @@ module EPC::Command
10
10
  status, response, headers = client.post(EPC::Config::DEPLOYMENTS_PATH + "/#{object_id}/copy", {:stage_name => stage})
11
11
 
12
12
  if status.failure?
13
- say("Request failed: [#{response[:message]}]")
13
+ say_err("Request failed: [#{response[:message]}]")
14
14
  else
15
15
  say("Copied new deployment to the #{stage} stage. ID: #{response[:id]}")
16
16
  end
@@ -24,7 +24,7 @@ module EPC::Command
24
24
  status, @id = create_deployment(solution_name, stage_name, versions, instances, memory)
25
25
  return status
26
26
  rescue Exception => ex
27
- say("Create deployment failed [Exception Caught (#{ex.class.name}): #{ex.to_s}].")
27
+ say_err("Create deployment failed [Exception Caught (#{ex.class.name}): #{ex.to_s}].")
28
28
  return 1
29
29
  end
30
30
 
@@ -32,7 +32,7 @@ module EPC::Command
32
32
  if @options[:replaces].present?
33
33
  status, response, headers = client.put(EPC::Config::DEPLOYMENTS_PATH + "/#{@id}", {:stage_name => "no_change", :replaces_id => @options[:replaces], :versions => "no_change"})
34
34
  if status.failure?
35
- say("Replacement request failed: [#{response[:message]}]")
35
+ say_err("Replacement request failed: [#{response[:message]}]")
36
36
  else
37
37
  say("Replacement request successful")
38
38
  end
@@ -58,7 +58,7 @@ module EPC::Command
58
58
  say("Successfully created deployment [#{response[:id]}] with [#{target_url}]")
59
59
  return status, response[:id]
60
60
  else
61
- say("Deployment creation failed [#{response[:message]}]. Aborting.")
61
+ say_err("Deployment creation failed [#{response[:message]}]. Aborting.")
62
62
  return status, nil
63
63
  end
64
64
  end
@@ -26,7 +26,7 @@ module EPC::Command
26
26
  status, response, headers = client.get(url)
27
27
 
28
28
  if status.failure?
29
- say("Deployments retrieval failed with [#{response[:message]}]")
29
+ say_err("Deployments retrieval failed with [#{response[:message]}]")
30
30
  elsif response.empty?
31
31
  say("You have no deployments created. You can create them with epc create deployment.")
32
32
  else
@@ -6,7 +6,7 @@ module EPC::Command
6
6
 
7
7
  status, response, headers = client.get(EPC::Config::DEPLOYMENTS_PATH + "/#{object_id}?include=solution,deployment_stage,approvals,deployer,submitter")
8
8
  if status.failure?
9
- say("Request failed: [#{response[:message]}]")
9
+ say_err("Request failed: [#{response[:message]}]")
10
10
  return status
11
11
  end
12
12
 
@@ -7,7 +7,7 @@ module EPC::Command
7
7
  if status.successful?
8
8
  say("Deployment submitted for approval")
9
9
  else
10
- say("Request failed: [#{response[:message]}]")
10
+ say_err("Request failed: [#{response[:message]}]")
11
11
  end
12
12
  return status
13
13
  end
@@ -21,7 +21,7 @@ module EPC::Command
21
21
  if status.successful?
22
22
  say("Deployment updated")
23
23
  else
24
- say("Request failed with: [#{response[:message]}]")
24
+ say_err("Request failed with: [#{response[:message]}]")
25
25
  end
26
26
  return status
27
27
  end