Skip to main content

Turbine GraphQL Python SDK (generated via ariadne-codegen)

Project description

Turbine Python SDK

Minimal, sync-first Python client for the Turbine GraphQL API.

Getting Started

Installation from PyPI

Install from PyPI as netrise-turbine-sdk:

# pip
pip install netrise-turbine-sdk

# poetry
poetry add netrise-turbine-sdk

# uv
uv add netrise-turbine-sdk

Configure environment variables

The SDK automatically loads environment variables from a .env file in your current working directory when you call TurbineClientConfig.from_env(). You can also set environment variables directly.

Option 1: Using a .env file (recommended)

Create a .env file in your project directory:

endpoint=https://apollo.turbine.netrise.io/graphql/v3
audience=https://prod.turbine.netrise.io/
domain=https://authn.turbine.netrise.io
client_id=<client_id>
client_secret=<client_secret>
organization_id=<org_id>

The SDK will automatically load these when you call TurbineClientConfig.from_env(). The .env file is searched in:

  • Current working directory (most common)
  • Parent directories (walks up the directory tree)

Option 2: Set environment variables directly

import os
os.environ["endpoint"] = "https://apollo.turbine.netrise.io/graphql/v3"
# ... set other variables

cfg = TurbineClientConfig.from_env(load_env_file=False)

Option 3: Disable automatic .env loading

If you prefer to load .env files manually:

from dotenv import load_dotenv
load_dotenv()  # Your custom loading logic

cfg = TurbineClientConfig.from_env(load_env_file=False)

Populate the missing values. Reach out to mailto:support@netrise.io if you need assistance.

Union Field Aliasing Convention

When GraphQL union types have members with identically-named fields that return different types, the SDK automatically applies aliases to disambiguate them. This is necessary because code generators cannot create a single Python type for fields with conflicting return types.

Naming Convention

Aliased fields follow the pattern: {camelCaseTypeName}{PascalCaseFieldName}

For example, the NotificationControl union has AssetAnalysisControl and UserManagementControl types that both define an events field with different return types. In the generated SDK, these become:

  • AssetAnalysisControl.eventsassetAnalysisControlEvents
  • UserManagementControl.eventsuserManagementControlEvents

Example Usage

# Accessing aliased fields on union type members
notification_settings = client.query_notification_settings()

for pref in notification_settings.preferences:
    for control in pref.controls:
        # Access the aliased field based on the control type
        if hasattr(control, 'assetAnalysisControlEvents'):
            events = control.assetAnalysisControlEvents
        elif hasattr(control, 'userManagementControlEvents'):
            events = control.userManagementControlEvents

This aliasing is applied automatically during SDK generation and only affects fields that would otherwise cause type conflicts.

Reducing response size (Lite / Summary queries)

The default query_* and iter_* methods request every scalar and nested object the server exposes. That is convenient for exploration but can be expensive: for a large asset sweep the full query_assets_relay payload includes full analytic, risk, filesystems, exploit rollups, and asset-group metadata per node. When you only need enough data to decide "should I fetch deeper?" the SDK ships trimmed counterparts that typically cut the response body by ~70–80%:

Full paginator Lite variant Summary variant
iter_assets_relay iter_assets_relay_lite iter_assets_relay_summary
iter_vulnerabilities iter_vulnerabilities_lite
iter_dependencies iter_dependencies_lite
iter_misconfigurations iter_misconfigurations_lite
iter_detailed_vulnerabilities iter_detailed_vulnerabilities_lite
query_vulnerability query_vulnerability_lite

The Lite variants keep the fields most callers use (top-level identifiers, severity, CVSS score, rollup counts) and drop deeply-nested objects like exploit.references, correlations, currentRemediation, full CVSS v2 / v3 / v4 blocks, and component digests. The Summary variant of the assets query is even thinner and returns only id, name, and analytic.{vulnerability,misconfigurations,components}.

When to pick which

  1. Full (iter_assets_relay, etc.) — you need every field for audit / export / BI use cases and bandwidth is not a concern.
  2. Lite (iter_*_lite) — you want a table-friendly view plus a couple of CVSS / EPSS scalars. Good default for UIs and CSV exports.
  3. Summary (iter_assets_relay_summary) — you are performing an org-wide sweep to decide which assets to drill into. Combine with a follow-up iter_vulnerabilities/iter_misconfigurations/iter_dependencies call gated on non-zero counts in analytic to avoid the N+1 fanout described in the SDK FAQ.

Example: surgical sweep

from netrise_turbine_sdk import TurbineClient, TurbineClientConfig

sdk = TurbineClient(TurbineClientConfig.from_env())

for asset in sdk.iter_assets_relay_summary(page_size=100):
    counts = asset.analytic
    if counts.vulnerability.critical + counts.vulnerability.high > 0:
        for vuln in sdk.iter_vulnerabilities_lite(asset_id=asset.id):
            print(asset.name, vuln.cve, vuln.severity, vuln.cvss_score)
    if counts.misconfigurations.failed > 0:
        for m in sdk.iter_misconfigurations_lite(asset_id=asset.id):
            print(asset.name, m.check_id, m.severity, m.result)

With the asset sweep payload trimmed to ~3 fields per node and iter_vulnerabilities_lite dropping CVSS v2/v4 plus exploit / correlation blocks, scenario A from the customer write-up (100 assets × 60 vulns) moves from ~601 full-weight calls to ~601 Lite calls at roughly 20–30% of the original wire bytes.

License

See LICENSE for details.

Documentation

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

netrise_turbine_sdk-0.1.15.tar.gz (99.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

netrise_turbine_sdk-0.1.15-py3-none-any.whl (152.3 kB view details)

Uploaded Python 3

File details

Details for the file netrise_turbine_sdk-0.1.15.tar.gz.

File metadata

  • Download URL: netrise_turbine_sdk-0.1.15.tar.gz
  • Upload date:
  • Size: 99.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for netrise_turbine_sdk-0.1.15.tar.gz
Algorithm Hash digest
SHA256 bf1bef0aa415bf8f8d951a8a2cf38bd0eef4f30c8289b1a3fdd6697380db4ba6
MD5 b6ae95a1755aeaed346aa10d2705fef0
BLAKE2b-256 06f0d807e1baa62ab6d74aa6896420e88c86abbfcb9209bae289295be2a7d413

See more details on using hashes here.

File details

Details for the file netrise_turbine_sdk-0.1.15-py3-none-any.whl.

File metadata

File hashes

Hashes for netrise_turbine_sdk-0.1.15-py3-none-any.whl
Algorithm Hash digest
SHA256 c7dd1ee0cb7398ad31f829fc7e28826cd007c1d754f7f83a4519f681063c7405
MD5 1bf1731e70012564cccf6709f78a4b50
BLAKE2b-256 f24208beec15bac7629b1b4495bc49c56f85a0e84a4696610817adb0eb1cc559

See more details on using hashes here.

Supported by

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