pihole6api 0.1.3__py3-none-any.whl → 0.1.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
pihole6api/conn.py CHANGED
@@ -3,6 +3,7 @@ import urllib3
3
3
  from urllib.parse import urljoin
4
4
  import warnings
5
5
  import time
6
+ import json
6
7
 
7
8
  # Suppress InsecureRequestWarning
8
9
  urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
pihole6api/ftl_info.py CHANGED
@@ -62,14 +62,30 @@ class PiHole6FtlInfo:
62
62
  """Retrieve Pi-hole version details."""
63
63
  return self.connection.get("info/version")
64
64
 
65
- def get_dnsmasq_logs(self):
66
- """Retrieve DNS log content."""
67
- return self.connection.get("logs/dnsmasq")
65
+ def get_dnsmasq_logs(self, next_id=None):
66
+ """
67
+ Retrieve DNS log content from the embedded DNS resolver (dnsmasq).
68
+
69
+ :param next_id: Optional ID to fetch only new log lines since the last request.
70
+ """
71
+ params = {"nextID": next_id} if next_id is not None else {}
72
+ return self.connection.get("logs/dnsmasq", params=params)
73
+
68
74
 
69
- def get_ftl_logs(self):
70
- """Retrieve FTL log content."""
71
- return self.connection.get("logs/ftl")
75
+ def get_ftl_logs(self, next_id=None):
76
+ """
77
+ Retrieve FTL log content.
78
+
79
+ :param next_id: Optional ID to fetch only new log lines since the last request.
80
+ """
81
+ params = {"nextID": next_id} if next_id is not None else {}
82
+ return self.connection.get("logs/ftl", params=params)
72
83
 
73
- def get_webserver_logs(self):
74
- """Retrieve webserver log content."""
75
- return self.connection.get("logs/webserver")
84
+ def get_webserver_logs(self, next_id=None):
85
+ """
86
+ Retrieve webserver log content.
87
+
88
+ :param next_id: Optional ID to fetch only new log lines since the last request.
89
+ """
90
+ params = {"nextID": next_id} if next_id is not None else {}
91
+ return self.connection.get("logs/webserver", params=params)
@@ -52,7 +52,7 @@ class PiHole6ListManagement:
52
52
  """
53
53
  encoded_address = urllib.parse.quote(address, safe="")
54
54
  params = {"type": list_type}
55
- return self.connection.get(f"lists/{encoded_address}")
55
+ return self.connection.get(f"lists/{encoded_address}", params=params)
56
56
 
57
57
  def update_list(self, address, list_type=None, comment=None, groups=None, enabled=True):
58
58
  """
@@ -85,10 +85,21 @@ class PiHole6ListManagement:
85
85
  params = {"type": list_type}
86
86
  return self.connection.delete(f"lists/{encoded_address}", params=params)
87
87
 
88
- def search_list(self, domain):
88
+ def search_list(self, domain, num=None, partial=False, debug=False):
89
89
  """
90
90
  Search for a domain in Pi-hole's lists.
91
91
 
92
92
  :param domain: Domain to search for.
93
+ :param num: Maximum number of results to be returned (optional).
94
+ :param partial: Boolean flag to enable partial matching (optional).
95
+ :param debug: Boolean flag to add debug information to the response (optional).
93
96
  """
94
- return self.connection.get(f"search/{domain}")
97
+ params = {
98
+ "partial": str(partial).lower(),
99
+ "debug": str(debug).lower(),
100
+ }
101
+ if num is not None:
102
+ params["n"] = num
103
+
104
+ return self.connection.get(f"search/{domain}", params=params)
105
+
@@ -3,9 +3,20 @@ class PiHole6NetworkInfo:
3
3
  """Handles Pi-hole network information API endpoints."""
4
4
  self.connection = connection
5
5
 
6
- def get_devices(self):
7
- """Get information about devices on the local network."""
8
- return self.connection.get("network/devices")
6
+ def get_devices(self, max_devices=None, max_addresses=None):
7
+ """
8
+ Get information about devices on the local network.
9
+
10
+ :param max_devices: Optional maximum number of devices to show.
11
+ :param max_addresses: Optional maximum number of addresses to show.
12
+ """
13
+ params = {}
14
+ if max_devices is not None:
15
+ params["max_devices"] = max_devices
16
+ if max_addresses is not None:
17
+ params["max_addresses"] = max_addresses
18
+
19
+ return self.connection.get("network/devices", params=params)
9
20
 
10
21
  def delete_device(self, device_id):
11
22
  """
@@ -15,14 +26,26 @@ class PiHole6NetworkInfo:
15
26
  """
16
27
  return self.connection.delete(f"network/devices/{device_id}")
17
28
 
18
- def get_gateway(self):
19
- """Get information about the gateway of the Pi-hole."""
20
- return self.connection.get("network/gateway")
29
+ def get_gateway(self, detailed=False):
30
+ """
31
+ Get information about the gateway of the Pi-hole.
21
32
 
22
- def get_interfaces(self):
23
- """Get information about network interfaces of the Pi-hole."""
24
- return self.connection.get("network/interfaces")
33
+ :param detailed: Boolean flag to request detailed interface/routing information (default: False).
34
+ """
35
+ return self.connection.get("network/gateway", params={"detailed": detailed})
25
36
 
26
- def get_routes(self):
27
- """Get information about network routes of the Pi-hole."""
28
- return self.connection.get("network/routes")
37
+ def get_interfaces(self, detailed=False):
38
+ """
39
+ Get information about network interfaces of the Pi-hole.
40
+
41
+ :param detailed: Boolean flag to request detailed interface/routing information (default: False).
42
+ """
43
+ return self.connection.get("network/interfaces", params={"detailed": detailed})
44
+
45
+ def get_routes(self, detailed=False):
46
+ """
47
+ Get information about network routes of the Pi-hole.
48
+
49
+ :param detailed: Boolean flag to request detailed interface/routing information (default: False).
50
+ """
51
+ return self.connection.get("network/routes", params={"detailed": detailed})
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: pihole6api
3
- Version: 0.1.3
3
+ Version: 0.1.4
4
4
  Summary: Python API Client for Pi-hole 6
5
5
  Author-email: Shane Barbetta <shane@barbetta.me>
6
6
  License: MIT
@@ -30,7 +30,7 @@ This package provides a simple, modular SDK for the PiHole 6 REST API.
30
30
  ## Features
31
31
 
32
32
  * Automatically handles authentication and renewal
33
- * Gracefully error management
33
+ * Graceful error management
34
34
  * Logically organized modules
35
35
  * Easily maintained
36
36
 
@@ -130,7 +130,6 @@ client.actions.restart_dns()
130
130
  | `dhcp` | Manage DHCP leases |
131
131
  | `network_info` | View network devices, interfaces, routes |
132
132
  | `actions` | Flush logs, restart services |
133
- | `padd` | Fetch summarized data for PADD |
134
133
 
135
134
  ## License
136
135
 
@@ -3,17 +3,17 @@ pihole6api/actions.py,sha256=8CBkr8nYfT8yfdCO6F9M9nompaYcFdsaYGiEa1eVDCw,693
3
3
  pihole6api/client.py,sha256=HYdRh3CSZJ0srbkpjIVnLo-iy1avqKDUne5ji2Aq394,2013
4
4
  pihole6api/client_management.py,sha256=opPYGrjuW6SiwuxuvoOxnqjpmflU2znKHsqFbGSS3Gg,2439
5
5
  pihole6api/config.py,sha256=NdBHOudz147oIs5YVR3U4WLvqk3hU3HlZHnshy1NK4g,4680
6
- pihole6api/conn.py,sha256=qqC-PO6a2RR_dluhSeu_RMeo6TpA8_Xlg5CA2FTwG7Y,5825
6
+ pihole6api/conn.py,sha256=60Q9paDCD6Bwmdg_G9mOUr86Hzj9G-dhMwL7F3NvLB8,5837
7
7
  pihole6api/dhcp.py,sha256=1A3z-3q9x51-6MOC3JMl7yR_5pHmRxZtMWtPqzWxYm0,629
8
8
  pihole6api/dns_control.py,sha256=mxV3AIuGCsx0-1ibpMXor9QUGd_fDFfeaUENPhIK_TY,853
9
9
  pihole6api/domain_management.py,sha256=vxhQSG5F8EFDGqtiNkF0H_KOWFMerXaAuJZT0nMa8ec,3492
10
- pihole6api/ftl_info.py,sha256=e9W9vwkF8nHzjVlHpIMe-55qhhQngMj0swMlp2QNvPg,2540
10
+ pihole6api/ftl_info.py,sha256=FINHFotI1sQgkL0OPaNqW-rk4h1ua6QHnRh5gFXXRIE,3210
11
11
  pihole6api/group_management.py,sha256=MGHwegw-b9U9PIA-IBzqT-a1kYkpXyjfSXJJJjkyTxc,2225
12
- pihole6api/list_management.py,sha256=B98FdgsIZhfRJHRxtRmwWsRPJ4rGlhvN-9gFEGdbb-c,3396
12
+ pihole6api/list_management.py,sha256=52cCe3lEAvHYkyBOYdxkOn7C2I39fBUNsMpNC_rGiCI,3876
13
13
  pihole6api/metrics.py,sha256=czNyx9tUf2yZi_HnUpqykrtW51c042Rxq3zFl2_GjLY,7379
14
- pihole6api/network_info.py,sha256=u5NIteFoI-yav05eE6v81-9gs3MeZVBlNCSBS5gzCT8,1006
15
- pihole6api-0.1.3.dist-info/LICENSE,sha256=hpO6J6J9O1VZxZeHQTxKMTmuobaHbApiZxp279I4xNU,1062
16
- pihole6api-0.1.3.dist-info/METADATA,sha256=JMgYTLowrNI52DPCEaVpBIqiD4NHBX9av86qJLQ8-wg,3837
17
- pihole6api-0.1.3.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
18
- pihole6api-0.1.3.dist-info/top_level.txt,sha256=Qrh46lxEC54rBR8T53em-tuZLWbmi1SDwL1rOhsgrME,11
19
- pihole6api-0.1.3.dist-info/RECORD,,
14
+ pihole6api/network_info.py,sha256=E1qQ7DsCb7qplt0oQIyKhUY12ExNF6bv6thm9rbNqwY,1953
15
+ pihole6api-0.1.4.dist-info/LICENSE,sha256=hpO6J6J9O1VZxZeHQTxKMTmuobaHbApiZxp279I4xNU,1062
16
+ pihole6api-0.1.4.dist-info/METADATA,sha256=F7_jh48dzzmrzazbdrvsBhh4_zdN6BhDhJasq7KH1lM,3778
17
+ pihole6api-0.1.4.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
18
+ pihole6api-0.1.4.dist-info/top_level.txt,sha256=Qrh46lxEC54rBR8T53em-tuZLWbmi1SDwL1rOhsgrME,11
19
+ pihole6api-0.1.4.dist-info/RECORD,,