conn

Functions

agol

Initialize and return an ArcGIS Online GIS connection using credentials.

hart

Initialize and return a HART API connection tuple (URL, HTTPBasicAuth).

hbsmr

Initialize and return a HBSMR API connection response.

msal

Initialize and return an EmailMsal connection object.

token

Initialize and return an ArcGIS GIS connection using a token.

vault

Initialize and return a VaultCipher instance for encryption/decryption.

agol(url, user, password, debug=False)

Initialize and return an ArcGIS Online GIS connection using credentials.

Parameters:
  • url (str) – The target AGOL URL.

  • user (str) – The AGOL username.

  • password (str) – The user password.

  • debug (bool) – If True, prints connection status. Defaults to False.

Caution

SECURITY WARNING: This method currently disables SSL certificate verification (verify_cert=False) by default. This makes the connection vulnerable to Man-in-the-Middle (MitM) attacks. Please ensure you are connecting over a trusted network or manually provide a certificate bundle in your own implementation if higher security is required.

from ntsm.conn import agol
gis = agol(url="https://nt.maps.arcgis.com", user="username", password="password", debug=True)
Return type:

Any

Returns:

An authenticated AGOL GIS object if successful, otherwise None.

hart(url, user, password, debug=False)

Initialize and return a HART API connection tuple (URL, HTTPBasicAuth).

Parameters:
  • url (str) – The base HART API URL.

  • user (str) – The user username.

  • password (str) – The user password.

  • debug (bool) – If True, prints connection status. Defaults to False.

from ntsm.conn import hart
import requests
url, auth = hart(url="API_URL", user="user", password="pwd")
response = requests.get(url, auth=auth)
Return type:

Any

Returns:

Tuple of (api_url, auth_object) if successful, otherwise None.

hbsmr(url, user, password, debug=False)

Initialize and return a HBSMR API connection response.

Parameters:
  • url (str) – The HBSMR API endpoint.

  • user (str) – The user username.

  • password (str) – The user password.

  • debug (bool) – If True, prints connection status. Defaults to False.

from ntsm.conn import hbsmr
resp = hbsmr(url="API_URL", user="user", password="pwd")
if resp:
    data = resp.json()
Return type:

Any

Returns:

The response object from the HBSMR API if successful, otherwise None.

msal(tenant_id, client_id, client_email, client_secret, debug=False)

Initialize and return an EmailMsal connection object.

Parameters:
  • tenant_id (str) – Azure AD Tenant ID.

  • client_id (str) – Azure AD Client ID.

  • client_email (str) – The mailbox used to send email.

  • client_secret (str) – The client secret.

  • debug (bool) – If True, prints connection status. Defaults to False.

from ntsm.conn import msal
mail = msal(tenant_id="...", client_id="...", client_email="...", client_secret="...")
mail.send(to="test@example.com", subject="Hello", body="Test")
Return type:

Any

Returns:

An authenticated EmailMsal instance if successful, otherwise None.

token(token, debug=False)

Initialize and return an ArcGIS GIS connection using a token.

Parameters:
  • token (str) – The ArcGIS authentication token.

  • debug (bool) – If True, prints connection status. Defaults to False.

from ntsm.conn import token
gis = token(token="YOUR_ARCGIS_TOKEN", debug=True)
Return type:

Any

Returns:

An authenticated GIS object if successful, otherwise None.

vault(key_file=None, key_env=None)

Initialize and return a VaultCipher instance for encryption/decryption.

Sets up a secure vault using either a physical master key file or an environment variable.

Parameters:
  • key_file (str) – Absolute path to the master key file.

  • key_env (str) – Name of the environment variable containing the key.

from ntsm.conn import vault
# via environment variable
v = vault(key_env="GIS_KEY")
# OR via local file
v = vault(key_file="C:/keys/prod.key")
Return type:

Any

Returns:

An instance of VaultCipher.