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
data/lib/epc.rb CHANGED
@@ -25,6 +25,10 @@ module EPC
25
25
  end
26
26
 
27
27
  module Command
28
+ autoload(:Role, "#{ROOT}/epc/modules/role")
29
+ autoload(:Config, "#{ROOT}/epc/modules/config")
30
+
31
+
28
32
  autoload(:BaseCommand, "#{ROOT}/epc/command/base_command")
29
33
  autoload(:BuildCommand, "#{ROOT}/epc/command/build_command")
30
34
  autoload(:ListConfigsCommand, "#{ROOT}/epc/command/config/list_configs_command")
@@ -48,7 +52,7 @@ module EPC
48
52
  autoload(:UnarchiveSolutionCommand, "#{ROOT}/epc/command/solution/unarchive_solution_command")
49
53
  autoload(:ListServicetypesCommand, "#{ROOT}/epc/command/servicetype/list_servicetypes_command")
50
54
  autoload(:CreateServicedefinitionCommand, "#{ROOT}/epc/command/servicedefinition/create_servicedefinition_command")
51
- autoload(:UndefineServiceCommand, "#{ROOT}/epc/command/undefine_service_command")
55
+ autoload(:DeleteServicedefinitionCommand, "#{ROOT}/epc/command/servicedefinition/delete_servicedefinition_command")
52
56
  autoload(:ListServicedefinitionsCommand, "#{ROOT}/epc/command/servicedefinition/list_servicedefinitions_command")
53
57
  autoload(:CreateServiceversionCommand, "#{ROOT}/epc/command/serviceversion/create_serviceversion_command")
54
58
  autoload(:ListServiceversionsCommand, "#{ROOT}/epc/command/serviceversion/list_serviceversions_command")
@@ -59,13 +63,13 @@ module EPC
59
63
  autoload(:CreateUserCommand, "#{ROOT}/epc/command/user/create_user_command")
60
64
  autoload(:CreateDeploymentCommand, "#{ROOT}/epc/command/deployment/create_deployment_command")
61
65
  autoload(:ShowDeploymentCommand, "#{ROOT}/epc/command/deployment/show_deployment_command")
62
- autoload(:SubmitDeploymentCommand, "#{ROOT}/epc/command/submit_deployment_command")
63
- autoload(:VoteDeploymentCommand, "#{ROOT}/epc/command/vote_deployment_command")
66
+ autoload(:SubmitDeploymentCommand, "#{ROOT}/epc/command/deployment/submit_deployment_command")
67
+ autoload(:VoteDeploymentCommand, "#{ROOT}/epc/command/deployment/vote_deployment_command")
64
68
  autoload(:ListDeploymentsCommand, "#{ROOT}/epc/command/deployment/list_deployments_command")
65
69
  autoload(:ListDeploymentstagesCommand, "#{ROOT}/epc/command/deploymentstage/list_deploymentstages_command")
66
70
  autoload(:DeployCommand, "#{ROOT}/epc/command/deploy_command")
67
71
  autoload(:UndeployCommand, "#{ROOT}/epc/command/undeploy_command")
68
- autoload(:CopyDeploymentCommand, "#{ROOT}/epc/command/copy_deployment_command")
72
+ autoload(:CopyDeploymentCommand, "#{ROOT}/epc/command/deployment/copy_deployment_command")
69
73
  autoload(:ListApprovalsCommand, "#{ROOT}/epc/command/list_approvals_command")
70
74
  autoload(:CreateDependencyCommand, "#{ROOT}/epc/command/create_dependency_command")
71
75
  autoload(:ListDependenciesCommand, "#{ROOT}/epc/command/list_dependencies_command")
@@ -85,7 +89,6 @@ module EPC
85
89
  autoload(:ShowProjecttypeCommand, "#{ROOT}/epc/command/projecttype/show_projecttype_command")
86
90
  autoload(:UpdateDeploymentCommand, "#{ROOT}/epc/command/deployment/update_deployment_command")
87
91
  autoload(:InfoCommand, "#{ROOT}/epc/command/info_command")
88
- autoload(:ListVersionsCommand, "#{ROOT}/epc/command/list_versions_command")
89
92
  autoload(:ArchiveProjectCommand, "#{ROOT}/epc/command/project/archive_project_command")
90
93
  autoload(:UnarchiveProjectCommand, "#{ROOT}/epc/command/project/unarchive_project_command")
91
94
  autoload(:ListAttachedlibrariesCommand, "#{ROOT}/epc/command/list_attachedlibraries_command")
@@ -130,14 +133,31 @@ module EPC
130
133
  autoload(:ShowPluginCommand, "#{ROOT}/epc/command/plugin/show_plugin_command")
131
134
  autoload(:UpdatePluginCommand, "#{ROOT}/epc/command/plugin/update_plugin_command")
132
135
  autoload(:DeletePluginCommand, "#{ROOT}/epc/command/plugin/delete_plugin_command")
136
+ autoload(:AttachtoProjectCommand, "#{ROOT}/epc/command/project/attachto_project_command")
137
+ autoload(:DetachfromProjectCommand, "#{ROOT}/epc/command/project/detachfrom_project_command")
138
+ autoload(:ListRuntimetypesCommand, "#{ROOT}/epc/command/runtimetype/list_runtimetypes_command")
139
+ autoload(:CreateRuntimeCommand, "#{ROOT}/epc/command/runtime/create_runtime_command")
140
+ autoload(:DeleteRuntimeCommand, "#{ROOT}/epc/command/runtime/delete_runtime_command")
141
+ autoload(:UpdateRuntimeCommand, "#{ROOT}/epc/command/runtime/update_runtime_command")
142
+ autoload(:CreateProjecttypeCommand, "#{ROOT}/epc/command/projecttype/create_projecttype_command")
143
+ autoload(:DeleteProjecttypeCommand, "#{ROOT}/epc/command/projecttype/delete_projecttype_command")
144
+ autoload(:UpdateProjecttypeCommand, "#{ROOT}/epc/command/projecttype/update_projecttype_command")
145
+ autoload(:ShowProjectSnapshotCommand, "#{ROOT}/epc/command/project/show_project_snapshot_command")
146
+ autoload(:ListUserpropertiesCommand, "#{ROOT}/epc/command/userproperty/list_user_properties_command")
133
147
 
134
148
 
135
149
  autoload(:CreateCommand, "#{ROOT}/epc/command/create_command")
136
150
  autoload(:ListCommand, "#{ROOT}/epc/command/list_command")
137
151
  autoload(:ShowCommand, "#{ROOT}/epc/command/show_command")
152
+ autoload(:AttachtoCommand, "#{ROOT}/epc/command/attachto_command")
138
153
  autoload(:UpdateCommand, "#{ROOT}/epc/command/update_command")
139
154
  autoload(:DeleteCommand, "#{ROOT}/epc/command/delete_command")
140
155
  autoload(:ArchiveCommand, "#{ROOT}/epc/command/archive_command")
141
156
  autoload(:UnarchiveCommand, "#{ROOT}/epc/command/unarchive_command")
157
+ autoload(:AttachtoCommand, "#{ROOT}/epc/command/attachto_command")
158
+ autoload(:DetachfromCommand, "#{ROOT}/epc/command/detachfrom_command")
159
+ autoload(:CopyCommand, "#{ROOT}/epc/command/copy_command")
160
+ autoload(:VoteCommand, "#{ROOT}/epc/command/vote_command")
161
+ autoload(:SubmitCommand, "#{ROOT}/epc/command/submit_command")
142
162
  end
143
163
  end
@@ -8,7 +8,7 @@ module EPC::Client
8
8
  status, body, headers = super(url, 'application/json', skip_signature)
9
9
  [status, json_parse(body), headers]
10
10
  rescue JSON::ParserError
11
- raise BadResponse, "Can't parse response into JSON", body
11
+ raise BadResponse, "Invalid response received. Response status: #{status}", body
12
12
  end
13
13
  end
14
14
 
@@ -17,7 +17,7 @@ module EPC::Client
17
17
  status, body, headers = super(url, payload.to_json, 'application/json', {}, skip_signature)
18
18
  [status, json_parse(body), headers]
19
19
  rescue JSON::ParserError
20
- raise BadResponse, "Can't parse response into JSON", body
20
+ raise BadResponse, "Invalid response received. Response status: #{status}", body
21
21
  end
22
22
  end
23
23
 
@@ -26,7 +26,7 @@ module EPC::Client
26
26
  status, body, headers = super(url, payload.to_json, 'application/json')
27
27
  [status, json_parse(body), headers]
28
28
  rescue JSON::ParserError
29
- raise BadResponse, "Can't parse response into JSON", body
29
+ raise BadResponse, "Invalid response received. Response status: #{status}", body
30
30
  end
31
31
  end
32
32
 
@@ -35,7 +35,7 @@ module EPC::Client
35
35
  status, body, headers = super(url, payload.to_json, 'application/json')
36
36
  [status, json_parse(body), headers]
37
37
  rescue JSON::ParserError
38
- raise BadResponse, "Can't parse response into JSON", body
38
+ raise BadResponse, "Invalid response received. Response status: #{status}", body
39
39
  end
40
40
  end
41
41
 
@@ -1,12 +1,13 @@
1
1
  module EPC::Command
2
2
  class ArchiveCommand < BaseCommand
3
3
 
4
- def execute(object = nil)
5
- @object_type, @object_id = @object.split(":") rescue [nil, nil]
6
- raise FatalError, "Object incorrectly specified" if @object_type.blank?
7
- klass = "EPC::Command::Archive#{@object_type.to_s.gsub("-","").capitalize}Command"
8
- command = eval(klass).new(client, @options)
9
- command.go(@object_id)
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
+ @klass_name = "EPC::Command::Archive#{@object_type.to_s.gsub("-","").capitalize}Command"
8
+ command = eval(@klass_name).new(client, @options)
9
+ command.context_params = context_params
10
+ command.go(params)
10
11
  end
11
12
  end
12
13
  end
@@ -0,0 +1,13 @@
1
+ module EPC::Command
2
+ class AttachtoCommand < BaseCommand
3
+
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
+ @klass_name = "EPC::Command::Attachto#{@object_type.to_s.gsub("-","").capitalize}Command"
8
+ command = eval(@klass_name).new(client, @options)
9
+ command.context_params = context_params
10
+ command.execute(params)
11
+ end
12
+ end
13
+ end
@@ -11,6 +11,12 @@ module EPC
11
11
  attr_reader :client
12
12
  attr_reader :options
13
13
 
14
+ attr_accessor :object_type
15
+ attr_accessor :object_id
16
+ attr_accessor :target_type
17
+ attr_accessor :target_id
18
+ attr_accessor :klass_name
19
+
14
20
  @@retrieval_rules = {
15
21
  :Role => {
16
22
  :required_type => :numeric,
@@ -47,6 +53,13 @@ module EPC
47
53
  @@required_options << {:name => opts, :mode => options_hash[:mode], :message => options_hash[:message]}
48
54
  end
49
55
 
56
+ def self.include_module(object_type)
57
+ mod = object_type.capitalize
58
+ if EPC::Config.module_exists?(mod)
59
+ self.send :include, eval("EPC::Command::#{mod}")
60
+ end
61
+ end
62
+
50
63
  def initialize(client, options = {})
51
64
  @client = client
52
65
  @options = options.dup
@@ -60,10 +73,26 @@ module EPC
60
73
  say("You must be logged in to run this command")
61
74
  return 1
62
75
  else
76
+ check_options
63
77
  return translate_status_to_exit_code(execute(*args))
64
78
  end
65
79
  end
66
80
 
81
+ def check_options
82
+ @@required_options.each do |req_opt|
83
+ raise FatalError, req_opt[:message] unless req_opt[:name].map{|opt| @options[opt].present?}.send(req_opt[:mode])
84
+
85
+ end
86
+ end
87
+
88
+ def context_params
89
+ return [object_type, object_id, target_type, target_id]
90
+ end
91
+
92
+ def context_params=(params)
93
+ @object_type, @object_id, @target_type, @target_id = params
94
+ end
95
+
67
96
  private
68
97
 
69
98
  def translate_status_to_exit_code(status)
@@ -102,11 +131,90 @@ module EPC
102
131
  value.respond_to?(:empty?) ? value.empty? : !value
103
132
  end
104
133
 
134
+ def pluralize(string)
135
+ case string.downcase
136
+ when "library" then return "libraries"
137
+ when "dependency" then return "dependencies"
138
+ end
139
+ return string + "s"
140
+ end
141
+
105
142
  def check_params
106
143
  return if ["solution", "project"].include?(@object_type.downcase)
107
144
  raise FatalError, "You need to specify the #{@object_type.downcase} identifier" if @object_id.blank?
108
145
  end
109
146
 
147
+ def has_target?
148
+ return target_type.present? && target_id.present?
149
+ end
150
+
151
+ def require_object
152
+ raise InputError, "#{object_type.capitalize} not found" if object_type.blank? || object_id.blank?
153
+ end
154
+
155
+ def require_target
156
+ raise InputError, "Target incorrectly specified" if target_type.blank? || target_id.blank?
157
+ end
158
+
159
+ def resolve_context(args, opts = {})
160
+ defaults = {
161
+ :skip_object_resolution => Proc.new{|type, id| false},
162
+ :skip_target_resolution => Proc.new{|type, id| false}
163
+ }.merge!(opts)
164
+ @object_id, @object_type, args = parse_context_param(args, defaults[:skip_object_resolution])
165
+ raise InputError, "Invalid command" if @object_type.blank?
166
+ @target_id, @target_type, args = parse_context_param(args, defaults[:skip_target_resolution])
167
+ return args
168
+ end
169
+
170
+ def parse_context_param(params, skip_proc)
171
+ return [nil, nil, params] unless is_context_param?((params.first rescue nil))
172
+ param = params.shift
173
+ param_parts = param.split(":")
174
+ type = param_parts[0]
175
+ id = param_parts[1..-1].join(":")
176
+ if skip_proc.call(type, id)
177
+ return id, type, params
178
+ else
179
+ if has_local_context?(type)
180
+ return infer_local_context(type, id).insert(-1, params)
181
+ else
182
+ return [retrieve_identifier_for(translate_type(type), id), type, params]
183
+ end
184
+ end
185
+ end
186
+
187
+ def translate_type(type)
188
+ return "UserGroup" if type.downcase == "group"
189
+ return "RuntimeEnv" if type.downcase == "runtime"
190
+ return "RuntimeEnvType" if type.downcase == "runtimetype"
191
+ return "Project" if type.downcase == "dependency"
192
+ return type
193
+ end
194
+
195
+ def has_local_context?(type)
196
+ return ["solution", "project"].include?(type.downcase)
197
+ end
198
+
199
+ def infer_local_context(type, id)
200
+ path = File.expand_path(".")
201
+ if type.downcase == "solution"
202
+ solution_id, solution_name = infer_solution_context(id, path)
203
+ return [solution_id, type]
204
+ elsif type.downcase == "project"
205
+ ids = id.split(":") rescue [nil, nil]
206
+ if ids.size == 1
207
+ project_name = ids[0]
208
+ solution_name = nil
209
+ elsif ids.size == 2
210
+ solution_name, project_name = ids
211
+ end
212
+ solution_id, solution_name = infer_solution_context(solution_name, path)
213
+ project_id, project_name = infer_project_context(project_name, path, solution_id)
214
+ return [project_id, type]
215
+ end
216
+ end
217
+
110
218
  def numeric?(value)
111
219
  return value.is_a?(Integer) || (value =~ /\d/) == 0
112
220
  end
@@ -157,18 +265,14 @@ module EPC
157
265
  return File.join(File.split(path)[0...-1])
158
266
  end
159
267
 
160
- def normalize_params(params)
161
- return params if is_target_param?(params.first)
162
- return params.insert(0, "")
163
- end
164
-
165
- def is_target_param?(param)
268
+ def is_context_param?(param)
269
+ return false if param.blank?
166
270
  target_type = param.split(":").first rescue ""
167
- return object_types.include?(target_type.downcase)
271
+ return object_types.include?(target_type.downcase) || object_types.map{|o| pluralize(o)}.include?(target_type.downcase)
168
272
  end
169
273
 
170
274
  def object_types
171
- return %q(
275
+ return %w(
172
276
  config
173
277
  dependency
174
278
  deployment
@@ -178,7 +282,10 @@ module EPC
178
282
  librarylanguage
179
283
  libraryset
180
284
  objectrole
285
+ objecttype
181
286
  permission
287
+ runtime
288
+ runtimetype
182
289
  permissiongroup
183
290
  plugin
184
291
  project
@@ -190,6 +297,8 @@ module EPC
190
297
  serviceversion
191
298
  solution
192
299
  user
300
+ metrics
301
+ user-properties
193
302
  )
194
303
 
195
304
  end
@@ -197,7 +306,7 @@ module EPC
197
306
  def retrieve_identifier_for(entity, *args)
198
307
  entity = entity.to_sym
199
308
  match_value = args.join(":")
200
- raise InternalError if match_value.blank?
309
+ return nil if match_value.blank?
201
310
  rule = @@retrieval_rules[entity.to_sym] || {:required_type => :numeric}
202
311
  if rule[:required_type] == :numeric
203
312
  if numeric?(match_value)
@@ -206,18 +315,16 @@ module EPC
206
315
  return identify_resource(entity, match_value)
207
316
  end
208
317
  end
209
-
210
- raise InputError, "Request failed: [Resource Not Found]" if entity_identifier.nil?
211
318
  return entity_identifier
212
319
  end
213
320
 
214
321
  def identify_resource(object_type, object_identifier)
215
- obj_identifier = CGI.escape(object_identifier).gsub(".", "%2e")
322
+ obj_identifier = CGI.escape(object_identifier).gsub(".", "%2e").gsub("+", "%20")
216
323
  status, response, headers = client.get(EPC::Config::OBJECT_TYPES_PATH + "/identify/#{object_type}/#{obj_identifier}")
217
324
  if status.successful?
218
325
  return response[:id]
219
326
  else
220
- raise InputError, "Request failed: [#{object_type.capitalize} not found]"
327
+ return nil
221
328
  end
222
329
  end
223
330
 
@@ -269,7 +376,6 @@ module EPC
269
376
  # :get_project_name : for when you have a numeric project_id, but you also want the name
270
377
  def infer_project_context(p_identifier, path, s_identifier = nil, options = {})
271
378
  if p_identifier.blank?
272
-
273
379
  if EPC::Config.is_project_dir?(path)
274
380
  project_id = EPC::Config.get_project_value(path, "id")
275
381
  project_name = EPC::Config.get_project_value(path, "name")
@@ -372,21 +478,6 @@ module EPC
372
478
  digest.hexdigest
373
479
  end
374
480
 
375
- def extract_configuration_level(path, target_string)
376
- config_type, config_id = target_string.split(":") rescue [nil, nil]
377
-
378
- if config_id.nil?
379
- if EPC::Config.is_project_dir?(path)
380
- config_id = EPC::Config.get_project_value(path, "id")
381
- config_type = "Project"
382
- elsif EPC::Config.is_solution_dir?(path)
383
- config_id = EPC::Config.get_solution_value(path, "id")
384
- config_type = "Solution"
385
- end
386
- end
387
-
388
- return [config_type, config_id]
389
- end
390
481
 
391
482
  def show_build_status(build_id)
392
483
  status, response, headers = client.get("#{EPC::Config::BUILDS_PATH}/#{build_id}/status")
@@ -2,14 +2,14 @@ module EPC::Command
2
2
  class CreateConfigCommand < BaseCommand
3
3
  CONFIG_LEVELS = {
4
4
  :org => "Organization",
5
- :runtime => "RuntimeEnvironment",
5
+ :runtime => "RuntimeEnv",
6
6
  :stage => "DeploymentStage",
7
7
  :solution => "Solution",
8
8
  :project => "Project",
9
9
  :user => "User"
10
10
  }
11
11
 
12
- def execute(target, *args)
12
+ def execute(args = [])
13
13
  raise FatalError, "You have to specify a key and its value." if args.empty? && @options[:file].nil?
14
14
 
15
15
  path = File.expand_path(".")
@@ -17,19 +17,15 @@ module EPC::Command
17
17
  @options[:value_type] = "text" if @options[:value_type].nil?
18
18
  @options[:required] = false if @options[:required].nil?
19
19
 
20
- config_type, config_id = extract_configuration_level(path, target)
20
+ config_type, config_id = extract_configuration_level(path, [target_type, target_id])
21
21
 
22
- raise FatalError, "You need to specify a config type" if config_type.blank?
22
+ raise InputError, "Config type invalid. Must be one of: [#{CONFIG_LEVELS.values.join(",")}]" if config_type.blank?
23
+
24
+ raise InputError, "Configuration context could not be determined" if config_id.blank?
23
25
 
24
26
  params = []
25
27
  if @options[:file].present?
26
- params = EPC::Config.read_content_as_json(@options[:file])
27
- params.each do |param|
28
- if param[:configurable_type].nil? || param[:configurable_id].nil?
29
- param[:configurable_type] = config_type
30
- param[:configurable_id] = config_id
31
- end
32
- end
28
+ params = parse_config_value_file(@options[:file], config_type, config_id)
33
29
  else
34
30
  args.each do |arg|
35
31
  name, value = arg.split("=")
@@ -1,16 +1,17 @@
1
1
  module EPC::Command
2
2
  class DeleteConfigCommand < DeleteCommand
3
3
 
4
- def execute(key = nil, target = nil, *args)
4
+ def execute(args = [])
5
5
 
6
6
  path = "."
7
7
  path = File.expand_path(path)
8
+ key = object_id
8
9
 
9
- config_type, config_id = extract_configuration_level(path, target)
10
+ config_type, config_id = extract_configuration_level(path, [target_type, target_id])
10
11
  request_path = EPC::Config::CONFIGURATIONS_PATH+"/#{config_type}/#{config_id}"
11
12
 
12
- if ["solution", "project"].include?(config_type.downcase) && !@options[:stage_name].nil?
13
- request_path += "/#{@options[:stage_name]}"
13
+ if ["solution", "project"].include?(config_type.downcase) && !@options[:stage].nil?
14
+ request_path += "/#{@options[:stage]}"
14
15
  end
15
16
 
16
17
  status, response, headers = client.get(request_path)
@@ -50,7 +51,6 @@ module EPC::Command
50
51
  end
51
52
  return status
52
53
 
53
-
54
54
  end
55
55
 
56
56
  end