epc 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- 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 BindServiceCommand < BaseCommand
|
3
|
+
|
4
|
+
def execute(service = nil)
|
5
|
+
path = File.expand_path(".")
|
6
|
+
|
7
|
+
raise FatalError, "You must specify the service to be bound" if service.blank?
|
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
|
+
if numeric?(service)
|
16
|
+
service_version_id = service.to_i
|
17
|
+
else
|
18
|
+
service_version_id = get_resource_id(EPC::Config::SERVICE_VERSIONS_PATH, :label, service)
|
19
|
+
end
|
20
|
+
|
21
|
+
raise FatalError, "Project or service incorrectly specified" if service.nil? || service == 0 || project_id.nil?
|
22
|
+
|
23
|
+
status, response, headers = client.post(EPC::Config::PROJECTS_PATH + "/#{project_id}/add_service_version", {:version_id => service_version_id})
|
24
|
+
|
25
|
+
if status.successful?
|
26
|
+
say("Service bound.")
|
27
|
+
else
|
28
|
+
say("Request failed: [#{response[:message]}]")
|
29
|
+
end
|
30
|
+
|
31
|
+
return status
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
|
2
|
+
module EPC::Command
|
3
|
+
class BuildCommand < BaseCommand
|
4
|
+
|
5
|
+
|
6
|
+
def execute(*args)
|
7
|
+
path = "."
|
8
|
+
path = File.expand_path(path)
|
9
|
+
|
10
|
+
projects_data = {}
|
11
|
+
|
12
|
+
if @options[:no_poll].present? && @options[:timeout].present?
|
13
|
+
raise InputError, "You cannot specify both --nopoll and --timeout options at the same time"
|
14
|
+
end
|
15
|
+
|
16
|
+
@timeout = GIVEUP_TICKS
|
17
|
+
|
18
|
+
solution_id, solution_name = infer_solution_context(nil, path)
|
19
|
+
|
20
|
+
if EPC::Config.is_solution_dir?(path)
|
21
|
+
if args.empty?
|
22
|
+
proceed = ask_yn("You are building the [#{solution_name}] solution. Correct: [Yn]? ")
|
23
|
+
Dir.glob(path +"/*/").select{|dir| EPC::Config.is_project_dir?(dir)}.map{|pth| projects_data[EPC::Config.get_project_value(pth, "id")] = nil}
|
24
|
+
else
|
25
|
+
names = []
|
26
|
+
args.map{|e| e.split("=")}.each do |project_name, version|
|
27
|
+
if numeric?(project_name)
|
28
|
+
project_id = project_name.to_i
|
29
|
+
else
|
30
|
+
project_id, p_name = infer_project_context(project_name, path, solution_id)
|
31
|
+
end
|
32
|
+
raise FatalError, "Project not found.Please run this command with the correct project name." if project_id.nil? || project_id == 0
|
33
|
+
|
34
|
+
names << project_name
|
35
|
+
projects_data[project_id] = version
|
36
|
+
end
|
37
|
+
|
38
|
+
proceed = ask_yn("You are building the [#{names.join(",")}] projects belonging to the [#{solution_name}] solution. Correct: [Yn]? ")
|
39
|
+
end
|
40
|
+
|
41
|
+
elsif EPC::Config.is_project_dir?(path)
|
42
|
+
project_id, project_name = infer_project_context(project_name, path, false)
|
43
|
+
raise FatalError, "Project could not be inferred" if project_id.nil?
|
44
|
+
|
45
|
+
proceed = ask_yn("You are building the [#{project_name}] project belonging to the [#{solution_name}] solution. Correct: [Yn]? ")
|
46
|
+
projects_data[project_id] = (args.first rescue nil)
|
47
|
+
end
|
48
|
+
|
49
|
+
return 1 if (proceed.upcase == "N" rescue true )
|
50
|
+
|
51
|
+
|
52
|
+
parse_timeout_value
|
53
|
+
|
54
|
+
if projects_data.keys
|
55
|
+
created, id = create_build(projects_data, @options[:note])
|
56
|
+
if created && @options[:no_poll].nil?
|
57
|
+
say("Building - ")
|
58
|
+
return poll_for_build_status(id)
|
59
|
+
end
|
60
|
+
else
|
61
|
+
say("Failed to find the project ID in the EPC configuration. Aborting")
|
62
|
+
end
|
63
|
+
return 1
|
64
|
+
end
|
65
|
+
|
66
|
+
private
|
67
|
+
|
68
|
+
def create_build(project_data, note = nil)
|
69
|
+
versions = (project_data.reject{|k,v| v.nil? || v.empty?}.map{|k,v| {:project_id => k, :version => v}} rescue [])
|
70
|
+
status, response, headers = client.post("#{EPC::Config::BUILDS_PATH}", { :project_ids => project_data.keys, :project_versions => versions, :note => note})
|
71
|
+
if status == 202
|
72
|
+
say("Build already in progress. Retrieving build status")
|
73
|
+
return true, response[:id]
|
74
|
+
elsif status.successful?
|
75
|
+
say("Successfully kicked off a build with [#{target_url}]")
|
76
|
+
return true, response[:id]
|
77
|
+
else
|
78
|
+
say("Build kickoff failed [#{response[:message]}]. Aborting.")
|
79
|
+
return false
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module EPC::Command
|
2
|
+
class CreateConfigCommand < BaseCommand
|
3
|
+
CONFIG_LEVELS = {
|
4
|
+
:org => "Organization",
|
5
|
+
:runtime => "RuntimeEnvironment",
|
6
|
+
:stage => "DeploymentStage",
|
7
|
+
:solution => "Solution",
|
8
|
+
:project => "Project",
|
9
|
+
:user => "User"
|
10
|
+
}
|
11
|
+
|
12
|
+
def execute(target, *args)
|
13
|
+
raise FatalError, "You have to specify a key and its value." if args.empty? && @options[:file].nil?
|
14
|
+
|
15
|
+
path = File.expand_path(".")
|
16
|
+
|
17
|
+
@options[:value_type] = "text" if @options[:value_type].nil?
|
18
|
+
@options[:required] = false if @options[:required].nil?
|
19
|
+
|
20
|
+
config_type, config_id = extract_configuration_level(path, target)
|
21
|
+
|
22
|
+
raise FatalError, "You need to specify a config type" if config_type.blank?
|
23
|
+
|
24
|
+
params = []
|
25
|
+
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
|
33
|
+
else
|
34
|
+
args.each do |arg|
|
35
|
+
name, value = arg.split("=")
|
36
|
+
params << {:name => name, :value => value, :value_type => @options[:value_type], :configurable_id => config_id, :configurable_type => config_type, :required => options[:required], :no_override => @options[:no_override]}
|
37
|
+
if ["solution", "project"].include?(config_type.downcase) && @options[:stage].present?
|
38
|
+
params.last[:stage_name] = @options[:stage]
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
raise FatalError, "You must specify at least one config value" if params.nil? || params.empty?
|
44
|
+
|
45
|
+
status, response, headers = client.post(EPC::Config::CONFIGURATIONS_PATH, {:config_values => params})
|
46
|
+
|
47
|
+
if status.successful?
|
48
|
+
say("Configuration values saved.")
|
49
|
+
else
|
50
|
+
say("Request failed with message [#{response[:message]}]")
|
51
|
+
end
|
52
|
+
return status
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module EPC::Command
|
2
|
+
class CopyDeploymentCommand < BaseCommand
|
3
|
+
|
4
|
+
def execute(deployment_id = nil, stage = nil)
|
5
|
+
path = File.expand_path(".")
|
6
|
+
|
7
|
+
raise FatalError, "You must specify a deployment id and the stage name" if deployment_id.nil? || stage.nil?
|
8
|
+
|
9
|
+
status, response, headers = client.post(EPC::Config::DEPLOYMENTS_PATH + "/#{deployment_id}/copy", {:stage_name => stage})
|
10
|
+
|
11
|
+
if status.failure?
|
12
|
+
say("Request failed: [#{response[:message]}]")
|
13
|
+
else
|
14
|
+
say("Copied new deployment to the #{stage} stage. ID: #{response[:id]}")
|
15
|
+
end
|
16
|
+
|
17
|
+
return status
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module EPC::Command
|
2
|
+
class CreateCommand < BaseCommand
|
3
|
+
required_arguments_count 1, :message => "You have to specify an object for the create command"
|
4
|
+
|
5
|
+
def execute(object_type = nil, *params)
|
6
|
+
klass = "EPC::Command::Create#{object_type.to_s.gsub("-","").capitalize}Command"
|
7
|
+
params = normalize_params(params)
|
8
|
+
command = eval(klass).new(client, @options)
|
9
|
+
command.go(*params)
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module EPC::Command
|
2
|
+
class CreateDependencyCommand < BaseCommand
|
3
|
+
|
4
|
+
def execute(parent = nil)
|
5
|
+
path = File.expand_path(".")
|
6
|
+
|
7
|
+
solution_name = @options[:solution_name]
|
8
|
+
project_name = parent
|
9
|
+
|
10
|
+
solution_id, solution_name = infer_solution_context(solution_name, path)
|
11
|
+
project_id, project_name = infer_project_context(project_name, path, solution_id)
|
12
|
+
|
13
|
+
if project_id.nil? || project_id == 0 || solution_id.nil? || solution_id == 0
|
14
|
+
say("Project/solution could not be inferred")
|
15
|
+
say(EPC::Help::COMMAND_USAGES[:create_dependency])
|
16
|
+
return 1
|
17
|
+
end
|
18
|
+
|
19
|
+
if numeric?(@options[:dependency])
|
20
|
+
dependency_id = @options[:dependency].to_i
|
21
|
+
else
|
22
|
+
dependency_id = get_resource_id(EPC::Config::SOLUTIONS_PATH + "/#{solution_id}/projects", "name", @options[:dependency] )
|
23
|
+
end
|
24
|
+
|
25
|
+
if dependency_id.nil? || dependency_id == 0
|
26
|
+
say("Dependency could not be inferred")
|
27
|
+
say(EPC::Help::COMMAND_USAGES[:create_dependency])
|
28
|
+
return 1
|
29
|
+
end
|
30
|
+
|
31
|
+
dependency_type = @options[:dependency_type] || 1
|
32
|
+
|
33
|
+
status, response, headers = client.post(EPC::Config::PROJECTS_PATH + "/#{project_id}/add_dependency",
|
34
|
+
{:dependency_id => dependency_id, :dependency_kind => dependency_type})
|
35
|
+
if status.successful?
|
36
|
+
say("Dependency defined")
|
37
|
+
else
|
38
|
+
say("Request failed: [#{response[:message]}]")
|
39
|
+
end
|
40
|
+
return status
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module EPC::Command
|
2
|
+
class DefineServiceCommand < BaseCommand
|
3
|
+
|
4
|
+
def execute(service_name = nil)
|
5
|
+
if service_name.nil?
|
6
|
+
say("You must specify a name for the service")
|
7
|
+
say(EPC::Help::COMMAND_USAGES[:define_service])
|
8
|
+
return 1
|
9
|
+
end
|
10
|
+
|
11
|
+
if @options[:service_type].nil?
|
12
|
+
say("You must specify a service type with -t option.")
|
13
|
+
return 1
|
14
|
+
end
|
15
|
+
|
16
|
+
if numeric?(@options[:service_type])
|
17
|
+
service_type_id = @options[:service_type].to_i
|
18
|
+
else
|
19
|
+
service_type_id = get_resource_id(EPC::Config::SERVICE_TYPES_PATH, :name, @options[:service_type])
|
20
|
+
end
|
21
|
+
|
22
|
+
if service_type_id.nil? || service_type_id == 0
|
23
|
+
say("#{@options[:service_type]} service type could not be found.")
|
24
|
+
return 1
|
25
|
+
end
|
26
|
+
|
27
|
+
status, response, headers = client.post(EPC::Config::SERVICE_DEFINITIONS_PATH, {:name => service_name, :type_id => service_type_id})
|
28
|
+
if status.failure?
|
29
|
+
say("Service definition failed with: [#{response['message']}]")
|
30
|
+
else
|
31
|
+
say("#{service_name} has been defined.")
|
32
|
+
end
|
33
|
+
return status
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module EPC::Command
|
2
|
+
class DeleteConfigCommand < BaseCommand
|
3
|
+
|
4
|
+
def execute(*args)
|
5
|
+
if args.empty?
|
6
|
+
say("You must specify the key you wish to delete.")
|
7
|
+
return 1
|
8
|
+
end
|
9
|
+
|
10
|
+
path = "."
|
11
|
+
path = File.expand_path(path)
|
12
|
+
|
13
|
+
config_type, config_id = extract_configuration_level(path, @options)
|
14
|
+
request_path = EPC::Config::CONFIGURATIONS_PATH+"/#{config_type}/#{config_id}"
|
15
|
+
|
16
|
+
if ["solution", "project"].include?(config_type.downcase) && !@options[:stage_name].nil?
|
17
|
+
request_path += "/#{@options[:stage_name]}"
|
18
|
+
end
|
19
|
+
|
20
|
+
status, response, headers = client.get(request_path)
|
21
|
+
|
22
|
+
raise FatalError, "Configuration retrieval failed with [#{response[:message]}]" if status.failure?
|
23
|
+
|
24
|
+
existing_keys = response
|
25
|
+
|
26
|
+
if existing_keys.empty?
|
27
|
+
say("There are no configurations defined for this project.")
|
28
|
+
return 1
|
29
|
+
end
|
30
|
+
|
31
|
+
args.each do |key|
|
32
|
+
key_id = existing_keys.detect{|k| k[:name] == key }[:id] rescue nil
|
33
|
+
if key_id.nil?
|
34
|
+
say("#{key} is not defined.")
|
35
|
+
return 1
|
36
|
+
end
|
37
|
+
|
38
|
+
question = "Are you sure you want to delete the config value [#{key}] defined on [#{config_type}-#{config_id}"
|
39
|
+
if ["solution", "project"].include?(config_type.downcase) && !@options[:stage].nil?
|
40
|
+
question += "-#{@options[:stage]}"
|
41
|
+
end
|
42
|
+
|
43
|
+
question += "]. Correct? [Yn] "
|
44
|
+
|
45
|
+
proceed = ask_yn(question)
|
46
|
+
if proceed.upcase == 'N'
|
47
|
+
next
|
48
|
+
end
|
49
|
+
|
50
|
+
status, response, headers = client.delete(EPC::Config::CONFIGURATIONS_PATH + "/#{key_id}")
|
51
|
+
if status.failure?
|
52
|
+
say("Request failed: [#{response[:message]}]")
|
53
|
+
else
|
54
|
+
say("#{key} succesfully removed.")
|
55
|
+
end
|
56
|
+
return status
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module EPC::Command
|
2
|
+
class DeleteDependencyCommand < BaseCommand
|
3
|
+
|
4
|
+
def execute(dependency_id = nil)
|
5
|
+
path = File.expand_path(".")
|
6
|
+
|
7
|
+
solution_name = @options[:solution_name]
|
8
|
+
project_name = @options[:project_name]
|
9
|
+
|
10
|
+
solution_id, solution_name = infer_solution_context(solution_name, path)
|
11
|
+
project_id, project_name = infer_project_context(project_name, path, solution_id)
|
12
|
+
|
13
|
+
if dependency_id.blank?
|
14
|
+
say("You must specify a dependency_id")
|
15
|
+
say(EPC::Help::COMMAND_USAGES[:delete_dependency])
|
16
|
+
return 1
|
17
|
+
end
|
18
|
+
|
19
|
+
if project_id.blank? || project_id == 0
|
20
|
+
say("Project could not be inferred")
|
21
|
+
say(EPC::Help::COMMAND_USAGES[:delete_dependency])
|
22
|
+
return 1
|
23
|
+
end
|
24
|
+
|
25
|
+
proceed = ask_yn("Are you sure you want to delete the dependency with id = [#{dependency_id}]. Correct? [Yn] ")
|
26
|
+
if proceed.upcase == 'N'
|
27
|
+
return 1
|
28
|
+
end
|
29
|
+
|
30
|
+
status, response, headers = client.delete(EPC::Config::PROJECTS_PATH + "/#{project_id}/remove_dependency/#{dependency_id}")
|
31
|
+
if status.successful?
|
32
|
+
say("Dependency deleted")
|
33
|
+
else
|
34
|
+
say("Request failed: [#{response[:message]}]")
|
35
|
+
end
|
36
|
+
return status
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module EPC::Command
|
2
|
+
class DeleteGroupCommand < BaseCommand
|
3
|
+
|
4
|
+
def execute(group = nil)
|
5
|
+
if group.nil?
|
6
|
+
say("You need to specify a group id/name")
|
7
|
+
say(EPC::Help::COMMAND_USAGES[:delete_group])
|
8
|
+
return 1
|
9
|
+
end
|
10
|
+
|
11
|
+
proceed = ask_yn("Are you sure you want to delete the [#{group}] group? [Yn] ")
|
12
|
+
if proceed.upcase == "N"
|
13
|
+
return 1
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
if numeric?(group)
|
18
|
+
group_id = group.to_i
|
19
|
+
else
|
20
|
+
group_id = get_resource_id(EPC::Config::GROUPS_PATH, :name, group)
|
21
|
+
end
|
22
|
+
|
23
|
+
if group_id.nil?
|
24
|
+
say("Group could not be determined")
|
25
|
+
return 1
|
26
|
+
end
|
27
|
+
|
28
|
+
status, response, headers = client.delete(EPC::Config::GROUPS_PATH + "/#{group_id}")
|
29
|
+
|
30
|
+
if status.successful?
|
31
|
+
say("Group deleted")
|
32
|
+
else
|
33
|
+
say("Request failed: [#{response[:message]}]")
|
34
|
+
end
|
35
|
+
|
36
|
+
return status
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module EPC::Command
|
2
|
+
class DeleteLibraryCommand < BaseCommand
|
3
|
+
|
4
|
+
def execute(library_name = nil, version = nil, group = nil)
|
5
|
+
raise FatalError, "You must specify a library name" if library_name.nil?
|
6
|
+
|
7
|
+
proceed = ask_yn("Are you sure you want to delete the [#{library_name}] library? [Yn] ")
|
8
|
+
if proceed.upcase == 'N'
|
9
|
+
return 1
|
10
|
+
end
|
11
|
+
|
12
|
+
if numeric?(library_name)
|
13
|
+
library_id = library_name.to_i
|
14
|
+
else
|
15
|
+
library_id = retrieve_libraries([{:name => library_name, :library_version => version, :group => group}]).first rescue nil
|
16
|
+
end
|
17
|
+
|
18
|
+
raise FatalError, "Library could not be determined" if library_id.nil? || library_id == 0
|
19
|
+
|
20
|
+
status, response, headers = client.delete(EPC::Config::LIBRARIES_PATH + "/#{library_id}")
|
21
|
+
if status.successful?
|
22
|
+
say("Library deleted")
|
23
|
+
else
|
24
|
+
say("Request failed: [#{response[:message]}]")
|
25
|
+
end
|
26
|
+
return status
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|