Class: SaikuClient::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/saiku_client.rb

Instance Method Summary collapse

Instance Method Details

#cookiesObject



15
16
17
18
19
20
21
# File 'lib/saiku_client.rb', line 15

def cookies
  @cookies ||= lambda {
    r = RestClient.post(build_url("/session", include_user: false),
                        username: Config[:user], password: Config[:password])
    r.cookies
  }.call
end

#query_info(qname) ⇒ Object



27
28
29
# File 'lib/saiku_client.rb', line 27

def query_info(qname)
  ::JSON.parse get("/repository/#{qname}")
end

#repo_infoObject



23
24
25
# File 'lib/saiku_client.rb', line 23

def repo_info
  ::JSON.parse get("/repository")
end

#run_query(xml_string) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/saiku_client.rb', line 31

def run_query(xml_string)
  qname = rand(1000000).to_s

  post("/query/#{qname}", xml: xml_string)
  wait_for_query qname

  results = ::CSV.parse get("/query/#{qname}/export/csv")
  delete("/query/#{qname}")

  results
end

#wait_for_query(qname) ⇒ Object



43
44
45
46
47
48
49
# File 'lib/saiku_client.rb', line 43

def wait_for_query(qname)
  begin
    get("/query/#{qname}/result")
  rescue RestClient::RequestTimeout
    wait_for_query(qname)
  end
end