Skip to main content

Cortex Xpanse Python SDK

Overview

This library is intended to be an interface to the Cortex Xpanse Public API.

Install

pip install xpanse

Requirements

Python 3.7+

Usage

Cortex Xpanse Public API Documentation

# Import client
from xpanse.client import XpanseClient

# Initialize client
client = XpanseClient()

# Get assets iterator object and dump to a list
assets = client.assets.list().dump()

You can view more example code in the examples directory.

Configuration

A valid API Key, API Key ID, and Fully Qualified Domain Name (FQDN) are required for use.

Reference the docs for more information with Getting Started.

RECOMMENDED


You can supply them as environment variables.

export CORTEX_FQDN=<Your Xpanse Instance URL>
export CORTEX_API_KEY=<API Key>
export CORTEX_API_KEY_ID=<API Key ID>

NOT RECOMMENDED


The following parameters can be set inline using the XpanseClient constructor.

This is not recommended, as it easily exposes sensitive credentials in your source code.

# Import client
from xpanse.client import XpanseClient

# Initialize client - THIS IS NOT RECOMMENDED, SET ENVIRONMENT VARIABLES INSTEAD
client = XpanseClient(url="https://my-company.crtx.us.paloaltonetworks.com",
                      api_key="xxxxxxxxxxxxxxxApiKeyxxxxxxxxxxxxxxx",
                      api_key_id=1)

Logging

Logging is handled through the python logging package. To enable different levels of verbosity in your scripts you can do the following:

import logging

# Set the logging level
logging.basicConfig(level=logging.DEBUG)

You can read more at https://docs.python.org/3/library/logging.html.

Release files for xpanse 2.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for xpanse 2.1.0
File Size Uploaded
xpanse-2.1.0.tar.gz 45.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for xpanse 2.1.0
File Interpreter ABI Platform
xpanse-2.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 106.2 kB

Release files / xpanse-2.1.0.tar.gz

Download URL xpanse-2.1.0.tar.gz
Size 45.1 kB
Tags Source
SHA-256 checksum
How to use checksums
18915f075dfab1d8d976dbadbfadb27b5c07c5ba56ee62418674a744ff44dd2d
BLAKE2b-256 checksum
How to use checksums
53c56227ea1c994edca97100d279ff053aa41f6aa2928605b2c0073957003788
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.17

Release files / xpanse-2.1.0-py3-none-any.whl

Download URL xpanse-2.1.0-py3-none-any.whl
Size 61.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5cafd2f18da2ca48251c22c48b0a4c2a669827e0c728bf282c20b3bde4350ad9
BLAKE2b-256 checksum
How to use checksums
aa6b1679da4728725a461d9786b2e6f3d25b2936c3b0861ff9a0de720c1bb296
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.17
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page