Class: CloudflareClient::Zone::Log

Inherits:
Base show all
Defined in:
lib/cloudflare_client/zone/log.rb

Constant Summary

Constants inherited from CloudflareClient::Zone

VALID_ZONE_STATUSES

Constants inherited from CloudflareClient

API_BASE, POSSIBLE_API_SETTINGS, VALID_BUNDLE_METHODS, VALID_DIRECTIONS, VALID_MATCHES, VERSION

Instance Attribute Summary

Attributes inherited from Base

#zone_id

Instance Method Summary collapse

Methods inherited from Base

#initialize

Methods inherited from CloudflareClient::Zone

#create_zone, #delete_zone, #edit_zone, #initialize, #purge_zone_cache, #update_zone_settings, #zone, #zone_activation_check, #zone_setting, #zone_settings, #zones

Methods inherited from CloudflareClient

#initialize

Constructor Details

This class inherits a constructor from CloudflareClient::Zone::Base

Instance Method Details

#list_by_time(start_time:, end_time: nil, count: nil) ⇒ Object

get logs using only timestamps



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/cloudflare_client/zone/log.rb', line 9

def list_by_time(start_time:, end_time: nil, count: nil)
  id_check(:start_time, start_time)
  timestamp_check(:start_time, start_time)

  params = {start: start_time}

  unless end_time.nil?
    timestamp_check(:end_time, end_time)
    params[:end] = end_time
  end

  params[:count] = count unless count.nil?

  cf_get(path: "/zones/#{zone_id}/logs/requests", params: params, extra_headers: {'Accept-encoding': 'gzip'})
end

#list_since(ray_id:, end_time: nil, count: nil) ⇒ Object

get all logs after a given ray_id. end_time must be a valid unix timestamp



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/cloudflare_client/zone/log.rb', line 35

def list_since(ray_id:, end_time: nil, count: nil)
  params = {start_id: ray_id}

  unless end_time.nil?
    timestamp_check(:end_time, end_time)
    params[:end] = end_time
  end

  params[:count] = count unless count.nil?

  cf_get(
    path: "/zones/#{zone_id}/logs/requests/#{ray_id}",
    params: params,
    extra_headers: {'Accept-encoding': 'gzip'}
  )
end

#show(ray_id:) ⇒ Object

get a single log entry by it's ray_id



27
28
29
30
31
# File 'lib/cloudflare_client/zone/log.rb', line 27

def show(ray_id:)
  id_check(:ray_id, ray_id)

  cf_get(path: "/zones/#{zone_id}/logs/requests/#{ray_id}")
end