ey-core 3.4.2 → 3.6.3
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 +1 -2
- data/README.md +65 -8
- data/ey-core.gemspec +6 -5
- data/features/docker_registry_credentials.feature +21 -0
- data/features/environment_variables.feature +54 -0
- data/features/step_definitions/accounts_steps.rb +14 -0
- data/features/step_definitions/applications_steps.rb +7 -14
- 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 +15 -0
- data/features/support/environment_variable_helpers.rb +20 -0
- data/features/support/mock_api.rb +0 -1
- data/features/support/resource_helpers.rb +12 -0
- data/lib/ey-core/cli/deploy.rb +14 -11
- 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/chef.rb +1 -1
- data/lib/ey-core/cli/helpers/core.rb +32 -3
- data/lib/ey-core/cli/helpers/server_sieve.rb +7 -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 +7 -1
- data/lib/ey-core/client/mock.rb +5 -0
- data/lib/ey-core/client.rb +35 -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/deployment.rb +1 -0
- data/lib/ey-core/models/environment.rb +57 -45
- 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/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/deploy_environment_application.rb +1 -0
- 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/auto_scaling_helpers.rb +35 -0
- data/lib/ey-core/test_helpers.rb +2 -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 +88 -18
@@ -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] = {
|
@@ -30,6 +30,7 @@ class Ey::Core::Client
|
|
30
30
|
"migrate_command" => options["deploy"]["migrate"] ? (options["deploy"]["migrate_command"] || "rake db:migrate") : nil,
|
31
31
|
"migrate" => options["deploy"]["migrate"] || false,
|
32
32
|
"resolved_ref" => options["deploy"]["ref"],
|
33
|
+
"serverside_version" => options["deploy"]["serverside_version"],
|
33
34
|
"started_at" => Time.now,
|
34
35
|
"successful" => true
|
35
36
|
}
|
@@ -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
|
@@ -0,0 +1,49 @@
|
|
1
|
+
class Ey::Core::Client
|
2
|
+
class Real
|
3
|
+
def destroy_auto_scaling_policy(params = {})
|
4
|
+
id = params["id"]
|
5
|
+
url = params["url"]
|
6
|
+
|
7
|
+
request(
|
8
|
+
:method => :delete,
|
9
|
+
:url => url,
|
10
|
+
:path => "/auto_scaling_policies/#{id}",
|
11
|
+
)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class Mock
|
16
|
+
def destroy_auto_scaling_policy(params = {})
|
17
|
+
request_id = self.uuid
|
18
|
+
url = params.delete("url")
|
19
|
+
|
20
|
+
auto_scaling_policy_id = params["id"] || url && url.split('/').last
|
21
|
+
|
22
|
+
auto_scaling_policy = self.data[:auto_scaling_policies][auto_scaling_policy_id]
|
23
|
+
auto_scaling_policy.merge!(
|
24
|
+
"deleted_at" => Time.now,
|
25
|
+
"resource_url" => url_for("/auto_scaling_policies/#{auto_scaling_policy_id}")
|
26
|
+
)
|
27
|
+
|
28
|
+
auto_scaling_group = find(
|
29
|
+
:auto_scaling_groups,
|
30
|
+
resource_identity(auto_scaling_policy["auto_scaling_group"])
|
31
|
+
)
|
32
|
+
auto_scaling_group.delete("auto_scaling_policy")
|
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_policies, auto_scaling_policy_id, auto_scaling_policy],
|
40
|
+
"type" => "deprovision_auto_scaling_policy",
|
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,71 @@
|
|
1
|
+
class Ey::Core::Client
|
2
|
+
class Real
|
3
|
+
def discover_container_service_deployments(params={})
|
4
|
+
url = params.delete("url")
|
5
|
+
|
6
|
+
request(
|
7
|
+
:method => :get,
|
8
|
+
:url => url,
|
9
|
+
:params => params,
|
10
|
+
:path => "/container_service_deployments/discover",
|
11
|
+
)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class Mock
|
16
|
+
def discover_container_service_deployments(params={})
|
17
|
+
extract_url_params!(params)
|
18
|
+
|
19
|
+
callback_url = params.delete("callback_url")
|
20
|
+
deployment_id = self.uuid
|
21
|
+
resource_id = self.uuid
|
22
|
+
|
23
|
+
existing_deploymens = self.data[:container_service_deployments].values.select do |deployment|
|
24
|
+
deployment["container_service_id"] == container_service["id"]
|
25
|
+
end
|
26
|
+
existing_deploymens = nil if existing_deploymens.empty?
|
27
|
+
|
28
|
+
resources = existing_deploymens || [{
|
29
|
+
"id" => deployment_id,
|
30
|
+
"container_service_id" => params["container_service_id"],
|
31
|
+
"public_ip_address" => "123.456.789.123",
|
32
|
+
"private_ip_address" => "10.0.1.2",
|
33
|
+
"container_instance_id" => SecureRandom.uuid,
|
34
|
+
"port_mappings" => [{
|
35
|
+
"container_port" => "80",
|
36
|
+
"host_port" => "80",
|
37
|
+
"protocol" => "tcp"
|
38
|
+
}],
|
39
|
+
"provisioned_id" => resource_id,
|
40
|
+
"health_status" => "HEALTHY",
|
41
|
+
"task_arn" => SecureRandom.uuid,
|
42
|
+
"container_health_status" => [{
|
43
|
+
"container_arn" => SecureRandom.uuid,
|
44
|
+
"health_status" => SecureRandom.uuid
|
45
|
+
}]
|
46
|
+
}]
|
47
|
+
|
48
|
+
request = {
|
49
|
+
"id" => request_id,
|
50
|
+
"type" => "discover_container_service_deployments",
|
51
|
+
"successful" => true,
|
52
|
+
"started_at" => Time.now,
|
53
|
+
"finished_at" => nil,
|
54
|
+
"resource" => [:container_service_deployments, resource_id, resources, "/container_service_deployments"]
|
55
|
+
}
|
56
|
+
|
57
|
+
self.data[:container_service_deployments][deployment_id] = request
|
58
|
+
|
59
|
+
response_hash = request.dup
|
60
|
+
response_hash.delete("resource")
|
61
|
+
|
62
|
+
response(
|
63
|
+
:body => {"request" => response_hash},
|
64
|
+
:status => 200,
|
65
|
+
:headers => {
|
66
|
+
"Content-Type" => "application/json; charset=utf8"
|
67
|
+
}
|
68
|
+
)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
class Ey::Core::Client
|
2
|
+
class Real
|
3
|
+
def discover_server(options={})
|
4
|
+
provider_id = options.delete("provider")
|
5
|
+
|
6
|
+
request(
|
7
|
+
:method => :post,
|
8
|
+
:path => "/providers/#{provider_id}/servers/discover",
|
9
|
+
:body => options
|
10
|
+
)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class Mock
|
15
|
+
def discover_server(options={})
|
16
|
+
options = Cistern::Hash.stringify_keys(options)
|
17
|
+
|
18
|
+
provider_id = options.delete("provider")
|
19
|
+
request_id = self.uuid
|
20
|
+
|
21
|
+
options["server"]["role"] ||= "app"
|
22
|
+
options["server"]["flavor"] ||= "m4.large"
|
23
|
+
|
24
|
+
server = self.data[:servers].values.detect do |s|
|
25
|
+
!s["deleted_at"] && s["provider"] == url_for("/providers/#{provider_id}") && s["provisioned_id"] == options["server"]["provisioned_id"]
|
26
|
+
end
|
27
|
+
|
28
|
+
resource = if server
|
29
|
+
server
|
30
|
+
else
|
31
|
+
if auto_scaling_group_id = options["auto_scaling_group"]
|
32
|
+
find(:auto_scaling_groups, auto_scaling_group_id)
|
33
|
+
end
|
34
|
+
|
35
|
+
s = self.requests.new(create_server(options).body["request"]).resource! # cheating
|
36
|
+
self.data[:servers][s.id]
|
37
|
+
end
|
38
|
+
|
39
|
+
request = {
|
40
|
+
"id" => request_id,
|
41
|
+
"type" => "discover_server",
|
42
|
+
"successful" => true,
|
43
|
+
"started_at" => Time.now,
|
44
|
+
"finished_at" => nil,
|
45
|
+
"resource_url" => url_for("/servers/#{resource["id"]}"),
|
46
|
+
"resource" => [:servers, resource["id"], resource],
|
47
|
+
}
|
48
|
+
|
49
|
+
self.data[:requests][request_id] = request
|
50
|
+
|
51
|
+
response_hash = request.dup
|
52
|
+
response_hash.delete("resource")
|
53
|
+
|
54
|
+
response(
|
55
|
+
:body => {"request" => response_hash},
|
56
|
+
:status => 201,
|
57
|
+
)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -17,7 +17,7 @@ class Ey::Core::Client
|
|
17
17
|
def get_applications(params={})
|
18
18
|
extract_url_params!(params)
|
19
19
|
|
20
|
-
headers, applications_page = search_and_page(params, :applications, search_keys: %w[type repository account name environment])
|
20
|
+
headers, applications_page = search_and_page(params, :applications, search_keys: %w[id type repository account name environment])
|
21
21
|
|
22
22
|
response(
|
23
23
|
:body => {"applications" => applications_page},
|
@@ -0,0 +1,27 @@
|
|
1
|
+
class Ey::Core::Client
|
2
|
+
class Real
|
3
|
+
def get_auto_scaling_alarm(params = {})
|
4
|
+
id = params["id"]
|
5
|
+
url = params["url"]
|
6
|
+
|
7
|
+
request(
|
8
|
+
:method => :get,
|
9
|
+
:path => "auto_scaling_alarms/#{id}",
|
10
|
+
:url => url
|
11
|
+
)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class Mock
|
16
|
+
def get_auto_scaling_alarm(params = {})
|
17
|
+
response(
|
18
|
+
:body => {
|
19
|
+
"auto_scaling_alarm" => self.find(
|
20
|
+
:auto_scaling_alarms,
|
21
|
+
resource_identity(params)
|
22
|
+
)
|
23
|
+
},
|
24
|
+
)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
class Ey::Core::Client
|
2
|
+
class Real
|
3
|
+
def get_auto_scaling_alarms(params = {})
|
4
|
+
query = Ey::Core.paging_parameters(params)
|
5
|
+
url = params.delete("url")
|
6
|
+
|
7
|
+
request(
|
8
|
+
:params => params,
|
9
|
+
:path => "/auto_scaling_alarms",
|
10
|
+
:query => params,
|
11
|
+
:url => url,
|
12
|
+
)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class Mock
|
17
|
+
def get_auto_scaling_alarms(params = {})
|
18
|
+
extract_url_params!(params)
|
19
|
+
|
20
|
+
headers, auto_scaling_alarms_page = search_and_page(
|
21
|
+
params,
|
22
|
+
:auto_scaling_alarms,
|
23
|
+
search_keys: %w{ id auto_scaling_policy },
|
24
|
+
resources: data[:auto_scaling_alarms]
|
25
|
+
)
|
26
|
+
|
27
|
+
response(
|
28
|
+
:body => { "auto_scaling_alarms" => auto_scaling_alarms_page },
|
29
|
+
:status => 200,
|
30
|
+
:headers => headers
|
31
|
+
)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class Ey::Core::Client
|
2
|
+
class Real
|
3
|
+
def get_auto_scaling_group(params={})
|
4
|
+
id = params["id"]
|
5
|
+
url = params["url"]
|
6
|
+
|
7
|
+
request(
|
8
|
+
:path => "auto_scaling_groups/#{id}",
|
9
|
+
:url => url,
|
10
|
+
)
|
11
|
+
end
|
12
|
+
end # Real
|
13
|
+
|
14
|
+
class Mock
|
15
|
+
def get_auto_scaling_group(params={})
|
16
|
+
response(
|
17
|
+
:body => {"auto_scaling_group" => self.find(:auto_scaling_groups, resource_identity(params))},
|
18
|
+
)
|
19
|
+
end
|
20
|
+
end # Mock
|
21
|
+
end # Ey::Core::Client
|
@@ -0,0 +1,29 @@
|
|
1
|
+
class Ey::Core::Client
|
2
|
+
class Real
|
3
|
+
def get_auto_scaling_groups(options={})
|
4
|
+
query = Ey::Core.paging_parameters(options)
|
5
|
+
url = options.delete("url")
|
6
|
+
|
7
|
+
request(
|
8
|
+
:params => options,
|
9
|
+
:query => query,
|
10
|
+
:path => "/auto_scaling_groups",
|
11
|
+
:url => url,
|
12
|
+
)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class Mock
|
17
|
+
def get_auto_scaling_groups(options={})
|
18
|
+
extract_url_params!(options)
|
19
|
+
|
20
|
+
headers, auto_scaling_groups_page = search_and_page(options, :auto_scaling_groups, search_keys: %w[environment environment_id account account_id provider provider_id provisioned_id])
|
21
|
+
|
22
|
+
response(
|
23
|
+
:body => {"auto_scaling_groups" => auto_scaling_groups_page},
|
24
|
+
:status => 200,
|
25
|
+
:headers => headers
|
26
|
+
)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
class Ey::Core::Client
|
2
|
+
class Real
|
3
|
+
def get_auto_scaling_policies(params = {})
|
4
|
+
query = Ey::Core.paging_parameters(params)
|
5
|
+
url = params.delete("url")
|
6
|
+
|
7
|
+
request(
|
8
|
+
:params => params,
|
9
|
+
:path => "/auto_scaling_policies",
|
10
|
+
:query => params,
|
11
|
+
:url => url,
|
12
|
+
)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class Mock
|
17
|
+
def get_auto_scaling_policies(params = {})
|
18
|
+
extract_url_params!(params)
|
19
|
+
|
20
|
+
resources = data[:auto_scaling_policies].select { |_key, policy| filter_policy(params, policy) }
|
21
|
+
params.delete("types")
|
22
|
+
|
23
|
+
headers, auto_scaling_policies_page = search_and_page(
|
24
|
+
params,
|
25
|
+
:auto_scaling_policies,
|
26
|
+
search_keys: %w{ id auto_scaling_group },
|
27
|
+
resources: resources
|
28
|
+
)
|
29
|
+
|
30
|
+
response(
|
31
|
+
:body => { "auto_scaling_policies" => auto_scaling_policies_page },
|
32
|
+
:status => 200,
|
33
|
+
:headers => headers
|
34
|
+
)
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def filter_policy(params, item)
|
40
|
+
return false if params["auto_scaling_group"] != item["auto_scaling_group"]
|
41
|
+
|
42
|
+
types = params["types"]
|
43
|
+
types.is_a?(::Array) && types.include?(item["type"])
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
class Ey::Core::Client
|
2
|
+
class Real
|
3
|
+
def get_auto_scaling_policy(params = {})
|
4
|
+
id = params["id"]
|
5
|
+
url = params["url"]
|
6
|
+
|
7
|
+
request(
|
8
|
+
:method => :get,
|
9
|
+
:path => "auto_scaling_policies/#{id}",
|
10
|
+
:url => url
|
11
|
+
)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class Mock
|
16
|
+
def get_auto_scaling_policy(params = {})
|
17
|
+
response(
|
18
|
+
:body => {
|
19
|
+
"auto_scaling_policy" => self.find(
|
20
|
+
:auto_scaling_policies,
|
21
|
+
resource_identity(params)
|
22
|
+
)
|
23
|
+
},
|
24
|
+
)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class Ey::Core::Client
|
2
|
+
class Real
|
3
|
+
def get_environment_variable(params={})
|
4
|
+
id = params.delete("id")
|
5
|
+
url = params.delete("url")
|
6
|
+
|
7
|
+
request(
|
8
|
+
:path => "environment_variables/#{id}",
|
9
|
+
:url => url,
|
10
|
+
)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class Mock
|
15
|
+
def get_environment_variable(params={})
|
16
|
+
response(body: {"environment_variable" => find(:environment_variables, resource_identity(params))})
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|