Convert Resource class to dataclass
This commit is contained in:
parent
b9163ccfe6
commit
f037ed5c24
@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
import dataclasses
|
||||
import logging
|
||||
import sys
|
||||
from urllib.parse import urljoin
|
||||
@ -11,10 +12,10 @@ import nagiosplugin
|
||||
_log = logging.getLogger("nagiosplugin")
|
||||
|
||||
|
||||
class Batteries(nagiosplugin.Resource):
|
||||
def __init__(self, url: str, token: str):
|
||||
self.url = url
|
||||
self.token = token
|
||||
@dataclasses.dataclass
|
||||
class Entities(nagiosplugin.Resource):
|
||||
url: str
|
||||
token: str
|
||||
|
||||
def hass_get(self, endpoint: str) -> requests.Response:
|
||||
headers = {
|
||||
@ -79,7 +80,7 @@ def main():
|
||||
args = argp.parse_args()
|
||||
|
||||
check = nagiosplugin.Check(
|
||||
Batteries(args.url, args.token),
|
||||
Entities(args.url, args.token),
|
||||
nagiosplugin.ScalarContext("battery", args.warning, args.critical),
|
||||
)
|
||||
check.main(args.verbose)
|
||||
|
Loading…
Reference in New Issue
Block a user