# Path: credentials.py
# TINTRI_USER = "youraccount"
# 
# Path: credentials.py
# TINTRI_PASSWORD = "yourpassword"


import json
import time
import requests
import logging.config
from credentials import TINTRI_USER         # Login info now stored in credentials.py
from credentials import TINTRI_PASSWORD     # Login info now stored in credentials.py

class TintriNotConnectedException(Exception):
    pass


class MonitorJSON:
    """This is a simple class passed to Monitor threads so we can access the current JSON data in that thread"""
    def __init__(self):
        self.json = ""
        self.session = None
        self.data = TintriData()


def output_message(message):
    """This function will output an error message formatted in JSON to display on the StatusBoard app"""
    output = json.dumps({"error": message}, indent=4)
    return output


def generate_json(tintri_monitor):
    """This function will connect to the VNX web server, parse data and store the output in vnx_monitor.json"""
    logger = logging.getLogger("tintri")

    try:

        login_payload = {
            "typeId": "com.tintri.api.rest.vcommon.dto.rbac.RestApiCredentials",
            "newPassword": None,
            "roles": None,
            "username": TINTRI_USER,

# Path: credentials.py
# TINTRI_USER = "youraccount"
# 
# Path: credentials.py
# TINTRI_PASSWORD = "yourpassword"


# Path: tintri.py
import json
import time
import requests
import logging.config
from credentials import TINTRI_USER         # Login info now stored in credentials.py
from credentials import TINTRI_PASSWORD     # Login info now stored in credentials.py


class TintriNotConnectedException(Exception):
    pass


class MonitorJSON:
    """This is a simple class passed to Monitor threads so we can access the current JSON data in that thread"""
    def __init__(self):
        self.json = ""
        self.session = None
        self.data = TintriData()


def output_message(message):
    """This function will output an error message formatted in JSON to display on the StatusBoard app"""
    output = json.dumps({"error": message}, indent=4)
    return output


def generate_json(tintri_monitor):
    """This function will connect to the VNX web server, parse data and store the output in vnx_monitor.json"""
    logger = logging.getLogger("tintri")

    try:

        login_payload = {
            "typeId": "com.tintri.api.rest.vcommon.dto.rbac.RestApiCredentials",
            "newPassword": None,
            "roles": None,
            "username": TINTRI_USER,

            "password": TINTRI_PASSWORD