Add Ombi issues counter
This commit is contained in:
parent
1ee99481e4
commit
f950b3719f
5 changed files with 46 additions and 2 deletions
|
@ -3,7 +3,7 @@ from requests import Session, Request
|
|||
from datetime import datetime, timezone
|
||||
|
||||
from varken.helpers import connection_handler, hashit
|
||||
from varken.structures import OmbiRequestCounts, OmbiMovieRequest, OmbiTVRequest
|
||||
from varken.structures import OmbiRequestCounts, OmbiIssuesCounts, OmbiMovieRequest, OmbiTVRequest
|
||||
|
||||
|
||||
class OmbiAPI(object):
|
||||
|
@ -165,3 +165,31 @@ class OmbiAPI(object):
|
|||
]
|
||||
|
||||
self.dbmanager.write_points(influx_payload)
|
||||
|
||||
def get_issues_counts(self):
|
||||
now = datetime.now(timezone.utc).astimezone().isoformat()
|
||||
endpoint = '/api/v1/Issues/count'
|
||||
|
||||
req = self.session.prepare_request(Request('GET', self.server.url + endpoint))
|
||||
get = connection_handler(self.session, req, self.server.verify_ssl)
|
||||
|
||||
if not get:
|
||||
return
|
||||
|
||||
requests = OmbiIssuesCounts(**get)
|
||||
influx_payload = [
|
||||
{
|
||||
"measurement": "Ombi",
|
||||
"tags": {
|
||||
"type": "Issues_Counts"
|
||||
},
|
||||
"time": now,
|
||||
"fields": {
|
||||
"pending": requests.pending,
|
||||
"in_progress": requests.inProgress,
|
||||
"resolved": requests.resolved
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
self.dbmanager.write_points(influx_payload)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue