engineyard-cloud-client 1.0.4 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/engineyard-cloud-client.rb +4 -5
- data/lib/engineyard-cloud-client/connection.rb +2 -0
- data/lib/engineyard-cloud-client/models/app.rb +3 -1
- data/lib/engineyard-cloud-client/models/app_environment.rb +5 -2
- data/lib/engineyard-cloud-client/models/deployment.rb +2 -1
- data/lib/engineyard-cloud-client/models/environment.rb +7 -1
- data/lib/engineyard-cloud-client/models/instance.rb +1 -1
- data/lib/engineyard-cloud-client/models/keypair.rb +5 -0
- data/lib/engineyard-cloud-client/models/log.rb +1 -1
- data/lib/engineyard-cloud-client/models/recipes.rb +1 -0
- data/lib/engineyard-cloud-client/models/user.rb +7 -1
- data/lib/engineyard-cloud-client/test/fake_awsm/config.ru +22 -0
- data/lib/engineyard-cloud-client/test/fake_awsm/models/keypair.rb +13 -0
- data/lib/engineyard-cloud-client/test/fake_awsm/models/user.rb +1 -0
- data/lib/engineyard-cloud-client/test/fake_awsm/views/keypair.rabl +2 -0
- data/lib/engineyard-cloud-client/test/fake_awsm/views/keypairs.rabl +2 -0
- data/lib/engineyard-cloud-client/version.rb +1 -1
- data/spec/engineyard-cloud-client/integration/keypair_spec.rb +23 -0
- data/spec/engineyard-cloud-client/integration/user_spec.rb +10 -0
- metadata +8 -5
- data/spec/engineyard-cloud-client/models/keypair_spec.rb +0 -58
@@ -5,11 +5,10 @@ end
|
|
5
5
|
|
6
6
|
require 'engineyard-cloud-client/connection'
|
7
7
|
require 'engineyard-cloud-client/model_registry'
|
8
|
-
require 'engineyard-cloud-client/models'
|
9
|
-
require 'engineyard-cloud-client/
|
10
|
-
require 'engineyard-cloud-client/
|
11
|
-
require 'engineyard-cloud-client/
|
12
|
-
require 'engineyard-cloud-client/errors'
|
8
|
+
require 'engineyard-cloud-client/models/app'
|
9
|
+
require 'engineyard-cloud-client/models/app_environment'
|
10
|
+
require 'engineyard-cloud-client/models/environment'
|
11
|
+
require 'engineyard-cloud-client/models/user'
|
13
12
|
require 'multi_json'
|
14
13
|
require 'pp'
|
15
14
|
require 'forwardable'
|
@@ -1,5 +1,7 @@
|
|
1
|
+
require 'engineyard-cloud-client/models/api_struct'
|
2
|
+
require 'engineyard-cloud-client/models/account'
|
3
|
+
require 'engineyard-cloud-client/models/app_environment'
|
1
4
|
require 'engineyard-cloud-client/errors'
|
2
|
-
require 'engineyard-cloud-client/models'
|
3
5
|
|
4
6
|
module EY
|
5
7
|
class CloudClient
|
@@ -1,5 +1,8 @@
|
|
1
|
-
require 'engineyard-cloud-client/models'
|
2
|
-
require 'engineyard-cloud-client/
|
1
|
+
require 'engineyard-cloud-client/models/api_struct'
|
2
|
+
require 'engineyard-cloud-client/models/app'
|
3
|
+
require 'engineyard-cloud-client/models/environment'
|
4
|
+
require 'engineyard-cloud-client/models/deployment'
|
5
|
+
require 'engineyard-cloud-client/resolver_result'
|
3
6
|
|
4
7
|
module EY
|
5
8
|
class CloudClient
|
@@ -1,5 +1,11 @@
|
|
1
|
-
require 'engineyard-cloud-client/models'
|
1
|
+
require 'engineyard-cloud-client/models/api_struct'
|
2
|
+
require 'engineyard-cloud-client/models/account'
|
3
|
+
require 'engineyard-cloud-client/models/app'
|
4
|
+
require 'engineyard-cloud-client/models/app_environment'
|
5
|
+
require 'engineyard-cloud-client/models/instance'
|
6
|
+
require 'engineyard-cloud-client/models/log'
|
2
7
|
require 'engineyard-cloud-client/models/recipes'
|
8
|
+
require 'engineyard-cloud-client/resolver_result'
|
3
9
|
require 'engineyard-cloud-client/errors'
|
4
10
|
|
5
11
|
module EY
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'engineyard-cloud-client/models/api_struct'
|
2
|
+
require 'engineyard-cloud-client/errors'
|
2
3
|
|
3
4
|
module EY
|
4
5
|
class CloudClient
|
@@ -27,6 +28,10 @@ module EY
|
|
27
28
|
response = api.post("/keypairs", "keypair" => params)['keypair']
|
28
29
|
self.from_hash(api, response)
|
29
30
|
end
|
31
|
+
|
32
|
+
def destroy
|
33
|
+
api.delete("/keypairs/#{id}")
|
34
|
+
end
|
30
35
|
end
|
31
36
|
end
|
32
37
|
end
|
@@ -1,4 +1,6 @@
|
|
1
|
-
require 'engineyard-cloud-client/models'
|
1
|
+
require 'engineyard-cloud-client/models/api_struct'
|
2
|
+
require 'engineyard-cloud-client/models/account'
|
3
|
+
require 'engineyard-cloud-client/models/keypair'
|
2
4
|
|
3
5
|
module EY
|
4
6
|
class CloudClient
|
@@ -6,6 +8,10 @@ module EY
|
|
6
8
|
def accounts
|
7
9
|
EY::CloudClient::Account.all(api)
|
8
10
|
end
|
11
|
+
|
12
|
+
def keypairs
|
13
|
+
EY::CloudClient::Keypair.all(api)
|
14
|
+
end
|
9
15
|
end
|
10
16
|
end
|
11
17
|
end
|
@@ -87,6 +87,28 @@ class FakeAwsm < Sinatra::Base
|
|
87
87
|
render :rabl, :user, :format => "json"
|
88
88
|
end
|
89
89
|
|
90
|
+
post "/api/v2/keypairs" do
|
91
|
+
@keypair = @user.keypairs.create(params['keypair'])
|
92
|
+
render :rabl, :keypair, :format => "json"
|
93
|
+
end
|
94
|
+
|
95
|
+
get "/api/v2/keypairs" do
|
96
|
+
@keypairs = @user.keypairs
|
97
|
+
render :rabl, :keypairs, :format => "json"
|
98
|
+
end
|
99
|
+
|
100
|
+
delete "/api/v2/keypairs/:id" do
|
101
|
+
keypair = @user.keypairs.get(params['id'])
|
102
|
+
if keypair
|
103
|
+
keypair.destroy
|
104
|
+
status 204
|
105
|
+
""
|
106
|
+
else
|
107
|
+
status 404
|
108
|
+
return {"message" => "Keypair not found with id #{params['id'].inspect}"}.to_json
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
90
112
|
get "/api/v2/accounts" do
|
91
113
|
@accounts = @user.accounts
|
92
114
|
render :rabl, :accounts, :format => "json"
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'dm-core'
|
2
|
+
|
3
|
+
class Keypair
|
4
|
+
include DataMapper::Resource
|
5
|
+
|
6
|
+
property :id, Serial
|
7
|
+
property :name, String
|
8
|
+
property :public_key, String
|
9
|
+
property :fingerprint, String, :default => "12:34:56:78:9a:bc:de:f0:12:34:56:78:9a:bc:de:f0"
|
10
|
+
|
11
|
+
belongs_to :user
|
12
|
+
|
13
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe EY::CloudClient::Keypair do
|
4
|
+
before do
|
5
|
+
FakeWeb.allow_net_connect = true
|
6
|
+
end
|
7
|
+
|
8
|
+
it "creates, finds, and destroys keypairs" do
|
9
|
+
api = scenario_cloud_client "User Name"
|
10
|
+
keypair = EY::CloudClient::Keypair.create(api, {
|
11
|
+
"name" => 'laptop',
|
12
|
+
"public_key" => "ssh-rsa OTHERKEYPAIR"
|
13
|
+
})
|
14
|
+
|
15
|
+
keypair.name.should == "laptop"
|
16
|
+
keypair.public_key.should == "ssh-rsa OTHERKEYPAIR"
|
17
|
+
|
18
|
+
keypairs = EY::CloudClient::Keypair.all(api)
|
19
|
+
keypairs.should =~ [keypair]
|
20
|
+
|
21
|
+
keypair.destroy
|
22
|
+
end
|
23
|
+
end
|
@@ -12,4 +12,14 @@ describe EY::CloudClient::User do
|
|
12
12
|
user.accounts.size.should == 1
|
13
13
|
user.accounts.first.name.should == 'main'
|
14
14
|
end
|
15
|
+
|
16
|
+
it "has keypairs" do
|
17
|
+
api = scenario_cloud_client "User Name"
|
18
|
+
keypair = EY::CloudClient::Keypair.create(api, {
|
19
|
+
"name" => 'laptop',
|
20
|
+
"public_key" => "ssh-rsa OTHERKEYPAIR"
|
21
|
+
})
|
22
|
+
api.current_user.keypairs.should include(keypair)
|
23
|
+
keypair.destroy
|
24
|
+
end
|
15
25
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: engineyard-cloud-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -297,6 +297,7 @@ files:
|
|
297
297
|
- lib/engineyard-cloud-client/test/fake_awsm/models/deployment.rb
|
298
298
|
- lib/engineyard-cloud-client/test/fake_awsm/models/environment.rb
|
299
299
|
- lib/engineyard-cloud-client/test/fake_awsm/models/instance.rb
|
300
|
+
- lib/engineyard-cloud-client/test/fake_awsm/models/keypair.rb
|
300
301
|
- lib/engineyard-cloud-client/test/fake_awsm/models/user.rb
|
301
302
|
- lib/engineyard-cloud-client/test/fake_awsm/models.rb
|
302
303
|
- lib/engineyard-cloud-client/test/fake_awsm/scenarios.rb
|
@@ -308,6 +309,8 @@ files:
|
|
308
309
|
- lib/engineyard-cloud-client/test/fake_awsm/views/deployment.rabl
|
309
310
|
- lib/engineyard-cloud-client/test/fake_awsm/views/environments.rabl
|
310
311
|
- lib/engineyard-cloud-client/test/fake_awsm/views/instances.rabl
|
312
|
+
- lib/engineyard-cloud-client/test/fake_awsm/views/keypair.rabl
|
313
|
+
- lib/engineyard-cloud-client/test/fake_awsm/views/keypairs.rabl
|
311
314
|
- lib/engineyard-cloud-client/test/fake_awsm/views/resolve_app_environments.rabl
|
312
315
|
- lib/engineyard-cloud-client/test/fake_awsm/views/resolve_environments.rabl
|
313
316
|
- lib/engineyard-cloud-client/test/fake_awsm/views/user.rabl
|
@@ -324,12 +327,12 @@ files:
|
|
324
327
|
- spec/engineyard-cloud-client/integration/app_spec.rb
|
325
328
|
- spec/engineyard-cloud-client/integration/deployment_spec.rb
|
326
329
|
- spec/engineyard-cloud-client/integration/environment_spec.rb
|
330
|
+
- spec/engineyard-cloud-client/integration/keypair_spec.rb
|
327
331
|
- spec/engineyard-cloud-client/integration/user_spec.rb
|
328
332
|
- spec/engineyard-cloud-client/models/api_struct_spec.rb
|
329
333
|
- spec/engineyard-cloud-client/models/app_spec.rb
|
330
334
|
- spec/engineyard-cloud-client/models/environment_spec.rb
|
331
335
|
- spec/engineyard-cloud-client/models/instance_spec.rb
|
332
|
-
- spec/engineyard-cloud-client/models/keypair_spec.rb
|
333
336
|
- spec/spec_helper.rb
|
334
337
|
- spec/support/fixture_recipes.tgz
|
335
338
|
- spec/support/helpers.rb
|
@@ -348,7 +351,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
348
351
|
version: '0'
|
349
352
|
segments:
|
350
353
|
- 0
|
351
|
-
hash:
|
354
|
+
hash: 4182640677439881868
|
352
355
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
353
356
|
none: false
|
354
357
|
requirements:
|
@@ -357,7 +360,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
357
360
|
version: '0'
|
358
361
|
segments:
|
359
362
|
- 0
|
360
|
-
hash:
|
363
|
+
hash: 4182640677439881868
|
361
364
|
requirements: []
|
362
365
|
rubyforge_project:
|
363
366
|
rubygems_version: 1.8.24
|
@@ -371,12 +374,12 @@ test_files:
|
|
371
374
|
- spec/engineyard-cloud-client/integration/app_spec.rb
|
372
375
|
- spec/engineyard-cloud-client/integration/deployment_spec.rb
|
373
376
|
- spec/engineyard-cloud-client/integration/environment_spec.rb
|
377
|
+
- spec/engineyard-cloud-client/integration/keypair_spec.rb
|
374
378
|
- spec/engineyard-cloud-client/integration/user_spec.rb
|
375
379
|
- spec/engineyard-cloud-client/models/api_struct_spec.rb
|
376
380
|
- spec/engineyard-cloud-client/models/app_spec.rb
|
377
381
|
- spec/engineyard-cloud-client/models/environment_spec.rb
|
378
382
|
- spec/engineyard-cloud-client/models/instance_spec.rb
|
379
|
-
- spec/engineyard-cloud-client/models/keypair_spec.rb
|
380
383
|
- spec/spec_helper.rb
|
381
384
|
- spec/support/fixture_recipes.tgz
|
382
385
|
- spec/support/helpers.rb
|
@@ -1,58 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe EY::CloudClient::Keypair do
|
4
|
-
describe ".all" do
|
5
|
-
it "hits the index action in the API" do
|
6
|
-
response = {
|
7
|
-
"keypairs" => [
|
8
|
-
{
|
9
|
-
"fingerprint" => "11:f4:11:11:47:db:b7:3f:06:a9:XX:XX:XX:XX:XX:XX",
|
10
|
-
"id" => 123,
|
11
|
-
"name" => "macbook pro",
|
12
|
-
"public_key" => "ssh-dss MYKEYPAIR"
|
13
|
-
}
|
14
|
-
]
|
15
|
-
}
|
16
|
-
|
17
|
-
FakeWeb.register_uri(:get, "https://cloud.engineyard.com/api/v2/keypairs",
|
18
|
-
:body => response.to_json, :content_type => "application/json")
|
19
|
-
|
20
|
-
keypairs = EY::CloudClient::Keypair.all(cloud_client)
|
21
|
-
|
22
|
-
keypairs.length.should == 1
|
23
|
-
keypairs.first.name.should == "macbook pro"
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe ".create" do
|
28
|
-
it "hits the create action in the API" do
|
29
|
-
response = {
|
30
|
-
"keypair" => {
|
31
|
-
"fingerprint" => "ce:90:99:b8:62:74:66:2f:ec:bc:XX:XX:XX:XX:XX:XX",
|
32
|
-
"id" => 234,
|
33
|
-
"name" => "laptop",
|
34
|
-
"public_key" => "ssh-rsa OTHERKEYPAIR"
|
35
|
-
}
|
36
|
-
}
|
37
|
-
|
38
|
-
FakeWeb.register_uri(:post, "https://cloud.engineyard.com/api/v2/keypairs",
|
39
|
-
:body => response.to_json, :content_type => "application/json")
|
40
|
-
|
41
|
-
keypair = EY::CloudClient::Keypair.create(cloud_client, {
|
42
|
-
"name" => 'laptop',
|
43
|
-
"public_key" => "ssh-rsa OTHERKEYPAIR"
|
44
|
-
})
|
45
|
-
|
46
|
-
FakeWeb.should have_requested(:post, "https://cloud.engineyard.com/api/v2/keypairs")
|
47
|
-
|
48
|
-
keypair.name.should == "laptop"
|
49
|
-
keypair.public_key.should == "ssh-rsa OTHERKEYPAIR"
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
describe "#destroy" do
|
54
|
-
it "hits the destroy action in the API" do
|
55
|
-
pending
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|