Module: PiholeApi::AuthorisedEndpoints

Included in:
Client
Defined in:
lib/pihole-api/authorised_endpoints.rb

Instance Method Summary collapse

Instance Method Details

#disableObject



77
78
79
80
# File 'lib/pihole-api/authorised_endpoints.rb', line 77

def disable
  command = 'disable'
  authorise_and_send(http_method: :get, command: command)
end

#enableObject



72
73
74
75
# File 'lib/pihole-api/authorised_endpoints.rb', line 72

def enable
  command = 'enable'
  authorise_and_send(http_method: :get, command: command)
end

#get_all_queries(params: {}, from_time: nil, until_time: nil, latest_number_of_items: nil) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/pihole-api/authorised_endpoints.rb', line 46

def get_all_queries(params: {}, from_time: nil, until_time: nil, latest_number_of_items: nil)
  # API version 3:
  # First column: Timestamp of query
  # Second column: Type of query (IPv4 or IPv6)
  # Third column: Requested domain name
  # Fourth column: Requesting client
  # Fifth column: Answer type (1 = blocked by gravity.list, 2 = forwarded to upstream server, 3 = answered by local cache, 4 = blocked by wildcard blocking)

  if latest_number_of_items
    command = "getAllQueries=#{latest_number_of_items}"
  else
    command = 'getAllQueries'
  end

  if from_time
    command = "#{command}&from=#{from_time.to_i}&until=#{until_time.to_i}"
  end

  authorise_and_send(http_method: :get, command: command, params: params)
end

#get_forward_destinationsObject



36
37
38
39
# File 'lib/pihole-api/authorised_endpoints.rb', line 36

def get_forward_destinations
  command = 'getForwardDestinations'
  authorise_and_send(http_method: :get, command: command)
end

#get_query_sources(number_of_items = 10) ⇒ Object



26
27
28
29
# File 'lib/pihole-api/authorised_endpoints.rb', line 26

def get_query_sources(number_of_items=10)
  command = "getQuerySources=#{number_of_items}"
  authorise_and_send(http_method: :get, command: command)
end

#get_query_typesObject



41
42
43
44
# File 'lib/pihole-api/authorised_endpoints.rb', line 41

def get_query_types
  command = 'getQueryTypes'
  authorise_and_send(http_method: :get, command: command)
end

#over_time_data_10_minsObject



16
17
18
19
# File 'lib/pihole-api/authorised_endpoints.rb', line 16

def over_time_data_10_mins
  command = 'overTimeData10mins'
  authorise_and_send(http_method: :get, command: command)
end

#recent_blockedObject



67
68
69
70
# File 'lib/pihole-api/authorised_endpoints.rb', line 67

def recent_blocked
  command = 'recentBlocked'
  authorise_and_send(http_method: :get, command: command)
end

#summary(params: {}) ⇒ Object



11
12
13
14
# File 'lib/pihole-api/authorised_endpoints.rb', line 11

def summary(params: {})
  command = 'summary'
  authorise_and_send(http_method: :get, command: command, params: params)
end

#summary_rawObject

These endpoints need to be authorised discourse.pi-hole.net/t/pi-hole-api/1863



6
7
8
9
# File 'lib/pihole-api/authorised_endpoints.rb', line 6

def summary_raw
  command = "summaryRaw&auth=#{password}"
  authorise_and_send(http_method: :get, command: command)
end

#top_clients(number_of_items = 10) ⇒ Object



31
32
33
34
# File 'lib/pihole-api/authorised_endpoints.rb', line 31

def top_clients(number_of_items=10)
  command = "topClients=#{number_of_items}"
  authorise_and_send(http_method: :get, command: command)
end

#top_items(number_of_items = 10) ⇒ Object



21
22
23
24
# File 'lib/pihole-api/authorised_endpoints.rb', line 21

def top_items(number_of_items=10)
  command = "topItems=#{number_of_items}"
  authorise_and_send(http_method: :get, command: command)
end