epc 1.0.2
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.
- data/CHANGELOG +1 -0
- data/Gemfile +22 -0
- data/Rakefile +67 -0
- data/Rakefile.gem +1 -0
- data/bin/epc +10 -0
- data/lib/epc.rb +126 -0
- data/lib/epc/client/base_client.rb +80 -0
- data/lib/epc/client/http_client.rb +19 -0
- data/lib/epc/client/json_client.rb +48 -0
- data/lib/epc/command/archive_project_command.rb +24 -0
- data/lib/epc/command/archive_solution_command.rb +21 -0
- data/lib/epc/command/attach_library_command.rb +82 -0
- data/lib/epc/command/attach_libraryset_command.rb +32 -0
- data/lib/epc/command/attach_runtime_command.rb +27 -0
- data/lib/epc/command/base_command.rb +451 -0
- data/lib/epc/command/bind_service_command.rb +35 -0
- data/lib/epc/command/build_command.rb +83 -0
- data/lib/epc/command/config/create_config_command.rb +55 -0
- data/lib/epc/command/copy_deployment_command.rb +21 -0
- data/lib/epc/command/create_command.rb +13 -0
- data/lib/epc/command/create_dependency_command.rb +43 -0
- data/lib/epc/command/define_service_command.rb +37 -0
- data/lib/epc/command/delete_config_command.rb +63 -0
- data/lib/epc/command/delete_dependency_command.rb +40 -0
- data/lib/epc/command/delete_group_command.rb +40 -0
- data/lib/epc/command/delete_library_command.rb +30 -0
- data/lib/epc/command/delete_librarylanguage_command.rb +40 -0
- data/lib/epc/command/delete_libraryset_command.rb +40 -0
- data/lib/epc/command/delete_project_command.rb +54 -0
- data/lib/epc/command/delete_role_command.rb +25 -0
- data/lib/epc/command/delete_serviceversion_command.rb +52 -0
- data/lib/epc/command/delete_solution_command.rb +39 -0
- data/lib/epc/command/delete_user_command.rb +31 -0
- data/lib/epc/command/deploy_command.rb +142 -0
- data/lib/epc/command/deployment/create_deployment_command.rb +82 -0
- data/lib/epc/command/detach_library_command.rb +35 -0
- data/lib/epc/command/detach_libraryset_command.rb +8 -0
- data/lib/epc/command/group/create_group_command.rb +21 -0
- data/lib/epc/command/info_command.rb +11 -0
- data/lib/epc/command/library/create_library_command.rb +45 -0
- data/lib/epc/command/librarylanguage/create_librarylanguage_command.rb +24 -0
- data/lib/epc/command/libraryset/create_libraryset_command.rb +54 -0
- data/lib/epc/command/list_approvals_command.rb +27 -0
- data/lib/epc/command/list_attachedlibraries_command.rb +42 -0
- data/lib/epc/command/list_boundservices_command.rb +40 -0
- data/lib/epc/command/list_config_command.rb +60 -0
- data/lib/epc/command/list_dependencies_command.rb +43 -0
- data/lib/epc/command/list_deployments_command.rb +68 -0
- data/lib/epc/command/list_groups_command.rb +19 -0
- data/lib/epc/command/list_libraries_command.rb +19 -0
- data/lib/epc/command/list_librarylanguages_command.rb +19 -0
- data/lib/epc/command/list_librarysets_command.rb +26 -0
- data/lib/epc/command/list_objectroles_command.rb +25 -0
- data/lib/epc/command/list_objecttypes_command.rb +20 -0
- data/lib/epc/command/list_permissiongroups_command.rb +20 -0
- data/lib/epc/command/list_projects_command.rb +36 -0
- data/lib/epc/command/list_projecttypes_command.rb +20 -0
- data/lib/epc/command/list_rolepermissions_command.rb +21 -0
- data/lib/epc/command/list_roles_command.rb +26 -0
- data/lib/epc/command/list_runtimes_command.rb +16 -0
- data/lib/epc/command/list_service_types_command.rb +19 -0
- data/lib/epc/command/list_servicedefinitions_command.rb +19 -0
- data/lib/epc/command/list_serviceversions_command.rb +21 -0
- data/lib/epc/command/list_solutions_command.rb +25 -0
- data/lib/epc/command/list_stages_command.rb +21 -0
- data/lib/epc/command/list_users_command.rb +26 -0
- data/lib/epc/command/list_versions_command.rb +39 -0
- data/lib/epc/command/login_command.rb +32 -0
- data/lib/epc/command/logout_command.rb +20 -0
- data/lib/epc/command/objectrole/create_objectrole_command.rb +19 -0
- data/lib/epc/command/project/create_project_command.rb +78 -0
- data/lib/epc/command/pull_command.rb +209 -0
- data/lib/epc/command/push_command.rb +194 -0
- data/lib/epc/command/refresh_solution_command.rb +71 -0
- data/lib/epc/command/renew_command.rb +19 -0
- data/lib/epc/command/request_passwordchange_command.rb +23 -0
- data/lib/epc/command/role/create_role_command.rb +17 -0
- data/lib/epc/command/serviceversion/create_serviceversion_command.rb +33 -0
- data/lib/epc/command/show_deployment_command.rb +57 -0
- data/lib/epc/command/show_group_command.rb +35 -0
- data/lib/epc/command/show_libraryset_command.rb +54 -0
- data/lib/epc/command/show_project_command.rb +74 -0
- data/lib/epc/command/show_projecttype_command.rb +18 -0
- data/lib/epc/command/show_role_command.rb +46 -0
- data/lib/epc/command/show_solution_command.rb +54 -0
- data/lib/epc/command/show_user_command.rb +42 -0
- data/lib/epc/command/solution/create_solution_command.rb +34 -0
- data/lib/epc/command/solution/list_solutions_command.rb +25 -0
- data/lib/epc/command/solution/update_solution_command.rb +43 -0
- data/lib/epc/command/submit_deployment_command.rb +19 -0
- data/lib/epc/command/target_command.rb +26 -0
- data/lib/epc/command/unarchive_project_command.rb +23 -0
- data/lib/epc/command/unarchive_solution_command.rb +21 -0
- data/lib/epc/command/unbind_service_command.rb +42 -0
- data/lib/epc/command/undefine_service_command.rb +33 -0
- data/lib/epc/command/undeploy_command.rb +106 -0
- data/lib/epc/command/update_config_command.rb +62 -0
- data/lib/epc/command/update_deploymentproject_command.rb +54 -0
- data/lib/epc/command/update_group_command.rb +43 -0
- data/lib/epc/command/update_librarylanguage_command.rb +28 -0
- data/lib/epc/command/update_libraryset_command.rb +80 -0
- data/lib/epc/command/update_project_command.rb +49 -0
- data/lib/epc/command/update_role_command.rb +47 -0
- data/lib/epc/command/update_rolepermissions_command.rb +83 -0
- data/lib/epc/command/update_solution_command.rb +45 -0
- data/lib/epc/command/update_user_command.rb +57 -0
- data/lib/epc/command/user/create_user_command.rb +27 -0
- data/lib/epc/command/vote_deployment_command.rb +29 -0
- data/lib/epc/config.rb +245 -0
- data/lib/epc/error/basic_error.rb +6 -0
- data/lib/epc/error/fatal_error.rb +6 -0
- data/lib/epc/error/input_error.rb +6 -0
- data/lib/epc/error/internal_error.rb +6 -0
- data/lib/epc/help.rb +292 -0
- data/lib/epc/persistent_attributes.rb +18 -0
- data/lib/epc/runner.rb +177 -0
- data/lib/epc/tabular_outputter.rb +161 -0
- data/lib/epc/version.rb +3 -0
- data/lib/fixnum.rb +9 -0
- data/lib/object.rb +13 -0
- data/test/command/archive_project_command_test.rb +41 -0
- data/test/command/archive_solution_command_test.rb +40 -0
- data/test/command/attach_library_command_test.rb +124 -0
- data/test/command/attach_libraryset_command_test.rb +49 -0
- data/test/command/attach_runtime_command_test.rb +44 -0
- data/test/command/base_command_test.rb +276 -0
- data/test/command/bind_service_command_test.rb +46 -0
- data/test/command/build_command_test.rb +103 -0
- data/test/command/copy_deployment_command_test.rb +38 -0
- data/test/command/create_config_command_test.rb +124 -0
- data/test/command/create_dependency_command_test.rb +55 -0
- data/test/command/create_deployment_command_test.rb +136 -0
- data/test/command/create_group_command_test.rb +34 -0
- data/test/command/create_library_command_test.rb +61 -0
- data/test/command/create_librarylanguage_command_test.rb +51 -0
- data/test/command/create_libraryset_command_test.rb +81 -0
- data/test/command/create_objectrole_command_test.rb +37 -0
- data/test/command/create_project_command_test.rb +102 -0
- data/test/command/create_role_command_test.rb +31 -0
- data/test/command/create_serviceversion_command_test.rb +60 -0
- data/test/command/create_solution_command_test.rb +70 -0
- data/test/command/create_user_command_test.rb +54 -0
- data/test/command/define_service_command_test.rb +55 -0
- data/test/command/delete_config_command_test.rb +82 -0
- data/test/command/delete_dependency_command_test.rb +50 -0
- data/test/command/delete_group_command_test.rb +56 -0
- data/test/command/delete_library_command_test.rb +43 -0
- data/test/command/delete_librarylanguage_command_test.rb +55 -0
- data/test/command/delete_libraryset_command_test.rb +55 -0
- data/test/command/delete_project_command_test.rb +76 -0
- data/test/command/delete_role_command_test.rb +41 -0
- data/test/command/delete_serviceversion_command_test.rb +53 -0
- data/test/command/delete_solution_command_test.rb +79 -0
- data/test/command/delete_user_command_test.rb +56 -0
- data/test/command/deploy_command_test.rb +185 -0
- data/test/command/detach_library_command_test.rb +53 -0
- data/test/command/info_command_test.rb +17 -0
- data/test/command/list_approvals_command_test.rb +41 -0
- data/test/command/list_boundservices_command_test.rb +46 -0
- data/test/command/list_config_command_test.rb +72 -0
- data/test/command/list_dependencies_command_test.rb +46 -0
- data/test/command/list_deployments_command_test.rb +112 -0
- data/test/command/list_deploymentstages_command_test.rb +44 -0
- data/test/command/list_libraries_command_test.rb +42 -0
- data/test/command/list_librarylanguages_command_test.rb +34 -0
- data/test/command/list_librarysets_command_test.rb +33 -0
- data/test/command/list_objectroles_command_test.rb +41 -0
- data/test/command/list_objecttypes_command_test.rb +25 -0
- data/test/command/list_permissiongroups_command_test.rb +25 -0
- data/test/command/list_projects_command_test.rb +63 -0
- data/test/command/list_projecttypes_command_test.rb +39 -0
- data/test/command/list_rolepermissions_command_test.rb +39 -0
- data/test/command/list_roles_command_test.rb +46 -0
- data/test/command/list_runtimes_command_test.rb +30 -0
- data/test/command/list_service_types_command_test.rb +44 -0
- data/test/command/list_servicedefinitions_command_test.rb +44 -0
- data/test/command/list_serviceversions_command_test.rb +47 -0
- data/test/command/list_solutions_command_test.rb +48 -0
- data/test/command/list_users_command_test.rb +33 -0
- data/test/command/login_command_test.rb +83 -0
- data/test/command/logout_command_test.rb +30 -0
- data/test/command/pull_command_test.rb +229 -0
- data/test/command/push_command_test.rb +246 -0
- data/test/command/refresh_solution_command_test.rb +35 -0
- data/test/command/renew_command_test.rb +43 -0
- data/test/command/request_passwordchange_command_test.rb +31 -0
- data/test/command/show_group_command_test.rb +50 -0
- data/test/command/show_libraryset_command_test.rb +51 -0
- data/test/command/show_project_command_test.rb +57 -0
- data/test/command/show_projecttype_command_test.rb +46 -0
- data/test/command/show_role_command_test.rb +37 -0
- data/test/command/show_solution_command_test.rb +59 -0
- data/test/command/show_user_command_test.rb +50 -0
- data/test/command/submit_deployment_command_test.rb +37 -0
- data/test/command/target_command_test.rb +58 -0
- data/test/command/unarchive_project_command_test.rb +45 -0
- data/test/command/unarchive_solution_command_test.rb +43 -0
- data/test/command/unbind_service_command_test.rb +48 -0
- data/test/command/undefine_service_command_test.rb +49 -0
- data/test/command/update_config_command_test.rb +74 -0
- data/test/command/update_deploymentproject_command_test.rb +77 -0
- data/test/command/update_group_command_test.rb +69 -0
- data/test/command/update_librarylanguage_command_test.rb +43 -0
- data/test/command/update_libraryset_command_test.rb +113 -0
- data/test/command/update_project_command_test.rb +56 -0
- data/test/command/update_role_command_test.rb +42 -0
- data/test/command/update_rolepermissions_command_test.rb +54 -0
- data/test/command/update_solution_command_test.rb +58 -0
- data/test/command/update_user_command_test.rb +76 -0
- data/test/command/vote_deployment_command_test.rb +33 -0
- data/test/config_test.rb +70 -0
- data/test/successful_test.rb +21 -0
- data/test/test_files/pom.xml +273 -0
- data/test/test_helper.rb +25 -0
- metadata +470 -0
@@ -0,0 +1,71 @@
|
|
1
|
+
module EPC::Command
|
2
|
+
class RefreshSolutionCommand < BaseCommand
|
3
|
+
|
4
|
+
def execute(path = nil)
|
5
|
+
path = "." if path.nil?
|
6
|
+
path = File.expand_path(path)
|
7
|
+
path = project_solution_path(path)
|
8
|
+
|
9
|
+
solution_id, solution_name = infer_solution_context(nil, path)
|
10
|
+
|
11
|
+
raise FatalError, "Solution could not be inferred" if solution_id.nil?
|
12
|
+
|
13
|
+
if @options[:prompt_refresh] || @options[:prompt_refresh].nil?
|
14
|
+
proceed = ask_yn("You are about to refresh the #{solution_name} solution. This will retrieve any data that has changed and rename your solution and/or project directories.Are you sure? [Yn]: ")
|
15
|
+
if proceed.upcase == 'N'
|
16
|
+
return 1
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
status, response, message = client.get(EPC::Config::SOLUTIONS_PATH + "/#{solution_id}?include=config_values,projects,deployments,deployment_configs")
|
21
|
+
if status.failure?
|
22
|
+
say("Retrieval failed with message [#{response[:message]}]")
|
23
|
+
return status
|
24
|
+
end
|
25
|
+
|
26
|
+
EPC::Config.update_solution_metadata(response, path)
|
27
|
+
|
28
|
+
project_paths = []
|
29
|
+
|
30
|
+
response[:projects].each do |project|
|
31
|
+
project_paths << File.join(path, project[:name])
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
verified_project_paths = []
|
36
|
+
project_paths = (project_paths + Dir.glob("#{path}/**").select{|p| File.directory?(p) }).uniq
|
37
|
+
project_paths.each do |project_path|
|
38
|
+
if EPC::Config.is_project_dir?(project_path)
|
39
|
+
verified_project_paths << project_path
|
40
|
+
project_data = response[:projects].detect{|prj| prj[:id] == EPC::Config.get_project_value(project_path, "id") }
|
41
|
+
EPC::Config.write_project_metadata(project_data[:id], client, project_path) unless project_data.nil?
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
remaining = project_paths - verified_project_paths
|
46
|
+
|
47
|
+
remaining.each do |r_path|
|
48
|
+
p_name = File.basename(r_path)
|
49
|
+
p_id = response[:projects].detect{|prj| prj[:name] == p_name}[:id] rescue nil
|
50
|
+
if !p_id.nil?
|
51
|
+
unless FileTest.exists?(r_path)
|
52
|
+
mkdir(r_path)
|
53
|
+
end
|
54
|
+
EPC::Config.write_project_metadata(p_id, client, r_path)
|
55
|
+
verified_project_paths << r_path
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
verified_project_paths.each do |project_path|
|
60
|
+
EPC::Config.update_project_directory(project_path)
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
EPC::Config.update_solution_directory(path)
|
65
|
+
|
66
|
+
|
67
|
+
say("Solution refreshed. You may need to change directories to see the changes.") if @options[:prompt_refresh] || @options[:prompt_refresh].nil?
|
68
|
+
return status
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module EPC::Command
|
2
|
+
class RenewCommand < BaseCommand
|
3
|
+
def execute
|
4
|
+
begin
|
5
|
+
status, response, headers = client.put("#{EPC::Config::TOKENS_PATH}/renew")
|
6
|
+
if status.successful?
|
7
|
+
EPC::Config.store_auth_token(response[:authentication_token])
|
8
|
+
say("Successfully renewed with [#{target_url}]")
|
9
|
+
else
|
10
|
+
say("Renew failed [#{response[:message]}]. Please try again later.")
|
11
|
+
end
|
12
|
+
return status
|
13
|
+
rescue Exception => ex
|
14
|
+
say("Renew failed [#{ex}].")
|
15
|
+
return 1
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module EPC::Command
|
2
|
+
class RequestPasswordchangeCommand < BaseCommand
|
3
|
+
def execute(user = nil)
|
4
|
+
|
5
|
+
raise FatalError, "You need to specify an email/id" if user.blank?
|
6
|
+
|
7
|
+
if numeric?(user)
|
8
|
+
email = get_resource_attribute(EPC::Config::USERS_PATH, :email, :id, user.to_i)
|
9
|
+
else
|
10
|
+
email = user
|
11
|
+
end
|
12
|
+
|
13
|
+
status, response, headers = client.put(EPC::Config::USERS_PATH + "/#{email}/change_password_request")
|
14
|
+
if status.successful?
|
15
|
+
say("Request successfully sent.")
|
16
|
+
else
|
17
|
+
say("Request failed: [#{response[:message]}]")
|
18
|
+
end
|
19
|
+
|
20
|
+
return status
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module EPC::Command
|
2
|
+
class CreateRoleCommand < BaseCommand
|
3
|
+
def execute(*params)
|
4
|
+
role = params[1]
|
5
|
+
raise FatalError, "You must specify a role name" if role.blank?
|
6
|
+
|
7
|
+
status, response, headers = client.post(EPC::Config::ROLES_PATH, {:name => role})
|
8
|
+
|
9
|
+
if status.successful?
|
10
|
+
say("Role [#{role}] created")
|
11
|
+
else
|
12
|
+
say("Request failed: [#{response[:message]}]")
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module EPC::Command
|
2
|
+
class CreateServiceversionCommand < BaseCommand
|
3
|
+
|
4
|
+
def execute(*params)
|
5
|
+
label = params[1]
|
6
|
+
definition = params[2]
|
7
|
+
|
8
|
+
raise FatalError, "Label and definition identifier are both required." if label.nil? || definition.nil?
|
9
|
+
|
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
|
15
|
+
|
16
|
+
raise InputError, "Service definition not found" if definition_id.nil?
|
17
|
+
|
18
|
+
up_script = read_file(@options[:up_script]) unless blank?(@options[:up_script])
|
19
|
+
down_script = read_file(@options[:down_script]) unless blank?(@options[:down_script])
|
20
|
+
|
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})
|
22
|
+
|
23
|
+
if status.successful?
|
24
|
+
say("Service version successfully created.")
|
25
|
+
else
|
26
|
+
say("Request failed: [#{response[:message]}]")
|
27
|
+
end
|
28
|
+
return status
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'time'
|
2
|
+
module EPC::Command
|
3
|
+
class ShowDeploymentCommand < BaseCommand
|
4
|
+
|
5
|
+
def execute(deployment_id = nil)
|
6
|
+
if deployment_id.nil?
|
7
|
+
say("You must specifiy a deployment id")
|
8
|
+
say(EPC::Help::COMMAND_USAGES[:show_deployment])
|
9
|
+
return 1
|
10
|
+
end
|
11
|
+
|
12
|
+
status, response, headers = client.get(EPC::Config::DEPLOYMENTS_PATH + "/#{deployment_id}?include=solution,deployment_stage,approvals,deployer,submitter")
|
13
|
+
if status.failure?
|
14
|
+
say("Request failed: [#{response[:message]}]")
|
15
|
+
return status
|
16
|
+
end
|
17
|
+
|
18
|
+
response[:created_at] = Time.parse(response[:created_at]).strftime("%m/%d/%Y %I:%M%p") unless response[:created_at].nil?
|
19
|
+
response[:updated_at] = Time.parse(response[:updated_at]).strftime("%m/%d/%Y %I:%M%p") unless response[:updated_at].nil?
|
20
|
+
response[:stage] = response[:deployment_stage][:name]
|
21
|
+
response[:solution_id] = response[:solution][:id]
|
22
|
+
response[:solution_name] = response[:solution][:name]
|
23
|
+
response[:submitter] = response[:submitter][:name] rescue nil
|
24
|
+
response[:deployer] = response[:deployer][:name] rescue nil
|
25
|
+
deployments_table = EPC::TabularOutputter.new([response], [:id, :status, :stage, :solution_name, :submitter, :deployer, :updated_at, :note, :replaces])
|
26
|
+
say(deployments_table.print)
|
27
|
+
|
28
|
+
|
29
|
+
approvals = response[:approvals]
|
30
|
+
unless approvals.nil? || approvals.empty?
|
31
|
+
say("\nApprovals:")
|
32
|
+
approvals_table = EPC::TabularOutputter.new(approvals, [:id, :name, :approved, :approver_id, :approver_name])
|
33
|
+
say(approvals_table.print)
|
34
|
+
end
|
35
|
+
|
36
|
+
projects = response[:solution][:projects]
|
37
|
+
unless projects.nil? || projects.empty?
|
38
|
+
say("\n\nProjects details:")
|
39
|
+
projects.each do |project|
|
40
|
+
say("\n## #{project[:name]}")
|
41
|
+
project[:uri] = project[:uris].first unless project[:uris].nil?
|
42
|
+
projects_table = EPC::TabularOutputter.new([project], [:id, :name, :version, :status, :uri, :instances])
|
43
|
+
say(projects_table.print)
|
44
|
+
|
45
|
+
config_values = project[:config_values]
|
46
|
+
unless config_values.nil? || config_values.empty?
|
47
|
+
say("\nConfig values: ")
|
48
|
+
config_values_table = EPC::TabularOutputter.new(config_values, [:name, :value])
|
49
|
+
say(config_values_table.print)
|
50
|
+
end
|
51
|
+
say("\n\n")
|
52
|
+
end
|
53
|
+
end
|
54
|
+
return status
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module EPC::Command
|
2
|
+
class ShowGroupCommand < BaseCommand
|
3
|
+
def execute(group = nil)
|
4
|
+
raise FatalError, "You need to specify a group id/name" if group.nil?
|
5
|
+
|
6
|
+
if numeric?(group)
|
7
|
+
group_id = group.to_i
|
8
|
+
else
|
9
|
+
group_id = get_resource_id(EPC::Config::GROUPS_PATH, :name, group)
|
10
|
+
end
|
11
|
+
|
12
|
+
raise FatalError, "Could not determine group" if group_id.nil?
|
13
|
+
|
14
|
+
status, response, headers = client.get(EPC::Config::GROUPS_PATH + "/#{group_id}?include=users")
|
15
|
+
|
16
|
+
unless status.successful?
|
17
|
+
say("Request failed: [#{response[:message]}]")
|
18
|
+
return 1
|
19
|
+
end
|
20
|
+
|
21
|
+
group_table = EPC::TabularOutputter.new([response], [:id, :name])
|
22
|
+
users_table = EPC::TabularOutputter.new(response[:users], [:id, :name, :email])
|
23
|
+
|
24
|
+
say("\nGroup details: ")
|
25
|
+
say(group_table.print)
|
26
|
+
|
27
|
+
if response[:users].present?
|
28
|
+
say("\nGroup members: ")
|
29
|
+
say(users_table.print)
|
30
|
+
end
|
31
|
+
|
32
|
+
return status
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'time'
|
2
|
+
module EPC::Command
|
3
|
+
class ShowLibrarysetCommand < BaseCommand
|
4
|
+
|
5
|
+
def execute(library_set = nil)
|
6
|
+
if library_set.nil?
|
7
|
+
say("You must specify a library-set")
|
8
|
+
say(EPC::Help::COMMAND_USAGES[:show_libraryset])
|
9
|
+
return 1
|
10
|
+
end
|
11
|
+
|
12
|
+
if numeric?(library_set)
|
13
|
+
library_set_id = library_set.to_i
|
14
|
+
else
|
15
|
+
library_set_id = get_resource_id(EPC::Config::LIBRARY_SETS_PATH, :name, library_set)
|
16
|
+
end
|
17
|
+
|
18
|
+
if library_set_id.nil? || library_set_id == 0
|
19
|
+
say("Library set could not be determined")
|
20
|
+
return 1
|
21
|
+
end
|
22
|
+
|
23
|
+
status, response, headers = client.get(EPC::Config::LIBRARY_SETS_PATH + "/#{library_set_id}")
|
24
|
+
|
25
|
+
if status.failure?
|
26
|
+
say("Request failed: [#{response[:message]}]")
|
27
|
+
else
|
28
|
+
if options[:json].nil?
|
29
|
+
response[:language] = response[:library_language][:name] rescue nil
|
30
|
+
response[:created_by] = "#{response[:created_by][:name]}(#{response[:created_by][:id]})" rescue nil
|
31
|
+
response[:created_at] = Time.parse(response[:created_at]).strftime("%m/%d/%Y %I:%M%p") rescue nil
|
32
|
+
response[:updated_at] = Time.parse(response[:updated_at]).strftime("%m/%d/%Y %I:%M%p") rescue nil
|
33
|
+
set_table = EPC::TabularOutputter.new([response], [:id, :name, :language, :created_by, :created_at, :updated_at])
|
34
|
+
say(set_table.print)
|
35
|
+
|
36
|
+
libraries = response[:libraries]
|
37
|
+
unless libraries.empty?
|
38
|
+
say("\n")
|
39
|
+
libraries.each do |lib|
|
40
|
+
lib[:language] = lib[:library_language][:name] rescue nil
|
41
|
+
lib[:version] = lib[:library_version] rescue nil
|
42
|
+
end
|
43
|
+
libraries_table = EPC::TabularOutputter.new(libraries, [:id, :name, :language, :version, :group])
|
44
|
+
say(libraries_table.print)
|
45
|
+
end
|
46
|
+
else
|
47
|
+
say(response[:libraries].to_json)
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
return status
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'time'
|
2
|
+
module EPC::Command
|
3
|
+
class ShowProjectCommand < BaseCommand
|
4
|
+
|
5
|
+
def execute(project_name = nil)
|
6
|
+
path = "."
|
7
|
+
path = File.expand_path(path)
|
8
|
+
|
9
|
+
solution_name = @options[:solution_name]
|
10
|
+
|
11
|
+
solution_id, solution_name = infer_solution_context(solution_name, path)
|
12
|
+
project_id, project_name = infer_project_context(project_name, path, solution_id)
|
13
|
+
|
14
|
+
raise FatalError, "Project could not be found" if project_id.nil? || project_id == 0
|
15
|
+
|
16
|
+
status, response, message = client.get(EPC::Config::PROJECTS_PATH + "/#{project_id}?include=dependencies,roles,config_values")
|
17
|
+
if status.failure?
|
18
|
+
say("Request failed: [#{response[:message]}]")
|
19
|
+
return status
|
20
|
+
end
|
21
|
+
|
22
|
+
response[:created_at] = Time.parse(response[:created_at]).strftime("%m/%d/%Y %I:%M%p")
|
23
|
+
response[:last_build_date] = Time.parse(response[:last_build_date]).strftime("%m/%d/%Y %I:%M%p") unless response[:last_build_date].nil? || response[:last_build_date] == "N/A"
|
24
|
+
response[:last_push_date] = Time.parse(response[:last_push_date]).strftime("%m/%d/%Y %I:%M%p") unless response[:last_push_date].nil? || response[:last_push_date] == "N/A"
|
25
|
+
response[:last_build_status] = nil if response[:last_build_status] == "N/A" # temp hack
|
26
|
+
response[:last_build_status] = (response[:last_build_status] ? "BUILT" : "FAILED" rescue nil) unless response[:last_build_status].nil?
|
27
|
+
|
28
|
+
projects_table = EPC::TabularOutputter.new([response], {:id => "ID", :name => "NAME", :uri_name => "URI NAME", :created_at => "CREATED AT", :last_build_status => "BUILD STATUS", :last_build_date => "BUILD DATE", :last_build_version => "BUILD VERSION"})
|
29
|
+
|
30
|
+
unless response[:dependency_definitions].nil? || response[:dependency_definitions].empty?
|
31
|
+
dependencies = []
|
32
|
+
response[:dependency_definitions].each do |dep_def|
|
33
|
+
dependencies << {
|
34
|
+
id: dep_def[:dependency_id],
|
35
|
+
project_id: dep_def[:dependency][:id],
|
36
|
+
name: dep_def[:dependency][:name],
|
37
|
+
type: dep_def[:dependency_kind]
|
38
|
+
}
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
response[:last_push_by_id] = response[:last_push_by][:id]
|
43
|
+
response[:last_push_by_name] = response[:last_push_by][:name]
|
44
|
+
last_push_table = EPC::TabularOutputter.new([response], {:last_push_by_id => "USER ID", :last_push_by_name => "USER NAME", :last_push_date => "DATE"})
|
45
|
+
dependencies_table = EPC::TabularOutputter.new(dependencies, [:id, :project_id, :name, :type])
|
46
|
+
|
47
|
+
config_values_table = EPC::TabularOutputter.new(response[:config_values], [:id, :name, :no_override, :value, :value_type, :required])
|
48
|
+
roles_table = EPC::TabularOutputter.new(response[:roles], [:id, :name])
|
49
|
+
|
50
|
+
say("\nProject details:")
|
51
|
+
say(projects_table.print)
|
52
|
+
|
53
|
+
say("\nLast push info:")
|
54
|
+
say(last_push_table.print)
|
55
|
+
|
56
|
+
unless dependencies.nil? || dependencies.empty?
|
57
|
+
say("\nDependencies:")
|
58
|
+
say(dependencies_table.print)
|
59
|
+
end
|
60
|
+
|
61
|
+
unless response[:config_values].nil? || response[:config_values].empty?
|
62
|
+
say("\nConfig values:")
|
63
|
+
say(config_values_table.print)
|
64
|
+
end
|
65
|
+
|
66
|
+
unless response[:roles].nil? || response[:roles].empty?
|
67
|
+
say("\nRoles:")
|
68
|
+
say(roles_table.print)
|
69
|
+
end
|
70
|
+
return status
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module EPC::Command
|
2
|
+
class ShowProjecttypeCommand < BaseCommand
|
3
|
+
|
4
|
+
def execute(project_type = nil)
|
5
|
+
raise FatalError, "You must specify a project type id" if project_type.nil?
|
6
|
+
|
7
|
+
status, response, headers = client.get(EPC::Config::PROJECT_TYPES_PATH + "/#{project_type}")
|
8
|
+
|
9
|
+
if status.failure?
|
10
|
+
say("Request failed: [#{response[:message]}]")
|
11
|
+
else
|
12
|
+
type_table = EPC::TabularOutputter.new([response], [:id, :name, :runtime, :framework, :build_type])
|
13
|
+
say(type_table.print)
|
14
|
+
end
|
15
|
+
return status
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module EPC::Command
|
2
|
+
class ShowRoleCommand < BaseCommand
|
3
|
+
required_arguments_count 1, :message => "You need to specify a role id/name"
|
4
|
+
|
5
|
+
def execute(role = nil)
|
6
|
+
|
7
|
+
role_id = retrieve_system_role_identifier(role)
|
8
|
+
|
9
|
+
status, response, headers = client.get(EPC::Config::ROLES_PATH + "/#{role_id}?include=users,user_groups,grants")
|
10
|
+
|
11
|
+
unless status.successful?
|
12
|
+
say("Request failed: [#{response[:message]}]")
|
13
|
+
return 1
|
14
|
+
end
|
15
|
+
|
16
|
+
role_table = EPC::TabularOutputter.new([response], [:id, :name])
|
17
|
+
users_table = EPC::TabularOutputter.new(response[:users], [:id, :name])
|
18
|
+
user_groups_table = EPC::TabularOutputter.new(response[:user_groups], [:id, :name])
|
19
|
+
grants_table = EPC::TabularOutputter.new(response[:grants], [:id, :action, :secured_type, :secured_id])
|
20
|
+
|
21
|
+
say("Role:")
|
22
|
+
say(role_table.print)
|
23
|
+
say("\n")
|
24
|
+
|
25
|
+
if response[:users].present?
|
26
|
+
say("Users:")
|
27
|
+
say(users_table.print)
|
28
|
+
say("\n")
|
29
|
+
end
|
30
|
+
|
31
|
+
if response[:user_groups].present?
|
32
|
+
say("User groups:")
|
33
|
+
say(user_groups_table.print)
|
34
|
+
say("\n")
|
35
|
+
end
|
36
|
+
|
37
|
+
if response[:grants].present?
|
38
|
+
say("Grants:")
|
39
|
+
say(grants_table.print)
|
40
|
+
say("\n")
|
41
|
+
end
|
42
|
+
|
43
|
+
return status
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|