Skip to main content

A client library for accessing the Nile API

Project description

This is the Python SDK for interacting with Nile.

Installing

The Nile Python SDK is available on PyPI, and can be installed via:

pip install nile-api

(in a virtual environment as appropriate).

Usage

Usage examples of the SDK can be found in the Nile examples repository, within the directories with -python in their name.

Basic Example:

import os

from nile_api import AuthenticatedClient
from nile_api.api.users import create_user, list_users
from nile_api.models.create_user_request import CreateUserRequest

# Create an authenticated client with a workspace auth token
client = AuthenticatedClient(base_url='https://prod.thenile.dev', token=os.environ.get("NILE_WS_TOKEN"))

# Create a user
user = create_user.sync(
            workspace=os.environ.get("NILE_WORKSPACE"),
            client=client,
            json_body=CreateUserRequest(email="anon@anon.com", password="secret"),
        )

# Log created user to console
print(user.email);

# List all users in the workspace
users = list_users.sync(client=client, workspace=os.environ.get("NILE_WORKSPACE"))
for user in users:
    print(f"User {user.email!r} exists")

Development

Commands below generally make use of nox (in some sense a Python-based, testing-centric make).

You can install it by following its install instructions for your OS, or e.g. on macOS, by simply running:

brew install nox

Regenerating (updating) the client is done via openapi-python-client.

To do so, run:

nox -s regenerate

You will want to test the results. First, validate that the client generated with the expected structure (packages and modules):

To do so, run:

nox -s tests

Then you’ll want to do a quick smoke test and make sure the client actually works against Nile. Currently we do it by running https://github.com/TheNileDev/examples/tree/main/quickstart-python example. Before running it you’ll want to make sure that running the example will use the local client and not an installed one.

From the local nile-py repository directory run:

export PYTHONPATH=`pwd`:$PYTHONPATH
venv/bin/python -c "import nile_api; print(str(nile_api.__path__))"
cd ../examples/quickstart-python
./venv/bin/python src/all.py

We pin the version of this generator itself in a requirements file. To update the version of the generator that will be used, run:

nox -s update_openapi_requirements

which should regenerate the openapi-generator-requirements.txt file which you should then commit.

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

nile_api-0.2.8.tar.gz (44.7 kB view details)

Uploaded Source

Built Distribution

nile_api-0.2.8-py3-none-any.whl (125.2 kB view details)

Uploaded Python 3

File details

Details for the file nile_api-0.2.8.tar.gz.

File metadata

  • Download URL: nile_api-0.2.8.tar.gz
  • Upload date:
  • Size: 44.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for nile_api-0.2.8.tar.gz
Algorithm Hash digest
SHA256 4971a5d9e7729654621321f66ca2c70ab6e7a811a7eba603bc094f7261809eec
MD5 935362c5c81c5c799e3b0d020adf250a
BLAKE2b-256 ab37773e6dd0fbb6b6984a518e415de16807decdb00719083e49ba3f4e37047b

See more details on using hashes here.

File details

Details for the file nile_api-0.2.8-py3-none-any.whl.

File metadata

  • Download URL: nile_api-0.2.8-py3-none-any.whl
  • Upload date:
  • Size: 125.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for nile_api-0.2.8-py3-none-any.whl
Algorithm Hash digest
SHA256 0eda8d45b82c0fa816f9c7f8bf1adb51dcfadf42a98ef7c79b853b2e476aa6e5
MD5 b5c8cb5aa47be27321af8f74477051cd
BLAKE2b-256 15816209a0a908433e86bdf44670b9e8b305dc90821fa26e4829ef19f26ed3da

See more details on using hashes here.

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