zanshin-sdk-python


Namezanshin-sdk-python JSON
Version 1.6.2 PyPI version JSON
download
home_pagehttps://github.com/tenchi-security/zanshin-sdk-python
SummaryPython SDK to access the Tenchi Security Zanshin API v1
upload_time2024-04-23 17:55:32
maintainerNone
docs_urlNone
authorTenchi Security
requires_python<4.0,>=3.8
licenseApache Software License
keywords
VCS
bugtrack_url
requirements annotated-types anyio boto3 botocore certifi exceptiongroup h11 httpcore httpx idna jmespath pydantic-core pydantic python-dateutil s3transfer six sniffio typing-extensions urllib3 urllib3
Travis-CI No Travis.
coveralls test coverage
            ![ Coverage badge ](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/wiki/tenchi-security/zanshin-sdk-python/python-coverage-comment-action-badge.json)
[![PyPI version shields.io](https://img.shields.io/pypi/v/zanshinsdk.svg)](https://pypi.python.org/pypi/zanshinsdk/) [![PyPI pyversions](https://img.shields.io/pypi/pyversions/zanshinsdk.svg)](https://pypi.python.org/pypi/zanshinsdk/)

# Zanshin Python SDK

This Python package contains an SDK to interact with the [API of the Zanshin SaaS service](https://api.zanshin.tenchisecurity.com) from [Tenchi Security](https://www.tenchisecurity.com).

This SDK is used to implement a command-line utility, which is available on [Github](https://github.com/tenchi-security/zanshin-cli) and on [PyPI](https://pypi.python.org/pypi/zanshincli/).

## Setting up Credentials

There are three ways that the SDK handles credentials. The order of evaluation is:
- [**1st** Client Parameters](#client-parameters)
- [**2nd** Environment Variables](#environment-variables)
- [**3rd** Config File](#config-file)

### Client Parameters

When calling the `Client` class, you can pass the values API Key, API URL, Proxy URL and User Agent you want to use as below:

```python
from zanshinsdk import Client

client = Client(api_key="my_zanshin_api_key")

print(client.get_me())
```

> :warning: These values will overwrite anything you set as Environment Variables or in the Config File.

### Environment Variables

You can use the following Environment Variables to configure Zanshin SDK:
- `ZANSHIN_API_KEY`: Will setup your Zanshin credentials
- `ZANSHIN_API_URL`: Will define the API URL. Default is `https://api.zanshin.tenchisecurity.com`
- `ZANSHIN_USER_AGENT`: If you want to overwrite the User Agent when calling Zanshin API
- `HTTP_PROXY | HTTPS_PROXY`: Zanshin SDK uses HTTPX under the hood, checkout the [Environment Variables](https://www.python-httpx.org/environment_variables/#proxies) section of their documentation for more use cases

#### Usage

```shell
export ZANSHIN_API_KEY="eyJhbGciOiJIU..."
```

> :warning: These Environment Variables will overwrite anything you set on the Config File.

### Config File
Second is by using a configuration file in the format created by the Python [RawConfigParser](https://docs.python.org/3/library/configparser.html#configparser.RawConfigParser) class.

The file is located at `~/.tenchi/config`, where `~` is the [current user's home directory](https://docs.python.org/3/library/pathlib.html#pathlib.Path.home).

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](https://zanshin.tenchisecurity.com/my-profile).
* `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:
```ini
[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](https://www.python-httpx.org/) 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:

```python
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))
```

For more examples, checkout the [docs](zanshinsdk/docs/README.md).

All operations call `raise_for_status` on the httpx [Response object](https://www.python-httpx.org/api/#response) internally, so any 4xx or 5xx will raise [exceptions](https://www.python-httpx.org/exceptions/).

## Installing

To install the SDK, you can use `pip`. You have two options to install ZanshinSDK:
- *Essentials*

Using `pip install zanshinsdk` will install the SDK with all features exception ability to perform onboarding of new Scan Targets. For this, you'll need to install boto3.

- *With Boto3*

With `pip install zanshinsdk[with_boto3]` you'll automatically install [boto3](https://boto3.amazonaws.com/v1/documentation/api/latest/index.html) along with ZanshinSDK. This will enable you to perform Onboard of new Scan Targets via SDK.

## Testing

To run all tests call `make test` on the project root directory. Make sure there's a `[default]` profile configured, else some tests will fail.
Also, be sure to install `boto3` and `moto[all]` or some integration tests will fail.

# 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](https://zanshin.tenchisecurity.com).

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/tenchi-security/zanshin-sdk-python",
    "name": "zanshin-sdk-python",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": "Tenchi Security",
    "author_email": "contact@tenchisecurity.com",
    "download_url": "https://files.pythonhosted.org/packages/f3/4d/0898ac5ed98b6f0c3e0ea6846cd888b9080313c21cf2e8de4688da9f546a/zanshin_sdk_python-1.6.2.tar.gz",
    "platform": null,
    "description": "![ Coverage badge ](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/wiki/tenchi-security/zanshin-sdk-python/python-coverage-comment-action-badge.json)\n[![PyPI version shields.io](https://img.shields.io/pypi/v/zanshinsdk.svg)](https://pypi.python.org/pypi/zanshinsdk/) [![PyPI pyversions](https://img.shields.io/pypi/pyversions/zanshinsdk.svg)](https://pypi.python.org/pypi/zanshinsdk/)\n\n# Zanshin Python SDK\n\nThis Python package contains an SDK to interact with the [API of the Zanshin SaaS service](https://api.zanshin.tenchisecurity.com) from [Tenchi Security](https://www.tenchisecurity.com).\n\nThis SDK is used to implement a command-line utility, which is available on [Github](https://github.com/tenchi-security/zanshin-cli) and on [PyPI](https://pypi.python.org/pypi/zanshincli/).\n\n## Setting up Credentials\n\nThere are three ways that the SDK handles credentials. The order of evaluation is:\n- [**1st** Client Parameters](#client-parameters)\n- [**2nd** Environment Variables](#environment-variables)\n- [**3rd** Config File](#config-file)\n\n### Client Parameters\n\nWhen calling the `Client` class, you can pass the values API Key, API URL, Proxy URL and User Agent you want to use as below:\n\n```python\nfrom zanshinsdk import Client\n\nclient = Client(api_key=\"my_zanshin_api_key\")\n\nprint(client.get_me())\n```\n\n> :warning: These values will overwrite anything you set as Environment Variables or in the Config File.\n\n### Environment Variables\n\nYou can use the following Environment Variables to configure Zanshin SDK:\n- `ZANSHIN_API_KEY`: Will setup your Zanshin credentials\n- `ZANSHIN_API_URL`: Will define the API URL. Default is `https://api.zanshin.tenchisecurity.com`\n- `ZANSHIN_USER_AGENT`: If you want to overwrite the User Agent when calling Zanshin API\n- `HTTP_PROXY | HTTPS_PROXY`: Zanshin SDK uses HTTPX under the hood, checkout the [Environment Variables](https://www.python-httpx.org/environment_variables/#proxies) section of their documentation for more use cases\n\n#### Usage\n\n```shell\nexport ZANSHIN_API_KEY=\"eyJhbGciOiJIU...\"\n```\n\n> :warning: These Environment Variables will overwrite anything you set on the Config File.\n\n### Config File\nSecond is by using a configuration file in the format created by the Python [RawConfigParser](https://docs.python.org/3/library/configparser.html#configparser.RawConfigParser) class.\n\nThe file is located at `~/.tenchi/config`, where `~` is the [current user's home directory](https://docs.python.org/3/library/pathlib.html#pathlib.Path.home).\n\nEach section is treated as a configuration profile, and the SDK will look for a section called `default` if another is not explicitly selected.\n\nThese are the supported options:\n\n* `api_key` (required) which contains the Zanshin API key obtained at the [Zanshin web portal](https://zanshin.tenchisecurity.com/my-profile).\n* `user_agent` (optional) allows you to override the default user-agent header used by the SDK when making API requests.\n* `api_url` (optional) directs the SDK to use a different API endpoint than the default (https://api.zanshin.tenchisecurity.com).\n\nThis is what a minimal configuration file looks like:\n```ini\n[default]\napi_key = abcdefghijklmnopqrstuvxyz\n```\n\n## The SDK\n\nThe 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.\n\nThe network connections are done using the wonderful [httpx](https://www.python-httpx.org/) library.\n\nCurrently it focuses on returning the parsed JSON values instead of converting them into native classes for higher level abstractions.\n\nThe `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:\n\n```python\nfrom zanshinsdk import Client\nfrom json import dumps\n\nclient = Client()   # loads API key from the \"default\" profile in ~/.tenchi/config\nme = client.get_me()    # calls /me API endpoint\nprint(dumps(me, indent=4))\n```\n\nFor more examples, checkout the [docs](zanshinsdk/docs/README.md).\n\nAll operations call `raise_for_status` on the httpx [Response object](https://www.python-httpx.org/api/#response) internally, so any 4xx or 5xx will raise [exceptions](https://www.python-httpx.org/exceptions/).\n\n## Installing\n\nTo install the SDK, you can use `pip`. You have two options to install ZanshinSDK:\n- *Essentials*\n\nUsing `pip install zanshinsdk` will install the SDK with all features exception ability to perform onboarding of new Scan Targets. For this, you'll need to install boto3.\n\n- *With Boto3*\n\nWith `pip install zanshinsdk[with_boto3]` you'll automatically install [boto3](https://boto3.amazonaws.com/v1/documentation/api/latest/index.html) along with ZanshinSDK. This will enable you to perform Onboard of new Scan Targets via SDK.\n\n## Testing\n\nTo run all tests call `make test` on the project root directory. Make sure there's a `[default]` profile configured, else some tests will fail.\nAlso, be sure to install `boto3` and `moto[all]` or some integration tests will fail.\n\n# Support\n\nIf 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](https://zanshin.tenchisecurity.com).\n",
    "bugtrack_url": null,
    "license": "Apache Software License",
    "summary": "Python SDK to access the Tenchi Security Zanshin API v1",
    "version": "1.6.2",
    "project_urls": {
        "Homepage": "https://github.com/tenchi-security/zanshin-sdk-python"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "de9c203b02a7053be65484fb957e84dbeb3c32749b34358973f500690d09bcf3",
                "md5": "d6eaaa92bb0a257bf13524da13d0732e",
                "sha256": "d662ff6b30548220f09420ae884a9b631f104e123e562106791b6b0a5da0a75a"
            },
            "downloads": -1,
            "filename": "zanshin_sdk_python-1.6.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d6eaaa92bb0a257bf13524da13d0732e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.8",
            "size": 40463,
            "upload_time": "2024-04-23T17:55:30",
            "upload_time_iso_8601": "2024-04-23T17:55:30.502513Z",
            "url": "https://files.pythonhosted.org/packages/de/9c/203b02a7053be65484fb957e84dbeb3c32749b34358973f500690d09bcf3/zanshin_sdk_python-1.6.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f34d0898ac5ed98b6f0c3e0ea6846cd888b9080313c21cf2e8de4688da9f546a",
                "md5": "a7e171d16fe4bc695ce10be4043b3c98",
                "sha256": "1a6065e484e4509f6983938ba47cd60b575c4427d457738a2d8894bd817f3390"
            },
            "downloads": -1,
            "filename": "zanshin_sdk_python-1.6.2.tar.gz",
            "has_sig": false,
            "md5_digest": "a7e171d16fe4bc695ce10be4043b3c98",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.8",
            "size": 37730,
            "upload_time": "2024-04-23T17:55:32",
            "upload_time_iso_8601": "2024-04-23T17:55:32.242153Z",
            "url": "https://files.pythonhosted.org/packages/f3/4d/0898ac5ed98b6f0c3e0ea6846cd888b9080313c21cf2e8de4688da9f546a/zanshin_sdk_python-1.6.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-23 17:55:32",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "tenchi-security",
    "github_project": "zanshin-sdk-python",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "requirements": [
        {
            "name": "annotated-types",
            "specs": [
                [
                    "==",
                    "0.6.0"
                ]
            ]
        },
        {
            "name": "anyio",
            "specs": [
                [
                    "==",
                    "4.3.0"
                ]
            ]
        },
        {
            "name": "boto3",
            "specs": [
                [
                    "==",
                    "1.34.89"
                ]
            ]
        },
        {
            "name": "botocore",
            "specs": [
                [
                    "==",
                    "1.34.89"
                ]
            ]
        },
        {
            "name": "certifi",
            "specs": [
                [
                    "==",
                    "2024.2.2"
                ]
            ]
        },
        {
            "name": "exceptiongroup",
            "specs": [
                [
                    "==",
                    "1.2.1"
                ]
            ]
        },
        {
            "name": "h11",
            "specs": [
                [
                    "==",
                    "0.14.0"
                ]
            ]
        },
        {
            "name": "httpcore",
            "specs": [
                [
                    "==",
                    "1.0.5"
                ]
            ]
        },
        {
            "name": "httpx",
            "specs": [
                [
                    "==",
                    "0.27.0"
                ]
            ]
        },
        {
            "name": "idna",
            "specs": [
                [
                    "==",
                    "3.7"
                ]
            ]
        },
        {
            "name": "jmespath",
            "specs": [
                [
                    "==",
                    "1.0.1"
                ]
            ]
        },
        {
            "name": "pydantic-core",
            "specs": [
                [
                    "==",
                    "2.18.2"
                ]
            ]
        },
        {
            "name": "pydantic",
            "specs": [
                [
                    "==",
                    "2.7.1"
                ]
            ]
        },
        {
            "name": "python-dateutil",
            "specs": [
                [
                    "==",
                    "2.9.0.post0"
                ]
            ]
        },
        {
            "name": "s3transfer",
            "specs": [
                [
                    "==",
                    "0.10.1"
                ]
            ]
        },
        {
            "name": "six",
            "specs": [
                [
                    "==",
                    "1.16.0"
                ]
            ]
        },
        {
            "name": "sniffio",
            "specs": [
                [
                    "==",
                    "1.3.1"
                ]
            ]
        },
        {
            "name": "typing-extensions",
            "specs": [
                [
                    "==",
                    "4.11.0"
                ]
            ]
        },
        {
            "name": "urllib3",
            "specs": [
                [
                    "==",
                    "1.26.18"
                ]
            ]
        },
        {
            "name": "urllib3",
            "specs": [
                [
                    "==",
                    "2.2.1"
                ]
            ]
        }
    ],
    "lcname": "zanshin-sdk-python"
}
        
Elapsed time: 0.23162s