# Path: credentials.py
# VMWARE_VCENTER_USERNAME = "domain\\username"
# VMWARE_VCENTER_PASSWORD = "yourpassword"
# SNMP_COMMUNITY = "public"
# TINTRI_USER = "youraccount"
# TINTRI_PASSWORD = "yourpassword"
# WORKDESK_USER = 'youraccount'
# WORKDESK_PASSWORD = 'yourpassword'
# RUBRIK_USER = 'youraccount'
# RUBRIK_PASSWORD = 'yourpassword'
# NUTANIX_USER = 'youraccount'
# NUTANIX_PASSWORD = 'yourpassword'
# 
# Path: credentials.py
# VMWARE_VCENTER_USERNAME = "domain\\username"
# VMWARE_VCENTER_PASSWORD = "yourpassword"
# SNMP_COMMUNITY = "public"
# TINTRI_USER = "youraccount"
# TINTRI_PASSWORD = "yourpassword"
# WORKDESK_USER = 'youraccount'
# WORKDESK_PASSWORD = 'yourpassword'
# RUBRIK_USER = 'youraccount'
# RUBRIK_PASSWORD = 'yourpassword'
# NUTANIX_USER = 'youraccount'
# NUTANIX_PASSWORD = 'yourpassword'


import json
import time
import logging.config
import base64
import requests
from credentials import NETAPP_USER  # Login info now stored in credentials.py
from credentials import NETAPP_PASSWORD  # Login info now stored in credentials.py
    def __init__(self):
        self.json = ""
        self.session = None
        self.data = NetAppData()
        base64string = base64.encodebytes(
            ('%s:%s' % (NETAPP_USER, NETAPP_PASSWORD)).encode()
        ).decode().replace('\n', '')

        self.headers = {
            'authorization': "Basic %s" % base64string,
            'content-type': "application/json",
            'accept': "application/json"
        }


class NetAppRequestException(Exception):
    pass


def generate_json(netapp_monitor):
    """This function will connect to the NetApp RESTAPI, parse data and store the output in netapp_monitor.json"""

    logger = logging.getLogger("netapp")

    # Check if there is a working session and create a new one if it is not working
    if netapp_monitor.session is None:
        logger.debug("No existing REST API session, creating a new one.")
        # Create Session object that will allow us to issue commands without having to login each time
        netapp_monitor.session = requests.Session()
        netapp_monitor.session.headers.update({'content-type': 'application/json'})

# Path: credentials.py
# VMWARE_VCENTER_USERNAME = "domain\\username"
# VMWARE_VCENTER_PASSWORD = "yourpassword"
# SNMP_COMMUNITY = "public"
# TINTRI_USER = "youraccount"
# TINTRI_PASSWORD = "yourpassword"
# WORKDESK_USER = 'youraccount'
# WORKDESK_PASSWORD = 'yourpassword'
# RUBRIK_USER = 'youraccount'
# RUBRIK_PASSWORD = 'yourpassword'
# NUTANIX_USER = 'youraccount'
# NUTANIX_PASSWORD = 'yourpassword'
# 
# Path: credentials.py
# VMWARE_VCENTER_USERNAME = "domain\\username"
# VMWARE_VCENTER_PASSWORD = "yourpassword"
# SNMP_COMMUNITY = "public"
# TINTRI_USER = "youraccount"
# TINTRI_PASSWORD = "yourpassword"
# WORKDESK_USER = 'youraccount'
# WORKDESK_PASSWORD = 'yourpassword'
# RUBRIK_USER = 'youraccount'
# RUBRIK_PASSWORD = 'yourpassword'
# NUTANIX_USER = 'youraccount'
# NUTANIX_PASSWORD = 'yourpassword'


# Path: netapp.py
import json
import time
import logging.config
import base64
import requests
from credentials import NETAPP_USER  # Login info now stored in credentials.py
from credentials import NETAPP_PASSWORD  # Login info now stored in credentials.py

    def __init__(self):
        self.json = ""
        self.session = None
        self.data = NetAppData()
        base64string = base64.encodebytes(
            ('%s:%s' % (NETAPP_USER, NETAPP_PASSWORD)).encode()
        ).decode().replace('\n', '')

        self.headers = {
            'authorization': "Basic %s" % base64string,
            'content-type': "application/json",
            'accept': "application/json"
        }


class NetAppRequestException(Exception):
    pass


def generate_json(netapp_monitor):
    """This function will connect to the NetApp RESTAPI, parse data and store the output in netapp_monitor.json"""

    logger = logging.getLogger("netapp")

    # Check if there is a working session and create a new one if it is not working
    if netapp_monitor.session is None:
        logger.debug("No existing REST API session, creating a new one.")
        # Create Session object that will allow us to issue commands without having to login each time
        netapp_monitor.session = requests.Session()
        netapp_monitor.session.headers.update({'content-type': 'application/json'})

        netapp_monitor.session.auth = (NETAPP_USER, NETAPP_PASSWORD)