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 = Keen::HTTP::Sync.new(self.api_url).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