Skip to content

Add delete_io_data and expose io_client #98

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 21 additions & 7 deletions adafruit_portalbase/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
__version__ = "0.0.0+auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_PortalBase.git"

# pylint: disable=line-too-long, too-many-lines
# pylint: disable=line-too-long, too-many-lines, too-many-public-methods
# you'll need to pass in an io username and key
TIME_SERVICE = (
"https://io.adafruit.com/api/v2/%s/integrations/time/strftime?x-aio-key=%s"
Expand Down Expand Up @@ -493,8 +493,6 @@ def get_io_feed(self, feed_key, detailed=False):
except RuntimeError as exception:
print("An error occured, retrying! 1 -", exception)
continue
break
return None

def get_io_group(self, group_key):
"""Return the Adafruit IO Group that matches the group key
Expand All @@ -510,8 +508,6 @@ def get_io_group(self, group_key):
except RuntimeError as exception:
print("An error occured, retrying! 1 -", exception)
continue
break
return None

def get_io_data(self, feed_key):
"""Return all values from Adafruit IO Feed Data that matches the feed key
Expand All @@ -527,8 +523,21 @@ def get_io_data(self, feed_key):
except RuntimeError as exception:
print("An error occured, retrying! 1 -", exception)
continue
break
return None

def delete_io_data(self, feed_key: str, data_id: str):
"""Return all values from Adafruit IO Feed Data that matches the feed key

:param str feed_key: Name of feed key to receive data from.

"""
io_client = self._get_io_client()

while True:
try:
return io_client.delete_data(feed_key, data_id)
except RuntimeError as exception:
print("An error occured, retrying! 1 -", exception)
continue

def fetch(self, url, *, headers=None, timeout=10):
"""Fetch data from the specified url and return a response object
Expand Down Expand Up @@ -740,3 +749,8 @@ def process_json(self, json_data, json_path):
def is_connected(self):
"""Return whether we are connected."""
return self._wifi.is_connected

@property
def io_client(self):
"""Return the Adafruit IO Client."""
return self._get_io_client()