Skip to main content

Python SDK for Iconik's API

Project description

Pythonik

Pythonik is a comprehensive Python SDK designed for seamless interaction with the Iconik API. It offers a user-friendly interface to access various functionalities of Iconik, making it easier for developers to integrate and manage Iconik assets and metadata within their applications.

Features

  • Easy-to-use methods for accessing Iconik assets and metadata.
  • Robust handling of API authentication and requests.
  • Configurable timeout settings for API interactions.

Installation

You can install Pythonik directly from PyPI:

pip install nsa-pythonik

If you're using Poetry:

poetry add nsa-pythonik

Usage

Get an Asset from Iconik

To retrieve an asset from Iconik, use the following code:

from pythonik.client import PythonikClient
from pythonik.models.assets.assets import Asset
from pythonik.models.base import Response

app_id = secrets.get_secret("app_id")
auth_token = secrets.get_secret("auth_token")
asset_id = secrets.get_secret("asset_id")

client: PythonikClient = PythonikClient(app_id=app_id, auth_token=auth_token, timeout=10)


res: Response = client.assets().get(asset_id)
data: Asset = res.data
data_as_dict = data.model_dump()
data_as_json = data.model_dump_json()

Get Metadata from a View

To get metadata for an asset from a specific view, use the following code:

from pythonik.client import PythonikClient
from pythonik.models.assets.metadata import ViewMetadata
from pythonik.models.base import Response

app_id = secrets.get_secret("app_id")
auth_token = secrets.get_secret("auth_token")

asset_id = 'a31sd2asdf123jasdfq134'
view_id = 'a12sl34s56asdf123jhas2'

client: PythonikClient = PythonikClient(app_id=app_id, auth_token=auth_token, timeout=5)

default_model = ViewMetadata()
# intercept_404 intercepts 404 errors if no metadata is found in view and returns a ViewMetadata model you provide so you can handle the error gracefully
res: Response = client.metadata().get_asset_metadata(asset_id, view_id, intercept_404=default_model)
data: ViewMetadata = res.data
data_as_dict = data.model_dump()
data_as_json = data.model_dump_json()

Connecting to Different Iconik Environments

By default, Pythonik connects to the standard Iconik environment (https://app.iconik.io). To connect to a different Iconik environment, you can specify the base URL when initializing the client:

from pythonik.client import PythonikClient

client = PythonikClient(
    app_id=app_id,
    auth_token=auth_token,
    timeout=10,
    base_url="https://your-custom-iconik-instance.com"
)

This is useful when working with:

  • AWS Iconik deployments
  • Custom Iconik deployments (assuming this is possible)

Checkout the API reference and advanced usage guide to see all you can do with Pythonik.

Publishing to PyPI (for maintainers)

To publish a new version to PyPI please see the release how-to guide.

Using Poetry

This project uses Poetry for dependency management and packaging. Below are instructions on how to work with Poetry, create a Poetry shell, and run tests using pytest.

Setting Up Poetry

First, install Poetry if you haven't already:

Creating a Poetry Shell

To create and activate a Poetry shell, which sets up an isolated virtual environment for your project:

  1. Navigate to your project directory.

  2. Run the following command:

    poetry shell
    

This command will activate a virtual environment managed by Poetry. You can now run Python commands and scripts within this environment.

Install all dependencies including pytest

    poetry install

Running Tests with pytest

To run tests using pytest, follow these steps:

  1. Inside the Poetry shell, run the tests with the following command:

    pytest
    

This will discover and execute all the tests in your project.


By following these steps, you can efficiently manage dependencies, create a virtual environment, and run tests in your Python project using Poetry.

Support

For support, please contact NSA.

Roadmap

Details about upcoming features and enhancements will be added here.

Contributing

Please see the contribution guide for information on how to contribute.

Authors and Acknowledgment

This SDK is developed and maintained by North Shore Automation developers, including Brant Goddard, Prince Duepa, Giovann Wah, and Brandon Dedolph.

Contributors

License

License information will be available soon.

Project Status

Current project status and updates will be posted here.

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

nsa_pythonik-1.15.0.tar.gz (44.5 kB view details)

Uploaded Source

Built Distribution

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

nsa_pythonik-1.15.0-py3-none-any.whl (61.1 kB view details)

Uploaded Python 3

File details

Details for the file nsa_pythonik-1.15.0.tar.gz.

File metadata

  • Download URL: nsa_pythonik-1.15.0.tar.gz
  • Upload date:
  • Size: 44.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.12.0 Darwin/24.4.0

File hashes

Hashes for nsa_pythonik-1.15.0.tar.gz
Algorithm Hash digest
SHA256 725a0ad2e1a46579607ca6975bbdca53f75686aca4db983536447f4b1e5ab9f0
MD5 c14d37429eb0e5aa3f1d037dd72f5952
BLAKE2b-256 af09c106d37827a9a6d523dd860dafb3ae0360727c1db724a6ccbf41f63c075f

See more details on using hashes here.

File details

Details for the file nsa_pythonik-1.15.0-py3-none-any.whl.

File metadata

  • Download URL: nsa_pythonik-1.15.0-py3-none-any.whl
  • Upload date:
  • Size: 61.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.12.0 Darwin/24.4.0

File hashes

Hashes for nsa_pythonik-1.15.0-py3-none-any.whl
Algorithm Hash digest
SHA256 97e1cd45c754c07d3c761f97572e1e59e1b7bafd7f2e62bf84d3e1ce79154cec
MD5 a7024bd01e88e44c7eaef62d0b13cdcb
BLAKE2b-256 aaab0e62951a3c1d03d9bed3a02e6d3920e016cd79c2febbd49eefe0ce87c99b

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