# 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 re
import requests
from orionsdk import SwisClient
from __future__ import print_function

def main():
    npm_server = 'localhost'
    username = 'admin'
    password = ''
    target_node_ip = '1.2.3.4'
    snmpv3_credential_id = 3
    orion_engine_id = 1

    swis = SwisClient(npm_server, username, password)
    print("Add an SNMP v3 node:")

    corePluginContext = {
    	'BulkList': [{'Address': target_node_ip}],
    	'Credentials': [
    		{
    			'CredentialID': snmpv3_credential_id,
    			'Order': 1
    		}
    	],
    	'WmiRetriesCount': 0,

# 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: samples/discover_one_node.py
import re
import requests
from orionsdk import SwisClient

from __future__ import print_function

def main():
    npm_server = 'localhost'
    username = 'admin'
    password = ''
    target_node_ip = '1.2.3.4'
    snmpv3_credential_id = 3
    orion_engine_id = 1

    swis = SwisClient(npm_server, username, password)
    print("Add an SNMP v3 node:")

    corePluginContext = {
    	'BulkList': [{'Address': target_node_ip}],
    	'Credentials': [
    		{
    			'CredentialID': snmpv3_credential_id,
    			'Order': 1
    		}
    	],
    	'WmiRetriesCount': 0,

    	'WmiRetryIntervalMiliseconds': 1000