Sha256: 029615f88ae072cb5296148a3b12cff62b17c9cf332eafed4c3962b3adc7772b

Contents?: true

Size: 1.14 KB

Versions: 30

Compression:

Stored size: 1.14 KB

Contents

class TreasureData::API
module Database

  ####
  ## Database API
  ##

  # @return [Array<String>] names as array
  def list_databases
    code, body, res = get("/v3/database/list")
    if code != "200"
      raise_error("List databases failed", res)
    end
    js = checked_json(body, %w[databases])
    result = {}
    js["databases"].each {|m|
      name = m['name']
      count = m['count']
      created_at = m['created_at']
      updated_at = m['updated_at']
      permission = m['permission']
      result[name] = [count, created_at, updated_at, nil, permission] # set nil to org for API compatibiilty
    }
    return result
  end

  # @param [String] db
  # @return [true]
  def delete_database(db)
    code, body, res = post("/v3/database/delete/#{e db}")
    if code != "200"
      raise_error("Delete database failed", res)
    end
    return true
  end

  # @param [String] db
  # @param [Hash] opts
  # @return [true]
  def create_database(db, opts={})
    params = opts.dup
    code, body, res = post("/v3/database/create/#{e db}", params)
    if code != "200"
      raise_error("Create database failed", res)
    end
    return true
  end

end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
td-client-2.0.0 lib/td/client/api/database.rb
td-client-1.0.8 lib/td/client/api/database.rb
td-client-1.0.7 lib/td/client/api/database.rb
td-client-1.0.6 lib/td/client/api/database.rb
td-client-1.0.5 lib/td/client/api/database.rb
td-client-1.0.4 lib/td/client/api/database.rb
td-client-1.0.3 lib/td/client/api/database.rb
td-client-1.0.2 lib/td/client/api/database.rb
td-client-1.0.1 lib/td/client/api/database.rb
td-client-1.0.0-java lib/td/client/api/database.rb
td-client-1.0.0 lib/td/client/api/database.rb
td-client-0.8.85 lib/td/client/api/database.rb
td-client-0.8.84 lib/td/client/api/database.rb
td-client-0.8.83 lib/td/client/api/database.rb
td-client-0.8.82 lib/td/client/api/database.rb
td-client-0.8.81 lib/td/client/api/database.rb
td-client-0.8.80 lib/td/client/api/database.rb
td-client-0.8.79 lib/td/client/api/database.rb
td-client-0.8.78 lib/td/client/api/database.rb
td-client-0.9.0dev2 lib/td/client/api/database.rb