module TreasureData::API::BulkImport

Public Instance Methods

bulk_import_delete_part(name, part_name, opts={}) click to toggle source

@param [String] name @param [String] part_name @param [Hash] opts @return [nil]

# 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) click to toggle source

@param [String] name @param [Hash] opts @param [Proc] block @return [Array]

# 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.expand_path('../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={}) click to toggle source

@param [String] name @param [String] part_name @param [String, StringIO] stream @param [Fixnum] size @param [Hash] opts @return [nil]

# 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={}) click to toggle source

@param [String] name @param [Hash] opts @return [nil]

# 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={}) click to toggle source

@param [String] name @param [String] db @param [String] table @param [Hash] opts @return [nil]

# 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={}) click to toggle source

@param [String] name @param [Hash] opts @return [nil]

# 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={}) click to toggle source

@param [String] name @param [Hash] opts @return [nil]

# 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={}) click to toggle source

@param [String] name @param [Hash] opts @return [nil]

# 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={}) click to toggle source

@param [Hash] opts @return [Hash]

# 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={}) click to toggle source

@param [String] name @param [Hash] opts @return [String] job_id

# 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) click to toggle source

@param [String] name @return [Hash]

# 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={}) click to toggle source

@param [String] name @param [Hash] opts @return [nil]

# 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