niftycloud-restful-read-api 0.0.0 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +14 -1
- data/VERSION +1 -1
- data/lib/niftycloud-restful-read-api.rb +68 -2
- metadata +10 -10
data/README.md
CHANGED
@@ -78,9 +78,22 @@ config.ru から require して使うこともできます。
|
|
78
78
|
* /computing/addresses
|
79
79
|
* 付替アドレス一覧を取得できます
|
80
80
|
|
81
|
+
### RDB
|
82
|
+
|
83
|
+
* /rdb/db_instances
|
84
|
+
* DB サーバー一覧を取得できます
|
85
|
+
* /rdb/db_security_groups
|
86
|
+
* DB ファイアウォール一覧を取得できます
|
87
|
+
* /rdb/db_parameter_groups
|
88
|
+
* DB パラメーターグループ一覧を取得できます
|
89
|
+
* /rdb/db_snapshots
|
90
|
+
* DB スナップショット一覧を取得できます
|
91
|
+
* /rdb/db_engine_versions
|
92
|
+
* DB エンジンバージョン一覧を取得できます
|
93
|
+
|
81
94
|
## TODO
|
82
95
|
|
83
|
-
* ニフティクラウド
|
96
|
+
* ニフティクラウド MQ/ESS/DNS/Automation
|
84
97
|
|
85
98
|
## ライセンス
|
86
99
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.1
|
@@ -1,7 +1,17 @@
|
|
1
|
+
require 'logger'
|
1
2
|
require 'sinatra'
|
2
3
|
require 'json'
|
3
4
|
require 'NIFTY'
|
4
5
|
|
6
|
+
NIFTY::LOG.level = Logger::DEBUG
|
7
|
+
|
8
|
+
# monkey patch
|
9
|
+
class NIFTY::Base
|
10
|
+
def response_error?(response)
|
11
|
+
false
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
5
15
|
class NiftycloudRestfulReadApi < Sinatra::Base
|
6
16
|
class NiftyCloud
|
7
17
|
class Computing
|
@@ -10,7 +20,7 @@ class NiftycloudRestfulReadApi < Sinatra::Base
|
|
10
20
|
@api = NIFTY::Cloud::Base.new(
|
11
21
|
:access_key => options[:access_key_id],
|
12
22
|
:secret_key => options[:secret_access_key],
|
13
|
-
:
|
23
|
+
:server => "{options[:region]}.cp.cloud.nifty.com",
|
14
24
|
:path => '/api'
|
15
25
|
)
|
16
26
|
end
|
@@ -65,7 +75,6 @@ class NiftycloudRestfulReadApi < Sinatra::Base
|
|
65
75
|
def ssl_certificates
|
66
76
|
response = @api.describe_ssl_certificates
|
67
77
|
response.certsSet.item.to_a rescue []
|
68
|
-
[]
|
69
78
|
end
|
70
79
|
|
71
80
|
def addresses
|
@@ -73,6 +82,50 @@ class NiftycloudRestfulReadApi < Sinatra::Base
|
|
73
82
|
response.addressesSet.item.to_a rescue []
|
74
83
|
end
|
75
84
|
end
|
85
|
+
|
86
|
+
class Rdb
|
87
|
+
def initialize(options)
|
88
|
+
@api = NIFTY::Cloud::Base.new(
|
89
|
+
:access_key => options[:access_key_id],
|
90
|
+
:secret_key => options[:secret_access_key],
|
91
|
+
:server => "rdb.jp-#{options[:region]}.api.cloud.nifty.com",
|
92
|
+
:path => '/'
|
93
|
+
)
|
94
|
+
end
|
95
|
+
|
96
|
+
def db_instances
|
97
|
+
response = @api.send(:response_generator, 'Action' => 'DescribeDBInstances')
|
98
|
+
[response.DescribeDBInstancesResult.DBInstances.DBInstance.to_a].flatten rescue []
|
99
|
+
end
|
100
|
+
|
101
|
+
def db_security_groups
|
102
|
+
response = @api.send(:response_generator, 'Action' => 'DescribeDBSecurityGroups')
|
103
|
+
[response.DescribeDBSecurityGroupsResult.DBSecurityGroups.DBSecurityGroup.to_a].flatten rescue []
|
104
|
+
end
|
105
|
+
|
106
|
+
def db_parameter_groups
|
107
|
+
response = @api.send(:response_generator, 'Action' => 'DescribeDBParameterGroups')
|
108
|
+
[response.DescribeDBParameterGroupsResult.DBParameterGroups.DBParameterGroup.to_a].flatten rescue []
|
109
|
+
end
|
110
|
+
|
111
|
+
def db_snapshots
|
112
|
+
response = @api.send(:response_generator, 'Action' => 'DescribeDBSnapshots')
|
113
|
+
p response
|
114
|
+
[response.DescribeDBSnapshotsResult.DBSnapshots.DBSnapshot.to_a].flatten rescue []
|
115
|
+
end
|
116
|
+
|
117
|
+
def db_engine_versions
|
118
|
+
response = @api.send(:response_generator, 'Action' => 'DescribeDBEngineVersions')
|
119
|
+
[response.DescribeDBEngineVersionsResult.DBEngineVersions.DBEngineVersion.to_a].flatten rescue []
|
120
|
+
end
|
121
|
+
|
122
|
+
# TODO: Engine
|
123
|
+
#def orderable_db_instance_options
|
124
|
+
# response = @api.send(:response_generator, 'Action' => 'DescribeOrderableDBInstanceOptions')
|
125
|
+
# p response
|
126
|
+
# [response.DescribeOrderableDBInstanceOptionsResult.OrderableDBInstanceOptions.OrderableDBInstanceOption.to_a].flatten rescue []
|
127
|
+
#end
|
128
|
+
end
|
76
129
|
end
|
77
130
|
|
78
131
|
helpers do
|
@@ -83,6 +136,14 @@ class NiftycloudRestfulReadApi < Sinatra::Base
|
|
83
136
|
:secret_access_key => @secret_access_key
|
84
137
|
)
|
85
138
|
end
|
139
|
+
|
140
|
+
def rdb
|
141
|
+
@rdb ||= NiftyCloud::Rdb.new(
|
142
|
+
:region => @region,
|
143
|
+
:access_key_id => @access_key_id,
|
144
|
+
:secret_access_key => @secret_access_key
|
145
|
+
)
|
146
|
+
end
|
86
147
|
end
|
87
148
|
|
88
149
|
before do
|
@@ -95,4 +156,9 @@ class NiftycloudRestfulReadApi < Sinatra::Base
|
|
95
156
|
post '/computing/:resources' do
|
96
157
|
compute.send(params[:resources]).to_json
|
97
158
|
end
|
159
|
+
|
160
|
+
post '/rdb/:resources' do
|
161
|
+
NIFTY::VERSION = '2013-05-15N2013-12-16'
|
162
|
+
rdb.send(params[:resources]).to_json
|
163
|
+
end
|
98
164
|
end
|
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.
|
4
|
+
version: 0.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2014-06-25 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sinatra
|
16
|
-
requirement: &
|
16
|
+
requirement: &112748960 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *112748960
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: nifty-cloud-sdk
|
27
|
-
requirement: &
|
27
|
+
requirement: &112748480 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *112748480
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: bundler
|
38
|
-
requirement: &
|
38
|
+
requirement: &112748000 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *112748000
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: jeweler
|
49
|
-
requirement: &
|
49
|
+
requirement: &112747520 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *112747520
|
58
58
|
description: NIFTYCloud の情報取得系 API を RESTful に利用できるようにする Sinatra アプリ
|
59
59
|
email: tily05@gmail.com
|
60
60
|
executables:
|
@@ -90,7 +90,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
90
90
|
version: '0'
|
91
91
|
segments:
|
92
92
|
- 0
|
93
|
-
hash:
|
93
|
+
hash: 1998930701841461656
|
94
94
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
95
|
none: false
|
96
96
|
requirements:
|