Sha256: a8ab7e01365a367cae2e8f2221902717f6ed8a5a957ca98a53c02da8f429fbee

Contents?: true

Size: 979 Bytes

Versions: 11

Compression:

Stored size: 979 Bytes

Contents

class TreasureData::API
module Import

  ####
  ## Import API
  ##

  # @param [String] db
  # @param [String] table
  # @param [String] format
  # @param [String, StringIO] stream
  # @param [Fixnum] size
  # @param [String] unique_id
  # @return [Float] elapsed time
  def import(db, table, format, stream, size, unique_id=nil)
    if unique_id
      path = "/v3/table/import_with_id/#{e db}/#{e table}/#{unique_id}/#{format}"
    else
      path = "/v3/table/import/#{e db}/#{e table}/#{format}"
    end
    opts = {}
    if @host == DEFAULT_ENDPOINT
      opts[:host] = DEFAULT_IMPORT_ENDPOINT
    elsif @host == TreasureData::API::OLD_ENDPOINT # backward compatibility
      opts[:host] = 'api-import.treasure-data.com'
      opts[:ssl] = false
    end
    code, body, res = put(path, stream, size, opts)
    if code[0] != ?2
      raise_error("Import failed", res)
    end
    js = checked_json(body, %w[])
    time = js['elapsed_time'].to_f
    return time
  end

end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
td-client-1.0.7 lib/td/client/api/import.rb
td-client-1.0.6 lib/td/client/api/import.rb
td-client-1.0.5 lib/td/client/api/import.rb
td-client-1.0.4 lib/td/client/api/import.rb
td-client-1.0.3 lib/td/client/api/import.rb
td-client-1.0.2 lib/td/client/api/import.rb
td-client-1.0.1 lib/td/client/api/import.rb
td-client-1.0.0-java lib/td/client/api/import.rb
td-client-1.0.0 lib/td/client/api/import.rb
td-client-0.8.85 lib/td/client/api/import.rb
td-client-0.8.84 lib/td/client/api/import.rb