ey-core 3.1.11 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: bd619c98f8df6a367b18e450e20b2f0ef7ab8be7
4
+ data.tar.gz: d8ad89c80c163b0a55da4fe1e2506c2f74edaa78
5
+ SHA512:
6
+ metadata.gz: e710b35f185c9cae9d0f61f5f94b795110922fd7aa392e75092082b4b9c36f6a74ab63f29675b52eaed1e771d65af245adda73954033eeeafe23ce4de913a682
7
+ data.tar.gz: 5a879258d9d1699153927b1d7f029003df6c652fc8de3cae2eb9aa1256af5eaee8748a8c2ec5025d8aeed9a48e22290e0adad774ba0ca37caa353b1d40871024
@@ -0,0 +1,14 @@
1
+ ## Examples and snippets to use with the `ey-core console`
2
+
3
+ ### Getting started
4
+
5
+ With the _ey-core_ gem comes the `ey-core console` utility which allows to query the CoreAPI interactively. Below are a series of snippets with commands that will allow actions that normally are done through the EY dashboard, and others which aren't implemented yet but the CoreAPI already supports.
6
+
7
+ The backend will automatically allow/reject actions based on the api token the console is using. Upon a successful `ey-core login` said token is written on `$HOME/.ey-core` and picked up from there by the console. It's a good practice to issue `ey-core whoami` before opening the console to double check that the desired user is logged in.
8
+
9
+ - Addresses
10
+ - [List addresses allocated to the account](address.md#list-addresses-on-an-account)
11
+ - [Provision a new address](address.md#provision-new-address)
12
+ - [Attach an address to an instance/server](address.md#attach-address-to-instance)
13
+ - [Detach an address from an instance/server](address.md#detach-address-from-instance)
14
+
@@ -0,0 +1,51 @@
1
+ # IP Addresses
2
+
3
+ It's advised for each operation to capture the request via an *<operation>_prov_req* variable, which will hold the operation's status. The snippets below just wait for the request to finish (or timeout in 300sec), but the progress can be tracked issuing `<operation>_prov_req.reload` regularly.
4
+
5
+ -
6
+
7
+ <a name="list-addresses-on-an-account"></a>
8
+ ### List IPs addresses allocated to an account
9
+
10
+ ```
11
+ addresses
12
+ ```
13
+
14
+ -
15
+
16
+ <a name="provision-new-address"></a>
17
+ ### Provision a new IP address on the account
18
+
19
+ ```
20
+ new_address_specs = {:provider_id => "23952", :location => "us-east-1"}
21
+ address_prov_req = addresses.create(new_eip_specs)
22
+ address_prov_req.ready!(300)
23
+ ```
24
+
25
+ -
26
+
27
+ <a name="attach-address-to-instance"></a>
28
+ ### Attach an address to an instance
29
+
30
+ ```
31
+ addresses
32
+ address = addresses.first(ip_address: "111.222.333.444")
33
+ attach_prov_req = address.attach(servers.first(provisioned_id: "i-aabbccdd"))
34
+ attach_prov_req.ready!(300)
35
+ ```
36
+
37
+ -
38
+
39
+ <a name="detach-address-from-instance"></a>
40
+ ### Detach an address from an instance
41
+
42
+ ```
43
+ addresses
44
+ eip = addresses.first(ip_address: "111.222.333.444")
45
+ detach_prov_req = eip.detach
46
+ detach_prov_req.ready!(300)
47
+ ```
48
+
49
+ -
50
+
51
+
@@ -118,6 +118,7 @@ class Ey::Core::Client < Cistern::Service
118
118
  model :user
119
119
  model :volume
120
120
 
121
+ request :acknowledge_alert
121
122
  request :apply_environment_updates
122
123
  request :apply_server_updates
123
124
  request :attach_address
@@ -289,11 +290,13 @@ class Ey::Core::Client < Cistern::Service
289
290
  request :reboot_server
290
291
  request :request_callback
291
292
  request :reset_password
293
+ request :reset_server_state
292
294
  request :restart_environment_app_servers
293
295
  request :run_cluster_application_action
294
296
  request :run_environment_application_action
295
297
  request :signup
296
298
  request :timeout_deployment
299
+ request :unassign_environment
297
300
  request :update_addon
298
301
  request :update_address
299
302
  request :update_alert
@@ -302,6 +305,7 @@ class Ey::Core::Client < Cistern::Service
302
305
  request :update_blueprint
303
306
  request :update_environment
304
307
  request :update_membership
308
+ request :update_provider_location
305
309
  request :update_server
306
310
  request :update_ssl_certificate
307
311
  request :update_untracked_server
@@ -5,12 +5,15 @@ class Ey::Core::Client::Account < Ey::Core::Model
5
5
 
6
6
  attribute :cancelled_at, type: :time
7
7
  attribute :created_at, type: :time
8
- attribute :updated_at, type: :time
8
+ attribute :emergency_contact
9
+ attribute :fraudulent
10
+ attribute :legacy_id
9
11
  attribute :name
10
- attribute :support_plan
11
- attribute :signup_via
12
12
  attribute :plan_type
13
+ attribute :signup_via
14
+ attribute :support_plan
13
15
  attribute :type
16
+ attribute :updated_at, type: :time
14
17
 
15
18
  has_many :addresses
16
19
  has_many :applications
@@ -48,6 +48,11 @@ class Ey::Core::Client::Alert < Ey::Core::Model
48
48
  (type == "database-servers" || nil) && self.connection.database_servers.get!(identity)
49
49
  end
50
50
 
51
+ def acknowledge!
52
+ requires :id
53
+ merge_attributes(self.connection.acknowledge_alert("id" => self.id).body["legacy_alert"])
54
+ end
55
+
51
56
  def save!
52
57
  response = if new_record?
53
58
  params = {
@@ -21,6 +21,7 @@ class Ey::Core::Client::Environment < Ey::Core::Model
21
21
  has_one :account
22
22
  has_one :database_service
23
23
  has_one :firewall
24
+ has_one :assignee, assoc_name: :user, resource: :user
24
25
 
25
26
  has_many :costs
26
27
  has_many :keypairs
@@ -196,6 +197,11 @@ class Ey::Core::Client::Environment < Ey::Core::Model
196
197
  end
197
198
  end
198
199
 
200
+ def unassign!
201
+ requires :id
202
+ merge_attributes(self.connection.unassign_environment("id" => self.id).body["environment"])
203
+ end
204
+
199
205
  def save!
200
206
  if new_record?
201
207
  requires :application_id, :account_id, :region
@@ -8,4 +8,17 @@ class Ey::Core::Client::ProviderLocation < Ey::Core::Model
8
8
  attribute :limits, type: :hash
9
9
 
10
10
  has_one :provider
11
+
12
+ def save!
13
+ params = {
14
+ "id" => self.id,
15
+ "provider_location" => {
16
+ "limits" => self.limits,
17
+ },
18
+ }
19
+
20
+ unless new_record?
21
+ merge_attributes(self.connection.update_provider_location(params).body["provider_location"])
22
+ end
23
+ end
11
24
  end
@@ -17,9 +17,11 @@ class Ey::Core::Client::Server < Ey::Core::Model
17
17
  attribute :provisioned_at, type: :time
18
18
  attribute :provisioned_id
19
19
  attribute :public_hostname
20
+ attribute :public_key
20
21
  attribute :role
21
22
  attribute :ssh_port, type: :integer
22
23
  attribute :state
24
+ attribute :token
23
25
  attribute :updated_at, type: :time
24
26
  attribute :wait_for_chef, type: :boolean
25
27
  attribute :release_label
@@ -59,6 +61,18 @@ class Ey::Core::Client::Server < Ey::Core::Model
59
61
  )
60
62
  end
61
63
 
64
+ def reset_state(state)
65
+ params = {
66
+ "url" => self.collection.url,
67
+ "id" => self.id,
68
+ "state" => state
69
+ }
70
+
71
+ unless new_record?
72
+ merge_attributes(self.connection.reset_server_state(params).body["server"])
73
+ end
74
+ end
75
+
62
76
  def save!
63
77
  if new_record?
64
78
  requires :flavor_id, :role, :environment
@@ -3,6 +3,7 @@ class Ey::Core::Client::User < Ey::Core::Model
3
3
 
4
4
  identity :id
5
5
 
6
+ attribute :token, aliases: ["api_token"]
6
7
  attribute :name
7
8
  attribute :email
8
9
  attribute :staff
@@ -0,0 +1,29 @@
1
+ class Ey::Core::Client
2
+ class Real
3
+ def acknowledge_alert(params={})
4
+ id = params.delete("id")
5
+
6
+ request(
7
+ method: :put,
8
+ path: "legacy-alerts/#{id}/acknowledge"
9
+ )
10
+ end
11
+ end
12
+
13
+ class Mock
14
+ def acknowledge_alert(params={})
15
+ id = params.delete("id")
16
+
17
+ if alert = self.data[:alerts][id]
18
+ alert["acknowledged"] = true
19
+
20
+ response(
21
+ :body => {"legacy_alert" => alert},
22
+ :status => 200
23
+ )
24
+ else
25
+ response(status: 404)
26
+ end
27
+ end
28
+ end
29
+ end
@@ -32,6 +32,7 @@ class Ey::Core::Client
32
32
  "memberships" => url_for("/users/#{resource_id}/memberships"),
33
33
  "keypairs" => url_for("/users/#{resource_id}/keypairs"),
34
34
  "tokens" => url_for("/users/#{resource_id}/tokens"),
35
+ "api_token" => SecureRandom.hex(16),
35
36
  })
36
37
 
37
38
  self.data[:tokens][token_id] = {
@@ -25,7 +25,11 @@ class Ey::Core::Client
25
25
  self.data[:environments][environment_id]
26
26
  end.compact.uniq.inject({}) {|hash, env| hash[env["id"]] = env; hash}
27
27
 
28
- headers, environments_page = search_and_page(params, :environments, search_keys: %w[account project name], resources: resources)
28
+ if params.delete("exclude_ignored")
29
+ resources.reject! { |id,hash| hash["permanently_ignored"] }
30
+ end
31
+
32
+ headers, environments_page = search_and_page(params, :environments, search_keys: %w[account project name assignee_id], resources: resources)
29
33
 
30
34
  response(
31
35
  :body => {"environments" => environments_page},
@@ -0,0 +1,32 @@
1
+ class Ey::Core::Client
2
+ class Real
3
+ def reset_server_state(params={})
4
+ id = params.delete("id")
5
+ url = params.delete("url")
6
+
7
+ request(
8
+ :method => :put,
9
+ :path => "servers/#{id}/reset_state",
10
+ :body => params,
11
+ :url => url,
12
+ )
13
+ end
14
+ end # Real
15
+
16
+ class Mock
17
+ def reset_server_state(params={})
18
+ id = params["id"]
19
+ state = params["state"]
20
+
21
+ if server = self.data[:servers][id]
22
+ server[:state] = state
23
+ response(
24
+ :body => {"server" => server},
25
+ :status => 200,
26
+ )
27
+ else
28
+ response(status: 404)
29
+ end
30
+ end
31
+ end # Mock
32
+ end
@@ -0,0 +1,31 @@
1
+ class Ey::Core::Client
2
+ class Real
3
+ def unassign_environment(params={})
4
+ id = params["id"]
5
+ url = params["url"]
6
+
7
+ request(
8
+ :method => :put,
9
+ :url => url,
10
+ :path => "/environments/#{id}/unassign",
11
+ )
12
+ end
13
+ end # Real
14
+
15
+ class Mock
16
+ def unassign_environment(params={})
17
+ request_id = self.uuid
18
+ url = params.delete("url")
19
+
20
+ environment_id = params["id"] || url && url.split('/').last
21
+
22
+ environment = self.data[:environments][environment_id]
23
+ environment[:assignee] = nil
24
+
25
+ response(
26
+ :body => {"environment" => environment},
27
+ :status => 200,
28
+ )
29
+ end
30
+ end # Mock
31
+ end # Ey::Core::Client
@@ -0,0 +1,29 @@
1
+ class Ey::Core::Client
2
+ class Real
3
+ def update_provider_location(params={})
4
+ id = params.delete("id")
5
+ request(
6
+ :method => :put,
7
+ :path => "/provider-locations/#{id}",
8
+ :body => params,
9
+ )
10
+ end
11
+ end
12
+
13
+ class Mock
14
+ def update_provider_location(params={})
15
+ resource_id = params.delete("id")
16
+
17
+ if provider_location = self.data[:provider_locations][resource_id]
18
+ provider_location[:limits] = params["provider_location"]["limits"]
19
+
20
+ response(
21
+ :body => {"provider_location" => provider_location},
22
+ :status => 200,
23
+ )
24
+ else
25
+ response(status:404)
26
+ end
27
+ end
28
+ end
29
+ end
@@ -3,8 +3,8 @@ module Ey
3
3
  module TestHelpers
4
4
  module AccountHelpers
5
5
  def create_account(options={})
6
- creator = options[:creator] || create_client
7
- client = options[:client]
6
+ client = options[:client]
7
+ creator = options[:creator] || client || create_client
8
8
 
9
9
  attributes = options[:account] || {}
10
10
  attributes[:type] ||= "beta" # get around awsm billing requirements for tests
@@ -28,8 +28,8 @@ module Ey
28
28
  end
29
29
 
30
30
  def create_user(options={})
31
- creator = options[:creator] || create_client
32
- client = options[:client]
31
+ client = options[:client]
32
+ creator = options[:creator] || client || create_client
33
33
 
34
34
  attributes = options[:user] || {}
35
35
  attributes[:name] ||= Faker::Name.name
@@ -23,11 +23,14 @@ module Ey
23
23
 
24
24
  def create_server(client, options={})
25
25
  options = Cistern::Hash.stringify_keys(options)
26
-
27
- request = environment.servers.create(
28
- "flavor" => "m3.medium",
29
- "role" => "util",
30
- )
26
+ environment = options["environment"]
27
+
28
+ request = client.servers.create!({
29
+ :environment => environment,
30
+ :flavor_id => 'm3.medium',
31
+ :role => 'util',
32
+ :name => 'resque',
33
+ }.merge(options["server"] || {}))
31
34
 
32
35
  request.resource!
33
36
  end
@@ -1,5 +1,5 @@
1
1
  module Ey
2
2
  module Core
3
- VERSION = "3.1.11"
3
+ VERSION = "3.2.0"
4
4
  end
5
5
  end
@@ -0,0 +1,65 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'accounts' do
4
+ let(:client) {create_client}
5
+
6
+ let(:account) {
7
+ create_account(
8
+ client: client, creator: client,
9
+ account: {
10
+ owner: create_user(client: client, creator: client)
11
+ }.merge(details)
12
+ )
13
+ }
14
+
15
+ describe '#type' do
16
+ let(:details) {{type: 'oracle'}}
17
+
18
+ it 'is the account type for the account' do
19
+ expect(account.type).to eql('oracle')
20
+ end
21
+ end
22
+
23
+ describe '#signup_via' do
24
+ let(:details) {{signup_via: 'deis'}}
25
+
26
+ it 'is the service through which the owner signed up' do
27
+ expect(account.signup_via).to eql('deis')
28
+ end
29
+ end
30
+
31
+ describe '#legacy_id' do
32
+ let(:details) {{}}
33
+
34
+ # Fun fact: we're not allowed to set legacy_id in create_account
35
+ before(:each) do
36
+ client.data[:accounts][account.id].merge!(
37
+ {'legacy_id' => '19283'}
38
+ )
39
+
40
+ account.reload
41
+ end
42
+
43
+ it 'is the legacy_id for the account' do
44
+ expect(account.legacy_id).to eql('19283')
45
+ end
46
+ end
47
+
48
+ context 'when searched by legacy_id' do
49
+ let(:details) {{}}
50
+ let(:legacy_id) {Cistern::Mock.random_numbers(6)}
51
+ let(:searched) {client.accounts.all(legacy_id: legacy_id)}
52
+
53
+ before(:each) do
54
+ client.data[:accounts][account.id].merge!(
55
+ {'legacy_id' => legacy_id}
56
+ )
57
+
58
+ account.reload
59
+ end
60
+
61
+ it 'is a resounding success', mock_only: true do
62
+ expect(searched).to include(account)
63
+ end
64
+ end
65
+ end
data/spec/alerts_spec.rb CHANGED
@@ -144,5 +144,12 @@ describe 'alerts' do
144
144
  }.to change { alert.reload.finished_at }.from(nil).
145
145
  and change { database_server.alerts.all.size }.by(-1)
146
146
  end
147
+
148
+ it 'acknowledges the alert' do
149
+ alert = alerts.first
150
+ expect {
151
+ alert.acknowledge!
152
+ }.to change { alert.acknowledged }.from(false).to(true)
153
+ end
147
154
  end
148
155
  end
@@ -45,7 +45,6 @@ describe 'as a user' do
45
45
  let(:other_environment) { create_environment(enviroment: { name: Faker::Name.first_name}, application: app, account: account) }
46
46
 
47
47
  before do
48
- pending "adding servers to environments not yet implemented"
49
48
  create_server(client,
50
49
  provisioned_id: "i-a1000fce",
51
50
  provider: provider,
@@ -64,12 +63,68 @@ describe 'as a user' do
64
63
  expect(environments).to include(alerting_environment)
65
64
  expect(environments).not_to include(other_environment)
66
65
  end
66
+
67
+ context "and the environment is permanently ignored", mock_only: true do
68
+ before(:each) do
69
+ client.data[:environments][alerting_environment.id]["permanently_ignored"] = true
70
+ end
71
+
72
+ it "returns the ignored environment by default" do
73
+ expect(client.environments.alerting).to contain_exactly(alerting_environment)
74
+ end
75
+
76
+ it "filters it if you tell it to" do
77
+ expect(client.environments.alerting("exclude_ignored" => true)).to be_empty
78
+ end
79
+ end
67
80
  end
68
81
 
69
82
  context "with an environment" do
70
83
  let!(:name) { Faker::Name.first_name }
71
84
  let!(:environment) { create_environment(account: account, application: app, environment: {name: name}, configuration: {type: "production"}) }
72
85
 
86
+ describe '#assignee' do
87
+ let(:assignee) {client.environments.get(environment.id).assignee}
88
+
89
+ context 'for an environment with an assignee' do
90
+ let(:user) {create_user(client: client, creator: client)}
91
+
92
+ before(:each) do
93
+ # Since we can't set an assignee directly ...
94
+ client.data[:environments][environment.id]['assignee_id'] = user.id
95
+ end
96
+
97
+ it 'is the user assigned to the environment' do
98
+ expect(assignee).to eql(user)
99
+ end
100
+ end
101
+
102
+ context 'for an environment without an assignee' do
103
+ it 'is nil' do
104
+ expect(assignee).to be_nil
105
+ end
106
+ end
107
+ end
108
+
109
+ describe '#unassign!' do
110
+ let(:user) {create_user(client: client, creator: client)}
111
+
112
+ let(:test_env) {account.environments.get(environment.id)}
113
+
114
+ before(:each) do
115
+ # Since we can't set an assignee directly ...
116
+ client.data[:environments][environment.id]['assignee_id'] = user.id
117
+ end
118
+
119
+ it 'removes the assignment from the environment' do
120
+ expect(test_env.assignee).not_to be_nil
121
+
122
+ test_env.unassign!
123
+
124
+ expect(test_env.assignee).to be_nil
125
+ end
126
+ end
127
+
73
128
  it "has the right number of servers" do
74
129
  expect(environment.servers.count).to eq(5)
75
130
  end
@@ -18,7 +18,7 @@ describe 'as a user' do
18
18
  acknowledged: false)
19
19
  end
20
20
 
21
- it "should fetch a legacy alert" do
21
+ it "fetches a legacy alert" do
22
22
  a = client.legacy_alerts.get(1001)
23
23
 
24
24
  expect(a).not_to be_nil
@@ -29,7 +29,7 @@ describe 'as a user' do
29
29
  expect(a.server).to eq(server)
30
30
  end
31
31
 
32
- it "should list legacy alerts" do
32
+ it "lists legacy alerts" do
33
33
  legacy_alerts = client.legacy_alerts.all
34
34
  expect(legacy_alerts.size).to be(1)
35
35
 
@@ -22,7 +22,7 @@ describe 'provider locations' do
22
22
  before do
23
23
  end
24
24
 
25
- it "should find the provider location" do
25
+ it "finds the provider location" do
26
26
  location = client.provider_locations.get(provider_location.id)
27
27
 
28
28
  expect(location.id).to eq(provider_location.id)
@@ -46,7 +46,7 @@ describe 'provider locations' do
46
46
  end
47
47
  end
48
48
 
49
- it "should list provider locations" do
49
+ it "lists provider locations" do
50
50
  locations = provider.provider_locations.all
51
51
 
52
52
  expect(locations.size).to be > 0
@@ -60,5 +60,26 @@ describe 'provider locations' do
60
60
  expect(location.limits["addresses"]).to eq(provider_location.limits["addresses"])
61
61
  end
62
62
  end
63
+
64
+ describe '#limits=' do
65
+ let(:new_limits) {{servers: 25, addresses: 10}}
66
+
67
+ it 'sets new limits for the provider location' do
68
+ provider_location.limits = new_limits
69
+
70
+ expect(provider_location.limits).to eql(new_limits)
71
+ end
72
+
73
+ it 'is persisted when saved' do
74
+ limits = {"servers" => 20, "addresses" => 5}
75
+ provider_location.limits = new_limits
76
+
77
+ expect(provider.provider_locations.get(provider_location.id).limits).to eql(limits)
78
+
79
+ provider_location.save!
80
+
81
+ expect(provider.provider_locations.get(provider_location.id).limits).to eql(new_limits)
82
+ end
83
+ end
63
84
  end
64
85
  end
@@ -6,7 +6,7 @@ describe 'providers' do
6
6
  let!(:account) { create_account(client: client) }
7
7
 
8
8
  ["azure", "aws"].each do |provider|
9
- it "should have possible #{provider} locations without a provider type" do
9
+ it "has possible #{provider} locations without a provider type" do
10
10
  locations = client.provider.possible_locations(provider)
11
11
  expect(locations).to be_a(Array)
12
12
  expect(locations).not_to be_empty
@@ -14,8 +14,8 @@ describe 'providers' do
14
14
  end
15
15
 
16
16
  context "with an account" do
17
- ["aws", "azure"].each do |type|
18
- it "should create a #{type} provider" do
17
+ ["aws"].each do |type|
18
+ it "creates a #{type} provider" do
19
19
  provisioned_id = SecureRandom.hex(8)
20
20
  provider = account.providers.create!(type: type, provisioned_id: provisioned_id, credentials: {}).resource!
21
21
 
@@ -27,16 +27,16 @@ describe 'providers' do
27
27
  context "with a #{type} provider" do
28
28
  let!(:provider) { account.providers.create!(type: type, provisioned_id: SecureRandom.hex(8), credentials: {}).resource! }
29
29
 
30
- it "should get an provider" do
30
+ it "gets an provider" do
31
31
  expect(account.providers.get(provider.id)).to eq(provider)
32
32
  end
33
33
 
34
- it "should have possible provider locations" do
34
+ it "has possible provider locations" do
35
35
  expect(provider.possible_locations).to be_a(Array)
36
36
  expect(provider.possible_locations).not_to be_empty
37
37
  end
38
38
 
39
- it "should get providers" do
39
+ it "gets providers" do
40
40
  another_account = create_account(client: client)
41
41
  create_provider(account: another_account)
42
42
 
@@ -46,12 +46,12 @@ describe 'providers' do
46
46
  expect(account_providers.first).to eq(provider)
47
47
  end
48
48
 
49
- it "should destroy the provider" do
49
+ it "destroys the provider" do
50
50
  expect(provider.destroy.ready!).to be_successful
51
51
  expect(provider.reload.cancelled_at).not_to be_nil
52
52
  end
53
53
 
54
- it "should discover locations for the #{type} provider", :mock_only do
54
+ it "discovers locations for the #{type} provider", :mock_only do
55
55
  provider.possible_locations.each do |location_id|
56
56
  provider_location = nil
57
57
  expect {
@@ -71,7 +71,7 @@ describe 'providers' do
71
71
  let!(:client_1_account_1) { client_1.accounts.create!(owner: owner, name: Faker::Name.first_name)}
72
72
  let!(:client_1_account_2) { client_1.accounts.create!(owner: owner, name: Faker::Name.first_name)}
73
73
 
74
- it "should not clobber other accounts' providers" do
74
+ it "does not clobber other accounts' providers" do
75
75
  # this just tests that the mock behaves reasonably
76
76
  client_1_account_1.providers.create!(type: "aws").ready!
77
77
 
data/spec/servers_spec.rb CHANGED
@@ -42,6 +42,12 @@ describe 'servers' do
42
42
  end
43
43
  end
44
44
 
45
+ it "should reset the server state" do
46
+ expect {
47
+ server.reset_state('error')
48
+ }.to change { server.reload.state }.from('running').to('error')
49
+ end
50
+
45
51
  it "does not destroy" do
46
52
  expect {
47
53
  server.destroy
data/spec/users_spec.rb CHANGED
@@ -78,5 +78,31 @@ describe 'users' do
78
78
  expect(client.users.all(deleted: true)).to include(user)
79
79
  expect(client.users.all(with_deleted: true)).to include(user)
80
80
  end
81
+
82
+ context "for the current user" do
83
+ let!(:user) { client.users.current }
84
+
85
+ describe '#token' do
86
+ subject { user.token }
87
+
88
+ context 'for my own user' do
89
+ it { is_expected.not_to be_nil }
90
+ end
91
+
92
+ context 'for another user' do
93
+ context 'as a staff user' do
94
+ before(:each) do
95
+ client.data[:users][user.id][:staff] = true
96
+ end
97
+
98
+ it { is_expected.not_to be_nil }
99
+ end
100
+
101
+ context 'as a non-staff user' do
102
+ it { is_expected.not_to be_nil }
103
+ end
104
+ end
105
+ end
106
+ end
81
107
  end
82
108
  end
metadata CHANGED
@@ -1,164 +1,144 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ey-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.11
5
- prerelease:
4
+ version: 3.2.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Josh Lane
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2016-08-08 00:00:00.000000000 Z
11
+ date: 2016-10-06 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: addressable
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
19
  version: '2.2'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
26
  version: '2.2'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: awesome_print
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: belafonte
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - ">="
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - ">="
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: cistern
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ~>
59
+ - - "~>"
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0.12'
70
62
  type: :runtime
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ~>
66
+ - - "~>"
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0.12'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: colorize
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ! '>='
73
+ - - ">="
84
74
  - !ruby/object:Gem::Version
85
75
  version: '0'
86
76
  type: :runtime
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ! '>='
80
+ - - ">="
92
81
  - !ruby/object:Gem::Version
93
82
  version: '0'
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: ey-hmac
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
- - - ~>
87
+ - - "~>"
100
88
  - !ruby/object:Gem::Version
101
89
  version: '2.0'
102
90
  type: :runtime
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
- - - ~>
94
+ - - "~>"
108
95
  - !ruby/object:Gem::Version
109
96
  version: '2.0'
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: escape
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
- - - ! '>='
101
+ - - ">="
116
102
  - !ruby/object:Gem::Version
117
103
  version: '0'
118
104
  type: :runtime
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
- - - ! '>='
108
+ - - ">="
124
109
  - !ruby/object:Gem::Version
125
110
  version: '0'
126
111
  - !ruby/object:Gem::Dependency
127
112
  name: faraday
128
113
  requirement: !ruby/object:Gem::Requirement
129
- none: false
130
114
  requirements:
131
- - - ~>
115
+ - - "~>"
132
116
  - !ruby/object:Gem::Version
133
117
  version: '0.9'
134
118
  type: :runtime
135
119
  prerelease: false
136
120
  version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
121
  requirements:
139
- - - ~>
122
+ - - "~>"
140
123
  - !ruby/object:Gem::Version
141
124
  version: '0.9'
142
125
  - !ruby/object:Gem::Dependency
143
126
  name: faraday_middleware
144
127
  requirement: !ruby/object:Gem::Requirement
145
- none: false
146
128
  requirements:
147
- - - ~>
129
+ - - "~>"
148
130
  - !ruby/object:Gem::Version
149
131
  version: '0.9'
150
132
  type: :runtime
151
133
  prerelease: false
152
134
  version_requirements: !ruby/object:Gem::Requirement
153
- none: false
154
135
  requirements:
155
- - - ~>
136
+ - - "~>"
156
137
  - !ruby/object:Gem::Version
157
138
  version: '0.9'
158
139
  - !ruby/object:Gem::Dependency
159
140
  name: rack
160
141
  requirement: !ruby/object:Gem::Requirement
161
- none: false
162
142
  requirements:
163
143
  - - '='
164
144
  - !ruby/object:Gem::Version
@@ -166,7 +146,6 @@ dependencies:
166
146
  type: :runtime
167
147
  prerelease: false
168
148
  version_requirements: !ruby/object:Gem::Requirement
169
- none: false
170
149
  requirements:
171
150
  - - '='
172
151
  - !ruby/object:Gem::Version
@@ -174,209 +153,183 @@ dependencies:
174
153
  - !ruby/object:Gem::Dependency
175
154
  name: faye
176
155
  requirement: !ruby/object:Gem::Requirement
177
- none: false
178
156
  requirements:
179
- - - ! '>='
157
+ - - ">="
180
158
  - !ruby/object:Gem::Version
181
159
  version: '0'
182
160
  type: :runtime
183
161
  prerelease: false
184
162
  version_requirements: !ruby/object:Gem::Requirement
185
- none: false
186
163
  requirements:
187
- - - ! '>='
164
+ - - ">="
188
165
  - !ruby/object:Gem::Version
189
166
  version: '0'
190
167
  - !ruby/object:Gem::Dependency
191
168
  name: highline
192
169
  requirement: !ruby/object:Gem::Requirement
193
- none: false
194
170
  requirements:
195
- - - ! '>='
171
+ - - ">="
196
172
  - !ruby/object:Gem::Version
197
173
  version: '0'
198
174
  type: :runtime
199
175
  prerelease: false
200
176
  version_requirements: !ruby/object:Gem::Requirement
201
- none: false
202
177
  requirements:
203
- - - ! '>='
178
+ - - ">="
204
179
  - !ruby/object:Gem::Version
205
180
  version: '0'
206
181
  - !ruby/object:Gem::Dependency
207
182
  name: json
208
183
  requirement: !ruby/object:Gem::Requirement
209
- none: false
210
184
  requirements:
211
- - - <
185
+ - - "<"
212
186
  - !ruby/object:Gem::Version
213
187
  version: '2.0'
214
188
  type: :runtime
215
189
  prerelease: false
216
190
  version_requirements: !ruby/object:Gem::Requirement
217
- none: false
218
191
  requirements:
219
- - - <
192
+ - - "<"
220
193
  - !ruby/object:Gem::Version
221
194
  version: '2.0'
222
195
  - !ruby/object:Gem::Dependency
223
196
  name: mime-types
224
197
  requirement: !ruby/object:Gem::Requirement
225
- none: false
226
198
  requirements:
227
- - - ~>
199
+ - - "~>"
228
200
  - !ruby/object:Gem::Version
229
201
  version: '2.99'
230
202
  type: :runtime
231
203
  prerelease: false
232
204
  version_requirements: !ruby/object:Gem::Requirement
233
- none: false
234
205
  requirements:
235
- - - ~>
206
+ - - "~>"
236
207
  - !ruby/object:Gem::Version
237
208
  version: '2.99'
238
209
  - !ruby/object:Gem::Dependency
239
210
  name: oj
240
211
  requirement: !ruby/object:Gem::Requirement
241
- none: false
242
212
  requirements:
243
- - - ! '>='
213
+ - - ">="
244
214
  - !ruby/object:Gem::Version
245
215
  version: '0'
246
216
  type: :runtime
247
217
  prerelease: false
248
218
  version_requirements: !ruby/object:Gem::Requirement
249
- none: false
250
219
  requirements:
251
- - - ! '>='
220
+ - - ">="
252
221
  - !ruby/object:Gem::Version
253
222
  version: '0'
254
223
  - !ruby/object:Gem::Dependency
255
224
  name: oj_mimic_json
256
225
  requirement: !ruby/object:Gem::Requirement
257
- none: false
258
226
  requirements:
259
- - - ! '>='
227
+ - - ">="
260
228
  - !ruby/object:Gem::Version
261
229
  version: '0'
262
230
  type: :runtime
263
231
  prerelease: false
264
232
  version_requirements: !ruby/object:Gem::Requirement
265
- none: false
266
233
  requirements:
267
- - - ! '>='
234
+ - - ">="
268
235
  - !ruby/object:Gem::Version
269
236
  version: '0'
270
237
  - !ruby/object:Gem::Dependency
271
238
  name: pry
272
239
  requirement: !ruby/object:Gem::Requirement
273
- none: false
274
240
  requirements:
275
- - - ! '>='
241
+ - - ">="
276
242
  - !ruby/object:Gem::Version
277
243
  version: '0'
278
244
  type: :runtime
279
245
  prerelease: false
280
246
  version_requirements: !ruby/object:Gem::Requirement
281
- none: false
282
247
  requirements:
283
- - - ! '>='
248
+ - - ">="
284
249
  - !ruby/object:Gem::Version
285
250
  version: '0'
286
251
  - !ruby/object:Gem::Dependency
287
252
  name: sshkey
288
253
  requirement: !ruby/object:Gem::Requirement
289
- none: false
290
254
  requirements:
291
- - - ~>
255
+ - - "~>"
292
256
  - !ruby/object:Gem::Version
293
257
  version: '1.6'
294
258
  type: :runtime
295
259
  prerelease: false
296
260
  version_requirements: !ruby/object:Gem::Requirement
297
- none: false
298
261
  requirements:
299
- - - ~>
262
+ - - "~>"
300
263
  - !ruby/object:Gem::Version
301
264
  version: '1.6'
302
265
  - !ruby/object:Gem::Dependency
303
266
  name: table_print
304
267
  requirement: !ruby/object:Gem::Requirement
305
- none: false
306
268
  requirements:
307
- - - ! '>='
269
+ - - ">="
308
270
  - !ruby/object:Gem::Version
309
271
  version: '0'
310
272
  type: :runtime
311
273
  prerelease: false
312
274
  version_requirements: !ruby/object:Gem::Requirement
313
- none: false
314
275
  requirements:
315
- - - ! '>='
276
+ - - ">="
316
277
  - !ruby/object:Gem::Version
317
278
  version: '0'
318
279
  - !ruby/object:Gem::Dependency
319
280
  name: pry-nav
320
281
  requirement: !ruby/object:Gem::Requirement
321
- none: false
322
282
  requirements:
323
- - - ! '>='
283
+ - - ">="
324
284
  - !ruby/object:Gem::Version
325
285
  version: '0'
326
286
  type: :development
327
287
  prerelease: false
328
288
  version_requirements: !ruby/object:Gem::Requirement
329
- none: false
330
289
  requirements:
331
- - - ! '>='
290
+ - - ">="
332
291
  - !ruby/object:Gem::Version
333
292
  version: '0'
334
293
  - !ruby/object:Gem::Dependency
335
294
  name: rspec
336
295
  requirement: !ruby/object:Gem::Requirement
337
- none: false
338
296
  requirements:
339
- - - ~>
297
+ - - "~>"
340
298
  - !ruby/object:Gem::Version
341
299
  version: '3.0'
342
300
  type: :development
343
301
  prerelease: false
344
302
  version_requirements: !ruby/object:Gem::Requirement
345
- none: false
346
303
  requirements:
347
- - - ~>
304
+ - - "~>"
348
305
  - !ruby/object:Gem::Version
349
306
  version: '3.0'
350
307
  - !ruby/object:Gem::Dependency
351
308
  name: ffaker
352
309
  requirement: !ruby/object:Gem::Requirement
353
- none: false
354
310
  requirements:
355
- - - ! '>='
311
+ - - ">="
356
312
  - !ruby/object:Gem::Version
357
313
  version: '0'
358
314
  type: :development
359
315
  prerelease: false
360
316
  version_requirements: !ruby/object:Gem::Requirement
361
- none: false
362
317
  requirements:
363
- - - ! '>='
318
+ - - ">="
364
319
  - !ruby/object:Gem::Version
365
320
  version: '0'
366
321
  - !ruby/object:Gem::Dependency
367
322
  name: rake
368
323
  requirement: !ruby/object:Gem::Requirement
369
- none: false
370
324
  requirements:
371
- - - ! '>='
325
+ - - ">="
372
326
  - !ruby/object:Gem::Version
373
327
  version: '0'
374
328
  type: :development
375
329
  prerelease: false
376
330
  version_requirements: !ruby/object:Gem::Requirement
377
- none: false
378
331
  requirements:
379
- - - ! '>='
332
+ - - ">="
380
333
  - !ruby/object:Gem::Version
381
334
  version: '0'
382
335
  description: Engine Yard Core API Ruby Client
@@ -388,10 +341,10 @@ executables:
388
341
  extensions: []
389
342
  extra_rdoc_files: []
390
343
  files:
391
- - .gitignore
392
- - .ruby-gemset
393
- - .ruby-version
394
- - .travis.yml
344
+ - ".gitignore"
345
+ - ".ruby-gemset"
346
+ - ".ruby-version"
347
+ - ".travis.yml"
395
348
  - CHANGELOG.md
396
349
  - Gemfile
397
350
  - Guardfile
@@ -401,6 +354,8 @@ files:
401
354
  - bin/ey-core
402
355
  - examples/add_instance.rb
403
356
  - examples/boot_env.rb
357
+ - examples/console/README.md
358
+ - examples/console/address.md
404
359
  - examples/stop_env.rb
405
360
  - examples/terminate_instance.rb
406
361
  - ey-core.gemspec
@@ -570,6 +525,7 @@ files:
570
525
  - lib/ey-core/models/volume.rb
571
526
  - lib/ey-core/request.rb
572
527
  - lib/ey-core/request_failure.rb
528
+ - lib/ey-core/requests/acknowledge_alert.rb
573
529
  - lib/ey-core/requests/apply_environment_updates.rb
574
530
  - lib/ey-core/requests/apply_server_updates.rb
575
531
  - lib/ey-core/requests/attach_address.rb
@@ -745,11 +701,13 @@ files:
745
701
  - lib/ey-core/requests/reboot_server.rb
746
702
  - lib/ey-core/requests/request_callback.rb
747
703
  - lib/ey-core/requests/reset_password.rb
704
+ - lib/ey-core/requests/reset_server_state.rb
748
705
  - lib/ey-core/requests/restart_environment_app_servers.rb
749
706
  - lib/ey-core/requests/run_cluster_application_action.rb
750
707
  - lib/ey-core/requests/run_environment_application_action.rb
751
708
  - lib/ey-core/requests/signup.rb
752
709
  - lib/ey-core/requests/timeout_deployment.rb
710
+ - lib/ey-core/requests/unassign_environment.rb
753
711
  - lib/ey-core/requests/update_addon.rb
754
712
  - lib/ey-core/requests/update_address.rb
755
713
  - lib/ey-core/requests/update_alert.rb
@@ -759,6 +717,7 @@ files:
759
717
  - lib/ey-core/requests/update_connector.rb
760
718
  - lib/ey-core/requests/update_environment.rb
761
719
  - lib/ey-core/requests/update_membership.rb
720
+ - lib/ey-core/requests/update_provider_location.rb
762
721
  - lib/ey-core/requests/update_server.rb
763
722
  - lib/ey-core/requests/update_ssl_certificate.rb
764
723
  - lib/ey-core/requests/update_untracked_server.rb
@@ -776,6 +735,7 @@ files:
776
735
  - lib/ey-core/test_helpers/rspec.rb
777
736
  - lib/ey-core/token_authentication.rb
778
737
  - lib/ey-core/version.rb
738
+ - spec/account_spec.rb
779
739
  - spec/account_trial_spec.rb
780
740
  - spec/accounts_referrals_spec.rb
781
741
  - spec/accounts_spec.rb
@@ -841,30 +801,30 @@ files:
841
801
  homepage: ''
842
802
  licenses:
843
803
  - MIT
804
+ metadata: {}
844
805
  post_install_message:
845
806
  rdoc_options: []
846
807
  require_paths:
847
808
  - lib
848
809
  required_ruby_version: !ruby/object:Gem::Requirement
849
- none: false
850
810
  requirements:
851
- - - ! '>='
811
+ - - ">="
852
812
  - !ruby/object:Gem::Version
853
813
  version: '0'
854
814
  required_rubygems_version: !ruby/object:Gem::Requirement
855
- none: false
856
815
  requirements:
857
- - - ! '>='
816
+ - - ">="
858
817
  - !ruby/object:Gem::Version
859
818
  version: '0'
860
819
  requirements: []
861
820
  rubyforge_project:
862
- rubygems_version: 1.8.23.2
821
+ rubygems_version: 2.5.1
863
822
  signing_key:
864
- specification_version: 3
823
+ specification_version: 4
865
824
  summary: Client library providing real and mock functionality for accessing Engine
866
825
  Yard's Core API
867
826
  test_files:
827
+ - spec/account_spec.rb
868
828
  - spec/account_trial_spec.rb
869
829
  - spec/accounts_referrals_spec.rb
870
830
  - spec/accounts_spec.rb
@@ -927,4 +887,3 @@ test_files:
927
887
  - spec/tokens_spec.rb
928
888
  - spec/untracked_servers_spec.rb
929
889
  - spec/users_spec.rb
930
- has_rdoc: