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

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.
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,150 @@
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 DNSAliasService
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/dns_alias/associate_dns_alias.html
30
+ def associate_dns_alias(prefix: '', resource: '')
31
+ input = {
32
+ config: config,
33
+ properties: properties,
34
+ api_name: 'AssociateDNSAlias',
35
+ request_method: 'GET',
36
+ request_params: {
37
+ 'prefix' => prefix,
38
+ 'resource' => resource,
39
+ },
40
+ }
41
+
42
+ associate_dns_alias_input_validate input
43
+
44
+ request = Request.new input
45
+ request.send
46
+ end
47
+
48
+ private
49
+
50
+ def associate_dns_alias_input_validate(input)
51
+ input.deep_stringify_keys!
52
+
53
+ unless !input['request_params']['prefix'].nil? && !input['request_params']['prefix'].to_s.empty?
54
+ raise ParameterRequiredError.new('prefix', 'AssociateDNSAliasInput')
55
+ end
56
+
57
+ unless !input['request_params']['resource'].nil? && !input['request_params']['resource'].to_s.empty?
58
+ raise ParameterRequiredError.new('resource', 'AssociateDNSAliasInput')
59
+ end
60
+ end
61
+
62
+ public
63
+
64
+ # Documentation URL: https://docs.qingcloud.com/api/dns_alias/describe_dns_aliases.html
65
+ def describe_dns_aliases(dns_aliases: [], limit: nil, offset: nil, resource_id: '', search_word: '')
66
+ input = {
67
+ config: config,
68
+ properties: properties,
69
+ api_name: 'DescribeDNSAliases',
70
+ request_method: 'GET',
71
+ request_params: {
72
+ 'dns_aliases' => dns_aliases,
73
+ 'limit' => limit,
74
+ 'offset' => offset,
75
+ 'resource_id' => resource_id,
76
+ 'search_word' => search_word,
77
+ },
78
+ }
79
+
80
+ describe_dns_aliases_input_validate input
81
+
82
+ request = Request.new input
83
+ request.send
84
+ end
85
+
86
+ private
87
+
88
+ def describe_dns_aliases_input_validate(input)
89
+ input.deep_stringify_keys!
90
+ end
91
+
92
+ public
93
+
94
+ # Documentation URL: https://docs.qingcloud.com/api/dns_alias/dissociate_dns_aliases.html
95
+ def dissociate_dns_aliases(dns_aliases: [])
96
+ input = {
97
+ config: config,
98
+ properties: properties,
99
+ api_name: 'DissociateDNSAliases',
100
+ request_method: 'GET',
101
+ request_params: {
102
+ 'dns_aliases' => dns_aliases,
103
+ },
104
+ }
105
+
106
+ dissociate_dns_aliases_input_validate input
107
+
108
+ request = Request.new input
109
+ request.send
110
+ end
111
+
112
+ private
113
+
114
+ def dissociate_dns_aliases_input_validate(input)
115
+ input.deep_stringify_keys!
116
+
117
+ unless !input['request_params']['dns_aliases'].nil? && !input['request_params']['dns_aliases'].to_s.empty?
118
+ raise ParameterRequiredError.new('dns_aliases', 'DissociateDNSAliasesInput')
119
+ end
120
+ end
121
+
122
+ public
123
+
124
+ # Documentation URL: https://docs.qingcloud.com/api/dns_alias/get_dns_label.html
125
+ def get_dns_label
126
+ input = {
127
+ config: config,
128
+ properties: properties,
129
+ api_name: 'GetDNSLabel',
130
+ request_method: 'GET',
131
+ request_params: {
132
+ },
133
+ }
134
+
135
+ get_dns_label_input_validate input
136
+
137
+ request = Request.new input
138
+ request.send
139
+ end
140
+
141
+ private
142
+
143
+ def get_dns_label_input_validate(input)
144
+ input.deep_stringify_keys!
145
+ end
146
+
147
+ public
148
+ end
149
+ end
150
+ end
@@ -0,0 +1,389 @@
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 EIPService
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/eip/allocate_eips.html
30
+ def allocate_eips(bandwidth: nil, billing_mode: '', count: nil, eip_name: '', need_icp: nil)
31
+ input = {
32
+ config: config,
33
+ properties: properties,
34
+ api_name: 'AllocateEips',
35
+ request_method: 'GET',
36
+ request_params: {
37
+ 'bandwidth' => bandwidth,
38
+ 'billing_mode' => billing_mode, # billing_mode's available values: bandwidth, traffic
39
+ 'count' => count,
40
+ 'eip_name' => eip_name,
41
+ 'need_icp' => need_icp, # need_icp's available values: 0, 1
42
+ },
43
+ }
44
+
45
+ allocate_eips_input_validate input
46
+
47
+ request = Request.new input
48
+ request.send
49
+ end
50
+
51
+ private
52
+
53
+ def allocate_eips_input_validate(input)
54
+ input.deep_stringify_keys!
55
+
56
+ unless !input['request_params']['bandwidth'].nil? && !input['request_params']['bandwidth'].to_s.empty?
57
+ raise ParameterRequiredError.new('bandwidth', 'AllocateEipsInput')
58
+ end
59
+
60
+ if input['request_params']['billing_mode'] && !input['request_params']['billing_mode'].to_s.empty?
61
+ billing_mode_valid_values = %w(bandwidth traffic)
62
+ unless billing_mode_valid_values.include? input['request_params']['billing_mode'].to_s
63
+ raise ParameterValueNotAllowedError.new(
64
+ 'billing_mode',
65
+ input['request_params']['billing_mode'],
66
+ billing_mode_valid_values,
67
+ )
68
+ end
69
+ end
70
+
71
+ if input['request_params']['need_icp'] && !input['request_params']['need_icp'].to_s.empty?
72
+ need_icp_valid_values = %w(0 1)
73
+ unless need_icp_valid_values.include? input['request_params']['need_icp'].to_s
74
+ raise ParameterValueNotAllowedError.new(
75
+ 'need_icp',
76
+ input['request_params']['need_icp'],
77
+ need_icp_valid_values,
78
+ )
79
+ end
80
+ end
81
+ end
82
+
83
+ public
84
+
85
+ # Documentation URL: https://docs.qingcloud.com/api/eip/associate_eip.html
86
+ def associate_eip(eip: '', instance: '')
87
+ input = {
88
+ config: config,
89
+ properties: properties,
90
+ api_name: 'AssociateEip',
91
+ request_method: 'GET',
92
+ request_params: {
93
+ 'eip' => eip,
94
+ 'instance' => instance,
95
+ },
96
+ }
97
+
98
+ associate_eip_input_validate input
99
+
100
+ request = Request.new input
101
+ request.send
102
+ end
103
+
104
+ private
105
+
106
+ def associate_eip_input_validate(input)
107
+ input.deep_stringify_keys!
108
+
109
+ unless !input['request_params']['eip'].nil? && !input['request_params']['eip'].to_s.empty?
110
+ raise ParameterRequiredError.new('eip', 'AssociateEipInput')
111
+ end
112
+
113
+ unless !input['request_params']['instance'].nil? && !input['request_params']['instance'].to_s.empty?
114
+ raise ParameterRequiredError.new('instance', 'AssociateEipInput')
115
+ end
116
+ end
117
+
118
+ public
119
+
120
+ # Documentation URL: https://docs.qingcloud.com/api/eip/dissociate_eips.html
121
+ def change_eips_bandwidth(bandwidth: nil, eips: [])
122
+ input = {
123
+ config: config,
124
+ properties: properties,
125
+ api_name: 'ChangeEipsBandwidth',
126
+ request_method: 'GET',
127
+ request_params: {
128
+ 'bandwidth' => bandwidth,
129
+ 'eips' => eips,
130
+ },
131
+ }
132
+
133
+ change_eips_bandwidth_input_validate input
134
+
135
+ request = Request.new input
136
+ request.send
137
+ end
138
+
139
+ private
140
+
141
+ def change_eips_bandwidth_input_validate(input)
142
+ input.deep_stringify_keys!
143
+
144
+ unless !input['request_params']['bandwidth'].nil? && !input['request_params']['bandwidth'].to_s.empty?
145
+ raise ParameterRequiredError.new('bandwidth', 'ChangeEipsBandwidthInput')
146
+ end
147
+
148
+ unless !input['request_params']['eips'].nil? && !input['request_params']['eips'].to_s.empty?
149
+ raise ParameterRequiredError.new('eips', 'ChangeEipsBandwidthInput')
150
+ end
151
+ end
152
+
153
+ public
154
+
155
+ # Documentation URL: https://docs.qingcloud.com/api/eip/change_eips_billing_mode.html
156
+ def change_eips_billing_mode(billing_mode: '', eip_group: '', eips: [])
157
+ input = {
158
+ config: config,
159
+ properties: properties,
160
+ api_name: 'ChangeEipsBillingMode',
161
+ request_method: 'GET',
162
+ request_params: {
163
+ 'billing_mode' => billing_mode, # billing_mode's available values: bandwidth, traffic
164
+ 'eip_group' => eip_group,
165
+ 'eips' => eips,
166
+ },
167
+ }
168
+
169
+ change_eips_billing_mode_input_validate input
170
+
171
+ request = Request.new input
172
+ request.send
173
+ end
174
+
175
+ private
176
+
177
+ def change_eips_billing_mode_input_validate(input)
178
+ input.deep_stringify_keys!
179
+
180
+ unless !input['request_params']['billing_mode'].nil? && !input['request_params']['billing_mode'].to_s.empty?
181
+ raise ParameterRequiredError.new('billing_mode', 'ChangeEipsBillingModeInput')
182
+ end
183
+
184
+ if input['request_params']['billing_mode'] && !input['request_params']['billing_mode'].to_s.empty?
185
+ billing_mode_valid_values = %w(bandwidth traffic)
186
+ unless billing_mode_valid_values.include? input['request_params']['billing_mode'].to_s
187
+ raise ParameterValueNotAllowedError.new(
188
+ 'billing_mode',
189
+ input['request_params']['billing_mode'],
190
+ billing_mode_valid_values,
191
+ )
192
+ end
193
+ end
194
+
195
+ unless !input['request_params']['eips'].nil? && !input['request_params']['eips'].to_s.empty?
196
+ raise ParameterRequiredError.new('eips', 'ChangeEipsBillingModeInput')
197
+ end
198
+ end
199
+
200
+ public
201
+
202
+ # Documentation URL: https://docs.qingcloud.com/api/eip/describe_eips.html
203
+ def describe_eips(eips: [], instance_id: '', limit: nil, offset: nil, search_word: '', status: [], tags: [], verbose: nil)
204
+ input = {
205
+ config: config,
206
+ properties: properties,
207
+ api_name: 'DescribeEips',
208
+ request_method: 'GET',
209
+ request_params: {
210
+ 'eips' => eips,
211
+ 'instance_id' => instance_id,
212
+ 'limit' => limit,
213
+ 'offset' => offset,
214
+ 'search_word' => search_word,
215
+ 'status' => status,
216
+ 'tags' => tags,
217
+ 'verbose' => verbose,
218
+ },
219
+ }
220
+
221
+ describe_eips_input_validate input
222
+
223
+ request = Request.new input
224
+ request.send
225
+ end
226
+
227
+ private
228
+
229
+ def describe_eips_input_validate(input)
230
+ input.deep_stringify_keys!
231
+ end
232
+
233
+ public
234
+
235
+ # Documentation URL: https://docs.qingcloud.com/api/eip/dissociate_eips.html
236
+ def dissociate_eips(eips: [])
237
+ input = {
238
+ config: config,
239
+ properties: properties,
240
+ api_name: 'DissociateEips',
241
+ request_method: 'GET',
242
+ request_params: {
243
+ 'eips' => eips,
244
+ },
245
+ }
246
+
247
+ dissociate_eips_input_validate input
248
+
249
+ request = Request.new input
250
+ request.send
251
+ end
252
+
253
+ private
254
+
255
+ def dissociate_eips_input_validate(input)
256
+ input.deep_stringify_keys!
257
+
258
+ unless !input['request_params']['eips'].nil? && !input['request_params']['eips'].to_s.empty?
259
+ raise ParameterRequiredError.new('eips', 'DissociateEipsInput')
260
+ end
261
+ end
262
+
263
+ public
264
+
265
+ # Documentation URL: https://docs.qingcloud.com/api/monitor/get_monitor.html
266
+ def get_eip_monitor(end_time: '', meters: [], resource: '', start_time: '', step: '')
267
+ input = {
268
+ config: config,
269
+ properties: properties,
270
+ api_name: 'GetMonitor',
271
+ request_method: 'GET',
272
+ request_params: {
273
+ 'end_time' => end_time,
274
+ 'meters' => meters,
275
+ 'resource' => resource,
276
+ 'start_time' => start_time,
277
+ 'step' => step, # step's available values: 5m, 15m, 2h, 1d
278
+ },
279
+ }
280
+
281
+ get_eip_monitor_input_validate input
282
+
283
+ request = Request.new input
284
+ request.send
285
+ end
286
+
287
+ private
288
+
289
+ def get_eip_monitor_input_validate(input)
290
+ input.deep_stringify_keys!
291
+
292
+ unless !input['request_params']['end_time'].nil? && !input['request_params']['end_time'].to_s.empty?
293
+ raise ParameterRequiredError.new('end_time', 'GetEIPMonitorInput')
294
+ end
295
+
296
+ unless !input['request_params']['meters'].nil? && !input['request_params']['meters'].to_s.empty?
297
+ raise ParameterRequiredError.new('meters', 'GetEIPMonitorInput')
298
+ end
299
+
300
+ unless !input['request_params']['resource'].nil? && !input['request_params']['resource'].to_s.empty?
301
+ raise ParameterRequiredError.new('resource', 'GetEIPMonitorInput')
302
+ end
303
+
304
+ unless !input['request_params']['start_time'].nil? && !input['request_params']['start_time'].to_s.empty?
305
+ raise ParameterRequiredError.new('start_time', 'GetEIPMonitorInput')
306
+ end
307
+
308
+ unless !input['request_params']['step'].nil? && !input['request_params']['step'].to_s.empty?
309
+ raise ParameterRequiredError.new('step', 'GetEIPMonitorInput')
310
+ end
311
+
312
+ if input['request_params']['step'] && !input['request_params']['step'].to_s.empty?
313
+ step_valid_values = %w(5m 15m 2h 1d)
314
+ unless step_valid_values.include? input['request_params']['step'].to_s
315
+ raise ParameterValueNotAllowedError.new(
316
+ 'step',
317
+ input['request_params']['step'],
318
+ step_valid_values,
319
+ )
320
+ end
321
+ end
322
+ end
323
+
324
+ public
325
+
326
+ # Documentation URL: https://docs.qingcloud.com/api/eip/modify_eip_attributes.html
327
+ def modify_eip_attributes(description: '', eip: '', eip_name: '')
328
+ input = {
329
+ config: config,
330
+ properties: properties,
331
+ api_name: 'ModifyEipAttributes',
332
+ request_method: 'GET',
333
+ request_params: {
334
+ 'description' => description,
335
+ 'eip' => eip,
336
+ 'eip_name' => eip_name,
337
+ },
338
+ }
339
+
340
+ modify_eip_attributes_input_validate input
341
+
342
+ request = Request.new input
343
+ request.send
344
+ end
345
+
346
+ private
347
+
348
+ def modify_eip_attributes_input_validate(input)
349
+ input.deep_stringify_keys!
350
+
351
+ unless !input['request_params']['eip'].nil? && !input['request_params']['eip'].to_s.empty?
352
+ raise ParameterRequiredError.new('eip', 'ModifyEipAttributesInput')
353
+ end
354
+ end
355
+
356
+ public
357
+
358
+ # Documentation URL: https://docs.qingcloud.com/api/eip/release_eips.html
359
+ def release_eips(eips: [])
360
+ input = {
361
+ config: config,
362
+ properties: properties,
363
+ api_name: 'ReleaseEips',
364
+ request_method: 'GET',
365
+ request_params: {
366
+ 'eips' => eips,
367
+ },
368
+ }
369
+
370
+ release_eips_input_validate input
371
+
372
+ request = Request.new input
373
+ request.send
374
+ end
375
+
376
+ private
377
+
378
+ def release_eips_input_validate(input)
379
+ input.deep_stringify_keys!
380
+
381
+ unless !input['request_params']['eips'].nil? && !input['request_params']['eips'].to_s.empty?
382
+ raise ParameterRequiredError.new('eips', 'ReleaseEipsInput')
383
+ end
384
+ end
385
+
386
+ public
387
+ end
388
+ end
389
+ end