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,53 @@
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 'base64'
18
+ require 'cgi'
19
+ require 'openssl'
20
+
21
+ module QingCloud
22
+ module SDK
23
+ class Signer
24
+ def self.do(input)
25
+ input[:request_params].each do |k, v|
26
+ v = CGI.escape v.to_s.gsub(' ', '%20')
27
+ input[:request_params][k] = v.gsub '%2520', '%20'
28
+ end
29
+
30
+ # build string_to_sign
31
+ string_to_sign = "#{input[:request_method]}\n#{input[:config][:uri]}\n" \
32
+ "#{input[:request_params].sort.map { |k, v| "#{k}=#{v}" }.join('&')}"
33
+
34
+ # build signature
35
+ signature = Base64.encode64(
36
+ OpenSSL::HMAC.digest(
37
+ OpenSSL::Digest.new('sha256'),
38
+ input[:config][:qy_secret_access_key].to_s,
39
+ string_to_sign,
40
+ ),
41
+ ).strip
42
+ signature.tr! ' ', '+'
43
+ signature = CGI.escape signature
44
+
45
+ input[:request_params][:signature] = signature
46
+
47
+ Logger.debug "QingCloud request string to sign: [#{input[:id]}] #{string_to_sign}"
48
+ Logger.debug "QingCloud request signature: [#{input[:id]}] #{signature}"
49
+ input
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,1005 @@
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 CacheService
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/cache/add_cache_nodes.html
30
+ def add_cache_nodes(cache: '', node_count: nil, private_ips: [])
31
+ input = {
32
+ config: config,
33
+ properties: properties,
34
+ api_name: 'AddCacheNodes',
35
+ request_method: 'GET',
36
+ request_params: {
37
+ 'cache' => cache,
38
+ 'node_count' => node_count,
39
+ 'private_ips' => private_ips,
40
+ },
41
+ }
42
+
43
+ add_cache_nodes_input_validate input
44
+
45
+ request = Request.new input
46
+ request.send
47
+ end
48
+
49
+ private
50
+
51
+ def add_cache_nodes_input_validate(input)
52
+ input.deep_stringify_keys!
53
+
54
+ unless !input['request_params']['cache'].nil? && !input['request_params']['cache'].to_s.empty?
55
+ raise ParameterRequiredError.new('cache', 'AddCacheNodesInput')
56
+ end
57
+
58
+ unless !input['request_params']['node_count'].nil? && !input['request_params']['node_count'].to_s.empty?
59
+ raise ParameterRequiredError.new('node_count', 'AddCacheNodesInput')
60
+ end
61
+
62
+ input['request_params']['private_ips'].map do |x|
63
+ next unless x['cache_role'] && !x['cache_role'].to_s.empty?
64
+ cache_role_valid_values = %w(master slave)
65
+ next if cache_role_valid_values.include? x['cache_role'].to_s
66
+ raise ParameterValueNotAllowedError.new(
67
+ 'cache_role',
68
+ x['cache_role'],
69
+ cache_role_valid_values,
70
+ )
71
+ end
72
+ end
73
+
74
+ public
75
+
76
+ # Documentation URL: https://docs.qingcloud.com/api/cache/apply_cache_parameter_group.html
77
+ def apply_cache_parameter_group(cache_parameter_group: '', caches: [])
78
+ input = {
79
+ config: config,
80
+ properties: properties,
81
+ api_name: 'ApplyCacheParameterGroup',
82
+ request_method: 'GET',
83
+ request_params: {
84
+ 'cache_parameter_group' => cache_parameter_group,
85
+ 'caches' => caches,
86
+ },
87
+ }
88
+
89
+ apply_cache_parameter_group_input_validate input
90
+
91
+ request = Request.new input
92
+ request.send
93
+ end
94
+
95
+ private
96
+
97
+ def apply_cache_parameter_group_input_validate(input)
98
+ input.deep_stringify_keys!
99
+
100
+ unless !input['request_params']['cache_parameter_group'].nil? && !input['request_params']['cache_parameter_group'].to_s.empty?
101
+ raise ParameterRequiredError.new('cache_parameter_group', 'ApplyCacheParameterGroupInput')
102
+ end
103
+ end
104
+
105
+ public
106
+
107
+ # Documentation URL: https://docs.qingcloud.com/api/cache/change_cache_vxnet.html
108
+ def change_cache_vxnet(cache: '', private_ips: [], vxnet: '')
109
+ input = {
110
+ config: config,
111
+ properties: properties,
112
+ api_name: 'ChangeCacheVxnet',
113
+ request_method: 'GET',
114
+ request_params: {
115
+ 'cache' => cache,
116
+ 'private_ips' => private_ips,
117
+ 'vxnet' => vxnet,
118
+ },
119
+ }
120
+
121
+ change_cache_vxnet_input_validate input
122
+
123
+ request = Request.new input
124
+ request.send
125
+ end
126
+
127
+ private
128
+
129
+ def change_cache_vxnet_input_validate(input)
130
+ input.deep_stringify_keys!
131
+
132
+ unless !input['request_params']['cache'].nil? && !input['request_params']['cache'].to_s.empty?
133
+ raise ParameterRequiredError.new('cache', 'ChangeCacheVxnetInput')
134
+ end
135
+
136
+ input['request_params']['private_ips'].map do |x|
137
+ next unless x['cache_role'] && !x['cache_role'].to_s.empty?
138
+ cache_role_valid_values = %w(master slave)
139
+ next if cache_role_valid_values.include? x['cache_role'].to_s
140
+ raise ParameterValueNotAllowedError.new(
141
+ 'cache_role',
142
+ x['cache_role'],
143
+ cache_role_valid_values,
144
+ )
145
+ end
146
+
147
+ unless !input['request_params']['vxnet'].nil? && !input['request_params']['vxnet'].to_s.empty?
148
+ raise ParameterRequiredError.new('vxnet', 'ChangeCacheVxnetInput')
149
+ end
150
+ end
151
+
152
+ public
153
+
154
+ # Documentation URL: https://docs.qingcloud.com/api/cache/create_cache.html
155
+ def create_cache(auto_backup_time: nil, cache_class: nil, cache_name: '', cache_parameter_group: '', cache_size: nil, cache_type: '', master_count: nil, network_type: nil, node_count: nil, private_ips: [], replicate_count: nil, vxnet: '')
156
+ input = {
157
+ config: config,
158
+ properties: properties,
159
+ api_name: 'CreateCache',
160
+ request_method: 'GET',
161
+ request_params: {
162
+ 'auto_backup_time' => auto_backup_time,
163
+ 'cache_class' => cache_class, # cache_class's available values: 0, 1
164
+ 'cache_name' => cache_name,
165
+ 'cache_parameter_group' => cache_parameter_group,
166
+ 'cache_size' => cache_size,
167
+ 'cache_type' => cache_type,
168
+ 'master_count' => master_count,
169
+ 'network_type' => network_type,
170
+ 'node_count' => node_count,
171
+ 'private_ips' => private_ips,
172
+ 'replicate_count' => replicate_count,
173
+ 'vxnet' => vxnet,
174
+ },
175
+ }
176
+
177
+ create_cache_input_validate input
178
+
179
+ request = Request.new input
180
+ request.send
181
+ end
182
+
183
+ private
184
+
185
+ def create_cache_input_validate(input)
186
+ input.deep_stringify_keys!
187
+
188
+ if input['request_params']['cache_class'] && !input['request_params']['cache_class'].to_s.empty?
189
+ cache_class_valid_values = %w(0 1)
190
+ unless cache_class_valid_values.include? input['request_params']['cache_class'].to_s
191
+ raise ParameterValueNotAllowedError.new(
192
+ 'cache_class',
193
+ input['request_params']['cache_class'],
194
+ cache_class_valid_values,
195
+ )
196
+ end
197
+ end
198
+
199
+ unless !input['request_params']['cache_size'].nil? && !input['request_params']['cache_size'].to_s.empty?
200
+ raise ParameterRequiredError.new('cache_size', 'CreateCacheInput')
201
+ end
202
+
203
+ unless !input['request_params']['cache_type'].nil? && !input['request_params']['cache_type'].to_s.empty?
204
+ raise ParameterRequiredError.new('cache_type', 'CreateCacheInput')
205
+ end
206
+
207
+ input['request_params']['private_ips'].map do |x|
208
+ next unless x['cache_role'] && !x['cache_role'].to_s.empty?
209
+ cache_role_valid_values = %w(master slave)
210
+ next if cache_role_valid_values.include? x['cache_role'].to_s
211
+ raise ParameterValueNotAllowedError.new(
212
+ 'cache_role',
213
+ x['cache_role'],
214
+ cache_role_valid_values,
215
+ )
216
+ end
217
+
218
+ unless !input['request_params']['vxnet'].nil? && !input['request_params']['vxnet'].to_s.empty?
219
+ raise ParameterRequiredError.new('vxnet', 'CreateCacheInput')
220
+ end
221
+ end
222
+
223
+ public
224
+
225
+ # Documentation URL: https://docs.qingcloud.com/api/cache/create_cache_from_snapshot.html
226
+ def create_cache_from_snapshot(auto_backup_time: nil, cache_class: nil, cache_name: '', cache_parameter_group: '', cache_size: nil, cache_type: '', network_type: nil, node_count: nil, private_ips: [], snapshot: '', vxnet: '')
227
+ input = {
228
+ config: config,
229
+ properties: properties,
230
+ api_name: 'CreateCacheFromSnapshot',
231
+ request_method: 'GET',
232
+ request_params: {
233
+ 'auto_backup_time' => auto_backup_time,
234
+ 'cache_class' => cache_class, # cache_class's available values: 0, 1
235
+ 'cache_name' => cache_name,
236
+ 'cache_parameter_group' => cache_parameter_group,
237
+ 'cache_size' => cache_size,
238
+ 'cache_type' => cache_type,
239
+ 'network_type' => network_type,
240
+ 'node_count' => node_count,
241
+ 'private_ips' => private_ips,
242
+ 'snapshot' => snapshot,
243
+ 'vxnet' => vxnet,
244
+ },
245
+ }
246
+
247
+ create_cache_from_snapshot_input_validate input
248
+
249
+ request = Request.new input
250
+ request.send
251
+ end
252
+
253
+ private
254
+
255
+ def create_cache_from_snapshot_input_validate(input)
256
+ input.deep_stringify_keys!
257
+
258
+ if input['request_params']['cache_class'] && !input['request_params']['cache_class'].to_s.empty?
259
+ cache_class_valid_values = %w(0 1)
260
+ unless cache_class_valid_values.include? input['request_params']['cache_class'].to_s
261
+ raise ParameterValueNotAllowedError.new(
262
+ 'cache_class',
263
+ input['request_params']['cache_class'],
264
+ cache_class_valid_values,
265
+ )
266
+ end
267
+ end
268
+
269
+ input['request_params']['private_ips'].map do |x|
270
+ next unless x['cache_role'] && !x['cache_role'].to_s.empty?
271
+ cache_role_valid_values = %w(master slave)
272
+ next if cache_role_valid_values.include? x['cache_role'].to_s
273
+ raise ParameterValueNotAllowedError.new(
274
+ 'cache_role',
275
+ x['cache_role'],
276
+ cache_role_valid_values,
277
+ )
278
+ end
279
+
280
+ unless !input['request_params']['snapshot'].nil? && !input['request_params']['snapshot'].to_s.empty?
281
+ raise ParameterRequiredError.new('snapshot', 'CreateCacheFromSnapshotInput')
282
+ end
283
+
284
+ unless !input['request_params']['vxnet'].nil? && !input['request_params']['vxnet'].to_s.empty?
285
+ raise ParameterRequiredError.new('vxnet', 'CreateCacheFromSnapshotInput')
286
+ end
287
+ end
288
+
289
+ public
290
+
291
+ # Documentation URL: https://docs.qingcloud.com/api/cache/create_cache_parameter_group.html
292
+ def create_cache_parameter_group(cache_parameter_group_name: '', cache_type: '')
293
+ input = {
294
+ config: config,
295
+ properties: properties,
296
+ api_name: 'CreateCacheParameterGroup',
297
+ request_method: 'GET',
298
+ request_params: {
299
+ 'cache_parameter_group_name' => cache_parameter_group_name,
300
+ 'cache_type' => cache_type, # cache_type's available values: redis2.8.17, memcached1.4.13
301
+ },
302
+ }
303
+
304
+ create_cache_parameter_group_input_validate input
305
+
306
+ request = Request.new input
307
+ request.send
308
+ end
309
+
310
+ private
311
+
312
+ def create_cache_parameter_group_input_validate(input)
313
+ input.deep_stringify_keys!
314
+
315
+ unless !input['request_params']['cache_type'].nil? && !input['request_params']['cache_type'].to_s.empty?
316
+ raise ParameterRequiredError.new('cache_type', 'CreateCacheParameterGroupInput')
317
+ end
318
+
319
+ if input['request_params']['cache_type'] && !input['request_params']['cache_type'].to_s.empty?
320
+ cache_type_valid_values = ['redis2.8.17', 'memcached1.4.13']
321
+ unless cache_type_valid_values.include? input['request_params']['cache_type'].to_s
322
+ raise ParameterValueNotAllowedError.new(
323
+ 'cache_type',
324
+ input['request_params']['cache_type'],
325
+ cache_type_valid_values,
326
+ )
327
+ end
328
+ end
329
+ end
330
+
331
+ public
332
+
333
+ # Documentation URL: https://docs.qingcloud.com/api/cache/delete_cache_nodes.html
334
+ def delete_cache_nodes(cache: '', cache_nodes: [])
335
+ input = {
336
+ config: config,
337
+ properties: properties,
338
+ api_name: 'DeleteCacheNodes',
339
+ request_method: 'GET',
340
+ request_params: {
341
+ 'cache' => cache,
342
+ 'cache_nodes' => cache_nodes,
343
+ },
344
+ }
345
+
346
+ delete_cache_nodes_input_validate input
347
+
348
+ request = Request.new input
349
+ request.send
350
+ end
351
+
352
+ private
353
+
354
+ def delete_cache_nodes_input_validate(input)
355
+ input.deep_stringify_keys!
356
+
357
+ unless !input['request_params']['cache'].nil? && !input['request_params']['cache'].to_s.empty?
358
+ raise ParameterRequiredError.new('cache', 'DeleteCacheNodesInput')
359
+ end
360
+
361
+ unless !input['request_params']['cache_nodes'].nil? && !input['request_params']['cache_nodes'].to_s.empty?
362
+ raise ParameterRequiredError.new('cache_nodes', 'DeleteCacheNodesInput')
363
+ end
364
+ end
365
+
366
+ public
367
+
368
+ # Documentation URL: https://docs.qingcloud.com/api/cache/delete_cache_parameter_groups.html
369
+ def delete_cache_parameter_groups(cache_parameter_groups: [])
370
+ input = {
371
+ config: config,
372
+ properties: properties,
373
+ api_name: 'DeleteCacheParameterGroups',
374
+ request_method: 'GET',
375
+ request_params: {
376
+ 'cache_parameter_groups' => cache_parameter_groups,
377
+ },
378
+ }
379
+
380
+ delete_cache_parameter_groups_input_validate input
381
+
382
+ request = Request.new input
383
+ request.send
384
+ end
385
+
386
+ private
387
+
388
+ def delete_cache_parameter_groups_input_validate(input)
389
+ input.deep_stringify_keys!
390
+
391
+ unless !input['request_params']['cache_parameter_groups'].nil? && !input['request_params']['cache_parameter_groups'].to_s.empty?
392
+ raise ParameterRequiredError.new('cache_parameter_groups', 'DeleteCacheParameterGroupsInput')
393
+ end
394
+ end
395
+
396
+ public
397
+
398
+ # Documentation URL: https://docs.qingcloud.com/api/cache/delete_caches.html
399
+ def delete_caches(caches: [])
400
+ input = {
401
+ config: config,
402
+ properties: properties,
403
+ api_name: 'DeleteCaches',
404
+ request_method: 'GET',
405
+ request_params: {
406
+ 'caches' => caches,
407
+ },
408
+ }
409
+
410
+ delete_caches_input_validate input
411
+
412
+ request = Request.new input
413
+ request.send
414
+ end
415
+
416
+ private
417
+
418
+ def delete_caches_input_validate(input)
419
+ input.deep_stringify_keys!
420
+
421
+ unless !input['request_params']['caches'].nil? && !input['request_params']['caches'].to_s.empty?
422
+ raise ParameterRequiredError.new('caches', 'DeleteCachesInput')
423
+ end
424
+ end
425
+
426
+ public
427
+
428
+ # Documentation URL: https://docs.qingcloud.com/api/cache/describe_cache_nodes.html
429
+ def describe_cache_nodes(cache: '', cache_nodes: [], limit: nil, offset: nil, search_word: '', status: [], verbose: nil)
430
+ input = {
431
+ config: config,
432
+ properties: properties,
433
+ api_name: 'DescribeCacheNodes',
434
+ request_method: 'GET',
435
+ request_params: {
436
+ 'cache' => cache,
437
+ 'cache_nodes' => cache_nodes,
438
+ 'limit' => limit,
439
+ 'offset' => offset,
440
+ 'search_word' => search_word,
441
+ 'status' => status,
442
+ 'verbose' => verbose,
443
+ },
444
+ }
445
+
446
+ describe_cache_nodes_input_validate input
447
+
448
+ request = Request.new input
449
+ request.send
450
+ end
451
+
452
+ private
453
+
454
+ def describe_cache_nodes_input_validate(input)
455
+ input.deep_stringify_keys!
456
+ end
457
+
458
+ public
459
+
460
+ # Documentation URL: https://docs.qingcloud.com/api/cache/describe_cache_parameter_groups.html
461
+ def describe_cache_parameter_groups(cache_parameter_groups: [], cache_type: '', limit: nil, offset: nil, search_word: '', verbose: nil)
462
+ input = {
463
+ config: config,
464
+ properties: properties,
465
+ api_name: 'DescribeCacheParameterGroups',
466
+ request_method: 'GET',
467
+ request_params: {
468
+ 'cache_parameter_groups' => cache_parameter_groups,
469
+ 'cache_type' => cache_type,
470
+ 'limit' => limit,
471
+ 'offset' => offset,
472
+ 'search_word' => search_word,
473
+ 'verbose' => verbose,
474
+ },
475
+ }
476
+
477
+ describe_cache_parameter_groups_input_validate input
478
+
479
+ request = Request.new input
480
+ request.send
481
+ end
482
+
483
+ private
484
+
485
+ def describe_cache_parameter_groups_input_validate(input)
486
+ input.deep_stringify_keys!
487
+ end
488
+
489
+ public
490
+
491
+ # Documentation URL: https://docs.qingcloud.com/api/cache/describe_cache_parameters.html
492
+ def describe_cache_parameters(cache_parameter_group: '', verbose: nil)
493
+ input = {
494
+ config: config,
495
+ properties: properties,
496
+ api_name: 'DescribeCacheParameters',
497
+ request_method: 'GET',
498
+ request_params: {
499
+ 'cache_parameter_group' => cache_parameter_group,
500
+ 'verbose' => verbose,
501
+ },
502
+ }
503
+
504
+ describe_cache_parameters_input_validate input
505
+
506
+ request = Request.new input
507
+ request.send
508
+ end
509
+
510
+ private
511
+
512
+ def describe_cache_parameters_input_validate(input)
513
+ input.deep_stringify_keys!
514
+
515
+ unless !input['request_params']['cache_parameter_group'].nil? && !input['request_params']['cache_parameter_group'].to_s.empty?
516
+ raise ParameterRequiredError.new('cache_parameter_group', 'DescribeCacheParametersInput')
517
+ end
518
+ end
519
+
520
+ public
521
+
522
+ # Documentation URL: https://docs.qingcloud.com/api/cache/describe_caches.html
523
+ def describe_caches(cache_type: [], caches: [], limit: nil, offset: nil, search_word: '', status: [], tags: [], verbose: nil)
524
+ input = {
525
+ config: config,
526
+ properties: properties,
527
+ api_name: 'DescribeCaches',
528
+ request_method: 'GET',
529
+ request_params: {
530
+ 'cache_type' => cache_type,
531
+ 'caches' => caches,
532
+ 'limit' => limit,
533
+ 'offset' => offset,
534
+ 'search_word' => search_word,
535
+ 'status' => status,
536
+ 'tags' => tags,
537
+ 'verbose' => verbose,
538
+ },
539
+ }
540
+
541
+ describe_caches_input_validate input
542
+
543
+ request = Request.new input
544
+ request.send
545
+ end
546
+
547
+ private
548
+
549
+ def describe_caches_input_validate(input)
550
+ input.deep_stringify_keys!
551
+ end
552
+
553
+ public
554
+
555
+ # Documentation URL: https://docs.qingcloud.com/api/monitor/get_cache_monitor.html
556
+ def get_cache_monitor(end_time: '', meters: [], resource: '', start_time: '', step: '')
557
+ input = {
558
+ config: config,
559
+ properties: properties,
560
+ api_name: 'GetCacheMonitor',
561
+ request_method: 'GET',
562
+ request_params: {
563
+ 'end_time' => end_time,
564
+ 'meters' => meters,
565
+ 'resource' => resource,
566
+ 'start_time' => start_time,
567
+ 'step' => step, # step's available values: 5m, 15m, 2h, 1d
568
+ },
569
+ }
570
+
571
+ get_cache_monitor_input_validate input
572
+
573
+ request = Request.new input
574
+ request.send
575
+ end
576
+
577
+ private
578
+
579
+ def get_cache_monitor_input_validate(input)
580
+ input.deep_stringify_keys!
581
+
582
+ unless !input['request_params']['end_time'].nil? && !input['request_params']['end_time'].to_s.empty?
583
+ raise ParameterRequiredError.new('end_time', 'GetCacheMonitorInput')
584
+ end
585
+
586
+ unless !input['request_params']['meters'].nil? && !input['request_params']['meters'].to_s.empty?
587
+ raise ParameterRequiredError.new('meters', 'GetCacheMonitorInput')
588
+ end
589
+
590
+ unless !input['request_params']['resource'].nil? && !input['request_params']['resource'].to_s.empty?
591
+ raise ParameterRequiredError.new('resource', 'GetCacheMonitorInput')
592
+ end
593
+
594
+ unless !input['request_params']['start_time'].nil? && !input['request_params']['start_time'].to_s.empty?
595
+ raise ParameterRequiredError.new('start_time', 'GetCacheMonitorInput')
596
+ end
597
+
598
+ unless !input['request_params']['step'].nil? && !input['request_params']['step'].to_s.empty?
599
+ raise ParameterRequiredError.new('step', 'GetCacheMonitorInput')
600
+ end
601
+
602
+ if input['request_params']['step'] && !input['request_params']['step'].to_s.empty?
603
+ step_valid_values = %w(5m 15m 2h 1d)
604
+ unless step_valid_values.include? input['request_params']['step'].to_s
605
+ raise ParameterValueNotAllowedError.new(
606
+ 'step',
607
+ input['request_params']['step'],
608
+ step_valid_values,
609
+ )
610
+ end
611
+ end
612
+ end
613
+
614
+ public
615
+
616
+ # Documentation URL: https://docs.qingcloud.com/api/cache/modify_cache_attributes.html
617
+ def modify_cache_attributes(auto_backup_time: nil, cache: '', cache_name: '', description: '')
618
+ input = {
619
+ config: config,
620
+ properties: properties,
621
+ api_name: 'ModifyCacheAttributes',
622
+ request_method: 'GET',
623
+ request_params: {
624
+ 'auto_backup_time' => auto_backup_time,
625
+ 'cache' => cache,
626
+ 'cache_name' => cache_name,
627
+ 'description' => description,
628
+ },
629
+ }
630
+
631
+ modify_cache_attributes_input_validate input
632
+
633
+ request = Request.new input
634
+ request.send
635
+ end
636
+
637
+ private
638
+
639
+ def modify_cache_attributes_input_validate(input)
640
+ input.deep_stringify_keys!
641
+
642
+ unless !input['request_params']['cache'].nil? && !input['request_params']['cache'].to_s.empty?
643
+ raise ParameterRequiredError.new('cache', 'ModifyCacheAttributesInput')
644
+ end
645
+ end
646
+
647
+ public
648
+
649
+ # Documentation URL: https://docs.qingcloud.com/api/cache/modify_cache_node_attributes.html
650
+ def modify_cache_node_attributes(cache_node: '', cache_node_name: '')
651
+ input = {
652
+ config: config,
653
+ properties: properties,
654
+ api_name: 'ModifyCacheNodeAttributes',
655
+ request_method: 'GET',
656
+ request_params: {
657
+ 'cache_node' => cache_node,
658
+ 'cache_node_name' => cache_node_name,
659
+ },
660
+ }
661
+
662
+ modify_cache_node_attributes_input_validate input
663
+
664
+ request = Request.new input
665
+ request.send
666
+ end
667
+
668
+ private
669
+
670
+ def modify_cache_node_attributes_input_validate(input)
671
+ input.deep_stringify_keys!
672
+
673
+ unless !input['request_params']['cache_node'].nil? && !input['request_params']['cache_node'].to_s.empty?
674
+ raise ParameterRequiredError.new('cache_node', 'ModifyCacheNodeAttributesInput')
675
+ end
676
+ end
677
+
678
+ public
679
+
680
+ # Documentation URL: https://docs.qingcloud.com/api/cache/modify_cache_parameter_group_attributes.html
681
+ def modify_cache_parameter_group_attributes(cache_parameter_group: '', cache_parameter_group_name: '', description: '')
682
+ input = {
683
+ config: config,
684
+ properties: properties,
685
+ api_name: 'ModifyCacheParameterGroupAttributes',
686
+ request_method: 'GET',
687
+ request_params: {
688
+ 'cache_parameter_group' => cache_parameter_group,
689
+ 'cache_parameter_group_name' => cache_parameter_group_name,
690
+ 'description' => description,
691
+ },
692
+ }
693
+
694
+ modify_cache_parameter_group_attributes_input_validate input
695
+
696
+ request = Request.new input
697
+ request.send
698
+ end
699
+
700
+ private
701
+
702
+ def modify_cache_parameter_group_attributes_input_validate(input)
703
+ input.deep_stringify_keys!
704
+
705
+ unless !input['request_params']['cache_parameter_group'].nil? && !input['request_params']['cache_parameter_group'].to_s.empty?
706
+ raise ParameterRequiredError.new('cache_parameter_group', 'ModifyCacheParameterGroupAttributesInput')
707
+ end
708
+ end
709
+
710
+ public
711
+
712
+ # Documentation URL: https://docs.qingcloud.com/api/cache/reset_cache_parameters.html
713
+ def reset_cache_parameters(cache_parameter_group: '', cache_parameter_names: [])
714
+ input = {
715
+ config: config,
716
+ properties: properties,
717
+ api_name: 'ResetCacheParameters',
718
+ request_method: 'GET',
719
+ request_params: {
720
+ 'cache_parameter_group' => cache_parameter_group,
721
+ 'cache_parameter_names' => cache_parameter_names,
722
+ },
723
+ }
724
+
725
+ reset_cache_parameters_input_validate input
726
+
727
+ request = Request.new input
728
+ request.send
729
+ end
730
+
731
+ private
732
+
733
+ def reset_cache_parameters_input_validate(input)
734
+ input.deep_stringify_keys!
735
+
736
+ unless !input['request_params']['cache_parameter_group'].nil? && !input['request_params']['cache_parameter_group'].to_s.empty?
737
+ raise ParameterRequiredError.new('cache_parameter_group', 'ResetCacheParametersInput')
738
+ end
739
+ end
740
+
741
+ public
742
+
743
+ # Documentation URL: https://docs.qingcloud.com/api/cache/resize_cache.html
744
+ def resize_caches(cache_size: nil, caches: [])
745
+ input = {
746
+ config: config,
747
+ properties: properties,
748
+ api_name: 'ResizeCaches',
749
+ request_method: 'GET',
750
+ request_params: {
751
+ 'cache_size' => cache_size,
752
+ 'caches' => caches,
753
+ },
754
+ }
755
+
756
+ resize_caches_input_validate input
757
+
758
+ request = Request.new input
759
+ request.send
760
+ end
761
+
762
+ private
763
+
764
+ def resize_caches_input_validate(input)
765
+ input.deep_stringify_keys!
766
+
767
+ unless !input['request_params']['cache_size'].nil? && !input['request_params']['cache_size'].to_s.empty?
768
+ raise ParameterRequiredError.new('cache_size', 'ResizeCachesInput')
769
+ end
770
+
771
+ unless !input['request_params']['caches'].nil? && !input['request_params']['caches'].to_s.empty?
772
+ raise ParameterRequiredError.new('caches', 'ResizeCachesInput')
773
+ end
774
+ end
775
+
776
+ public
777
+
778
+ # Documentation URL: https://docs.qingcloud.com/api/cache/restart_cache_nodes.html
779
+ def restart_cache_nodes(cache: '', cache_nodes: [])
780
+ input = {
781
+ config: config,
782
+ properties: properties,
783
+ api_name: 'RestartCacheNodes',
784
+ request_method: 'GET',
785
+ request_params: {
786
+ 'cache' => cache,
787
+ 'cache_nodes' => cache_nodes,
788
+ },
789
+ }
790
+
791
+ restart_cache_nodes_input_validate input
792
+
793
+ request = Request.new input
794
+ request.send
795
+ end
796
+
797
+ private
798
+
799
+ def restart_cache_nodes_input_validate(input)
800
+ input.deep_stringify_keys!
801
+
802
+ unless !input['request_params']['cache'].nil? && !input['request_params']['cache'].to_s.empty?
803
+ raise ParameterRequiredError.new('cache', 'RestartCacheNodesInput')
804
+ end
805
+
806
+ unless !input['request_params']['cache_nodes'].nil? && !input['request_params']['cache_nodes'].to_s.empty?
807
+ raise ParameterRequiredError.new('cache_nodes', 'RestartCacheNodesInput')
808
+ end
809
+ end
810
+
811
+ public
812
+
813
+ # restart_caches: Only available for memcached.
814
+ # Documentation URL: https://docs.qingcloud.com/api/cache/restart_caches.html
815
+ def restart_caches(caches: [])
816
+ input = {
817
+ config: config,
818
+ properties: properties,
819
+ api_name: 'RestartCaches',
820
+ request_method: 'GET',
821
+ request_params: {
822
+ 'caches' => caches,
823
+ },
824
+ }
825
+
826
+ restart_caches_input_validate input
827
+
828
+ request = Request.new input
829
+ request.send
830
+ end
831
+
832
+ private
833
+
834
+ def restart_caches_input_validate(input)
835
+ input.deep_stringify_keys!
836
+
837
+ unless !input['request_params']['caches'].nil? && !input['request_params']['caches'].to_s.empty?
838
+ raise ParameterRequiredError.new('caches', 'RestartCachesInput')
839
+ end
840
+ end
841
+
842
+ public
843
+
844
+ # Documentation URL: https://docs.qingcloud.com/api/cache/start_caches.html
845
+ def start_caches(caches: [])
846
+ input = {
847
+ config: config,
848
+ properties: properties,
849
+ api_name: 'StartCaches',
850
+ request_method: 'GET',
851
+ request_params: {
852
+ 'caches' => caches,
853
+ },
854
+ }
855
+
856
+ start_caches_input_validate input
857
+
858
+ request = Request.new input
859
+ request.send
860
+ end
861
+
862
+ private
863
+
864
+ def start_caches_input_validate(input)
865
+ input.deep_stringify_keys!
866
+
867
+ unless !input['request_params']['caches'].nil? && !input['request_params']['caches'].to_s.empty?
868
+ raise ParameterRequiredError.new('caches', 'StartCachesInput')
869
+ end
870
+ end
871
+
872
+ public
873
+
874
+ # Documentation URL: https://docs.qingcloud.com/api/cache/stop_caches.html
875
+ def stop_caches(caches: [])
876
+ input = {
877
+ config: config,
878
+ properties: properties,
879
+ api_name: 'StopCaches',
880
+ request_method: 'GET',
881
+ request_params: {
882
+ 'caches' => caches,
883
+ },
884
+ }
885
+
886
+ stop_caches_input_validate input
887
+
888
+ request = Request.new input
889
+ request.send
890
+ end
891
+
892
+ private
893
+
894
+ def stop_caches_input_validate(input)
895
+ input.deep_stringify_keys!
896
+
897
+ unless !input['request_params']['caches'].nil? && !input['request_params']['caches'].to_s.empty?
898
+ raise ParameterRequiredError.new('caches', 'StopCachesInput')
899
+ end
900
+ end
901
+
902
+ public
903
+
904
+ # Documentation URL: https://docs.qingcloud.com/api/cache/update_cache.html
905
+ def update_cache(cache: '', private_ips: [])
906
+ input = {
907
+ config: config,
908
+ properties: properties,
909
+ api_name: 'UpdateCache',
910
+ request_method: 'GET',
911
+ request_params: {
912
+ 'cache' => cache,
913
+ 'private_ips' => private_ips,
914
+ },
915
+ }
916
+
917
+ update_cache_input_validate input
918
+
919
+ request = Request.new input
920
+ request.send
921
+ end
922
+
923
+ private
924
+
925
+ def update_cache_input_validate(input)
926
+ input.deep_stringify_keys!
927
+
928
+ unless !input['request_params']['cache'].nil? && !input['request_params']['cache'].to_s.empty?
929
+ raise ParameterRequiredError.new('cache', 'UpdateCacheInput')
930
+ end
931
+
932
+ input['request_params']['private_ips'].map do |x|
933
+ next unless x['cache_role'] && !x['cache_role'].to_s.empty?
934
+ cache_role_valid_values = %w(master slave)
935
+ next if cache_role_valid_values.include? x['cache_role'].to_s
936
+ raise ParameterValueNotAllowedError.new(
937
+ 'cache_role',
938
+ x['cache_role'],
939
+ cache_role_valid_values,
940
+ )
941
+ end
942
+ end
943
+
944
+ public
945
+
946
+ # Documentation URL: https://docs.qingcloud.com/api/cache/update_cache_parameters.html
947
+ def update_cache_parameters(cache_parameter_group: '', parameters: [])
948
+ input = {
949
+ config: config,
950
+ properties: properties,
951
+ api_name: 'UpdateCacheParameters',
952
+ request_method: 'GET',
953
+ request_params: {
954
+ 'cache_parameter_group' => cache_parameter_group,
955
+ 'parameters' => parameters,
956
+ },
957
+ }
958
+
959
+ update_cache_parameters_input_validate input
960
+
961
+ request = Request.new input
962
+ request.send
963
+ end
964
+
965
+ private
966
+
967
+ def update_cache_parameters_input_validate(input)
968
+ input.deep_stringify_keys!
969
+
970
+ unless !input['request_params']['cache_parameter_group'].nil? && !input['request_params']['cache_parameter_group'].to_s.empty?
971
+ raise ParameterRequiredError.new('cache_parameter_group', 'UpdateCacheParametersInput')
972
+ end
973
+
974
+ unless input['request_params']['parameters'].nil?
975
+
976
+ unless !input['request_params']['parameters']['cache_parameter_name'].nil? && !input['request_params']['parameters']['cache_parameter_name'].to_s.empty?
977
+ raise ParameterRequiredError.new('cache_parameter_name', 'cache_parameter')
978
+ end
979
+
980
+ unless !input['request_params']['parameters']['cache_parameter_value'].nil? && !input['request_params']['parameters']['cache_parameter_value'].to_s.empty?
981
+ raise ParameterRequiredError.new('cache_parameter_value', 'cache_parameter')
982
+ end
983
+
984
+ if input['request_params']['parameters']['is_readonly'] && !input['request_params']['parameters']['is_readonly'].to_s.empty?
985
+ is_readonly_valid_values = %w(0 1)
986
+ unless is_readonly_valid_values.include? input['request_params']['parameters']['is_readonly'].to_s
987
+ raise ParameterValueNotAllowedError.new(
988
+ 'is_readonly',
989
+ input['request_params']['parameters']['is_readonly'],
990
+ is_readonly_valid_values,
991
+ )
992
+ end
993
+ end
994
+
995
+ end
996
+
997
+ if input['request_params']['parameters'].nil?
998
+ raise ParameterRequiredError.new('parameters', 'UpdateCacheParametersInput')
999
+ end
1000
+ end
1001
+
1002
+ public
1003
+ end
1004
+ end
1005
+ end