ey-core 3.4.0 → 3.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.ruby-version +1 -1
- data/.travis.yml +1 -0
- data/CHANGELOG.md +27 -5
- data/Gemfile +0 -1
- data/README.md +65 -8
- data/Rakefile +4 -1
- data/ey-core.gemspec +9 -5
- data/features/accounts.feature +13 -0
- data/features/applications.feature +29 -0
- data/features/current_user.feature +14 -0
- data/features/docker_registry_credentials.feature +21 -0
- data/features/environment_variables.feature +54 -0
- data/features/environments.feature +30 -0
- data/features/init.feature +6 -0
- data/features/login.feature +6 -0
- data/features/scp.feature +6 -0
- data/features/step_definitions/accounts_steps.rb +37 -0
- data/features/step_definitions/applications_steps.rb +39 -0
- data/features/step_definitions/current_user_steps.rb +11 -0
- data/features/step_definitions/deprecated_command_steps.rb +3 -0
- data/features/step_definitions/docker_registry_credentials_steps.rb +3 -0
- data/features/step_definitions/environment_variables_steps.rb +51 -0
- data/features/step_definitions/environments_steps.rb +52 -0
- data/features/step_definitions/version_steps.rb +3 -0
- data/features/support/account_helpers.rb +89 -0
- data/features/support/app_helpers.rb +19 -0
- data/features/support/aruba.rb +1 -0
- data/features/support/boilerplate.rb +1 -0
- data/features/support/client_helpers.rb +36 -0
- data/features/support/config_file_helpers.rb +42 -0
- data/features/support/core.rb +19 -0
- data/features/support/deployment_helpers.rb +19 -0
- data/features/support/env.rb +40 -0
- data/features/support/environment_helpers.rb +23 -0
- data/features/support/environment_variable_helpers.rb +20 -0
- data/features/support/fake_kernel.rb +23 -0
- data/features/support/io.rb +5 -0
- data/features/support/mock_api.rb +20 -0
- data/features/support/output_helpers.rb +7 -0
- data/features/support/resource_helpers.rb +201 -0
- data/features/support/server_helpers.rb +27 -0
- data/features/version.feature +8 -0
- data/features/whoami.feature +14 -0
- data/lib/ey-core/cli/deploy.rb +4 -4
- data/lib/ey-core/cli/docker_registry_login.rb +29 -0
- data/lib/ey-core/cli/environment_variables.rb +71 -0
- data/lib/ey-core/cli/helpers/core.rb +29 -0
- data/lib/ey-core/cli/main.rb +5 -4
- data/lib/ey-core/cli/servers.rb +35 -17
- data/lib/ey-core/cli/ssh.rb +1 -1
- data/lib/ey-core/client.rb +35 -0
- data/lib/ey-core/client/mock.rb +5 -0
- data/lib/ey-core/collections/auto_scaling_alarms.rb +8 -0
- data/lib/ey-core/collections/auto_scaling_groups.rb +8 -0
- data/lib/ey-core/collections/auto_scaling_policies.rb +33 -0
- data/lib/ey-core/collections/container_clusters.rb +9 -0
- data/lib/ey-core/collections/container_service_deployments.rb +17 -0
- data/lib/ey-core/collections/environment_variables.rb +8 -0
- data/lib/ey-core/collections/servers.rb +4 -0
- data/lib/ey-core/models/account.rb +10 -0
- data/lib/ey-core/models/address.rb +2 -0
- data/lib/ey-core/models/application.rb +1 -0
- data/lib/ey-core/models/auto_scaling_alarm.rb +54 -0
- data/lib/ey-core/models/auto_scaling_group.rb +75 -0
- data/lib/ey-core/models/base_auto_scaling_policy.rb +61 -0
- data/lib/ey-core/models/container_service_deployment.rb +17 -0
- data/lib/ey-core/models/environment.rb +60 -47
- data/lib/ey-core/models/environment_variable.rb +29 -0
- data/lib/ey-core/models/request.rb +6 -0
- data/lib/ey-core/models/server.rb +2 -0
- data/lib/ey-core/models/simple_auto_scaling_policy.rb +24 -0
- data/lib/ey-core/models/step_auto_scaling_policy.rb +24 -0
- data/lib/ey-core/models/target_auto_scaling_policy.rb +24 -0
- data/lib/ey-core/requests/boot_environment.rb +1 -1
- data/lib/ey-core/requests/create_account.rb +5 -0
- data/lib/ey-core/requests/create_address.rb +1 -0
- data/lib/ey-core/requests/create_application.rb +8 -7
- data/lib/ey-core/requests/create_auto_scaling_alarm.rb +69 -0
- data/lib/ey-core/requests/create_auto_scaling_group.rb +62 -0
- data/lib/ey-core/requests/create_auto_scaling_policy.rb +68 -0
- data/lib/ey-core/requests/create_environment.rb +2 -0
- data/lib/ey-core/requests/create_environment_variable.rb +39 -0
- data/lib/ey-core/requests/create_user.rb +8 -6
- data/lib/ey-core/requests/destroy_auto_scaling_alarm.rb +49 -0
- data/lib/ey-core/requests/destroy_auto_scaling_group.rb +44 -0
- data/lib/ey-core/requests/destroy_auto_scaling_policy.rb +49 -0
- data/lib/ey-core/requests/discover_container_service_deployments.rb +71 -0
- data/lib/ey-core/requests/discover_server.rb +60 -0
- data/lib/ey-core/requests/get_applications.rb +1 -1
- data/lib/ey-core/requests/get_auto_scaling_alarm.rb +27 -0
- data/lib/ey-core/requests/get_auto_scaling_alarms.rb +34 -0
- data/lib/ey-core/requests/get_auto_scaling_group.rb +21 -0
- data/lib/ey-core/requests/get_auto_scaling_groups.rb +29 -0
- data/lib/ey-core/requests/get_auto_scaling_policies.rb +46 -0
- data/lib/ey-core/requests/get_auto_scaling_policy.rb +27 -0
- data/lib/ey-core/requests/get_deployments.rb +1 -1
- data/lib/ey-core/requests/get_environment_variable.rb +19 -0
- data/lib/ey-core/requests/get_environment_variables.rb +29 -0
- data/lib/ey-core/requests/get_environments.rb +1 -1
- data/lib/ey-core/requests/get_ssl_certificate.rb +1 -1
- data/lib/ey-core/requests/retrieve_docker_registry_credentials.rb +24 -0
- data/lib/ey-core/requests/update_auto_scaling_alarm.rb +45 -0
- data/lib/ey-core/requests/update_auto_scaling_group.rb +45 -0
- data/lib/ey-core/requests/update_auto_scaling_policy.rb +46 -0
- data/lib/ey-core/requests/update_environment_variable.rb +25 -0
- data/lib/ey-core/test_helpers.rb +2 -0
- data/lib/ey-core/test_helpers/auto_scaling_helpers.rb +35 -0
- data/lib/ey-core/version.rb +1 -1
- data/spec/addresses_spec.rb +2 -1
- data/spec/auto_scaling_alarms_spec.rb +40 -0
- data/spec/auto_scaling_groups_spec.rb +28 -0
- data/spec/auto_scaling_policies_spec.rb +94 -0
- data/spec/docker_registry_credentials_spec.rb +16 -0
- data/spec/environments_spec.rb +18 -0
- data/spec/servers_spec.rb +8 -0
- data/spec/spec_helper.rb +7 -0
- data/spec/support/core.rb +0 -2
- metadata +192 -18
@@ -0,0 +1,24 @@
|
|
1
|
+
class Ey::Core::Client::StepAutoScalingPolicy < Ey::Core::Client::BaseAutoScalingPolicy
|
2
|
+
identity :id
|
3
|
+
attribute :auto_scaling_group_id, aliases: "auto_scaling_group", squash: ["id"]
|
4
|
+
attribute :estimated_warmup, type: :integer
|
5
|
+
attribute :action_type
|
6
|
+
attribute :action_unit
|
7
|
+
attribute :steps, type: :array
|
8
|
+
|
9
|
+
has_many :auto_scaling_alarms
|
10
|
+
|
11
|
+
def policy_params
|
12
|
+
{
|
13
|
+
"estimated_warmup" => estimated_warmup,
|
14
|
+
"action_type" => action_type,
|
15
|
+
"action_unit" => action_unit,
|
16
|
+
"steps" => steps,
|
17
|
+
"type" => type
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
def policy_requires
|
22
|
+
requires :steps, :action_unit, :action_type, :estimated_warmup
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class Ey::Core::Client::TargetAutoScalingPolicy < Ey::Core::Client::BaseAutoScalingPolicy
|
2
|
+
identity :id
|
3
|
+
attribute :auto_scaling_group_id, aliases: "auto_scaling_group", squash: ["id"]
|
4
|
+
attribute :estimated_warmup, type: :integer
|
5
|
+
attribute :target_value, type: :float
|
6
|
+
attribute :disable_scale_in, type: :boolean
|
7
|
+
attribute :metric_type
|
8
|
+
|
9
|
+
has_many :auto_scaling_alarms
|
10
|
+
|
11
|
+
def policy_params
|
12
|
+
{
|
13
|
+
"estimated_warmup" => estimated_warmup,
|
14
|
+
"target_value" => target_value,
|
15
|
+
"disable_scale_in" => disable_scale_in,
|
16
|
+
"metric_type" => metric_type,
|
17
|
+
"type" => type
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
def policy_requires
|
22
|
+
requires :target_value, :metric_type, :estimated_warmup
|
23
|
+
end
|
24
|
+
end
|
@@ -36,7 +36,7 @@ class Ey::Core::Client
|
|
36
36
|
role_to_use = (type == 'app_instances' && index == 0) ? "app_master" : role
|
37
37
|
server = server_hash(role: role_to_use, environment: environment, flavor: server_data["flavor"]["id"], name: server_data["name"])
|
38
38
|
if role_to_use == "app_master"
|
39
|
-
if ip_id = params["cluster_configuration"]["ip_id"]
|
39
|
+
if ip_id = params["cluster_configuration"]["configuration"]["ip_id"]
|
40
40
|
if find(:addresses, ip_id)
|
41
41
|
server[:address] = url_for("/addresses/#{ip_id}")
|
42
42
|
end
|
@@ -24,6 +24,11 @@ class Ey::Core::Client
|
|
24
24
|
|
25
25
|
self.data[:accounts][resource_id] = resource.merge(:account_users => [owner_id], :account_owners => [owner_id])
|
26
26
|
|
27
|
+
resource.merge!(
|
28
|
+
:environments_url => url_for("/accounts/#{resource_id}/environments"),
|
29
|
+
:applications_url => url_for("/accounts/#{resource_id}/applications")
|
30
|
+
)
|
31
|
+
|
27
32
|
response(
|
28
33
|
:body => {"account" => resource},
|
29
34
|
:status => 201,
|
@@ -40,13 +40,14 @@ class Ey::Core::Client
|
|
40
40
|
end
|
41
41
|
|
42
42
|
resource.merge!(
|
43
|
-
"account"
|
44
|
-
"archives"
|
45
|
-
"keypairs"
|
46
|
-
"language"
|
47
|
-
"created_at"
|
48
|
-
"updated_at"
|
49
|
-
"id"
|
43
|
+
"account" => url_for("/accounts/#{account_id}"),
|
44
|
+
"archives" => url_for("/applications/#{resource_id}/archives"),
|
45
|
+
"keypairs" => url_for("/applications/#{resource_id}/keypairs"),
|
46
|
+
"language" => language,
|
47
|
+
"created_at" => Time.now,
|
48
|
+
"updated_at" => Time.now,
|
49
|
+
"id" => resource_id,
|
50
|
+
"environment_variables" => url_for("/applications/#{resource_id}/environment_variables")
|
50
51
|
)
|
51
52
|
|
52
53
|
key = mock_ssh_key
|
@@ -0,0 +1,69 @@
|
|
1
|
+
class Ey::Core::Client
|
2
|
+
class Real
|
3
|
+
def create_auto_scaling_alarm(options = {})
|
4
|
+
params = Cistern::Hash.stringify_keys(options)
|
5
|
+
|
6
|
+
url = params.delete("url")
|
7
|
+
auto_scaling_policy_id = params["auto_scaling_policy_id"]
|
8
|
+
|
9
|
+
body = {
|
10
|
+
auto_scaling_alarm: params,
|
11
|
+
auto_scaling_policy_id: auto_scaling_policy_id
|
12
|
+
}
|
13
|
+
|
14
|
+
request(
|
15
|
+
:method => :post,
|
16
|
+
:url => url,
|
17
|
+
:path => "/auto_scaling_policies/auto_scaling_alarms",
|
18
|
+
:body => body
|
19
|
+
)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class Mock
|
24
|
+
def create_auto_scaling_alarm(options = {})
|
25
|
+
params = Cistern::Hash.stringify_keys(options)
|
26
|
+
|
27
|
+
request_id = self.serial_id
|
28
|
+
resource_id = self.uuid
|
29
|
+
|
30
|
+
auto_scaling_policy_id = params.delete("auto_scaling_policy_id")
|
31
|
+
auto_scaling_policy = find(:auto_scaling_policies, auto_scaling_policy_id)
|
32
|
+
|
33
|
+
resource = params["auto_scaling_alarm"].dup
|
34
|
+
arn = "arn:aws:cloudwatch:eu-west-1:000000000000:metricAlarm:00000000-0000-0000-0000-000000000000:alarmName/#{resource["name"]}"
|
35
|
+
|
36
|
+
now = Time.now
|
37
|
+
|
38
|
+
resource.merge!(
|
39
|
+
"id" => resource_id,
|
40
|
+
"created_at" => now,
|
41
|
+
"auto_scaling_policy" => auto_scaling_policy["id"],
|
42
|
+
"provisioned_id" => arn,
|
43
|
+
"resource_url" => url_for("/auto_scaling_alarms/#{resource_id}")
|
44
|
+
)
|
45
|
+
|
46
|
+
request = {
|
47
|
+
"id" => request_id,
|
48
|
+
"created_at" => now - 2,
|
49
|
+
"updated_at" => now,
|
50
|
+
"started_at" => now - 1,
|
51
|
+
"finished_at" => now,
|
52
|
+
"message" => nil,
|
53
|
+
"read_channel" => nil,
|
54
|
+
"resource" => [:auto_scaling_alarms, resource_id, resource],
|
55
|
+
"resource_url" => url_for("/auto_scaling_alarms/#{resource_id}"),
|
56
|
+
"type" => "provision_auto_scaling_alarm",
|
57
|
+
"successful" => true,
|
58
|
+
}
|
59
|
+
|
60
|
+
self.data[:auto_scaling_alarms][resource_id] = resource
|
61
|
+
self.data[:requests][request_id] = request
|
62
|
+
|
63
|
+
response(
|
64
|
+
:body => { "request" => request },
|
65
|
+
:status => 200
|
66
|
+
)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
class Ey::Core::Client
|
2
|
+
class Real
|
3
|
+
def create_auto_scaling_group(options={})
|
4
|
+
url = options.delete("url")
|
5
|
+
|
6
|
+
request(
|
7
|
+
:method => :post,
|
8
|
+
:url => url,
|
9
|
+
:path => "/auto_scaling_groups",
|
10
|
+
:body => options
|
11
|
+
)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class Mock
|
16
|
+
def create_auto_scaling_group(options={})
|
17
|
+
url = options.delete("url")
|
18
|
+
|
19
|
+
environment_id = options.delete("environment")
|
20
|
+
environment = find(:environments, environment_id)
|
21
|
+
resource_id = self.uuid
|
22
|
+
resource = options["auto_scaling_group"].dup
|
23
|
+
|
24
|
+
now = Time.now
|
25
|
+
|
26
|
+
resource.merge!(
|
27
|
+
"created_at" => now,
|
28
|
+
"environment" => url_for("/environments/#{environment_id}"),
|
29
|
+
"id" => resource_id,
|
30
|
+
"location_id" => environment["region"],
|
31
|
+
"provisioned_id" => "#{environment["name"]}#{SecureRandom.uuid}",
|
32
|
+
"desired_capacity" => 1,
|
33
|
+
"resource_url" => url_for("/auto_scaling_groups/#{resource_id}"),
|
34
|
+
)
|
35
|
+
|
36
|
+
self.data[:auto_scaling_groups][resource_id] = resource
|
37
|
+
|
38
|
+
environment.merge!("auto_scaling_group" => url_for("/auto_scaling_groups/#{resource_id}"))
|
39
|
+
|
40
|
+
request = {
|
41
|
+
"created_at" => now - 2,
|
42
|
+
"finished_at" => now,
|
43
|
+
"id" => self.uuid,
|
44
|
+
"message" => nil,
|
45
|
+
"read_channel" => nil,
|
46
|
+
"resource" => [:auto_scaling_groups, resource_id, resource],
|
47
|
+
"resource_url" => url_for("/auto_scaling_groups/#{resource_id}"),
|
48
|
+
"started_at" => now - 1,
|
49
|
+
"successful" => true,
|
50
|
+
"type" => "provision_auto_scaling_group",
|
51
|
+
"updated_at" => now,
|
52
|
+
}
|
53
|
+
|
54
|
+
self.data[:requests][request["id"]] = request
|
55
|
+
|
56
|
+
response(
|
57
|
+
:body => {"request" => request},
|
58
|
+
:status => 200
|
59
|
+
)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
class Ey::Core::Client
|
2
|
+
class Real
|
3
|
+
def create_auto_scaling_policy(options = {})
|
4
|
+
params = Cistern::Hash.stringify_keys(options)
|
5
|
+
url = params.delete("url")
|
6
|
+
auto_scaling_group_id = params.delete("auto_scaling_group_id")
|
7
|
+
body = {
|
8
|
+
auto_scaling_policy: params,
|
9
|
+
auto_scaling_group_id: auto_scaling_group_id
|
10
|
+
}
|
11
|
+
|
12
|
+
request(
|
13
|
+
:method => :post,
|
14
|
+
:url => url,
|
15
|
+
:path => "/auto_scaling_policies",
|
16
|
+
:body => body
|
17
|
+
)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class Mock
|
22
|
+
def create_auto_scaling_policy(options = {})
|
23
|
+
params = Cistern::Hash.stringify_keys(options)
|
24
|
+
|
25
|
+
request_id = self.serial_id
|
26
|
+
resource_id = self.uuid
|
27
|
+
|
28
|
+
auto_scaling_group_id = params.delete("auto_scaling_group_id")
|
29
|
+
auto_scaling_group = find(:auto_scaling_groups, auto_scaling_group_id)
|
30
|
+
|
31
|
+
resource = params["auto_scaling_policy"].dup
|
32
|
+
arn = "scalingPolicy:00000000-0000-0000-0000-000000000000:autoScalingGroupName/#{auto_scaling_group["name"]}:policyName/#{resource["name"]}"
|
33
|
+
|
34
|
+
now = Time.now
|
35
|
+
|
36
|
+
resource.merge!(
|
37
|
+
"id" => resource_id,
|
38
|
+
"created_at" => now,
|
39
|
+
"auto_scaling_group" => auto_scaling_group["id"],
|
40
|
+
"arn" => arn,
|
41
|
+
"resource_url" => url_for("/auto_scaling_policies/#{resource_id}"),
|
42
|
+
"auto_scaling_alarms" => url_for("/auto_scaling_alarms?auto_scaling_policy=#{resource_id}")
|
43
|
+
)
|
44
|
+
|
45
|
+
request = {
|
46
|
+
"id" => request_id,
|
47
|
+
"created_at" => now - 2,
|
48
|
+
"updated_at" => now,
|
49
|
+
"started_at" => now - 1,
|
50
|
+
"finished_at" => now,
|
51
|
+
"message" => nil,
|
52
|
+
"read_channel" => nil,
|
53
|
+
"resource" => [:auto_scaling_policies, resource_id, resource],
|
54
|
+
"resource_url" => url_for("/auto_scaling_policies/#{resource_id}"),
|
55
|
+
"type" => "provision_auto_scaling_policy",
|
56
|
+
"successful" => true,
|
57
|
+
}
|
58
|
+
|
59
|
+
self.data[:auto_scaling_policies][resource_id] = resource
|
60
|
+
self.data[:requests][request_id] = request
|
61
|
+
|
62
|
+
response(
|
63
|
+
:body => { "request" => request },
|
64
|
+
:status => 200
|
65
|
+
)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -48,6 +48,8 @@ class Ey::Core::Client
|
|
48
48
|
"stack_name" => "nginx_passenger4",
|
49
49
|
"updated_at" => Time.now,
|
50
50
|
"username" => "deploy",
|
51
|
+
"service_level" => "default",
|
52
|
+
"environment_variables" => url_for("/environments/#{resource_id}/environment_variables")
|
51
53
|
)
|
52
54
|
|
53
55
|
self.data[:environments][resource_id] = resource
|
@@ -0,0 +1,39 @@
|
|
1
|
+
class Ey::Core::Client
|
2
|
+
class Real
|
3
|
+
def create_environment_variable(_params={})
|
4
|
+
params = Cistern::Hash.stringify_keys(_params)
|
5
|
+
environment_id = params.delete("environment_id")
|
6
|
+
application_id = params.delete("application_id")
|
7
|
+
body = { environment_variable: params, environment_id: environment_id, application_id: application_id }
|
8
|
+
|
9
|
+
request(
|
10
|
+
:method => :post,
|
11
|
+
:path => "/environment_variables",
|
12
|
+
:body => body
|
13
|
+
)
|
14
|
+
end
|
15
|
+
end # Real
|
16
|
+
|
17
|
+
class Mock
|
18
|
+
def create_environment_variable(_params={})
|
19
|
+
params = Cistern::Hash.stringify_keys(_params)
|
20
|
+
|
21
|
+
resource_id = serial_id
|
22
|
+
environment = find(:environments, params["environment_id"])
|
23
|
+
application = find(:applications, params["application_id"])
|
24
|
+
|
25
|
+
params["id"] = resource_id
|
26
|
+
params["environment_name"] = environment["name"]
|
27
|
+
params["environment"] = url_for("/environments/#{environment['id']}")
|
28
|
+
params["application_name"] = application["name"]
|
29
|
+
params["application"] = url_for("/applications/#{application['id']}")
|
30
|
+
|
31
|
+
self.data[:environment_variables][resource_id] = params
|
32
|
+
|
33
|
+
response(
|
34
|
+
:body => {"environment_variable" => params},
|
35
|
+
:status => 201,
|
36
|
+
)
|
37
|
+
end
|
38
|
+
end # Mock
|
39
|
+
end # Ey::Core::Client
|
@@ -27,12 +27,14 @@ class Ey::Core::Client
|
|
27
27
|
resource = params["user"].dup
|
28
28
|
|
29
29
|
resource.merge!({
|
30
|
-
"id"
|
31
|
-
"accounts"
|
32
|
-
"memberships"
|
33
|
-
"keypairs"
|
34
|
-
"tokens"
|
35
|
-
"
|
30
|
+
"id" => resource_id,
|
31
|
+
"accounts" => url_for("/users/#{resource_id}/accounts"),
|
32
|
+
"memberships" => url_for("/users/#{resource_id}/memberships"),
|
33
|
+
"keypairs" => url_for("/users/#{resource_id}/keypairs"),
|
34
|
+
"tokens" => url_for("/users/#{resource_id}/tokens"),
|
35
|
+
"environments" => url_for("/accounts/#{resource_id}/environments"),
|
36
|
+
"applications" => url_for("/accounts/#{resource_id}/applications"),
|
37
|
+
"api_token" => SecureRandom.hex(16),
|
36
38
|
})
|
37
39
|
|
38
40
|
self.data[:tokens][token_id] = {
|
@@ -0,0 +1,49 @@
|
|
1
|
+
class Ey::Core::Client
|
2
|
+
class Real
|
3
|
+
def destroy_auto_scaling_alarm(params = {})
|
4
|
+
id = params["id"]
|
5
|
+
url = params["url"]
|
6
|
+
|
7
|
+
request(
|
8
|
+
:method => :delete,
|
9
|
+
:url => url,
|
10
|
+
:path => "/auto_scaling_alarms/#{id}",
|
11
|
+
)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class Mock
|
16
|
+
def destroy_auto_scaling_alarm(params = {})
|
17
|
+
request_id = self.uuid
|
18
|
+
url = params.delete("url")
|
19
|
+
|
20
|
+
auto_scaling_alarm_id = params["id"] || url && url.split('/').last
|
21
|
+
|
22
|
+
auto_scaling_alarm = self.data[:auto_scaling_alarms][auto_scaling_alarm_id]
|
23
|
+
auto_scaling_alarm.merge!(
|
24
|
+
"deleted_at" => Time.now,
|
25
|
+
"resource_url" => url_for("/auto_scaling_alarms/#{auto_scaling_alarm_id}")
|
26
|
+
)
|
27
|
+
|
28
|
+
auto_scaling_policy = find(
|
29
|
+
:auto_scaling_policies,
|
30
|
+
resource_identity(auto_scaling_alarm["auto_scaling_policy"])
|
31
|
+
)
|
32
|
+
auto_scaling_policy.delete("auto_scaling_alarm")
|
33
|
+
|
34
|
+
self.data[:requests][request_id] = {
|
35
|
+
"id" => request_id,
|
36
|
+
"finished_at" => nil,
|
37
|
+
"successful" => "true",
|
38
|
+
"started_at" => Time.now,
|
39
|
+
"resource" => [:auto_scaling_alarms, auto_scaling_alarm_id, auto_scaling_alarm],
|
40
|
+
"type" => "deprovision_auto_scaling_alarm",
|
41
|
+
}
|
42
|
+
|
43
|
+
response(
|
44
|
+
body: { "request" => self.data[:requests][request_id] },
|
45
|
+
status: 201
|
46
|
+
)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
class Ey::Core::Client
|
2
|
+
class Real
|
3
|
+
def destroy_auto_scaling_group(params={})
|
4
|
+
id = params["id"]
|
5
|
+
url = params["url"]
|
6
|
+
|
7
|
+
request(
|
8
|
+
:method => :delete,
|
9
|
+
:url => url,
|
10
|
+
:path => "/auto_scaling_groups/#{id}",
|
11
|
+
)
|
12
|
+
end
|
13
|
+
end # Real
|
14
|
+
|
15
|
+
class Mock
|
16
|
+
def destroy_auto_scaling_group(params={})
|
17
|
+
request_id = self.uuid
|
18
|
+
url = params.delete("url")
|
19
|
+
|
20
|
+
auto_scaling_group_id = params["id"] || url && url.split('/').last
|
21
|
+
|
22
|
+
auto_scaling_group = self.data[:auto_scaling_groups][auto_scaling_group_id].dup
|
23
|
+
auto_scaling_group["deleted_at"] = Time.now
|
24
|
+
auto_scaling_group["resource_url"] = url_for("/auto_scaling_groups/#{auto_scaling_group_id}")
|
25
|
+
|
26
|
+
environment = find(:environments, resource_identity(auto_scaling_group["environment"]))
|
27
|
+
environment.delete("auto_scaling_group")
|
28
|
+
|
29
|
+
self.data[:requests][request_id] = {
|
30
|
+
"id" => request_id,
|
31
|
+
"finished_at" => nil,
|
32
|
+
"successful" => "true",
|
33
|
+
"started_at" => Time.now,
|
34
|
+
"resource" => [:auto_scaling_groups, auto_scaling_group_id, auto_scaling_group],
|
35
|
+
"type" => "deprovision_auto_scaling_group",
|
36
|
+
}
|
37
|
+
|
38
|
+
response(
|
39
|
+
:body => {"request" => {id: request_id}},
|
40
|
+
:status => 201,
|
41
|
+
)
|
42
|
+
end
|
43
|
+
end # Mock
|
44
|
+
end # Ey::Core::Client
|