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.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| nextlayer_sdk_python-1.2.1.tar.gz | 9.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nextlayer_sdk_python-1.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 19.7 kB
Release files / nextlayer_sdk_python-1.2.1.tar.gz
| Download URL | nextlayer_sdk_python-1.2.1.tar.gz |
|---|---|
| Size | 9.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
96e6b91b77281add02381f8ca457de41eb23da973e9ef9e4d023b780c830edd0
|
|
BLAKE2b-256 checksum How to use checksums |
7e8d39e08790e4751a1dc011f95976ceaa6d16742bccc81b9ad0d36646c2082c
|
| 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.1-py3-none-any.whl
| Download URL | nextlayer_sdk_python-1.2.1-py3-none-any.whl |
|---|---|
| Size | 10.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bd55f79af38f148b84fa4724f69b37c41d716b173569ec730015a4bb42258c5a
|
|
BLAKE2b-256 checksum How to use checksums |
35817eb741d222818c52976ebdb8f8d87d7f68dbf462a382b35878ea4625b1bd
|
| 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
|