qingcloud-sdk 0.4.1 → 2.0.0.pre.alpha.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +201 -21
  3. data/README.md +141 -61
  4. data/bin/console +3 -3
  5. data/lib/qingcloud/sdk.rb +16 -14
  6. data/lib/qingcloud/sdk/general/config.rb +70 -0
  7. data/lib/qingcloud/sdk/general/contract.rb +28 -17
  8. data/lib/qingcloud/sdk/general/default/config.yaml +13 -0
  9. data/lib/qingcloud/sdk/general/error.rb +41 -32
  10. data/lib/qingcloud/sdk/general/logger.rb +54 -0
  11. data/lib/qingcloud/sdk/request/preprocessor.rb +81 -0
  12. data/lib/qingcloud/sdk/request/request.rb +80 -0
  13. data/lib/qingcloud/sdk/request/signer.rb +53 -0
  14. data/lib/qingcloud/sdk/service/cache.rb +1005 -0
  15. data/lib/qingcloud/sdk/service/dns_alias.rb +150 -0
  16. data/lib/qingcloud/sdk/service/eip.rb +389 -0
  17. data/lib/qingcloud/sdk/service/image.rb +304 -0
  18. data/lib/qingcloud/sdk/service/instance.rb +585 -0
  19. data/lib/qingcloud/sdk/service/job.rb +71 -0
  20. data/lib/qingcloud/sdk/service/key_pair.rb +257 -0
  21. data/lib/qingcloud/sdk/service/load_balancer.rb +1119 -0
  22. data/lib/qingcloud/sdk/service/mongo.rb +566 -0
  23. data/lib/qingcloud/sdk/service/qingcloud.rb +185 -0
  24. data/lib/qingcloud/sdk/service/rdb.rb +751 -0
  25. data/lib/qingcloud/sdk/service/router.rb +778 -0
  26. data/lib/qingcloud/sdk/service/security_group.rb +645 -0
  27. data/lib/qingcloud/sdk/service/shared_storage.rb +666 -0
  28. data/lib/qingcloud/sdk/service/snapshot.rb +283 -0
  29. data/lib/qingcloud/sdk/service/tag.rb +227 -0
  30. data/lib/qingcloud/sdk/service/user_data.rb +61 -0
  31. data/lib/qingcloud/sdk/service/volume.rb +296 -0
  32. data/lib/qingcloud/sdk/service/vxnet.rb +295 -0
  33. data/lib/qingcloud/sdk/version.rb +19 -5
  34. metadata +98 -29
  35. data/.gitignore +0 -13
  36. data/.rspec +0 -2
  37. data/.travis.yml +0 -3
  38. data/Rakefile +0 -6
  39. data/lib/qingcloud/sdk/iaas/connector.rb +0 -99
  40. data/lib/qingcloud/sdk/iaas/foundation.rb +0 -73
  41. data/lib/qingcloud/sdk/iaas/service.rb +0 -1274
  42. data/lib/qingcloud/sdk/template/config.json +0 -4
  43. data/lib/qingcloud/sdk/utility/file_manager.rb +0 -43
  44. data/lib/qingcloud/sdk/utility/json_parser.rb +0 -41
  45. data/lib/qingcloud/sdk/utility/logger.rb +0 -19
  46. data/qingcloud-sdk.gemspec +0 -31
@@ -0,0 +1,283 @@
1
+ # +-------------------------------------------------------------------------
2
+ # | Copyright (C) 2016 Yunify, Inc.
3
+ # +-------------------------------------------------------------------------
4
+ # | Licensed under the Apache License, Version 2.0 (the "License");
5
+ # | you may not use this work except in compliance with the License.
6
+ # | You may obtain a copy of the License in the LICENSE file, or at:
7
+ # |
8
+ # | http://www.apache.org/licenses/LICENSE-2.0
9
+ # |
10
+ # | Unless required by applicable law or agreed to in writing, software
11
+ # | distributed under the License is distributed on an "AS IS" BASIS,
12
+ # | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # | See the License for the specific language governing permissions and
14
+ # | limitations under the License.
15
+ # +-------------------------------------------------------------------------
16
+
17
+ require 'active_support/core_ext/hash/keys'
18
+
19
+ module QingCloud
20
+ module SDK
21
+ class SnapshotService
22
+ attr_accessor :config, :properties
23
+
24
+ def initialize(config, properties)
25
+ self.config = config
26
+ self.properties = properties.deep_symbolize_keys
27
+ end
28
+
29
+ # Documentation URL: https://docs.qingcloud.com/api/snapshot/apply_snapshots.html
30
+ def apply_snapshots(snapshots: [])
31
+ input = {
32
+ config: config,
33
+ properties: properties,
34
+ api_name: 'ApplySnapshots',
35
+ request_method: 'GET',
36
+ request_params: {
37
+ 'snapshots' => snapshots,
38
+ },
39
+ }
40
+
41
+ apply_snapshots_input_validate input
42
+
43
+ request = Request.new input
44
+ request.send
45
+ end
46
+
47
+ private
48
+
49
+ def apply_snapshots_input_validate(input)
50
+ input.deep_stringify_keys!
51
+
52
+ unless !input['request_params']['snapshots'].nil? && !input['request_params']['snapshots'].to_s.empty?
53
+ raise ParameterRequiredError.new('snapshots', 'ApplySnapshotsInput')
54
+ end
55
+ end
56
+
57
+ public
58
+
59
+ # Documentation URL: https://docs.qingcloud.com/api/snapshot/capture_instance_from_snapshot.html
60
+ def capture_instance_from_snapshot(image_name: '', snapshot: '')
61
+ input = {
62
+ config: config,
63
+ properties: properties,
64
+ api_name: 'CaptureInstanceFromSnapshot',
65
+ request_method: 'GET',
66
+ request_params: {
67
+ 'image_name' => image_name,
68
+ 'snapshot' => snapshot,
69
+ },
70
+ }
71
+
72
+ capture_instance_from_snapshot_input_validate input
73
+
74
+ request = Request.new input
75
+ request.send
76
+ end
77
+
78
+ private
79
+
80
+ def capture_instance_from_snapshot_input_validate(input)
81
+ input.deep_stringify_keys!
82
+
83
+ unless !input['request_params']['snapshot'].nil? && !input['request_params']['snapshot'].to_s.empty?
84
+ raise ParameterRequiredError.new('snapshot', 'CaptureInstanceFromSnapshotInput')
85
+ end
86
+ end
87
+
88
+ public
89
+
90
+ # Documentation URL: https://docs.qingcloud.com/api/snapshot/create_snapshots.html
91
+ def create_snapshots(is_full: nil, resources: [], snapshot_name: '')
92
+ input = {
93
+ config: config,
94
+ properties: properties,
95
+ api_name: 'CreateSnapshots',
96
+ request_method: 'GET',
97
+ request_params: {
98
+ 'is_full' => is_full, # is_full's available values: 0, 1
99
+ 'resources' => resources,
100
+ 'snapshot_name' => snapshot_name,
101
+ },
102
+ }
103
+
104
+ create_snapshots_input_validate input
105
+
106
+ request = Request.new input
107
+ request.send
108
+ end
109
+
110
+ private
111
+
112
+ def create_snapshots_input_validate(input)
113
+ input.deep_stringify_keys!
114
+
115
+ if input['request_params']['is_full'] && !input['request_params']['is_full'].to_s.empty?
116
+ is_full_valid_values = %w(0 1)
117
+ unless is_full_valid_values.include? input['request_params']['is_full'].to_s
118
+ raise ParameterValueNotAllowedError.new(
119
+ 'is_full',
120
+ input['request_params']['is_full'],
121
+ is_full_valid_values,
122
+ )
123
+ end
124
+ end
125
+
126
+ unless !input['request_params']['resources'].nil? && !input['request_params']['resources'].to_s.empty?
127
+ raise ParameterRequiredError.new('resources', 'CreateSnapshotsInput')
128
+ end
129
+ end
130
+
131
+ public
132
+
133
+ # Documentation URL: https://docs.qingcloud.com/api/snapshot/create_volume_from_snapshot.html
134
+ def create_volume_from_snapshot(snapshot: '', volume_name: '')
135
+ input = {
136
+ config: config,
137
+ properties: properties,
138
+ api_name: 'CreateVolumeFromSnapshot',
139
+ request_method: 'GET',
140
+ request_params: {
141
+ 'snapshot' => snapshot,
142
+ 'volume_name' => volume_name,
143
+ },
144
+ }
145
+
146
+ create_volume_from_snapshot_input_validate input
147
+
148
+ request = Request.new input
149
+ request.send
150
+ end
151
+
152
+ private
153
+
154
+ def create_volume_from_snapshot_input_validate(input)
155
+ input.deep_stringify_keys!
156
+
157
+ unless !input['request_params']['snapshot'].nil? && !input['request_params']['snapshot'].to_s.empty?
158
+ raise ParameterRequiredError.new('snapshot', 'CreateVolumeFromSnapshotInput')
159
+ end
160
+ end
161
+
162
+ public
163
+
164
+ # Documentation URL: https://docs.qingcloud.com/api/snapshot/delete_snapshots.html
165
+ def delete_snapshots(snapshots: [])
166
+ input = {
167
+ config: config,
168
+ properties: properties,
169
+ api_name: 'DeleteSnapshots',
170
+ request_method: 'GET',
171
+ request_params: {
172
+ 'snapshots' => snapshots,
173
+ },
174
+ }
175
+
176
+ delete_snapshots_input_validate input
177
+
178
+ request = Request.new input
179
+ request.send
180
+ end
181
+
182
+ private
183
+
184
+ def delete_snapshots_input_validate(input)
185
+ input.deep_stringify_keys!
186
+
187
+ unless !input['request_params']['snapshots'].nil? && !input['request_params']['snapshots'].to_s.empty?
188
+ raise ParameterRequiredError.new('snapshots', 'DeleteSnapshotsInput')
189
+ end
190
+ end
191
+
192
+ public
193
+
194
+ # Documentation URL: https://docs.qingcloud.com/api/snapshot/describe_snapshots.html
195
+ def describe_snapshots(limit: nil, offset: nil, resource_id: '', search_word: '', snapshot_type: nil, snapshots: [], status: [], tags: [], verbose: nil)
196
+ input = {
197
+ config: config,
198
+ properties: properties,
199
+ api_name: 'DescribeSnapshots',
200
+ request_method: 'GET',
201
+ request_params: {
202
+ 'limit' => limit,
203
+ 'offset' => offset,
204
+ 'resource_id' => resource_id,
205
+ 'search_word' => search_word,
206
+ 'snapshot_type' => snapshot_type, # snapshot_type's available values: 0, 1
207
+ 'snapshots' => snapshots,
208
+ 'status' => status,
209
+ 'tags' => tags,
210
+ 'verbose' => verbose, # verbose's available values: 0, 1
211
+ },
212
+ }
213
+
214
+ describe_snapshots_input_validate input
215
+
216
+ request = Request.new input
217
+ request.send
218
+ end
219
+
220
+ private
221
+
222
+ def describe_snapshots_input_validate(input)
223
+ input.deep_stringify_keys!
224
+
225
+ if input['request_params']['snapshot_type'] && !input['request_params']['snapshot_type'].to_s.empty?
226
+ snapshot_type_valid_values = %w(0 1)
227
+ unless snapshot_type_valid_values.include? input['request_params']['snapshot_type'].to_s
228
+ raise ParameterValueNotAllowedError.new(
229
+ 'snapshot_type',
230
+ input['request_params']['snapshot_type'],
231
+ snapshot_type_valid_values,
232
+ )
233
+ end
234
+ end
235
+
236
+ if input['request_params']['verbose'] && !input['request_params']['verbose'].to_s.empty?
237
+ verbose_valid_values = %w(0 1)
238
+ unless verbose_valid_values.include? input['request_params']['verbose'].to_s
239
+ raise ParameterValueNotAllowedError.new(
240
+ 'verbose',
241
+ input['request_params']['verbose'],
242
+ verbose_valid_values,
243
+ )
244
+ end
245
+ end
246
+ end
247
+
248
+ public
249
+
250
+ # Documentation URL: https://docs.qingcloud.com/api/snapshot/modify_snapshot_attributes.html
251
+ def modify_snapshot_attributes(description: '', snapshot: '', snapshot_name: '')
252
+ input = {
253
+ config: config,
254
+ properties: properties,
255
+ api_name: 'ModifySnapshotAttributes',
256
+ request_method: 'GET',
257
+ request_params: {
258
+ 'description' => description,
259
+ 'snapshot' => snapshot,
260
+ 'snapshot_name' => snapshot_name,
261
+ },
262
+ }
263
+
264
+ modify_snapshot_attributes_input_validate input
265
+
266
+ request = Request.new input
267
+ request.send
268
+ end
269
+
270
+ private
271
+
272
+ def modify_snapshot_attributes_input_validate(input)
273
+ input.deep_stringify_keys!
274
+
275
+ unless !input['request_params']['snapshot'].nil? && !input['request_params']['snapshot'].to_s.empty?
276
+ raise ParameterRequiredError.new('snapshot', 'ModifySnapshotAttributesInput')
277
+ end
278
+ end
279
+
280
+ public
281
+ end
282
+ end
283
+ end
@@ -0,0 +1,227 @@
1
+ # +-------------------------------------------------------------------------
2
+ # | Copyright (C) 2016 Yunify, Inc.
3
+ # +-------------------------------------------------------------------------
4
+ # | Licensed under the Apache License, Version 2.0 (the "License");
5
+ # | you may not use this work except in compliance with the License.
6
+ # | You may obtain a copy of the License in the LICENSE file, or at:
7
+ # |
8
+ # | http://www.apache.org/licenses/LICENSE-2.0
9
+ # |
10
+ # | Unless required by applicable law or agreed to in writing, software
11
+ # | distributed under the License is distributed on an "AS IS" BASIS,
12
+ # | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # | See the License for the specific language governing permissions and
14
+ # | limitations under the License.
15
+ # +-------------------------------------------------------------------------
16
+
17
+ require 'active_support/core_ext/hash/keys'
18
+
19
+ module QingCloud
20
+ module SDK
21
+ class TagService
22
+ attr_accessor :config, :properties
23
+
24
+ def initialize(config, properties)
25
+ self.config = config
26
+ self.properties = properties.deep_symbolize_keys
27
+ end
28
+
29
+ # Documentation URL: https://docs.qingcloud.com/api/tag/attach_tags.html
30
+ def attach_tags(resource_tag_pairs: [])
31
+ input = {
32
+ config: config,
33
+ properties: properties,
34
+ api_name: 'AttachTags',
35
+ request_method: 'GET',
36
+ request_params: {
37
+ 'resource_tag_pairs' => resource_tag_pairs,
38
+ },
39
+ }
40
+
41
+ attach_tags_input_validate input
42
+
43
+ request = Request.new input
44
+ request.send
45
+ end
46
+
47
+ private
48
+
49
+ def attach_tags_input_validate(input)
50
+ input.deep_stringify_keys!
51
+
52
+ unless !input['request_params']['resource_tag_pairs'].nil? && !input['request_params']['resource_tag_pairs'].to_s.empty?
53
+ raise ParameterRequiredError.new('resource_tag_pairs', 'AttachTagsInput')
54
+ end
55
+
56
+ input['request_params']['resource_tag_pairs'].map do |x|
57
+ end
58
+ end
59
+
60
+ public
61
+
62
+ # Documentation URL: https://docs.qingcloud.com/api/tag/create_tag.html
63
+ def create_tag(color: '', tag_name: '')
64
+ input = {
65
+ config: config,
66
+ properties: properties,
67
+ api_name: 'CreateTag',
68
+ request_method: 'GET',
69
+ request_params: {
70
+ 'color' => color,
71
+ 'tag_name' => tag_name,
72
+ },
73
+ }
74
+
75
+ create_tag_input_validate input
76
+
77
+ request = Request.new input
78
+ request.send
79
+ end
80
+
81
+ private
82
+
83
+ def create_tag_input_validate(input)
84
+ input.deep_stringify_keys!
85
+ end
86
+
87
+ public
88
+
89
+ # Documentation URL: https://docs.qingcloud.com/api/tag/delete_tags.html
90
+ def delete_tags(tags: [])
91
+ input = {
92
+ config: config,
93
+ properties: properties,
94
+ api_name: 'DeleteTags',
95
+ request_method: 'GET',
96
+ request_params: {
97
+ 'tags' => tags,
98
+ },
99
+ }
100
+
101
+ delete_tags_input_validate input
102
+
103
+ request = Request.new input
104
+ request.send
105
+ end
106
+
107
+ private
108
+
109
+ def delete_tags_input_validate(input)
110
+ input.deep_stringify_keys!
111
+
112
+ unless !input['request_params']['tags'].nil? && !input['request_params']['tags'].to_s.empty?
113
+ raise ParameterRequiredError.new('tags', 'DeleteTagsInput')
114
+ end
115
+ end
116
+
117
+ public
118
+
119
+ # Documentation URL: https://docs.qingcloud.com/api/tag/describe_tags.html
120
+ def describe_tags(limit: nil, offset: nil, search_word: '', tags: [], verbose: nil)
121
+ input = {
122
+ config: config,
123
+ properties: properties,
124
+ api_name: 'DescribeTags',
125
+ request_method: 'GET',
126
+ request_params: {
127
+ 'limit' => limit,
128
+ 'offset' => offset,
129
+ 'search_word' => search_word,
130
+ 'tags' => tags,
131
+ 'verbose' => verbose, # verbose's available values: 0, 1
132
+ },
133
+ }
134
+
135
+ describe_tags_input_validate input
136
+
137
+ request = Request.new input
138
+ request.send
139
+ end
140
+
141
+ private
142
+
143
+ def describe_tags_input_validate(input)
144
+ input.deep_stringify_keys!
145
+
146
+ if input['request_params']['verbose'] && !input['request_params']['verbose'].to_s.empty?
147
+ verbose_valid_values = %w(0 1)
148
+ unless verbose_valid_values.include? input['request_params']['verbose'].to_s
149
+ raise ParameterValueNotAllowedError.new(
150
+ 'verbose',
151
+ input['request_params']['verbose'],
152
+ verbose_valid_values,
153
+ )
154
+ end
155
+ end
156
+ end
157
+
158
+ public
159
+
160
+ # Documentation URL: https://docs.qingcloud.com/api/tag/detach_tags.html
161
+ def detach_tags(resource_tag_pairs: [])
162
+ input = {
163
+ config: config,
164
+ properties: properties,
165
+ api_name: 'DetachTags',
166
+ request_method: 'GET',
167
+ request_params: {
168
+ 'resource_tag_pairs' => resource_tag_pairs,
169
+ },
170
+ }
171
+
172
+ detach_tags_input_validate input
173
+
174
+ request = Request.new input
175
+ request.send
176
+ end
177
+
178
+ private
179
+
180
+ def detach_tags_input_validate(input)
181
+ input.deep_stringify_keys!
182
+
183
+ unless !input['request_params']['resource_tag_pairs'].nil? && !input['request_params']['resource_tag_pairs'].to_s.empty?
184
+ raise ParameterRequiredError.new('resource_tag_pairs', 'DetachTagsInput')
185
+ end
186
+
187
+ input['request_params']['resource_tag_pairs'].map do |x|
188
+ end
189
+ end
190
+
191
+ public
192
+
193
+ # Documentation URL: https://docs.qingcloud.com/api/tag/modify_tag_attributes.html
194
+ def modify_tag_attributes(color: '', description: '', tag: '', tag_name: '')
195
+ input = {
196
+ config: config,
197
+ properties: properties,
198
+ api_name: 'ModifyTagAttributes',
199
+ request_method: 'GET',
200
+ request_params: {
201
+ 'color' => color,
202
+ 'description' => description,
203
+ 'tag' => tag,
204
+ 'tag_name' => tag_name,
205
+ },
206
+ }
207
+
208
+ modify_tag_attributes_input_validate input
209
+
210
+ request = Request.new input
211
+ request.send
212
+ end
213
+
214
+ private
215
+
216
+ def modify_tag_attributes_input_validate(input)
217
+ input.deep_stringify_keys!
218
+
219
+ unless !input['request_params']['tag'].nil? && !input['request_params']['tag'].to_s.empty?
220
+ raise ParameterRequiredError.new('tag', 'ModifyTagAttributesInput')
221
+ end
222
+ end
223
+
224
+ public
225
+ end
226
+ end
227
+ end