1: <?php
2:
3: namespace Cloudflare\Zone;
4:
5: use Cloudflare\Api;
6: use Cloudflare\Zone;
7:
8: /**
9: * CloudFlare API wrapper
10: *
11: * Analytics
12: * CloudFlare Analytics
13: *
14: * @author James Bell <[email protected]>
15: *
16: * @version 1
17: */
18: class Analytics extends Api
19: {
20: /**
21: * Default permissions level
22: *
23: * @var array
24: */
25: protected $permission_level = ['read' => '#analytics:read', 'edit' => '#analytics:edit'];
26:
27: /**
28: * Dashboard (permission needed: #analytics:read)
29: * The dashboard view provides both totals and timeseries data for the given zone and time period across the entire CloudFlare network.
30: *
31: * @param string $zone_identifier
32: * @param string|int|null $since The (inclusive) beginning of the requested time frame. This value can be a negative integer representing the number of minutes in the past relative to time the request is made,
33: * or can be an absolute timestamp that conforms to RFC 3339. At this point in time, it cannot exceed a time in the past greater than one year.
34: * @param string|int|null $until The (exclusive) end of the requested time frame. This value can be a negative integer representing the number of minutes in the past relative to time the request is made,
35: * or can be an absolute timestamp that conforms to RFC 3339. If omitted, the time of the request is used.
36: * @param bool $continuous When set to true, the range returned by the response acts like a sliding window to provide a contiguous time-window.
37: * Analytics data is processed and aggregated asynchronously and can sometimes lead to recent data points being incomplete if this value is set to false.
38: * If a start date provided is earlier than a date for which data is available, the API will return 0's for those dates until the first available date with data
39: */
40: public function dashboard($zone_identifier, $since = null, $until = null, $continuous = null)
41: {
42: $data = [
43: 'since' => $since,
44: 'until' => $until,
45: 'continuous' => $continuous,
46: ];
47:
48: return $this->get('zones/'.$zone_identifier.'/analytics/dashboard', $data);
49: }
50:
51: /**
52: * Analytics by Co-locations (permission needed: #analytics:read)
53: * This view provides a breakdown of analytics data by datacenter. Note: This is available to Enterprise customers only.
54: *
55: * @param string $zone_identifier
56: * @param string|int|null $since The (inclusive) beginning of the requested time frame. This value can be a negative integer representing the number of minutes in the past relative to time the request is made,
57: * or can be an absolute timestamp that conforms to RFC 3339. At this point in time, it cannot exceed a time in the past greater than one year.
58: * @param string|int|null $until The (exclusive) end of the requested time frame. This value can be a negative integer representing the number of minutes in the past relative to time the request is made,
59: * or can be an absolute timestamp that conforms to RFC 3339. If omitted, the time of the request is used.
60: * @param bool $continuous When set to true, the range returned by the response acts like a sliding window to provide a contiguous time-window.
61: * Analytics data is processed and aggregated asynchronously and can sometimes lead to recent data points being incomplete if this value is set to false.
62: * If a start date provided is earlier than a date for which data is available, the API will return 0's for those dates until the first available date with data
63: */
64: public function colos($zone_identifier, $since = null, $until = null, $continuous = null)
65: {
66: $data = [
67: 'since' => $since,
68: 'until' => $until,
69: 'continuous' => $continuous,
70: ];
71:
72: return $this->get('zones/'.$zone_identifier.'/analytics/colos', $data);
73: }
74: }
75: