Module: TreasureData::API::BulkImport
- Included in:
- TreasureData::API
- Defined in:
- lib/td/client/api/bulk_import.rb
Instance Method Summary collapse
- #bulk_import_delete_part(name, part_name, opts = {}) ⇒ nil
- #bulk_import_error_records(name, opts = {}, &block) ⇒ Array
- #bulk_import_upload_part(name, part_name, stream, size, opts = {}) ⇒ nil
- #commit_bulk_import(name, opts = {}) ⇒ nil
- #create_bulk_import(name, db, table, opts = {}) ⇒ nil
- #delete_bulk_import(name, opts = {}) ⇒ nil
- #freeze_bulk_import(name, opts = {}) ⇒ nil
- #list_bulk_import_parts(name, opts = {}) ⇒ nil
- #list_bulk_imports(opts = {}) ⇒ Hash
-
#perform_bulk_import(name, opts = {}) ⇒ String
Job_id.
- #show_bulk_import(name) ⇒ Hash
- #unfreeze_bulk_import(name, opts = {}) ⇒ nil
Instance Method Details
#bulk_import_delete_part(name, part_name, opts = {}) ⇒ nil
88 89 90 91 92 93 94 95 |
# File 'lib/td/client/api/bulk_import.rb', line 88 def bulk_import_delete_part(name, part_name, opts={}) params = opts.dup code, body, res = post("/v3/bulk_import/delete_part/#{e name}/#{e part_name}", params) if code[0] != ?2 raise_error("Delete a part failed", res) end return nil end |
#bulk_import_error_records(name, opts = {}, &block) ⇒ Array
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
# File 'lib/td/client/api/bulk_import.rb', line 150 def bulk_import_error_records(name, opts={}, &block) params = opts.dup code, body, res = get("/v3/bulk_import/error_records/#{e name}", params) if code != "200" raise_error("Failed to get bulk import error records", res) end if body.nil? || body.empty? if block return nil else return [] end end require File.('../compat_gzip_reader', File.dirname(__FILE__)) u = MessagePack::Unpacker.new(Zlib::GzipReader.new(StringIO.new(body))) if block begin u.each(&block) rescue EOFError end nil else result = [] begin u.each {|row| result << row } rescue EOFError end return result end end |
#bulk_import_upload_part(name, part_name, stream, size, opts = {}) ⇒ nil
76 77 78 79 80 81 82 |
# File 'lib/td/client/api/bulk_import.rb', line 76 def bulk_import_upload_part(name, part_name, stream, size, opts={}) code, body, res = put("/v3/bulk_import/upload_part/#{e name}/#{e part_name}", stream, size) if code[0] != ?2 raise_error("Upload a part failed", res) end return nil end |
#commit_bulk_import(name, opts = {}) ⇒ nil
137 138 139 140 141 142 143 144 |
# File 'lib/td/client/api/bulk_import.rb', line 137 def commit_bulk_import(name, opts={}) params = opts.dup code, body, res = post("/v3/bulk_import/commit/#{e name}", params) if code != "200" raise_error("Commit bulk import failed", res) end return nil end |
#create_bulk_import(name, db, table, opts = {}) ⇒ nil
13 14 15 16 17 18 19 20 |
# File 'lib/td/client/api/bulk_import.rb', line 13 def create_bulk_import(name, db, table, opts={}) params = opts.dup code, body, res = post("/v3/bulk_import/create/#{e name}/#{e db}/#{e table}", params) if code != "200" raise_error("Create bulk import failed", res) end return nil end |
#delete_bulk_import(name, opts = {}) ⇒ nil
25 26 27 28 29 30 31 32 |
# File 'lib/td/client/api/bulk_import.rb', line 25 def delete_bulk_import(name, opts={}) params = opts.dup code, body, res = post("/v3/bulk_import/delete/#{e name}", params) if code != "200" raise_error("Delete bulk import failed", res) end return nil end |
#freeze_bulk_import(name, opts = {}) ⇒ nil
100 101 102 103 104 105 106 107 |
# File 'lib/td/client/api/bulk_import.rb', line 100 def freeze_bulk_import(name, opts={}) params = opts.dup code, body, res = post("/v3/bulk_import/freeze/#{e name}", params) if code != "200" raise_error("Freeze bulk import failed", res) end return nil end |
#list_bulk_import_parts(name, opts = {}) ⇒ nil
60 61 62 63 64 65 66 67 68 |
# File 'lib/td/client/api/bulk_import.rb', line 60 def list_bulk_import_parts(name, opts={}) params = opts.dup code, body, res = get("/v3/bulk_import/list_parts/#{e name}", params) if code != "200" raise_error("List bulk import parts failed", res) end js = checked_json(body, %w[parts]) return js['parts'] end |
#list_bulk_imports(opts = {}) ⇒ Hash
47 48 49 50 51 52 53 54 55 |
# File 'lib/td/client/api/bulk_import.rb', line 47 def list_bulk_imports(opts={}) params = opts.dup code, body, res = get("/v3/bulk_import/list", params) if code != "200" raise_error("List bulk imports failed", res) end js = checked_json(body, %w[bulk_imports]) return js['bulk_imports'] end |
#perform_bulk_import(name, opts = {}) ⇒ String
Returns job_id.
124 125 126 127 128 129 130 131 132 |
# File 'lib/td/client/api/bulk_import.rb', line 124 def perform_bulk_import(name, opts={}) params = opts.dup code, body, res = post("/v3/bulk_import/perform/#{e name}", params) if code != "200" raise_error("Perform bulk import failed", res) end js = checked_json(body, %w[job_id]) return js['job_id'].to_s end |
#show_bulk_import(name) ⇒ Hash
36 37 38 39 40 41 42 43 |
# File 'lib/td/client/api/bulk_import.rb', line 36 def show_bulk_import(name) code, body, res = get("/v3/bulk_import/show/#{name}") if code != "200" raise_error("Show bulk import failed", res) end js = checked_json(body, %w[status]) return js end |
#unfreeze_bulk_import(name, opts = {}) ⇒ nil
112 113 114 115 116 117 118 119 |
# File 'lib/td/client/api/bulk_import.rb', line 112 def unfreeze_bulk_import(name, opts={}) params = opts.dup code, body, res = post("/v3/bulk_import/unfreeze/#{e name}", params) if code != "200" raise_error("Unfreeze bulk import failed", res) end return nil end |