Module: Wechat::Concern::Qcloud
- Included in:
- MpApi
- Defined in:
- lib/wechat/concern/qcloud.rb
Instance Method Summary collapse
- #invoke_cloud_function(function_name, post_body_params) ⇒ Object
- #qdb_add(add_query) ⇒ Object
- #qdb_aggregate(aggregate_query) ⇒ Object
- #qdb_collection_add(collection_name) ⇒ Object
- #qdb_collection_delete(collection_name) ⇒ Object
- #qdb_collections(limit: 10, offset: 0) ⇒ Object
- #qdb_count(count_query) ⇒ Object
- #qdb_delete(delete_query) ⇒ Object
- #qdb_migrate_export(query, file_path, file_type: Wechat::Qcloud::FILE_TYPE_JSON) ⇒ Object
- #qdb_migrate_import(collection_name, file_path, file_type: Wechat::Qcloud::FILE_TYPE_JSON, stop_on_error: false, conflict_mode: Wechat::Qcloud::CONFLICT_MODE_UPSERT) ⇒ Object
- #qdb_migrate_query(job_id) ⇒ Object
- #qdb_query(query) ⇒ Object
- #qdb_update(update_query) ⇒ Object
- #qdb_update_index(collection_name, create_indexes: [], drop_indexes: []) ⇒ Object
- #tcb_delete_files(fileid_list) ⇒ Object
- #tcb_do_upload_file(q_path, upload_url, signature, x_cos_security_token, x_cos_meta_fileid, file) ⇒ Object
- #tcb_download_files(file_list) ⇒ Object
- #tcb_preflight_upload_file(q_path) ⇒ Object
- #tcb_upload_file(q_path, file) ⇒ Object
Instance Method Details
#invoke_cloud_function(function_name, post_body_params) ⇒ Object
6 7 8 |
# File 'lib/wechat/concern/qcloud.rb', line 6 def invoke_cloud_function(function_name, post_body_params) post 'invokecloudfunction', JSON.generate(post_body_params), params: { env: qcloud.qcloud_env, name: function_name }, base: Wechat::Api::TCB_BASE end |
#qdb_add(add_query) ⇒ Object
62 63 64 |
# File 'lib/wechat/concern/qcloud.rb', line 62 def qdb_add(add_query) post 'databaseadd', JSON.generate(env: qcloud.qcloud_env, query: add_query), base: Wechat::Api::TCB_BASE end |
#qdb_aggregate(aggregate_query) ⇒ Object
78 79 80 |
# File 'lib/wechat/concern/qcloud.rb', line 78 def qdb_aggregate(aggregate_query) post 'databaseaggregate', JSON.generate(env: qcloud.qcloud_env, query: aggregate_query), base: Wechat::Api::TCB_BASE end |
#qdb_collection_add(collection_name) ⇒ Object
43 44 45 46 47 |
# File 'lib/wechat/concern/qcloud.rb', line 43 def qdb_collection_add(collection_name) collection_add_params_hash = { env: qcloud.qcloud_env, collection_name: collection_name } post 'databasecollectionadd', JSON.generate(collection_add_params_hash), base: Wechat::Api::TCB_BASE end |
#qdb_collection_delete(collection_name) ⇒ Object
49 50 51 52 53 |
# File 'lib/wechat/concern/qcloud.rb', line 49 def qdb_collection_delete(collection_name) collection_delete_params_hash = { env: qcloud.qcloud_env, collection_name: collection_name } post 'databasecollectiondelete', JSON.generate(collection_delete_params_hash), base: Wechat::Api::TCB_BASE end |
#qdb_collections(limit: 10, offset: 0) ⇒ Object
55 56 57 58 59 60 |
# File 'lib/wechat/concern/qcloud.rb', line 55 def qdb_collections(limit: 10, offset: 0) get_collections_params_hash = { env: qcloud.qcloud_env, limit: limit, offset: offset } post 'databasecollectionget', JSON.generate(get_collections_params_hash), base: Wechat::Api::TCB_BASE end |
#qdb_count(count_query) ⇒ Object
82 83 84 |
# File 'lib/wechat/concern/qcloud.rb', line 82 def qdb_count(count_query) post 'databasecount', JSON.generate(env: qcloud.qcloud_env, query: count_query), base: Wechat::Api::TCB_BASE end |
#qdb_delete(delete_query) ⇒ Object
66 67 68 |
# File 'lib/wechat/concern/qcloud.rb', line 66 def qdb_delete(delete_query) post 'databasedelete', JSON.generate(env: qcloud.qcloud_env, query: delete_query), base: Wechat::Api::TCB_BASE end |
#qdb_migrate_export(query, file_path, file_type: Wechat::Qcloud::FILE_TYPE_JSON) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/wechat/concern/qcloud.rb', line 20 def qdb_migrate_export(query, file_path, file_type: Wechat::Qcloud::FILE_TYPE_JSON) export_params_hash = { env: qcloud.qcloud_env, file_path: file_path, file_type: file_type, query: query } post 'databasemigrateexport', JSON.generate(export_params_hash), base: Wechat::Api::TCB_BASE end |
#qdb_migrate_import(collection_name, file_path, file_type: Wechat::Qcloud::FILE_TYPE_JSON, stop_on_error: false, conflict_mode: Wechat::Qcloud::CONFLICT_MODE_UPSERT) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/wechat/concern/qcloud.rb', line 10 def qdb_migrate_import(collection_name, file_path, file_type: Wechat::Qcloud::FILE_TYPE_JSON, stop_on_error: false, conflict_mode: Wechat::Qcloud::CONFLICT_MODE_UPSERT) import_params_hash = { env: qcloud.qcloud_env, collection_name: collection_name, file_path: file_path, file_type: file_type, stop_on_error: stop_on_error, conflict_mode: conflict_mode } post 'databasemigrateimport', JSON.generate(import_params_hash), base: Wechat::Api::TCB_BASE end |
#qdb_migrate_query(job_id) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/wechat/concern/qcloud.rb', line 28 def qdb_migrate_query(job_id) query_info_hash = { env: qcloud.qcloud_env, job_id: job_id } post 'databasemigratequeryinfo', JSON.generate(query_info_hash), base: Wechat::Api::TCB_BASE end |
#qdb_query(query) ⇒ Object
74 75 76 |
# File 'lib/wechat/concern/qcloud.rb', line 74 def qdb_query(query) post 'databasequery', JSON.generate(env: qcloud.qcloud_env, query: query), base: Wechat::Api::TCB_BASE end |
#qdb_update(update_query) ⇒ Object
70 71 72 |
# File 'lib/wechat/concern/qcloud.rb', line 70 def qdb_update(update_query) post 'databaseupdate', JSON.generate(env: qcloud.qcloud_env, query: update_query), base: Wechat::Api::TCB_BASE end |
#qdb_update_index(collection_name, create_indexes: [], drop_indexes: []) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/wechat/concern/qcloud.rb', line 35 def qdb_update_index(collection_name, create_indexes: [], drop_indexes: []) update_index_params_hash = { env: qcloud.qcloud_env, collection_name: collection_name, create_indexes: create_indexes, drop_indexes: drop_indexes } post 'updateindex', JSON.generate(update_index_params_hash), base: Wechat::Api::TCB_BASE end |
#tcb_delete_files(fileid_list) ⇒ Object
86 87 88 |
# File 'lib/wechat/concern/qcloud.rb', line 86 def tcb_delete_files(fileid_list) post 'batchdeletefile', JSON.generate(env: qcloud.qcloud_env, fileid_list: fileid_list), base: Wechat::Api::TCB_BASE end |
#tcb_do_upload_file(q_path, upload_url, signature, x_cos_security_token, x_cos_meta_fileid, file) ⇒ Object
98 99 100 101 102 103 104 105 106 |
# File 'lib/wechat/concern/qcloud.rb', line 98 def tcb_do_upload_file(q_path, upload_url, signature, x_cos_security_token, , file) form_file = file.is_a?(HTTP::FormData::File) ? file : HTTP::FormData::File.new(file) form_data = HTTP::FormData.create({ key: q_path, Signature: signature, 'x-cos-security-token': x_cos_security_token, 'x-cos-meta-fileid': , file: form_file }) client.httprb.post(upload_url, form: form_data, ssl_context: client.ssl_context) end |
#tcb_download_files(file_list) ⇒ Object
90 91 92 |
# File 'lib/wechat/concern/qcloud.rb', line 90 def tcb_download_files(file_list) post 'batchdownloadfile', JSON.generate(env: qcloud.qcloud_env, file_list: file_list), base: Wechat::Api::TCB_BASE end |
#tcb_preflight_upload_file(q_path) ⇒ Object
94 95 96 |
# File 'lib/wechat/concern/qcloud.rb', line 94 def tcb_preflight_upload_file(q_path) post 'uploadfile', JSON.generate(env: qcloud.qcloud_env, path: q_path), base: Wechat::Api::TCB_BASE end |
#tcb_upload_file(q_path, file) ⇒ Object
108 109 110 111 112 |
# File 'lib/wechat/concern/qcloud.rb', line 108 def tcb_upload_file(q_path, file) res = tcb_preflight_upload_file(q_path) tcb_do_upload_file(q_path, res['url'], res['authorization'], res['token'], res['cos_file_id'], file) res end |