Module: Keen::Client::MaintenanceMethods

Included in:
Keen::Client
Defined in:
lib/keen/client/maintenance_methods.rb

Instance Method Summary collapse

Instance Method Details

#delete(event_collection, params = {}) ⇒ Object

Runs a delete query. See detailed documentation here: keen.io/docs/maintenance/#deleting-event-collections

Parameters:

  • event_collection
  • params (Hash) (defaults to: {})

    (optional) filters (optional) [Array]



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/keen/client/maintenance_methods.rb', line 12

def delete(event_collection, params={})
  ensure_project_id!
  ensure_master_key!

  query_params = preprocess_params(params) if params != {}

  begin
    response = http_sync.delete(
        :path => [api_event_collection_resource_path(event_collection), query_params].compact.join('?'),
        :headers => api_headers(self.master_key, "sync"))
  rescue Exception => http_error
    raise HttpError.new("Couldn't perform delete of #{event_collection} on Keen IO: #{http_error.message}", http_error)
  end

  response_body = response.body ? response.body.chomp : ''
  process_response(response.code, response_body)
end

#event_collection(event_collection) ⇒ Object

Return the named collection for the configured project See detailed documentation here: keen.io/docs/api/reference/#event-collection-resource



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/keen/client/maintenance_methods.rb', line 71

def event_collection(event_collection)
  ensure_project_id!
  ensure_master_key!

  begin
    response = http_sync.get(
        :path => "/#{api_version}/projects/#{project_id}/events/#{event_collection}",
        :headers => api_headers(self.master_key, "sync"))
  rescue Exception => http_error
    raise HttpError.new("Couldn't perform events on Keen IO: #{http_error.message}", http_error)
  end

  response_body = response.body ? response.body.chomp : ''
  process_response(response.code, response_body)
end

#event_collectionsObject

Return list of collections for the configured project See detailed documentation here: keen.io/docs/api/reference/#event-resource



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/keen/client/maintenance_methods.rb', line 33

def event_collections
  ensure_project_id!
  ensure_master_key!

  begin
    response = http_sync.get(
        :path => "/#{api_version}/projects/#{project_id}/events",
        :headers => api_headers(self.master_key, "sync"))
  rescue Exception => http_error
    raise HttpError.new("Couldn't perform events on Keen IO: #{http_error.message}", http_error)
  end

  response_body = response.body ? response.body.chomp : ''
  process_response(response.code, response_body)
end

#project_infoObject

Return details for the current project See detailed documentation here: keen.io/docs/api/reference/#project-resource



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/keen/client/maintenance_methods.rb', line 52

def project_info
  ensure_project_id!
  ensure_master_key!

  begin
    response = http_sync.get(
        :path => "/#{api_version}/projects/#{project_id}",
        :headers => api_headers(self.master_key, "sync"))
  rescue Exception => http_error
    raise HttpError.new("Couldn't perform project info on Keen IO: #{http_error.message}", http_error)
  end

  response_body = response.body ? response.body.chomp : ''
  process_response(response.code, response_body)
end