ey-core 3.4.4 → 3.6.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +5 -5
  2. data/.ruby-version +1 -1
  3. data/CHANGELOG.md +27 -5
  4. data/Gemfile +1 -2
  5. data/README.md +65 -8
  6. data/ey-core.gemspec +6 -5
  7. data/features/docker_registry_credentials.feature +21 -0
  8. data/features/environment_variables.feature +54 -0
  9. data/features/step_definitions/accounts_steps.rb +14 -0
  10. data/features/step_definitions/applications_steps.rb +7 -14
  11. data/features/step_definitions/docker_registry_credentials_steps.rb +3 -0
  12. data/features/step_definitions/environment_variables_steps.rb +51 -0
  13. data/features/step_definitions/environments_steps.rb +15 -0
  14. data/features/support/environment_variable_helpers.rb +20 -0
  15. data/features/support/mock_api.rb +0 -1
  16. data/features/support/resource_helpers.rb +12 -0
  17. data/lib/ey-core/cli/deploy.rb +12 -9
  18. data/lib/ey-core/cli/docker_registry_login.rb +29 -0
  19. data/lib/ey-core/cli/environment_variables.rb +71 -0
  20. data/lib/ey-core/cli/helpers/chef.rb +1 -1
  21. data/lib/ey-core/cli/helpers/core.rb +32 -3
  22. data/lib/ey-core/cli/helpers/server_sieve.rb +7 -0
  23. data/lib/ey-core/cli/main.rb +5 -4
  24. data/lib/ey-core/cli/servers.rb +35 -17
  25. data/lib/ey-core/cli/ssh.rb +6 -0
  26. data/lib/ey-core/client/mock.rb +4 -0
  27. data/lib/ey-core/client.rb +27 -0
  28. data/lib/ey-core/collections/auto_scaling_alarms.rb +8 -0
  29. data/lib/ey-core/collections/auto_scaling_policies.rb +33 -0
  30. data/lib/ey-core/collections/container_clusters.rb +9 -0
  31. data/lib/ey-core/collections/container_service_deployments.rb +17 -0
  32. data/lib/ey-core/collections/environment_variables.rb +8 -0
  33. data/lib/ey-core/models/account.rb +10 -0
  34. data/lib/ey-core/models/address.rb +2 -0
  35. data/lib/ey-core/models/application.rb +1 -0
  36. data/lib/ey-core/models/auto_scaling_alarm.rb +54 -0
  37. data/lib/ey-core/models/auto_scaling_group.rb +26 -0
  38. data/lib/ey-core/models/base_auto_scaling_policy.rb +61 -0
  39. data/lib/ey-core/models/container_service_deployment.rb +17 -0
  40. data/lib/ey-core/models/deployment.rb +1 -0
  41. data/lib/ey-core/models/environment.rb +53 -47
  42. data/lib/ey-core/models/environment_variable.rb +29 -0
  43. data/lib/ey-core/models/request.rb +4 -0
  44. data/lib/ey-core/models/simple_auto_scaling_policy.rb +24 -0
  45. data/lib/ey-core/models/step_auto_scaling_policy.rb +24 -0
  46. data/lib/ey-core/models/target_auto_scaling_policy.rb +24 -0
  47. data/lib/ey-core/requests/create_account.rb +5 -0
  48. data/lib/ey-core/requests/create_address.rb +1 -0
  49. data/lib/ey-core/requests/create_application.rb +8 -7
  50. data/lib/ey-core/requests/create_auto_scaling_alarm.rb +69 -0
  51. data/lib/ey-core/requests/create_auto_scaling_policy.rb +68 -0
  52. data/lib/ey-core/requests/create_environment.rb +2 -1
  53. data/lib/ey-core/requests/create_environment_variable.rb +39 -0
  54. data/lib/ey-core/requests/create_user.rb +8 -6
  55. data/lib/ey-core/requests/deploy_environment_application.rb +1 -0
  56. data/lib/ey-core/requests/destroy_auto_scaling_alarm.rb +49 -0
  57. data/lib/ey-core/requests/destroy_auto_scaling_policy.rb +49 -0
  58. data/lib/ey-core/requests/discover_container_service_deployments.rb +71 -0
  59. data/lib/ey-core/requests/get_applications.rb +1 -1
  60. data/lib/ey-core/requests/get_auto_scaling_alarm.rb +27 -0
  61. data/lib/ey-core/requests/get_auto_scaling_alarms.rb +34 -0
  62. data/lib/ey-core/requests/get_auto_scaling_policies.rb +46 -0
  63. data/lib/ey-core/requests/get_auto_scaling_policy.rb +27 -0
  64. data/lib/ey-core/requests/get_deployments.rb +1 -1
  65. data/lib/ey-core/requests/get_environment_variable.rb +19 -0
  66. data/lib/ey-core/requests/get_environment_variables.rb +29 -0
  67. data/lib/ey-core/requests/get_environments.rb +1 -1
  68. data/lib/ey-core/requests/get_ssl_certificate.rb +1 -1
  69. data/lib/ey-core/requests/retrieve_docker_registry_credentials.rb +24 -0
  70. data/lib/ey-core/requests/update_auto_scaling_alarm.rb +45 -0
  71. data/lib/ey-core/requests/update_auto_scaling_policy.rb +46 -0
  72. data/lib/ey-core/requests/update_environment_variable.rb +25 -0
  73. data/lib/ey-core/test_helpers/auto_scaling_helpers.rb +35 -0
  74. data/lib/ey-core/test_helpers.rb +2 -0
  75. data/lib/ey-core/version.rb +1 -1
  76. data/spec/addresses_spec.rb +2 -1
  77. data/spec/auto_scaling_alarms_spec.rb +40 -0
  78. data/spec/auto_scaling_policies_spec.rb +94 -0
  79. data/spec/docker_registry_credentials_spec.rb +16 -0
  80. data/spec/spec_helper.rb +7 -0
  81. data/spec/support/core.rb +0 -2
  82. metadata +78 -18
@@ -45,7 +45,7 @@ module Ey
45
45
 
46
46
  def core_operator_and_environment_for(options={})
47
47
  unless options[:environment]
48
- raise "--environment is required (for a list of environments, try `ey environments`)"
48
+ raise "--environment is required (for a list of environments, try `ey-core environments`)"
49
49
  end
50
50
  operator = operator(options)
51
51
  environment = nil
@@ -61,7 +61,7 @@ module Ey
61
61
  end
62
62
  end
63
63
  unless environment
64
- raise "environment '#{options[:environment]}' not found (for a list of environments, try `ey environments`)"
64
+ raise "environment '#{options[:environment]}' not found (for a list of environments, try `ey-core environments`)"
65
65
  end
66
66
  [operator, environment]
67
67
  end
@@ -131,7 +131,7 @@ module Ey
131
131
  write_core_yaml(legacy_token)
132
132
  retry
133
133
  elsif e.message.match(/missing token/i)
134
- abort "Missing credentials: Run 'ey login' to retrieve your Engine Yard Cloud API token.".yellow
134
+ abort "Missing credentials: Run 'ey-core login' to retrieve your Engine Yard Cloud API token.".yellow
135
135
  else
136
136
  raise e
137
137
  end
@@ -173,6 +173,35 @@ module Ey
173
173
  end
174
174
  end
175
175
 
176
+ # Fetches a list of environments by given name or ID.
177
+ #
178
+ # @param environment_name_or_id [String] name or ID of environment.
179
+ #
180
+ # @return [Array<Ey::Core::Client::Environment>] list of environments.
181
+ def core_environments(environment_name_or_id)
182
+ core_client.environments.all(name: environment_name_or_id).tap do |result|
183
+ result << core_client.environments.get(environment_name_or_id) if result.empty?
184
+ end.to_a.compact
185
+ end
186
+
187
+ # Fetches a list of applications by given name or ID.
188
+ #
189
+ # @param application_name_or_id [String] name or ID of application.
190
+ #
191
+ # @return [Array<Ey::Core::Client::Environment>] list of environments.
192
+ def core_applications(application_name_or_id)
193
+ core_client.applications.all(name: application_name_or_id).tap do |result|
194
+ result << core_client.applications.get(application_name_or_id) if result.empty?
195
+ end.to_a.compact
196
+ end
197
+
198
+ # Fetches a list of environment variables available for current user.
199
+ #
200
+ # @return [Array<Ey::Core::Client::EnvironmentVariable>] list of environment variables.
201
+ def core_environment_variables
202
+ core_client.environment_variables
203
+ end
204
+
176
205
  def write_core_yaml(token=nil)
177
206
  core_yaml[core_url] = token if token
178
207
  File.open(self.class.core_file, "w") {|file|
@@ -6,6 +6,7 @@ module Ey
6
6
  ROLES = [
7
7
  :app_servers,
8
8
  :db_servers,
9
+ :app_master,
9
10
  :db_master,
10
11
  :utilities
11
12
  ]
@@ -56,6 +57,12 @@ module Ey
56
57
  def db_servers
57
58
  db_master + servers_api.all(role: 'db_slave').to_a
58
59
  end
60
+
61
+ def app_master
62
+ ['app_master', 'solo'].
63
+ map {|role| servers_api.all(role:role).to_a}.
64
+ flatten
65
+ end
59
66
 
60
67
  def db_master
61
68
  ['db_master', 'solo'].
@@ -2,7 +2,7 @@
2
2
  #require 'ostruct'
3
3
  #require 'ey-core'
4
4
  require 'ey-core/cli'
5
- require 'awesome_print'
5
+ require 'amazing_print'
6
6
  require 'belafonte'
7
7
  require 'rubygems/package'
8
8
  require 'escape'
@@ -13,7 +13,9 @@ require 'ey-core/cli/applications'
13
13
  require 'ey-core/cli/console'
14
14
  require 'ey-core/cli/current_user'
15
15
  require 'ey-core/cli/deploy'
16
+ require 'ey-core/cli/docker_registry_login'
16
17
  require 'ey-core/cli/environments'
18
+ require 'ey-core/cli/environment_variables'
17
19
  require 'ey-core/cli/help'
18
20
  require 'ey-core/cli/init'
19
21
  require 'ey-core/cli/login'
@@ -29,9 +31,6 @@ require 'ey-core/cli/version'
29
31
  require 'ey-core/cli/web'
30
32
  require 'ey-core/cli/whoami'
31
33
 
32
- Cistern.formatter = Cistern::Formatter::AwesomePrint
33
-
34
-
35
34
  module Ey
36
35
  module Core
37
36
  module Cli
@@ -44,7 +43,9 @@ module Ey
44
43
  mount Console
45
44
  mount CurrentUser
46
45
  mount Deploy
46
+ mount DockerRegistryLogin
47
47
  mount Environments
48
+ mount EnvironmentVariables
48
49
  mount Help
49
50
  mount Init
50
51
  mount Login
@@ -4,36 +4,54 @@ module Ey
4
4
  module Core
5
5
  module Cli
6
6
  class Servers < Subcommand
7
- title "servers"
8
- summary "List servers you have access to"
7
+ title 'servers'
8
+ summary 'List servers you have access to'
9
9
 
10
10
  option :account,
11
11
  short: 'c',
12
12
  long: 'account',
13
13
  description: 'Filter by account name or id',
14
- argument: 'Account'
14
+ argument: 'account'
15
15
 
16
16
  option :environment,
17
- short: "-e",
18
- long: "environment",
19
- description: "Filter by environment.",
20
- argument: "environment"
17
+ short: 'e',
18
+ long: 'environment',
19
+ description: 'Filter by environment.',
20
+ argument: 'environment'
21
+
22
+ option :role,
23
+ short: 'r',
24
+ long: 'role',
25
+ description: 'Filter by server role.',
26
+ argument: 'role'
21
27
 
22
28
  def handle
23
- puts TablePrint::Printer.
24
- new(servers, [{id: {width: 10}}, :role, :provisioned_id]).
25
- table_print
29
+ puts TablePrint::Printer.new(
30
+ servers,
31
+ [
32
+ { id: { width: 10 } },
33
+ :role,
34
+ :provisioned_id,
35
+ { public_hostname: { width: 50 } },
36
+ :name,
37
+ ]
38
+ ).table_print
26
39
  end
27
40
 
28
41
  private
29
42
  def servers
30
- if option(:account)
31
- core_client.servers.all(account: core_account)
32
- elsif environment = option(:environment)
33
- (core_client.environments.get(environment) || core_client.environments.first(name: environment)).servers.all
34
- else
35
- core_client.servers.all
36
- end
43
+ filter_opts = {}
44
+
45
+ operator =
46
+ if option(:environment)
47
+ core_account.environments.first(name: option(:environment))
48
+ else
49
+ filter_opts[:account] = core_account.id if option(:account)
50
+ core_client
51
+ end
52
+
53
+ filter_opts[:role] = option(:role).split(',') if option(:role)
54
+ operator ? operator.servers.all(filter_opts) : nil
37
55
  end
38
56
  end
39
57
  end
@@ -54,6 +54,10 @@ module Ey
54
54
  long: "app_servers",
55
55
  description: "Run command on all application servers"
56
56
 
57
+ switch :app_master,
58
+ long: "app_master",
59
+ description: "Run command on app master"
60
+
57
61
  switch :db_servers,
58
62
  long: "db_servers",
59
63
  description: "Run command on all database servers"
@@ -97,6 +101,7 @@ module Ey
97
101
  environment.servers,
98
102
  all: switch_active?(:all),
99
103
  app_servers: switch_active?(:app_servers),
104
+ app_master: switch_active?(:app_master),
100
105
  db_servers: switch_active?(:db_servers),
101
106
  db_master: switch_active?(:db_master),
102
107
  utilities: option(:utilities)
@@ -113,6 +118,7 @@ module Ey
113
118
  environment.servers,
114
119
  all: switch_active?(:all),
115
120
  app_servers: switch_active?(:app_servers),
121
+ app_master: switch_active?(:app_master),
116
122
  db_servers: switch_active?(:db_servers),
117
123
  db_master: switch_active?(:db_master),
118
124
  utilities: option(:utilities)
@@ -116,7 +116,9 @@ class Ey::Core::Client::Mock
116
116
  :application_archives => {},
117
117
  :application_deployments => {},
118
118
  :applications => {},
119
+ :auto_scaling_alarms => {},
119
120
  :auto_scaling_groups => {},
121
+ :auto_scaling_policies => {},
120
122
  :backup_files => {},
121
123
  :backups => {},
122
124
  :billing => {},
@@ -125,6 +127,7 @@ class Ey::Core::Client::Mock
125
127
  :components => components,
126
128
  :contact_assignments => [],
127
129
  :contacts => {},
130
+ :container_service_deployments => {},
128
131
  :costs => [],
129
132
  :database_plan_usages => Hash.new { |h1,k1| h1[k1] = {} },
130
133
  :database_server_firewalls => [],
@@ -137,6 +140,7 @@ class Ey::Core::Client::Mock
137
140
  :deployments => {},
138
141
  :environment_plan_usages => Hash.new { |h1,k1| h1[k1] = {} },
139
142
  :environments => {},
143
+ :environment_variables => {},
140
144
  :features => {},
141
145
  :firewall_rules => {},
142
146
  :firewalls => {},
@@ -14,11 +14,14 @@ class Ey::Core::Client < Cistern::Service
14
14
  collection :application_archives
15
15
  collection :application_deployments
16
16
  collection :applications
17
+ collection :auto_scaling_alarms
17
18
  collection :auto_scaling_groups
19
+ collection :auto_scaling_policies
18
20
  collection :backup_files
19
21
  collection :blueprints
20
22
  collection :components
21
23
  collection :contacts
24
+ collection :container_service_deployments
22
25
  collection :costs
23
26
  collection :database_plan_usages
24
27
  collection :database_server_revisions
@@ -29,6 +32,7 @@ class Ey::Core::Client < Cistern::Service
29
32
  collection :deployments
30
33
  collection :environment_plan_usages
31
34
  collection :environments
35
+ collection :environment_variables
32
36
  collection :features
33
37
  collection :firewall_rules
34
38
  collection :firewalls
@@ -71,12 +75,15 @@ class Ey::Core::Client < Cistern::Service
71
75
  model :application
72
76
  model :application_archive
73
77
  model :application_deployment
78
+ model :auto_scaling_alarm
74
79
  model :auto_scaling_group
75
80
  model :backup_file
81
+ model :base_auto_scaling_policy
76
82
  model :billing
77
83
  model :blueprint
78
84
  model :component
79
85
  model :contact
86
+ model :container_service_deployment
80
87
  model :cost
81
88
  model :database_plan_usage
82
89
  model :database_server
@@ -87,6 +94,7 @@ class Ey::Core::Client < Cistern::Service
87
94
  model :deployment
88
95
  model :environment
89
96
  model :environment_plan_usage
97
+ model :environment_variable
90
98
  model :feature
91
99
  model :firewall
92
100
  model :firewall_rule
@@ -109,10 +117,13 @@ class Ey::Core::Client < Cistern::Service
109
117
  model :server_event
110
118
  model :server_usage
111
119
  model :service
120
+ model :simple_auto_scaling_policy
112
121
  model :ssl_certificate
122
+ model :step_auto_scaling_policy
113
123
  model :storage
114
124
  model :storage_user
115
125
  model :support_trial
126
+ model :target_auto_scaling_policy
116
127
  model :task
117
128
  model :token
118
129
  model :untracked_address
@@ -136,12 +147,14 @@ class Ey::Core::Client < Cistern::Service
136
147
  request :create_alert
137
148
  request :create_application
138
149
  request :create_application_archive
150
+ request :create_auto_scaling_alarm
139
151
  request :create_auto_scaling_group
140
152
  request :create_backup_file
141
153
  request :create_database_server
142
154
  request :create_database_service
143
155
  request :create_database_service_snapshot
144
156
  request :create_environment
157
+ request :create_environment_variable
145
158
  request :create_firewall
146
159
  request :create_firewall_rule
147
160
  request :create_keypair
@@ -154,6 +167,7 @@ class Ey::Core::Client < Cistern::Service
154
167
  request :create_password_reset
155
168
  request :create_provider
156
169
  request :create_server
170
+ request :create_auto_scaling_policy
157
171
  request :create_ssl_certificate
158
172
  request :create_storage
159
173
  request :create_storage_user
@@ -165,6 +179,7 @@ class Ey::Core::Client < Cistern::Service
165
179
  request :deploy_environment_application
166
180
  request :deprovision_environment
167
181
  request :destroy_addon
182
+ request :destroy_auto_scaling_alarm
168
183
  request :destroy_auto_scaling_group
169
184
  request :destroy_blueprint
170
185
  request :destroy_database_server
@@ -177,12 +192,14 @@ class Ey::Core::Client < Cistern::Service
177
192
  request :destroy_logical_database
178
193
  request :destroy_provider
179
194
  request :destroy_server
195
+ request :destroy_auto_scaling_policy
180
196
  request :destroy_ssl_certificate
181
197
  request :destroy_storage
182
198
  request :destroy_storage_user
183
199
  request :destroy_user
184
200
  request :detach_address
185
201
  request :disable_feature
202
+ request :discover_container_service_deployments
186
203
  request :discover_database_server
187
204
  request :discover_database_server_snapshots
188
205
  request :discover_provider_location
@@ -208,6 +225,8 @@ class Ey::Core::Client < Cistern::Service
208
225
  request :get_application_deployment
209
226
  request :get_application_deployments
210
227
  request :get_applications
228
+ request :get_auto_scaling_alarm
229
+ request :get_auto_scaling_alarms
211
230
  request :get_auto_scaling_group
212
231
  request :get_auto_scaling_groups
213
232
  request :get_backup_file
@@ -236,6 +255,8 @@ class Ey::Core::Client < Cistern::Service
236
255
  request :get_environment_database_services
237
256
  request :get_environment_logical_databases
238
257
  request :get_environment_plan_usages
258
+ request :get_environment_variable
259
+ request :get_environment_variables
239
260
  request :get_environments
240
261
  request :get_feature
241
262
  request :get_features
@@ -278,6 +299,8 @@ class Ey::Core::Client < Cistern::Service
278
299
  request :get_server_events
279
300
  request :get_server_usages
280
301
  request :get_servers
302
+ request :get_auto_scaling_policy
303
+ request :get_auto_scaling_policies
281
304
  request :get_ssl_certificate
282
305
  request :get_ssl_certificates
283
306
  request :get_storage
@@ -301,6 +324,7 @@ class Ey::Core::Client < Cistern::Service
301
324
  request :reset_password
302
325
  request :reset_server_state
303
326
  request :restart_environment_app_servers
327
+ request :retrieve_docker_registry_credentials
304
328
  request :run_cluster_application_action
305
329
  request :run_environment_application_action
306
330
  request :signup
@@ -312,10 +336,13 @@ class Ey::Core::Client < Cistern::Service
312
336
  request :update_address
313
337
  request :update_alert
314
338
  request :update_application_archive
339
+ request :update_auto_scaling_alarm
315
340
  request :update_auto_scaling_group
341
+ request :update_auto_scaling_policy
316
342
  request :update_billing
317
343
  request :update_blueprint
318
344
  request :update_environment
345
+ request :update_environment_variable
319
346
  request :update_membership
320
347
  request :update_provider_location
321
348
  request :update_server
@@ -0,0 +1,8 @@
1
+ class Ey::Core::Client::AutoScalingAlarms < Ey::Core::Collection
2
+ model Ey::Core::Client::AutoScalingAlarm
3
+
4
+ self.model_root = "auto_scaling_alarm"
5
+ self.model_request = :get_auto_scaling_alarm
6
+ self.collection_root = "auto_scaling_alarms"
7
+ self.collection_request = :get_auto_scaling_alarms
8
+ end
@@ -0,0 +1,33 @@
1
+ class Ey::Core::Client::AutoScalingPolicies < Ey::Core::Collection
2
+ model Ey::Core::Client::BaseAutoScalingPolicy
3
+
4
+ MODELS_TO_TYPE = {
5
+ "simple" => Ey::Core::Client::SimpleAutoScalingPolicy,
6
+ "step" => Ey::Core::Client::StepAutoScalingPolicy,
7
+ "target" => Ey::Core::Client::TargetAutoScalingPolicy
8
+ }.freeze
9
+
10
+ self.model_root = "auto_scaling_policy"
11
+ self.model_request = :get_auto_scaling_policy
12
+ self.collection_root = "auto_scaling_policies"
13
+ self.collection_request = :get_auto_scaling_policies
14
+
15
+ def new(attributes = {})
16
+ unless attributes.is_a?(::Hash)
17
+ raise(ArgumentError.new("Initialization parameters must be an attributes hash, got #{attributes.class} #{attributes.inspect}"))
18
+ end
19
+
20
+ params = Cistern::Hash.stringify_keys(attributes)
21
+ type = params["type"] ||= "simple"
22
+ model = MODELS_TO_TYPE[type]
23
+ unless model
24
+ raise(ArgumentError.new("Unrecognized policy type #{type}. Allowed types are: #{MODELS_TO_TYPE.keys.join(', ')}"))
25
+ end
26
+ model.new(
27
+ {
28
+ :collection => self,
29
+ :connection => connection,
30
+ }.merge(params)
31
+ )
32
+ end
33
+ end
@@ -0,0 +1,9 @@
1
+ class Ey::Core::Client::ContainerClusters < Ey::Core::Collection
2
+
3
+ model Ey::Core::Client::ContainerCluster
4
+
5
+ self.model_root = "container_cluster"
6
+ self.model_request = :get_container_cluster
7
+ self.collection_root = "container_clusters"
8
+ self.collection_request = :get_container_clusters
9
+ end
@@ -0,0 +1,17 @@
1
+ class Ey::Core::Client::ContainerServiceDeployments < Ey::Core::Collection
2
+
3
+ model Ey::Core::Client::ContainerServiceDeployment
4
+
5
+ self.model_root = "container_service_deployment"
6
+ self.model_request = :get_container_service_deployment
7
+ self.collection_root = "container_service_deployments"
8
+ self.collection_request = :get_container_service_deployments
9
+
10
+ def discover(task_definition_arn)
11
+ params = {
12
+ "task_definition_arn" => task_definition_arn
13
+ }
14
+
15
+ connection.requests.new(connection.discover_container_service_deployments(params).body["request"])
16
+ end
17
+ end
@@ -0,0 +1,8 @@
1
+ class Ey::Core::Client::EnvironmentVariables < Ey::Core::Collection
2
+ model Ey::Core::Client::EnvironmentVariable
3
+
4
+ self.model_root = "environment_variable"
5
+ self.model_request = :get_environment_variable
6
+ self.collection_root = "environment_variables"
7
+ self.collection_request = :get_environment_variables
8
+ end
@@ -1,3 +1,5 @@
1
+ require 'hashie'
2
+
1
3
  class Ey::Core::Client::Account < Ey::Core::Model
2
4
  extend Ey::Core::Associations
3
5
 
@@ -67,4 +69,12 @@ class Ey::Core::Client::Account < Ey::Core::Model
67
69
  else raise NotImplementedError # update
68
70
  end
69
71
  end
72
+
73
+ # Get authorization data for an Amazon ECR registry.
74
+ # @param [String] location_id Aws region
75
+ # @return [Hashie::Mash]
76
+ def retrieve_docker_registry_credentials(location_id)
77
+ result = self.connection.retrieve_docker_registry_credentials(self.id, location_id).body
78
+ ::Hashie::Mash.new(result['docker_registry_credentials'])
79
+ end
70
80
  end
@@ -7,6 +7,7 @@ class Ey::Core::Client::Address < Ey::Core::Model
7
7
  attribute :ip_address
8
8
  attribute :provisioned_id
9
9
  attribute :location
10
+ attribute :scope
10
11
  attribute :disappeared_at, type: :time
11
12
 
12
13
  has_one :provider
@@ -37,6 +38,7 @@ class Ey::Core::Client::Address < Ey::Core::Model
37
38
  "provider" => self.provider_id,
38
39
  "address" => {
39
40
  "location" => self.location,
41
+ "scope" => self.scope,
40
42
  },
41
43
  }
42
44
 
@@ -12,6 +12,7 @@ class Ey::Core::Client::Application < Ey::Core::Model
12
12
 
13
13
  has_many :archives, key: :application_archives
14
14
  has_many :keypairs
15
+ has_many :environment_variables
15
16
 
16
17
  def save!
17
18
  params = {
@@ -0,0 +1,54 @@
1
+ class Ey::Core::Client::AutoScalingAlarm < Ey::Core::Model
2
+ extend Ey::Core::Associations
3
+
4
+ identity :id
5
+
6
+ attribute :deleted_at, type: :time
7
+ attribute :created_at, type: :time
8
+ attribute :updated_at, type: :time
9
+ attribute :auto_scaling_policy_id, aliases: "auto_scaling_policy", squash: ["id"]
10
+ attribute :name
11
+ attribute :aggregation_type
12
+ attribute :metric_type
13
+ attribute :operand
14
+ attribute :trigger_value, type: :float
15
+ attribute :number_of_periods, type: :integer
16
+ attribute :period_length, type: :integer
17
+ attribute :provisioned_id
18
+
19
+ has_one :auto_scaling_policy
20
+
21
+ def save!
22
+ requires :auto_scaling_policy_id, :trigger_value, :period_length
23
+ params = {
24
+ "auto_scaling_alarm" => {
25
+ "name" => name,
26
+ "trigger_value" => trigger_value,
27
+ "aggregation_type" => aggregation_type,
28
+ "metric_type" => metric_type,
29
+ "operand" => operand,
30
+ "period_length" => period_length,
31
+ "number_of_periods" => number_of_periods
32
+ },
33
+ "auto_scaling_policy_id" => auto_scaling_policy_id
34
+ }
35
+
36
+ if new_record?
37
+ requires :name
38
+ request_attributes = connection.create_auto_scaling_alarm(params).body["request"]
39
+ connection.requests.new(request_attributes)
40
+ else
41
+ requires :identity
42
+ params.merge!("id" => identity)
43
+ connection.requests.new(connection.update_auto_scaling_alarm(params).body["request"])
44
+ end
45
+ end
46
+
47
+ def destroy!
48
+ requires :identity
49
+
50
+ connection.requests.new(
51
+ connection.destroy_auto_scaling_alarm("id" => identity).body["request"]
52
+ )
53
+ end
54
+ end
@@ -10,6 +10,8 @@ class Ey::Core::Client::AutoScalingGroup < Ey::Core::Model
10
10
  attribute :minimum_size
11
11
  attribute :maximum_size
12
12
  attribute :desired_capacity
13
+ attribute :default_cooldown
14
+ attribute :grace_period
13
15
 
14
16
  has_one :environment
15
17
 
@@ -46,4 +48,28 @@ class Ey::Core::Client::AutoScalingGroup < Ey::Core::Model
46
48
  connection.requests.new(connection.update_auto_scaling_group(params).body["request"])
47
49
  end
48
50
  end
51
+
52
+ def simple_auto_scaling_policies
53
+ auto_scaling_policies("simple")
54
+ end
55
+
56
+ def step_auto_scaling_policies
57
+ auto_scaling_policies("step")
58
+ end
59
+
60
+ def target_auto_scaling_policies
61
+ auto_scaling_policies("target")
62
+ end
63
+
64
+ private
65
+
66
+ def auto_scaling_policies(types = nil)
67
+ requires :identity
68
+ data = connection.get_auto_scaling_policies(
69
+ "auto_scaling_group" => identity,
70
+ "types" => [*types]
71
+ ).body["auto_scaling_policies"]
72
+
73
+ connection.auto_scaling_policies.load(data)
74
+ end
49
75
  end
@@ -0,0 +1,61 @@
1
+ class Ey::Core::Client::BaseAutoScalingPolicy < Ey::Core::Model
2
+ extend Ey::Core::Associations
3
+
4
+ identity :id, type: :integer
5
+
6
+ attribute :provisioned_id
7
+ attribute :provisioner_id
8
+ attribute :type
9
+ attribute :name
10
+ attribute :configuration
11
+ attribute :auto_scaling_group_id
12
+
13
+ has_one :auto_scaling_group
14
+
15
+ def save!
16
+ requires :auto_scaling_group_id, :type
17
+ params = {
18
+ "url" => self.collection.url,
19
+ "auto_scaling_policy" => {
20
+ "name" => self.name
21
+ }.merge(policy_params),
22
+ "auto_scaling_group_id" => self.auto_scaling_group_id
23
+ }
24
+
25
+ if new_record?
26
+ policy_requires
27
+ requires :name
28
+ connection.requests.new(connection.create_auto_scaling_policy(params).body["request"])
29
+ else
30
+ requires :identity
31
+ params.merge("id" => identity)
32
+ connection.requests.new(connection.update_auto_scaling_policy(params).body["request"])
33
+ end
34
+ end
35
+
36
+ def destroy!
37
+ connection.requests.new(
38
+ self.connection.destroy_auto_scaling_policy("id" => self.id).body["request"]
39
+ )
40
+ end
41
+
42
+ def alarm
43
+ requires :identity
44
+
45
+ data = self.connection.get_auto_scaling_alarms(
46
+ "auto_scaling_policy_id" => identity
47
+ ).body["auto_scaling_alarms"]
48
+
49
+ self.connection.auto_scaling_alarms.load(data).first
50
+ end
51
+
52
+ private
53
+
54
+ def policy_params
55
+ raise NotImplementedError
56
+ end
57
+
58
+ def policy_requires
59
+ raise NotImplementedError
60
+ end
61
+ end