Skip to main content

A Python library at allows you to interface with the Smallstep API.

Project description

smallstep-python

smallstep-python is a Python library at allows you to interface with the Smallstep API.

We use openapi-python-client to generate a low level Python client that is located in smallstep/api_client/. See the smallstep/README.md for more information on using this generated library. We built a wrapper library on top of smallstep/api_client that is located in api.py. This adds a handful of helper features. At this time smallstep/api.py only supports a few API endpoints. See smallstep/api.py for details.

Requirements

  • Python 3.9
  • Smallstep Account
  • A very strong desire to allow a cute snake to manage your Smallstep account

Installation

We publish this package to https://pypi.org/project/smallstep-python/ and it can be installed via pip.

pip install smallstep-python

Development

Configuration

Create a .env file in the project root and add the following lines:

# Not needed unless you are using our run anywhere offering
# SMALLSTEP_API_HOST="https://gateway.smallstep.com/api"
SMALLSTEP_API_TOKEN="your_smallstep_api_token"

Adjust them to your needs. See config.py for configuration details. We use Pydantic Settings for easy settings management. Below is the order of precedence for configuration settings:

  1. Arguments passed to the Settings class initialiser.
  2. Environment variables, e.g. SMALLSTEP_MY_CONFIG_SETTING as described above.
  3. Variables loaded from a dotenv (.env) file.
  4. Variables loaded from the secrets directory.
  5. The default field values for the Settings model.

See the Pydantic Settings field value priority section for more information.

With Poetry

Install Poetry on your system with this.

Run this from the repo directory:

poetry install

Enter the Poetry shell with this:

poetry shell
pre-commit install

With venv

export VIRTUAL_ENV=${PWD}/.venv
python3 -m venv $VIRTUAL_ENV
export PATH="$VIRTUAL_ENV/bin:$PATH"
pip install wheel
pip install -r requirements.txt
. .venv/bin/activate
pre-commit install

Adding packages

Add packages to Poetry and then run pre-commit which will generate a requirements.txt file for you.

Development:

poetry add --group=dev rich
pre-commit

Production:

poetry add rich
pre-commit

License

Apache License Version 2.0

Copyright 2023 Smallstep Labs Inc.

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

smallstep_python-0.1.1.tar.gz (68.4 kB view hashes)

Uploaded Source

Built Distribution

smallstep_python-0.1.1-py3-none-any.whl (198.2 kB view hashes)

Uploaded Python 3

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