Class: CloudflareClient::Zone::Analytics

Inherits:
Base show all
Defined in:
lib/cloudflare_client/zone/analytics.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, #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

#colo_dashboard(since_ts: nil, until_ts: nil) ⇒ Object

creturn analytics for colos for a time window. since and untill must be RFC 3339 timestamps TODO: support continuous



15
16
17
18
19
20
# File 'lib/cloudflare_client/zone/analytics.rb', line 15

def colo_dashboard(since_ts: nil, until_ts: nil)
  raise 'since_ts must be a valid timestamp' if since_ts.nil? || !date_rfc3339?(since_ts)
  raise 'until_ts must be a valid timestamp' if until_ts.nil? || !date_rfc3339?(until_ts)

  cf_get(path: "/zones/#{zone_id}/analytics/dashboard")
end

#dns_by_time(dimensions: [], metrics: [], sort: [], filters: [], since_ts: nil, until_ts: nil, limit: 100, time_delta: 'hour') ⇒ Object

return analytics by time



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/cloudflare_client/zone/analytics.rb', line 33

def dns_by_time(dimensions: [],
                metrics: [],
                sort: [],
                filters: [],
                since_ts: nil,
                until_ts: nil,
                limit: 100,
                time_delta: 'hour')
  # TODO: what are valid dimensions?
  # TODO: what are valid metrics?
  unless since_ts.nil?
    raise 'since_ts must be a valid timestamp' unless date_rfc3339?(since_ts)
  end
  unless until_ts.nil?
    raise 'until_ts must be a valid timestamp' unless date_rfc3339?(until_ts)
  end

  params          = {limit: limit, time_delta: time_delta}
  params['since'] = since_ts
  params['until'] = until_ts

  cf_get(path: "/zones/#{zone_id}/dns_analytics/report/bytime", params: params)
end

#dns_tableObject

return a table of analytics



27
28
29
# File 'lib/cloudflare_client/zone/analytics.rb', line 27

def dns_table
  cf_get(path: "/zones/#{zone_id}/dns_analytics/report")
end

#zone_dashboardObject

return dashboard data for a given zone or colo



7
8
9
# File 'lib/cloudflare_client/zone/analytics.rb', line 7

def zone_dashboard
  cf_get(path: "/zones/#{zone_id}/analytics/dashboard")
end