Class: IndexTank::ApiClient

Inherits:
RestClient show all
Defined in:
lib/indextank_client.rb

Direct Known Subclasses

HerokuClient

Instance Method Summary collapse

Methods inherited from RestClient

#DELETE, #GET, #PUT

Constructor Details

#initialize(api_url) ⇒ ApiClient

Returns a new instance of ApiClient.



73
74
75
# File 'lib/indextank_client.rb', line 73

def initialize(api_url)
    @uri = URI.parse(api_url)
end

Instance Method Details

#create_index(name) ⇒ Object



82
83
84
85
86
# File 'lib/indextank_client.rb', line 82

def create_index(name)
    index = get_index(name)
    index.create_index()
    return index
end

#delete_index(name) ⇒ Object



88
89
90
# File 'lib/indextank_client.rb', line 88

def delete_index(name)
    return get_index(name).delete_index()
end

#get_index(name) ⇒ Object



77
78
79
80
# File 'lib/indextank_client.rb', line 77

def get_index(name)
    require 'cgi' unless defined?(CGI) && defined?(CGI::escape)
    return IndexClient.new("#{@uri}/v1/indexes/#{CGI.escape(name)}")
end

#list_indexesObject



92
93
94
95
# File 'lib/indextank_client.rb', line 92

def list_indexes()
    code, indexes = GET "/v1/indexes"
    return indexes.map do |name,| IndexClient.new "#{@uri}/v1/indexes/#{name}",  end
end