Skip to content

Be more explicit with API endpoint #6

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
Jun 16, 2020
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
11 changes: 4 additions & 7 deletions netdata/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,18 @@
class Netdata(object):
"""A class for handling connections with a Netdata instance."""

def __init__(self, host, loop, session, port=19999, data=None):
def __init__(self, host, loop, session, port=19999):
"""Initialize the connection to the Netdata instance."""
self._loop = loop
self._session = session
self.host = host
self.port = port
self.values = self.alarms = self.metrics = None
self.base_url = _INSTANCE.format(host=host, port=port, api=API_VERSION)
if data is None:
self.endpoint = _ALL_METRIC_ENDPOINT
if data == "alarms":
self.endpoint = _ALARMS_ENDPOINT
if data == "data":
self.endpoint = _DATA_ENDPOINT

async def get_data(self, resource):
"""Get detail for a resource from the data endpoint."""
self.endpoint = _DATA_ENDPOINT
url = "{}{}".format(self.base_url, self.endpoint.format(resource=resource))

try:
Expand All @@ -56,6 +51,7 @@ async def get_data(self, resource):

async def get_alarms(self):
"""Get alarms for a Netdata instance."""
self.endpoint = _ALARMS_ENDPOINT
url = "{}{}".format(self.base_url, self.endpoint)

try:
Expand All @@ -73,6 +69,7 @@ async def get_alarms(self):

async def get_allmetrics(self):
"""Get all available metrics from a Netdata instance."""
self.endpoint = _ALL_METRIC_ENDPOINT
url = "{}{}".format(self.base_url, self.endpoint)

try:
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy