Skip to main content

Stax Python SDK

Project description

Stax SDK for Python

staxapp is the Stax Software Development Kit (SDK) for Python, allowing users to interact with the Stax platform.

codecov build deploy PyPI - Python Version

Authentication

In order to use the Stax SDK for Python, you will need a valid Stax API Token.

Installation

Install the package using pip:

pip install staxapp

Configure environment variables:

export STAX_REGION=au1.staxapp.cloud
export STAX_ACCESS_KEY=<your_access_key>
export STAX_SECRET_KEY=<your_secret_key>
Client Auth Configuration

The Stax SDK can configure each client individually by passing in a config on init. When a client is created its configuration will be locked in and any change to the configurations will not affect the client.

This can be seen in our guide.

Optional configuration:

Token expiry

The Stax SDK can be configured to refresh the API Token prior to expiry. Suggested use when running within CI/CD tools to reduce overall auth calls

from staxapp.config import Config, StaxAuthRetryConfig

auth_retry_config = StaxAuthRetryConfig
auth_retry_config.token_expiry_threshold = 2
Config.api_auth_retry_config = auth_retry_config

(Deprecated): This value can also be set via the following Environment Var TOKEN_EXPIRY_THRESHOLD_IN_MINS

export TOKEN_EXPIRY_THRESHOLD_IN_MINS=2 # Type: Integer representing minutes
Retries

The Stax SDK has configured safe defaults for Auth and API retries. This behaviour can be adjusted via the SDK config: example.

from staxapp.config import Config, StaxAPIRetryConfig, StaxAuthRetryConfig

retry_config = StaxAPIRetryConfig
retry_config.retry_methods = ('GET', 'POST', 'PUT', 'DELETE', 'OPTIONS')
retry_config.status_codes = (429, 500, 502, 504)
retry_config.backoff_factor = 1.2
retry_config.max_attempts = 3
Config.api_retry_config = retry_config

auth_retry_config = StaxAuthRetryConfig
auth_retry_config.max_attempts = 3
Config.api_auth_retry_config = auth_retry_config
Logging levels

As the logging levels are set on the import of the Config module, the below configuration is available on the presense of following environment variables:

  • LOG_LEVEL: Default logger level

Value of environment variables should match Python - Logging Levels

Example: Changing the logging from INFO to DEBUG

export LOG_LEVEL=DEBUG
python run_example.py

Usage

Read Accounts

The following code can be used to read accounts within your Stax Organisation:

import json
import os

from staxapp.config import Config
from staxapp.openapi import StaxClient

Config.access_key = os.getenv("STAX_ACCESS_KEY")
Config.secret_key = os.getenv("STAX_SECRET_KEY")

# Read all accounts within your Stax Organisation
accounts = StaxClient("accounts")
response = accounts.ReadAccounts()
print(json.dumps(response, indent=4, sort_keys=True))

# Read all active accounts within your Stax Organisation and include tags in the response
accounts = StaxClient("accounts")
response = accounts.ReadAccounts(filter="ACTIVE", include_tags=True)
print(json.dumps(response, indent=4, sort_keys=True))

Contributing

For more information on contributing the to the Stax SDK, please see our guide.

Getting Help

  • If you're having trouble using the Stax SDK, please refer to our documentation.
  • If you've encountered an issue or found a bug, please open an issue.
  • For any other requests, please contact Stax support.

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

staxapp-1.4.0.tar.gz (69.9 kB view details)

Uploaded Source

Built Distribution

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

staxapp-1.4.0-py3-none-any.whl (63.2 kB view details)

Uploaded Python 3

File details

Details for the file staxapp-1.4.0.tar.gz.

File metadata

  • Download URL: staxapp-1.4.0.tar.gz
  • Upload date:
  • Size: 69.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for staxapp-1.4.0.tar.gz
Algorithm Hash digest
SHA256 f368b73cdf30439f65c57302ab6924682a3867ebd5111877774af3461edaa7ac
MD5 d166edc08b117df24abbc53d5a7796e7
BLAKE2b-256 40870a050d82f23f8ac90cb6534d7a9cf4491de81a38e38bbdc82b795779acb8

See more details on using hashes here.

File details

Details for the file staxapp-1.4.0-py3-none-any.whl.

File metadata

  • Download URL: staxapp-1.4.0-py3-none-any.whl
  • Upload date:
  • Size: 63.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for staxapp-1.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8349a00d7b4d014da783f1125e56bec1c8480f36e0a0b451104f169ce086a539
MD5 e12ac4c1a4650f8d893c266bd79637ea
BLAKE2b-256 13ebaa0f5804fe5e77ff063d70b5af75dc233c58c32a5b7133b237153ca76225

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