one_one 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5362ff5cc64c9a7f62fe2eaa96239736342229b1
4
- data.tar.gz: acac0345f77d76c465e889f758987efb699fd978
3
+ metadata.gz: 350082e4788bb39b37e37e43a2e778ea0b58257b
4
+ data.tar.gz: 3295119088b197b0e653dbc9be9668423a3d48a4
5
5
  SHA512:
6
- metadata.gz: e32585b4599d9a78d71f66a916dd030ba9a5a1f98eda4968ec5736ea6a3483106cf47f28371d1725aeafa67d13b499d57e8b01be307de42f64cd78e23110a85d
7
- data.tar.gz: d80abe069f2ff52df3716bbec9c484dbf9b2d72f5920e3d6baf61d06f7820273abf11974aef0f0ba7e89372c3964aabf248ea9b904261976b3bf0ae24a28bc75
6
+ metadata.gz: a0702cfcce7943e6a55be7c21180e85bd74c410c801e2deebb1370635ac8c0285c4d8ad1796a176e0c860b346c72c95186844493014eb91e6a2f16c543545787
7
+ data.tar.gz: 6552f075a6108c19c062c99c977ecadf68ccdc02e7eccc7122f77d828a13f9e9fe5aa8ea1d9b4a491433183535ff77343fbb984891502f4a3487d66c7535ca50
@@ -13,14 +13,17 @@ module OneOne
13
13
  autoload :Image, 'one_one/models/image'
14
14
  autoload :ServerAppliance, 'one_one/models/server_appliance'
15
15
  autoload :FirewallPolicy, 'one_one/models/firewall_policy'
16
+ autoload :InstanceType, 'one_one/models/instance_type'
16
17
 
17
18
  # mappings
18
19
  autoload :ServerMapping, 'one_one/mappings/server_mapping'
19
20
  autoload :ImageMapping, 'one_one/mappings/image_mapping'
20
21
  autoload :ServerApplianceMapping, 'one_one/mappings/server_appliance_mapping'
21
22
  autoload :FirewallPolicyMapping, 'one_one/mappings/firewall_policy_mapping'
23
+ autoload :InstanceTypeMapping, 'one_one/mappings/instance_type_mapping'
22
24
 
23
25
  # resources
26
+ autoload :BaseResource, 'one_one/resources/base_resource'
24
27
  autoload :ServerResource, 'one_one/resources/server_resource'
25
28
  autoload :ImageResource, 'one_one/resources/image_resource'
26
29
  autoload :ServerApplianceResource, 'one_one/resources/server_appliance_resource'
@@ -0,0 +1,13 @@
1
+ module OneOne
2
+ class InstanceTypeMapping
3
+ include Kartograph::DSL
4
+
5
+ kartograph do
6
+ mapping InstanceType
7
+
8
+ property :id, scopes: [:read]
9
+ property :name, scopes: [:read]
10
+ property :hardware, scopes: [:read]
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,7 @@
1
+ module OneOne
2
+ class InstanceType < Base
3
+ attribute :id
4
+ attribute :name
5
+ attribute :hardware
6
+ end
7
+ end
@@ -0,0 +1,12 @@
1
+ module OneOne
2
+ class BaseResource < ResourceKit::Resource
3
+ # TODO: find a way to get this working
4
+ def shared_handlers(context)
5
+ proc do
6
+ default_handler do |response|
7
+ fail "Unexpected response status #{response.status}... #{response.body}"
8
+ end
9
+ end.call(context)
10
+ end
11
+ end
12
+ end
@@ -1,7 +1,11 @@
1
1
  module OneOne
2
- class FirewallPolicyResource < ResourceKit::Resource
2
+ class FirewallPolicyResource < BaseResource
3
3
  resources do
4
- action :all, 'GET /api/v1/firewall_policies' do
4
+ default_handler do |response|
5
+ fail "Unexpected response status #{response.status}... #{response.body}"
6
+ end
7
+
8
+ action :all, 'GET /v1/firewall_policies' do
5
9
  handler(200) do |response|
6
10
  FirewallPolicyMapping.extract_collection(response.body, :read)
7
11
  end
@@ -1,5 +1,5 @@
1
1
  module OneOne
2
- class ImageResource < ResourceKit::Resource
2
+ class ImageResource < BaseResource
3
3
  resources do
4
4
  default_handler do |response|
5
5
  fail "Unexpected response status #{response.status}... #{response.body}"
@@ -1,5 +1,5 @@
1
1
  module OneOne
2
- class ServerApplianceResource < ResourceKit::Resource
2
+ class ServerApplianceResource < BaseResource
3
3
  resources do
4
4
  default_handler do |response|
5
5
  fail "Unexpected response status #{response.status}... #{response.body}"
@@ -1,6 +1,8 @@
1
1
  module OneOne
2
- class ServerResource < ResourceKit::Resource
2
+ class ServerResource < BaseResource
3
3
  resources do
4
+ ACTION_HANDLERS = %w(power_on power_off reboot)
5
+
4
6
  default_handler do |response|
5
7
  fail "Unexpected response status #{response.status}... #{response.body}"
6
8
  end
@@ -17,12 +19,42 @@ module OneOne
17
19
  end
18
20
  end
19
21
 
22
+ action :delete, 'DELETE /v1/servers/:id' do
23
+ handler(202) do |response|
24
+ ServerMapping.extract_single(response.body, :read)
25
+ end
26
+ end
27
+
20
28
  action :create, 'POST /v1/servers' do
21
29
  body { |object| ServerMapping.representation_for(:create, object) }
22
30
  handler(202) do |response|
23
31
  ServerMapping.extract_single(response.body, :read)
24
32
  end
25
33
  end
34
+
35
+ ACTION_HANDLERS.each do |action|
36
+ action action.to_sym, 'PUT /v1/servers/:id/status/action' do
37
+ body do |object|
38
+ {
39
+ action: action.upcase,
40
+ method: (object[:method] || 'HARDWARE')
41
+ }.to_json
42
+ end
43
+ handler(200, 202) do |response|
44
+ ServerMapping.extract_single(response.body, :read)
45
+ end
46
+
47
+ # handler(202) do |response|
48
+ # ServerMapping.extract_single(response.body, :read)
49
+ # end
50
+ end
51
+ end
52
+
53
+ action :instance_types, 'GET /v1/servers/fixed_instance_sizes' do
54
+ handler(200) do |response|
55
+ InstanceTypeMapping.extract_collection(response.body, :read)
56
+ end
57
+ end
26
58
  end
27
59
  end
28
60
  end
@@ -1,3 +1,3 @@
1
1
  module OneOne
2
- VERSION = '0.1.0'
2
+ VERSION = '0.2.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: one_one
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Connor Atherton
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-07-01 00:00:00.000000000 Z
11
+ date: 2015-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -143,13 +143,16 @@ files:
143
143
  - lib/one_one/client.rb
144
144
  - lib/one_one/mappings/firewall_policy_mapping.rb
145
145
  - lib/one_one/mappings/image_mapping.rb
146
+ - lib/one_one/mappings/instance_type_mapping.rb
146
147
  - lib/one_one/mappings/server_appliance_mapping.rb
147
148
  - lib/one_one/mappings/server_mapping.rb
148
149
  - lib/one_one/models/base.rb
149
150
  - lib/one_one/models/firewall_policy.rb
150
151
  - lib/one_one/models/image.rb
152
+ - lib/one_one/models/instance_type.rb
151
153
  - lib/one_one/models/server.rb
152
154
  - lib/one_one/models/server_appliance.rb
155
+ - lib/one_one/resources/base_resource.rb
153
156
  - lib/one_one/resources/firewall_policy_resource.rb
154
157
  - lib/one_one/resources/image_resource.rb
155
158
  - lib/one_one/resources/server_appliance_resource.rb