# Path: orionsdk/swisclient.py
# class SwisClient:
#     def __init__(self, hostname, username, password, verify=False, session=None):
#         self.url = "https://{}:17778/SolarWinds/InformationService/v3/Json/".\
#                 format(hostname)
#         self._session = session or requests.Session()
#         self._session.auth = (username, password)
#         self._session.headers.update({'Content-Type': 'application/json'})
#         self._session.verify = verify
# 
#     def query(self, query, **params):
#         return self._req(
#                 "POST",
#                 "Query",
#                 {'query': query, 'parameters': params}).json()
# 
#     def invoke(self, entity, verb, *args):
#         return self._req(
#                 "POST",
#                 "Invoke/{}/{}".format(entity, verb), args).json()
# 
#     def create(self, entity, **properties):
#         return self._req(
#                 "POST",
#                 "Create/" + entity, properties).json()
# 
#     def read(self, uri):
#         return self._req("GET", uri).json()
# 
#     def update(self, uri, **properties):
#         self._req("POST", uri, properties)
# 
#     def bulkupdate(self, uris, **properties):
#         self._req("POST", "BulkUpdate",
#             {'uris': uris, 'properties': properties})
# 
#     def delete(self, uri):
#         self._req("DELETE", uri)
# 
#     def bulkdelete(self, uris):
#         self._req("POST", "BulkDelete", {'uris': uris})
# 
#     def _req(self, method, frag, data=None):
#         resp = self._session.request(method, 
#                                      self.url + frag,
#                                      data=json.dumps(data, default=_json_serial))
# 
#         # try to extract reason from response when request returns error
#         if 400 <= resp.status_code < 600:
#             try:
#                 resp.reason = json.loads(resp.text)['Message']
#             except:
#                 pass
# 
#         resp.raise_for_status()
#         return resp


import logging
from .swisclient import SwisClient
# -*- coding: utf-8 -*-
"""SolarWinds Class Overview

The following class is used to create an object representing a SolarWinds Orion instance.  The object provides simple
getter and setter methods for common SolarWinds actions.  These methods abstract out the underlying details and SWQL
calls making SolarWinds automation more accessible to a broader audience.

"""



class SolarWinds:

    def __init__(self, npm_server, username, password, logger=None):

        self.logger = logger or logging.getLogger('__name__')

        # Create the SWIS client for use throughout the instance.

# Path: orionsdk/swisclient.py
# class SwisClient:
#     def __init__(self, hostname, username, password, verify=False, session=None):
#         self.url = "https://{}:17778/SolarWinds/InformationService/v3/Json/".\
#                 format(hostname)
#         self._session = session or requests.Session()
#         self._session.auth = (username, password)
#         self._session.headers.update({'Content-Type': 'application/json'})
#         self._session.verify = verify
# 
#     def query(self, query, **params):
#         return self._req(
#                 "POST",
#                 "Query",
#                 {'query': query, 'parameters': params}).json()
# 
#     def invoke(self, entity, verb, *args):
#         return self._req(
#                 "POST",
#                 "Invoke/{}/{}".format(entity, verb), args).json()
# 
#     def create(self, entity, **properties):
#         return self._req(
#                 "POST",
#                 "Create/" + entity, properties).json()
# 
#     def read(self, uri):
#         return self._req("GET", uri).json()
# 
#     def update(self, uri, **properties):
#         self._req("POST", uri, properties)
# 
#     def bulkupdate(self, uris, **properties):
#         self._req("POST", "BulkUpdate",
#             {'uris': uris, 'properties': properties})
# 
#     def delete(self, uri):
#         self._req("DELETE", uri)
# 
#     def bulkdelete(self, uris):
#         self._req("POST", "BulkDelete", {'uris': uris})
# 
#     def _req(self, method, frag, data=None):
#         resp = self._session.request(method, 
#                                      self.url + frag,
#                                      data=json.dumps(data, default=_json_serial))
# 
#         # try to extract reason from response when request returns error
#         if 400 <= resp.status_code < 600:
#             try:
#                 resp.reason = json.loads(resp.text)['Message']
#             except:
#                 pass
# 
#         resp.raise_for_status()
#         return resp


# Path: orionsdk/solarwinds.py
import logging
from .swisclient import SwisClient

# -*- coding: utf-8 -*-
"""SolarWinds Class Overview

The following class is used to create an object representing a SolarWinds Orion instance.  The object provides simple
getter and setter methods for common SolarWinds actions.  These methods abstract out the underlying details and SWQL
calls making SolarWinds automation more accessible to a broader audience.

"""



class SolarWinds:

    def __init__(self, npm_server, username, password, logger=None):

        self.logger = logger or logging.getLogger('__name__')

        # Create the SWIS client for use throughout the instance.

        self.swis = SwisClient(npm_server, username, password)