From 47feadcce8a2b9fc8662d8b0d001a08fc30fb916 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Tue, 16 Jun 2020 12:15:28 +0200 Subject: [PATCH 1/2] Allow custom path --- netdata/__init__.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/netdata/__init__.py b/netdata/__init__.py index 4b3087a..e8a3e96 100644 --- a/netdata/__init__.py +++ b/netdata/__init__.py @@ -5,11 +5,11 @@ import aiohttp import async_timeout +from yarl import URL from . import exceptions _LOGGER = logging.getLogger(__name__) -_INSTANCE = "http://{host}:{port}/api/v{api}/" _DATA_ENDPOINT = "data?chart={resource}&before=0&after=-1&options=seconds" _ALARMS_ENDPOINT = "alarms?all&format=json" _ALL_METRIC_ENDPOINT = ( @@ -22,14 +22,18 @@ class Netdata(object): """A class for handling connections with a Netdata instance.""" - def __init__(self, host, loop, session, port=19999): + def __init__(self, host, loop, session, port=19999, path=None): """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 path is None: + self.base_url = URL.build(scheme="http", host=host, port=port, path=f"/api/v{API_VERSION}/") + else: + self.base_url = URL.build(scheme="http", host=host, port=port, path=path) + async def get_data(self, resource): """Get detail for a resource from the data endpoint.""" From a33b21430b652fdeac5fb237a058a7e91727fe39 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Tue, 16 Jun 2020 12:19:23 +0200 Subject: [PATCH 2/2] Prepare for 0.2.0 --- setup.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index 7b10c37..c16810f 100644 --- a/setup.py +++ b/setup.py @@ -20,11 +20,11 @@ setup( name='netdata', - version='0.1.2', + version='0.2.0', description='Python API for interacting with Netdata.', long_description=long_description, - url='https://github.com/fabaff/python-netdata', - download_url='https://github.com/fabaff/python-netdata/releases', + url='https://github.com/home-assistant-ecosystem/python-netdata', + download_url='https://github.com/home-assistant-ecosystem/python-netdata/releases', author='Fabian Affolter', author_email='fabian@affolter-engineering.ch', license='MIT', @@ -39,7 +39,7 @@ 'Operating System :: MacOS :: MacOS X', 'Operating System :: Microsoft :: Windows', 'Operating System :: POSIX', - 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.8', 'Topic :: Utilities', ], ) 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