7. V-Stream API Examples

7.1. Authentication

7.1.1. LOGIN

To authenticate with the HAWK V-Stream Interface, you must follow the normal process for authenticating to the API.

#!/usr/bin/env python

import requests
import json
import datetime
import time
import hashlib

from hawkAPI.lib.core.hawkcore import hawkcore
from hawkAPI.lib.core.hawkapi import hawkapi
from hawkAPI.lib.core.hawklib import hawklib


url = "https://10.14.0.13:8080/API/1.1/"
username = "admin"
password = "password"

hawk = hawkcore(url)
hawk.logfile("/var/log/hawk/hawk-test-api.log")
hawk.SSLVerify(False)

try:
        hawk.logit("info", "Logging into API")
        hawk.login(username, password)
except Exception, e:
        hawk.logit("critical", 'Unable to login to API, how can we continue?')
        sys.exit(-1)


api = hawkapi(hawk)

This will properly authenticate you with the API and allow for further communications.