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,35 @@
|
|
1
|
+
module EPC::Command
|
2
|
+
class DetachLibraryCommand < BaseCommand
|
3
|
+
|
4
|
+
def execute(name = nil, version = nil, group = nil)
|
5
|
+
path = File.expand_path(".")
|
6
|
+
|
7
|
+
raise FatalError, "You must specify the library to be detached." if name.nil?
|
8
|
+
|
9
|
+
solution_name = @options[:solution_name]
|
10
|
+
project_name = @options[:project_name]
|
11
|
+
|
12
|
+
solution_id, solution_name = infer_solution_context(solution_name, path)
|
13
|
+
project_id, project_name = infer_project_context(project_name, path, solution_id)
|
14
|
+
|
15
|
+
raise FatalError, "Project could not be inferred" if project_id.nil?
|
16
|
+
|
17
|
+
if numeric?(name)
|
18
|
+
library_id = name.to_i
|
19
|
+
else
|
20
|
+
library_id = retrieve_libraries([{:name => name, :library_version => version, :group => group}]).first rescue nil
|
21
|
+
end
|
22
|
+
|
23
|
+
raise FatalError, "Could not determine library" if library_id.nil?
|
24
|
+
|
25
|
+
status, response, headers = client.delete(EPC::Config::PROJECTS_PATH + "/#{project_id}/detach_library/#{library_id}")
|
26
|
+
|
27
|
+
if status.successful?
|
28
|
+
say("Library detached from project.")
|
29
|
+
else
|
30
|
+
say("Request failed: [#{response[:message]}]")
|
31
|
+
end
|
32
|
+
return status
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module EPC::Command
|
2
|
+
class CreateGroupCommand < BaseCommand
|
3
|
+
|
4
|
+
def execute(*params)
|
5
|
+
name = params[1]
|
6
|
+
|
7
|
+
raise FatalError, "You need to specify a name for the group" if name.blank?
|
8
|
+
|
9
|
+
status, response, headers = client.post(EPC::Config::GROUPS_PATH, {:name => name})
|
10
|
+
|
11
|
+
if status.successful?
|
12
|
+
say("Group [#{name}] created")
|
13
|
+
else
|
14
|
+
say("Failed to create [#{name}] group: [#{response[:message]}]")
|
15
|
+
end
|
16
|
+
|
17
|
+
return status
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module EPC::Command
|
2
|
+
class CreateLibraryCommand < BaseCommand
|
3
|
+
|
4
|
+
def execute(target = nil, *args)
|
5
|
+
|
6
|
+
raise FatalError, "Parameters incorrectly specified" if args.size < 3
|
7
|
+
|
8
|
+
params = {}
|
9
|
+
params[:name] = args[0]
|
10
|
+
|
11
|
+
if numeric?(args[1])
|
12
|
+
params[:language_id] = args[1].to_i
|
13
|
+
else
|
14
|
+
params[:language_id] = get_resource_id(EPC::Config::LIBRARY_LANGUAGES_PATH, :name, args[1], :case_sensitivity => false)
|
15
|
+
end
|
16
|
+
|
17
|
+
raise InputError, "Unable to determine library language" if params[:language_id].nil? || params[:language_id] == 0
|
18
|
+
|
19
|
+
params[:library_version] = args[2]
|
20
|
+
params[:group] = args[3]
|
21
|
+
params[:sha1] = sha1(@options[:file]) if @options[:file]
|
22
|
+
params[:scope] = @options[:scope] if @options[:scope]
|
23
|
+
|
24
|
+
status, response, headers = client.post(EPC::Config::LIBRARIES_PATH, params)
|
25
|
+
if status.successful?
|
26
|
+
say("Created library [#{args[0]}] with ID [#{response[:id]}]")
|
27
|
+
upload_library(@options[:file], response[:url], response[:signature]) if @options[:file]
|
28
|
+
else
|
29
|
+
say("Request failed: [#{response[:message]}]")
|
30
|
+
end
|
31
|
+
return status
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
def upload_library(file, url, signature)
|
36
|
+
status, response, headers = http_client.post(url, { :file => File.new(file, "rb") }, nil, { 'X-AGILEMETHODS-SIGNATURE' => signature }, true )
|
37
|
+
if status.successful?
|
38
|
+
say("Successfully pushed library to the repository")
|
39
|
+
else
|
40
|
+
say("Failed to push the library to the repository [status = #{status}]")
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module EPC::Command
|
2
|
+
class CreateLibrarylanguageCommand < BaseCommand
|
3
|
+
|
4
|
+
def execute(target = nil, *names)
|
5
|
+
|
6
|
+
raise FatalError, "You need to specify a name for the language" if names.blank?
|
7
|
+
|
8
|
+
failures = []
|
9
|
+
names.each do |name|
|
10
|
+
status, response, headers = client.post(EPC::Config::LIBRARY_LANGUAGES_PATH, {:name => name})
|
11
|
+
|
12
|
+
if status.successful?
|
13
|
+
say("Language [#{name}] added")
|
14
|
+
failures << false
|
15
|
+
else
|
16
|
+
say("Failed to create [#{name}] language: [#{response[:message]}]")
|
17
|
+
failures << true
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
failures.all? ? 1 : 0
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module EPC::Command
|
2
|
+
class CreateLibrarysetCommand < BaseCommand
|
3
|
+
|
4
|
+
def execute(*params)
|
5
|
+
|
6
|
+
set = params[1]
|
7
|
+
language = params[2]
|
8
|
+
|
9
|
+
raise FatalError, "You need to specify a name for the set" if set.blank?
|
10
|
+
|
11
|
+
raise FatalError, "You need to specify a language" if language.blank?
|
12
|
+
|
13
|
+
params = {}
|
14
|
+
params[:name] = set
|
15
|
+
|
16
|
+
if numeric?(language)
|
17
|
+
language_id = language.to_i
|
18
|
+
else
|
19
|
+
language_id = get_resource_id(EPC::Config::LIBRARY_LANGUAGES_PATH, :name, language, :case_sensitivity => false)
|
20
|
+
end
|
21
|
+
params[:language_id] = language_id
|
22
|
+
|
23
|
+
status, response, headers = client.post(EPC::Config::LIBRARY_SETS_PATH, params)
|
24
|
+
if status.successful?
|
25
|
+
say("Set [#{set}] created")
|
26
|
+
set_id = response[:id]
|
27
|
+
|
28
|
+
if @options[:file].present?
|
29
|
+
libraries = EPC::Config.read_content_as_json(@options[:file])
|
30
|
+
libraries = libraries.map{|h| {:name => h["name"], :library_version => h["library_version"], :group => h["group"]}}
|
31
|
+
lib_ids = retrieve_libraries(libraries)
|
32
|
+
|
33
|
+
failures = []
|
34
|
+
lib_ids.each do |lib_id|
|
35
|
+
status, response, headers = client.post(EPC::Config::LIBRARY_SETS_PATH + "/#{set_id}/attach_library", :library_id => lib_id)
|
36
|
+
if status.successful?
|
37
|
+
say("Library [#{lib_id}] added to set")
|
38
|
+
failures << false
|
39
|
+
else
|
40
|
+
say("Failed to add [#{lib_id}]: [#{response[:message]}]")
|
41
|
+
failures << true
|
42
|
+
end
|
43
|
+
end
|
44
|
+
return failures.all? ? 1 : 0
|
45
|
+
end
|
46
|
+
else
|
47
|
+
say("Request failed: [#{response[:message]}]")
|
48
|
+
end
|
49
|
+
|
50
|
+
return status
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module EPC::Command
|
2
|
+
class ListApprovalsCommand < BaseCommand
|
3
|
+
|
4
|
+
def execute(deployment_id = nil)
|
5
|
+
path = File.expand_path(".")
|
6
|
+
|
7
|
+
if deployment_id.nil?
|
8
|
+
say("You must specify a deployment id")
|
9
|
+
say(EPC::Help::COMMAND_USAGES[:list_approvals])
|
10
|
+
return 1
|
11
|
+
end
|
12
|
+
|
13
|
+
status, response, headers = client.get(EPC::Config::DEPLOYMENTS_PATH + "/#{deployment_id}/approvals")
|
14
|
+
|
15
|
+
if status.failure?
|
16
|
+
say("Request failed: [#{response[:message]}]")
|
17
|
+
elsif response.empty?
|
18
|
+
say("No approvals have been defined")
|
19
|
+
else
|
20
|
+
approvals_table = EPC::TabularOutputter.new(response, [:id, :name, :approved, :approver_id, :approver_name, :confirmed_at])
|
21
|
+
say(approvals_table.print)
|
22
|
+
end
|
23
|
+
return status
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module EPC::Command
|
2
|
+
class ListAttachedlibrariesCommand < BaseCommand
|
3
|
+
|
4
|
+
def execute(project_name = nil)
|
5
|
+
path = File.expand_path(".")
|
6
|
+
|
7
|
+
solution_name = @options[:solution_name]
|
8
|
+
|
9
|
+
solution_id, solution_name = infer_solution_context(solution_name, path)
|
10
|
+
project_id, project_name = infer_project_context(project_name, path, solution_id)
|
11
|
+
|
12
|
+
if project_id.nil? || project_id == 0
|
13
|
+
say(EPC::Help::COMMAND_USAGES[:list_attachedlibraries])
|
14
|
+
return 1
|
15
|
+
end
|
16
|
+
|
17
|
+
status, response, headers = client.get(EPC::Config::PROJECTS_PATH + "/#{project_id}/libraries")
|
18
|
+
|
19
|
+
if status.failure?
|
20
|
+
say("Request failed: [#{response[:message]}]")
|
21
|
+
elsif response.empty?
|
22
|
+
say("No libraries are attached to this project.")
|
23
|
+
say("You can bind them with epc attach library")
|
24
|
+
else
|
25
|
+
if @options[:json].nil?
|
26
|
+
response.each do |resp|
|
27
|
+
resp[:version] = resp[:library_version]
|
28
|
+
end
|
29
|
+
|
30
|
+
libraries_table = EPC::TabularOutputter.new(response, [:id, :name, :language, :scope, :version, :group])
|
31
|
+
|
32
|
+
say("Attached libraries: ")
|
33
|
+
say(libraries_table.print)
|
34
|
+
else
|
35
|
+
say(response.to_json)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
return status
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module EPC::Command
|
2
|
+
class ListBoundservicesCommand < BaseCommand
|
3
|
+
|
4
|
+
def execute(project_name = nil)
|
5
|
+
path = File.expand_path(".")
|
6
|
+
|
7
|
+
solution_name = @options[:solution_name]
|
8
|
+
|
9
|
+
solution_id, solution_name = infer_solution_context(solution_name, path)
|
10
|
+
project_id, project_name = infer_project_context(project_name, path, solution_id)
|
11
|
+
|
12
|
+
if project_id.nil? || project_id == 0
|
13
|
+
say(EPC::Help::COMMAND_USAGES[:list_boundservices])
|
14
|
+
return 1
|
15
|
+
end
|
16
|
+
|
17
|
+
status, response, headers = client.get(EPC::Config::PROJECTS_PATH + "/#{project_id}/service_versions")
|
18
|
+
|
19
|
+
if status.failure?
|
20
|
+
say("Request failed: [#{response[:message]}]")
|
21
|
+
elsif response.empty?
|
22
|
+
say("No services are bound to this project.")
|
23
|
+
say("You can bind them with epc bind project")
|
24
|
+
else
|
25
|
+
response.each do |resp|
|
26
|
+
resp[:label] = resp[:service_version][:label]
|
27
|
+
resp[:definition_name] = resp[:service_version][:service_definition][:name]
|
28
|
+
end
|
29
|
+
|
30
|
+
services_table = EPC::TabularOutputter.new(response, [:id, :label, :definition_name])
|
31
|
+
|
32
|
+
say("Bound services:")
|
33
|
+
say(services_table.print)
|
34
|
+
end
|
35
|
+
return status
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module EPC::Command
|
2
|
+
class ListConfigCommand < BaseCommand
|
3
|
+
|
4
|
+
def execute(target = nil)
|
5
|
+
sol_or_project_configs = false
|
6
|
+
|
7
|
+
path = File.expand_path(".")
|
8
|
+
|
9
|
+
config_type, config_id = extract_configuration_level(path, target)
|
10
|
+
|
11
|
+
raise FatalError, "Configuration context could not inferred" if config_type.nil?
|
12
|
+
|
13
|
+
request_path = EPC::Config::CONFIGURATIONS_PATH+"/#{config_type}/#{config_id}"
|
14
|
+
|
15
|
+
if ["solution", "project"].include?(config_type.downcase) && @options[:stage].present?
|
16
|
+
request_path += "/#{@options[:stage]}"
|
17
|
+
elsif ["solution", "project"].include?(config_type.downcase) && @options[:stage].blank?
|
18
|
+
sol_or_project_configs = true
|
19
|
+
end
|
20
|
+
|
21
|
+
title = "#{config_type}"
|
22
|
+
if config_type == "Solution" && EPC::Config.is_solution_dir?(path) && EPC::Config.get_solution_value(path, "id") == config_id
|
23
|
+
title += "-#{EPC::Config.get_solution_value(path, "name")}"
|
24
|
+
elsif config_type == "Project" && EPC::Config.is_project_dir?(path) && EPC::Config.get_project_value(path, "id") == config_id
|
25
|
+
title += "-#{EPC::Config.get_project_value(path, "name")}"
|
26
|
+
end
|
27
|
+
title += "(#{config_id})"
|
28
|
+
if !@options[:stage].nil? && config_type != "DeploymentStage"
|
29
|
+
title += "/#{@options[:stage]}"
|
30
|
+
end
|
31
|
+
get_configs_from(request_path, title)
|
32
|
+
|
33
|
+
if sol_or_project_configs
|
34
|
+
stages = %w(Development Testing Staging Production)
|
35
|
+
stages.each do |stage|
|
36
|
+
get_configs_from(request_path + "/#{stage}", "#{title}/#{stage}")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
return @status
|
40
|
+
end
|
41
|
+
|
42
|
+
def get_configs_from(path, title)
|
43
|
+
status, response, headers = client.get(path)
|
44
|
+
@status = status
|
45
|
+
if status.failure?
|
46
|
+
say("Configuration retrieval failed with [#{response[:message]}]")
|
47
|
+
return false
|
48
|
+
end
|
49
|
+
|
50
|
+
if response.empty?
|
51
|
+
say("No configuration keys have been defined for #{title}.")
|
52
|
+
return []
|
53
|
+
end
|
54
|
+
|
55
|
+
config_table = EPC::TabularOutputter.new(response, [:name, :value, :value_type, :required])
|
56
|
+
say("\n" + title)
|
57
|
+
say(config_table.print)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module EPC::Command
|
2
|
+
class ListDependenciesCommand < BaseCommand
|
3
|
+
|
4
|
+
def execute(project_name = nil)
|
5
|
+
path = File.expand_path(".")
|
6
|
+
|
7
|
+
solution_name = @options[:solution_name]
|
8
|
+
|
9
|
+
solution_id, solution_name = infer_solution_context(solution_name, path)
|
10
|
+
project_id, project_name = infer_project_context(project_name, path, solution_id)
|
11
|
+
|
12
|
+
if project_id.nil?
|
13
|
+
say("Project could not be inferred")
|
14
|
+
say(EPC::Help::COMMAND_USAGES[:list_dependencies])
|
15
|
+
return 1
|
16
|
+
end
|
17
|
+
|
18
|
+
status, response, headers = client.get(EPC::Config::PROJECTS_PATH + "/#{project_id}/list_dependencies")
|
19
|
+
if status.failure?
|
20
|
+
say("Request failed: [#{response[:message]}]")
|
21
|
+
elsif response.empty?
|
22
|
+
say("Project [#{project_name}] has no dependencies")
|
23
|
+
else
|
24
|
+
response.each do |resp|
|
25
|
+
resp[:dependency_kind] = dependency_type(resp[:dependency_kind])
|
26
|
+
end
|
27
|
+
|
28
|
+
dependencies_table = EPC::TabularOutputter.new(response, [:id, :dependency_id, :dependency_name, :dependency_kind])
|
29
|
+
say(dependencies_table.print)
|
30
|
+
end
|
31
|
+
return status
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def dependency_type(kind)
|
38
|
+
return "compile" if kind == 1
|
39
|
+
return "runtime" if kind == 2
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
|
2
|
+
module EPC::Command
|
3
|
+
class ListDeploymentsCommand < BaseCommand
|
4
|
+
|
5
|
+
def execute(*args)
|
6
|
+
path = File.expand_path(".")
|
7
|
+
|
8
|
+
|
9
|
+
if @options[:solution_name].present?
|
10
|
+
name = @options[:solution_name]
|
11
|
+
if numeric?(name)
|
12
|
+
id = name.to_i
|
13
|
+
else
|
14
|
+
id = get_resource_id(EPC::Config::SOLUTIONS_PATH, :name, name)
|
15
|
+
end
|
16
|
+
url = EPC::Config::SOLUTIONS_PATH + "/#{id}/deployments"
|
17
|
+
elsif @options[:stage_name].present?
|
18
|
+
name = @options[:stage_name]
|
19
|
+
if numeric?(name)
|
20
|
+
id = name.to_i
|
21
|
+
else
|
22
|
+
id = get_resource_id(EPC::Config::DEPLOYMENT_STAGES_PATH, :name, name, :case_sensitivity => false)
|
23
|
+
end
|
24
|
+
url = EPC::Config::DEPLOYMENT_STAGES_PATH + "/#{id}/deployments"
|
25
|
+
|
26
|
+
elsif @options[:user_name].present?
|
27
|
+
name = @options[:user_name]
|
28
|
+
if numeric?(name)
|
29
|
+
id = name.to_i
|
30
|
+
else
|
31
|
+
id = get_resource_id(EPC::Config::USERS_PATH, :name, name)
|
32
|
+
end
|
33
|
+
url = EPC::Config::USERS_PATH + "/#{id}/deployments"
|
34
|
+
end
|
35
|
+
|
36
|
+
if id.nil?
|
37
|
+
if EPC::Config.is_solution_dir?(path) || EPC::Config.is_project_dir?(path)
|
38
|
+
id, name = infer_solution_context(nil, path)
|
39
|
+
if id.present?
|
40
|
+
url = EPC::Config::SOLUTIONS_PATH + "/#{id}/deployments"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
raise FatalError, "Solution/stage/deployer could not be inferred." if id.nil?
|
46
|
+
|
47
|
+
status, response, headers = client.get(url)
|
48
|
+
|
49
|
+
if status.failure?
|
50
|
+
say("Deployments retrieval failed with [#{response[:message]}]")
|
51
|
+
elsif response.empty?
|
52
|
+
say("You have no deployments created. You can create them with epc create deployment.")
|
53
|
+
else
|
54
|
+
response = response.select{|d| d[:status] == @options[:status]} unless @options[:status].nil?
|
55
|
+
if response.empty?
|
56
|
+
say("You have no deployments created. You can create them with epc create deployment.")
|
57
|
+
return 0
|
58
|
+
end
|
59
|
+
response.sort!{|a, b| b[:id] <=> a[:id]}
|
60
|
+
deployments_table = EPC::TabularOutputter.new(response, {:id => "ID", :deployer_name => "DEPLOYER", :solution_name => "SOLUTION", :deployment_stage_name => "STAGE", :status => "STATUS"})
|
61
|
+
say(deployments_table.print)
|
62
|
+
end
|
63
|
+
return status
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
end
|