niftycloud-restful-read-api 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -61,6 +61,8 @@ config.ru から require して使うこともできます。
61
61
 
62
62
  * /computing/regions
63
63
  * リージョン一覧を取得できます
64
+ * /computing/availability_zones
65
+ * 利用可能ゾーン一覧を取得できます
64
66
  * /computing/instances
65
67
  * サーバー一覧を取得できます
66
68
  * /computing/volumes
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.0.4
@@ -31,18 +31,34 @@ class NiftycloudRestfulReadApi < Sinatra::Base
31
31
  :path => '/api'
32
32
  )
33
33
  end
34
-
35
- def regions
36
- response = @api.send(:response_generator, 'Action' => 'DescribeRegions')
37
- response.regionInfo.item.to_a rescue []
34
+
35
+ def items(options)
36
+ response = @api.send(:response_generator, 'Action' => options[:action])
37
+ response[options[:key]].item.to_a rescue []
38
+ end
39
+
40
+ {
41
+ :regions => {:action => 'DescribeRegions', :key => 'regionInfo'},
42
+ :availability_zones => {:action => 'DescribeAvailabilityZones', :key => 'availabilityZoneInfo'},
43
+ :volumes => {:action => 'DescribeVolumes', :key => 'volumeSet'},
44
+ :key_pairs => {:action => 'DescribeKeyPairs', :key => 'keySet'},
45
+ :images => {:action => 'DescribeImages', :key => 'imagesSet'},
46
+ :security_groups => {:action => 'DescribeSecurityGroups', :key => 'securityGroupInfo'},
47
+ :ssl_certificates => {:action => 'DescribeSSLCertificates', :key => 'certsSet'},
48
+ :addresses => {:action => 'DescribeAddresses', :key => 'addressesSet'}
49
+ }.each do |method, options|
50
+ define_method method do
51
+ items(:action => options[:action], :key => options[:key])
52
+ end
53
+ end
54
+
55
+ def load_balancers
56
+ response = @api.describe_load_balancers
57
+ response.DescribeLoadBalancersResult.LoadBalancerDescriptions.member.to_a rescue []
38
58
  end
39
-
40
- def instances
41
- response = @api.describe_instances
42
-
43
- return [] if response.reservationSet.nil?
44
59
 
45
- items = response.reservationSet.item
60
+ def instances
61
+ items = items(:action => 'DescribeInstances', :key => 'reservationSet')
46
62
  instances = items.map do |item|
47
63
  security_groups = item.groupSet.item.flatten.map {|item| item.groupId }
48
64
  instances = item.instancesSet.item.to_a
@@ -53,41 +69,6 @@ class NiftycloudRestfulReadApi < Sinatra::Base
53
69
  end
54
70
  instances.flatten
55
71
  end
56
-
57
- def volumes
58
- response = @api.describe_volumes
59
- response.volumeSet.item.to_a rescue []
60
- end
61
-
62
- def key_pairs
63
- response = @api.describe_key_pairs
64
- response.keySet.item.to_a rescue []
65
- end
66
-
67
- def images
68
- response = @api.describe_images
69
- response.imagesSet.item.to_a rescue []
70
- end
71
-
72
- def load_balancers
73
- response = @api.describe_load_balancers
74
- response.DescribeLoadBalancersResult.LoadBalancerDescriptions.member.to_a rescue []
75
- end
76
-
77
- def security_groups
78
- response = @api.describe_security_groups
79
- response.securityGroupInfo.item.to_a rescue []
80
- end
81
-
82
- def ssl_certificates
83
- response = @api.describe_ssl_certificates
84
- response.certsSet.item.to_a rescue []
85
- end
86
-
87
- def addresses
88
- response = @api.send(:response_generator, 'Action' => 'DescribeAddresses')
89
- response.addressesSet.item.to_a rescue []
90
- end
91
72
  end
92
73
 
93
74
  class Rdb
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: niftycloud-restful-read-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-06-26 00:00:00.000000000Z
12
+ date: 2014-06-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sinatra
16
- requirement: &144182160 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *144182160
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: nifty-cloud-sdk
27
- requirement: &144181320 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>='
@@ -32,10 +37,15 @@ dependencies:
32
37
  version: '0'
33
38
  type: :runtime
34
39
  prerelease: false
35
- version_requirements: *144181320
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: aws-sdk
38
- requirement: &144180180 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ! '>='
@@ -43,10 +53,15 @@ dependencies:
43
53
  version: '0'
44
54
  type: :runtime
45
55
  prerelease: false
46
- version_requirements: *144180180
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
47
62
  - !ruby/object:Gem::Dependency
48
63
  name: bundler
49
- requirement: &144178260 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
50
65
  none: false
51
66
  requirements:
52
67
  - - ! '>='
@@ -54,10 +69,15 @@ dependencies:
54
69
  version: '0'
55
70
  type: :development
56
71
  prerelease: false
57
- version_requirements: *144178260
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
58
78
  - !ruby/object:Gem::Dependency
59
79
  name: jeweler
60
- requirement: &144177380 !ruby/object:Gem::Requirement
80
+ requirement: !ruby/object:Gem::Requirement
61
81
  none: false
62
82
  requirements:
63
83
  - - ! '>='
@@ -65,7 +85,12 @@ dependencies:
65
85
  version: '0'
66
86
  type: :development
67
87
  prerelease: false
68
- version_requirements: *144177380
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
69
94
  description: NIFTYCloud の情報取得系 API を RESTful に利用できるようにする Sinatra アプリ
70
95
  email: tily05@gmail.com
71
96
  executables:
@@ -101,7 +126,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
101
126
  version: '0'
102
127
  segments:
103
128
  - 0
104
- hash: 3637886189179613779
129
+ hash: -3245465240281679413
105
130
  required_rubygems_version: !ruby/object:Gem::Requirement
106
131
  none: false
107
132
  requirements:
@@ -110,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
110
135
  version: '0'
111
136
  requirements: []
112
137
  rubyforge_project:
113
- rubygems_version: 1.8.13
138
+ rubygems_version: 1.8.23
114
139
  signing_key:
115
140
  specification_version: 3
116
141
  summary: NIFTYCloud の情報取得系 API を RESTful に利用できるようにする Sinatra アプリ