Configuration Handling

Applications need some kind of configuration. There are different settings you might want to change depending on the application environment like toggling the debug mode, setting credentials etc.

The way hexonet.apiconnector is designed usually requires the configuration to be provided at runtime when connecting to the HEXONET Backend API. You can hardcode the configuration in the code, which for many small scripts is for sure sufficient. Realtime applications and frontends need to cover some application logic around using this SDK like a login form and session management.

Configuration Basics

The configuration can be provided in two ways. Using the APIClient:

Python SDK Demo App
#!/usr/bin/python

# Import the ispapi library
from hexonet.apiconnector.apiclient import APIClient as AC

# -------- SESSIONLESS COMMUNICATION -----------

# Create a connection using the APIClient class and the appropriate
# methods to configure the connection as necessary.
# Don't have a HEXONET Account yet? Get one here:
# - Live System Account: https://www.hexonet.net/sign-up
# - Test/OT&E System Account: https://www.hexonet.net/signup-ote

print("---- SESSIONLESS COMMUNICATION ----")
cl = AC()
cl.useOTESystem()
cl.setCredentials("test.user", "test.passw0rd")
# use the below method in case you have an active
# ip filter setting
cl.setRemoteIPAddress("1.2.3.4")

# Call a command
r = cl.request({"Command": "QueryDomainList", "limit": 5})

# Get the result in the format you want
rlist = r.getListHash()
rhash = r.getHash()
rplain = r.getPlain()

# or use API methods to access specific data
col = r.getColumn("DOMAIN")  # get column domain
if col:
    col.getData()  # get all data of column DOMAIN
r.getColumnKeys()  # get all column keys
r.getColumnIndex("DOMAIN", 0)  # get data for column DOMAIN at index 0
r.getColumns()  # get all columns
r.getRecord(0)  # row at index 0
r.getRecords()  # get all rows
# ... and some more

# Get the response code and the response description
code = r.getCode()
description = r.getDescription()
print(str(code) + " " + description)

# -------- SESSION-BASED COMMUNICATION -----------
print("---- SESSION-BASED COMMUNICATION ----")
cl = AC()
cl.useOTESystem()
cl.setCredentials("test.user", "test.passw0rd")
cl.setRemoteIPAddress("1.2.3.4")

# Call a command
r = cl.login()
# cl.login("12345678"); -> 2FA: one time password

if r.isSuccess():
    print("LOGIN SUCCEEDED!")
    r = cl.request({"Command": "QueryDomainList", "limit": 5})
    rplain = r.getPlain()
    code = r.getCode()
    description = r.getDescription()
    print(str(code) + " " + description)
    # ... further commands ...
    r = cl.logout()
    if r.isSuccess():
        print("LOGOUT SUCCEEDED!")

Environment and Debug Features

Debug Features are also available in our Python SDK:

# activate debug mode
cl.enableDebugMode()

# disable debug mode
cl.disableDebugMode()

HEXONET provides two different Backend Systems that you might consider to use. Both require a separate Registration: - Live System Registration and - OT&E System Registration.

OT&E System

OT&E Sytem stands for Operational Test & Evaluation System. No costs, just for playing around with things. This system can be seen as a kind of sandbox system that allows to test your integration first before going live with it. This system and the use of our products and services is completely free of charge. To use this system, use APIClient’s method cl.useOTESystem(). Otherwise Live System will be used by default.

LIVE System

The real world system - This system and the use our services and products can lead to real costs depending on what you’re exactly doing. Live System will be used by default, but you can also use APIClient’s method cl.useLIVESystem() to add it in source code for reference.

Builtin Configuration Values

The following configuration values are used internally by hexonet.apiconnector:

Up to now - none, but this might change in future as we are continously improving our SDKs.