Skip to main content

nextlayer-sdk-python

Client utilities to interact with next layer public APIs.

Configuration

The module will use a YAML Config file to read it's configuration and also writes to it, to store obtained Tokens and their expiry (similar like kubctl does with kubeconfig).

Example ~/.nextlayer-sdk/auth.nlcustomers.yml:

server_url: https://login.nextlayer.at/auth/
realm_name: nlcustomers
client_id: nextlayer-sdk-python
username: foobar
password: topsecret

extra_params:
  audience: nextlayer-sdk-python

Except for username, all settings are optional, but if no password is supplied in config, the password will be asked interactively (if STDIN is a TTY) !

Alternatively the username can be suppled in the NEXTLAYERSDK_USERNAME environment variable or directly passed to the NlAuth constructor.

Alternatively the password can be suppliend in the NEXTLAYERSDK_PASSWORD environment variable.

Usage

import requests
from nextlayer.sdk.auth import NlAuth

nlauth = NlAuth()
access_token = nlauth.get_access_token()

# make Request to some API Endpoint
rsp = requests.get(
    "https://portal.nextlayer.at/apis/v1/users/self",
    headers={"Authorization": "Bearer " + access_token},
)
print(rsp.json())

You need to call the .get_access_token() Method every time you make API-Calls, because it checks if the Token is still valid and will refresh it if necessary.

Usage with httpx

import httpx

from nextlayer.sdk.auth_httpx import NlHttpxAuth

client = httpx.Client(
    timeout=httpx.Timeout(30.0),
    base_url=f"https://portal.nextlayer.at/apis/v1",
    auth=NlHttpxAuth(),
)
print(client.get("/users/self").json())

Usage fron commandline

The package also installs a commandline utility nextlayer-auth which takes care of obtaining an access token and printing out a proper Authorization: header.

curl -H "`nextlayer-auth`" https://portal.nextlayer.at/apis/v1/users/self

It can also be used to "logout" by cleaning up tokens in the yaml file with:

nextlayer-auth clear

Release files for nextlayer-sdk-python 1.2.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 nextlayer-sdk-python 1.2.0
File Size Uploaded
nextlayer_sdk_python-1.2.0.tar.gz 8.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for nextlayer-sdk-python 1.2.0
File Interpreter ABI Platform
nextlayer_sdk_python-1.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 19.2 kB

Release files / nextlayer_sdk_python-1.2.0.tar.gz

Download URL nextlayer_sdk_python-1.2.0.tar.gz
Size 8.8 kB
Tags Source
SHA-256 checksum
How to use checksums
ed71d71d012077c4fdfcf362a32ca0b60587ec24ac53b1356578552d40974845
BLAKE2b-256 checksum
How to use checksums
23c45a2b6c45c5b756884f74d5977983695ea37bf8cf4164f5eb454291797daf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.1 CPython/3.14.2 Linux/6.1.0-45-cloud-amd64

Release files / nextlayer_sdk_python-1.2.0-py3-none-any.whl

Download URL nextlayer_sdk_python-1.2.0-py3-none-any.whl
Size 10.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
52547238b4aa0f5d96b542e4a8ce6533e34830f820ea69040db0e53c6ac98e4d
BLAKE2b-256 checksum
How to use checksums
dabe07859475fd6f927d618c0d48211a9323471acfd3b776c66aede599305c56
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.1 CPython/3.14.2 Linux/6.1.0-45-cloud-amd64

Release history Release notifications | RSS feed

1.3.0

2 release files

1.2.1

2 release files

This release

1.2.0 This release

2 release files

1.1.0

2 release files

1.0.2

2 release files

1.0.1

2 release files

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