Skip to main content

Python SDK to access the Tenchi Security Zanshin API v1

Project description

PyPI version shields.io PyPI pyversions

Zanshin Python SDK

This Python package contains an SDK to interact with the API of the Zanshin SaaS service from Tenchi Security.

This SDK is used to implement a command-line utility, which is available on Github and on PyPI.

Configuration File

The way the SDK handles credentials is by using a configuration file in the format created by the Python RawConfigParser class.

The file is located at ~/.tenchi/config, where ~ is the current user’s home directory.

Each section is treated as a configuration profile, and the SDK will look for a section called default if another is not explicitly selected.

These are the supported options:

  • api_key (required) which contains the Zanshin API key obtained at the Zanshin web portal.

  • user_agent (optional) allows you to override the default user-agent header used by the SDK when making API requests.

  • api_url (optional) directs the SDK to use a different API endpoint than the default (https://api.zanshin.tenchisecurity.com).

This is what a minimal configuration file looks like:

[default]
api_key = abcdefghijklmnopqrstuvxyz

The SDK

The SDK uses Python 3 type hints extensively. It attempts to abstract API artifacts such as pagination by using Python generators, thus making the service easier to interact with.

The network connections are done using the wonderful httpx library.

Currently it focuses on returning the parsed JSON values instead of converting them into native classes for higher level abstractions.

The zanshinsdk.Client class is the main entry point of the SDK. Here is a quick example that shows information about the owner of the API key in use:

from zanshinsdk import Client
from json import dumps

client = Client()   # loads API key from the "default" profile in ~/.tenchi/config
me = client.get_me()    # calls /me API endpoint
print(dumps(me, indent=4))

All operations call raise_for_status on the httpx Response object internally, so any 4xx or 5xx will raise exceptions.

Support

If you are a Zanshin customer and have any questions regarding the use of the service, its API or this SDK package, please get in touch via e-mail at support {at} tenchisecurity {dot} com or via the support widget on the Zanshin Portal.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zanshinsdk-1.0.4.tar.gz (12.4 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page